コード例 #1
0
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_seconds':
             $this->wait_time_seconds = time() - $this->time;
             return $this->wait_time_seconds;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'wait_time_pending':
             $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time);
             return $this->wait_time_pending;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'plain_user_name':
             $this->plain_user_name = false;
             if ($this->user !== false) {
                 $this->plain_user_name = (string) $this->user->name_support;
             }
             return $this->plain_user_name;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'product':
             $this->product = false;
             if ($this->product_id > 0) {
                 try {
                     $this->product = erLhAbstractModelProduct::fetch($this->product_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->product;
             break;
         case 'product_name':
             $this->product_name = (string) $this->product;
             return $this->product_name;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'number_in_queue':
             $this->number_in_queue = 1;
             if ($this->status == self::STATUS_PENDING_CHAT) {
                 $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1;
             }
             return $this->number_in_queue;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
         case 'user_status_front':
             if ($this->online_user !== false) {
                 $this->user_status_front = erLhcoreClassChat::setActivityByChatAndOnlineUser($this, $this->online_user);
             } else {
                 $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1;
             }
             return $this->user_status_front;
             break;
         default:
             break;
     }
 }
コード例 #2
0
<?php

try {
    $file = erLhcoreClassModelChatFile::fetch((int) $Params['user_parameters']['file_id']);
    $hash = $Params['user_parameters']['hash'];
    if ($hash == md5($file->name . '_' . $file->chat_id)) {
        header('Content-type: ' . $file->type);
        header('Content-Disposition: attachment; filename="' . $file->id . '-' . $file->chat_id . '.' . $file->extension . '"');
        echo file_get_contents($file->file_path_server);
    }
} catch (Exception $e) {
    header('Location: /');
    exit;
}
exit;
コード例 #3
0
 public function __get($var)
 {
     switch ($var) {
         case 'last_visit_front':
             return $this->last_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->last_visit);
             break;
         case 'first_visit_front':
             return $this->first_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->first_visit);
             break;
         case 'invitation':
             $this->invitation = false;
             if ($this->invitation_id > 0) {
                 try {
                     $this->invitation = erLhAbstractModelProactiveChatInvitation::fetch($this->invitation_id);
                 } catch (Exception $e) {
                     $this->invitation = false;
                 }
             }
             return $this->invitation;
             break;
         case 'has_message_from_operator':
             return $this->message_seen == 0 && $this->operator_message != '';
             break;
         case 'notes_intro':
             return $this->notes_intro = $this->notes != '' ? '[ ' . mb_substr($this->notes, 0, 50) . ' ]' . '<br/>' : '';
             break;
         case 'chat':
             $this->chat = false;
             if ($this->chat_id > 0) {
                 try {
                     $this->chat = erLhcoreClassModelChat::fetch($this->chat_id);
                 } catch (Exception $e) {
                     //
                 }
             }
             return $this->chat;
             break;
         case 'can_view_chat':
             $this->can_view_chat = false;
             $currentUser = erLhcoreClassUser::instance();
             if ($this->operator_user_id == $currentUser->getUserID()) {
                 $this->can_view_chat = true;
                 // Faster way
             } else {
                 if ($this->chat instanceof erLhcoreClassModelChat) {
                     $this->can_view_chat = erLhcoreClassChat::hasAccessToRead($this->chat);
                 }
             }
             return $this->can_view_chat;
             break;
         case 'operator_user':
             $this->operator_user = false;
             if ($this->operator_user_id > 0) {
                 try {
                     $this->operator_user = erLhcoreClassModelUser::fetch($this->operator_user_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->operator_user;
             break;
         case 'operator_user_send':
             $this->operator_user_send = $this->operator_user !== false;
             return $this->operator_user_send;
             break;
         case 'operator_user_string':
             $this->operator_user_string = (string) $this->operator_user;
             return $this->operator_user_string;
             break;
         case 'time_on_site_front':
             $this->time_on_site_front = gmdate(erLhcoreClassModule::$dateHourFormat, $this->time_on_site);
             return $this->time_on_site_front;
             break;
         case 'tt_time_on_site_front':
             $this->tt_time_on_site_front = null;
             $diff = $this->tt_time_on_site;
             $days = floor($diff / (3600 * 24));
             $hours = floor(($diff - $days * 3600 * 24) / 3600);
             $minits = floor(($diff - $hours * 3600 - $days * 3600 * 24) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60 - $days * 3600 * 24;
             if ($days > 0) {
                 $this->tt_time_on_site_front = $days . ' d.';
             } elseif ($hours > 0) {
                 $this->tt_time_on_site_front = $hours . ' h.';
             } elseif ($minits > 0) {
                 $this->tt_time_on_site_front = $minits . ' m.';
             } elseif ($seconds >= 0) {
                 $this->tt_time_on_site_front = $seconds . ' s.';
             }
             return $this->tt_time_on_site_front;
             break;
         case 'last_visit_seconds_ago':
             $this->last_visit_seconds_ago = time() - $this->last_visit;
             return $this->last_visit_seconds_ago;
             break;
         case 'last_check_time_ago':
             $this->last_check_time_ago = time() - $this->last_check_time;
             return $this->last_check_time_ago;
             break;
         case 'visitor_tz_time':
             $this->visitor_tz_time = '-';
             if ($this->visitor_tz != '') {
                 $date = new DateTime(null, new DateTimeZone($this->visitor_tz));
                 $this->visitor_tz_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             }
             return $this->visitor_tz_time;
             break;
         case 'lastactivity_ago':
             $this->lastactivity_ago = '';
             if ($this->last_visit > 0) {
                 $periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec.");
                 $lengths = array("60", "60", "24", "7", "4.35", "12", "10");
                 $difference = time() - $this->last_visit;
                 for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
                     $difference /= $lengths[$j];
                 }
                 $difference = round($difference);
                 $this->lastactivity_ago = "{$difference} {$periods[$j]}";
             }
             return $this->lastactivity_ago;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'online_attr_system_array':
             $this->online_attr_system_array = array();
             if ($this->online_attr_system != '') {
                 $this->online_attr_system_array = json_decode($this->online_attr_system, true);
             }
             return $this->online_attr_system_array;
             break;
         case 'online_status':
             $this->online_status = 2;
             // Offline
             if (erLhcoreClassChat::$trackTimeout == 0) {
                 erLhcoreClassChat::$trackTimeout = 15;
             }
             if (erLhcoreClassChat::$trackActivity == true) {
                 if ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && $this->user_active == 1) {
                     //User still on site, it does not matter that he have closed widget.
                     $this->online_status = 0;
                     // Online
                 } elseif ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && $this->user_active == 0) {
                     $this->online_status = 1;
                     // Away
                 }
             } else {
                 if ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && time() - $this->last_user_msg_time < 300) {
                     //User still on site, it does not matter that he have closed widget.
                     $this->online_status = 0;
                     // Online
                 } elseif ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && time() - $this->last_user_msg_time >= 300) {
                     $this->online_status = 1;
                     // Away
                 }
             }
             return $this->online_status;
             break;
         default:
             break;
     }
 }
コード例 #4
0
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
         default:
             break;
     }
 }
コード例 #5
0
ファイル: lhbbcode.php プロジェクト: Topspot/livehelperchat
 public static function _make_url_mail_file($matches)
 {
     if (isset($matches[1])) {
         list($fileID, $hash) = explode('_', $matches[1]);
         try {
             $file = erLhcoreClassModelChatFile::fetch($fileID);
             // Check that user has permission to see the chat. Let say if user purposely types file bbcode
             if ($hash == md5($file->name . '_' . $file->chat_id)) {
                 return erLhcoreClassXMP::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurldirect('file/downloadfile') . "/{$file->id}/{$hash}";
             }
         } catch (Exception $e) {
         }
         return '';
     }
     return '';
 }
コード例 #6
0
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_seconds':
             $this->wait_time_seconds = time() - $this->time;
             return $this->wait_time_seconds;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'wait_time_pending':
             $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time);
             return $this->wait_time_pending;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'plain_user_name':
             $this->plain_user_name = false;
             if ($this->user !== false) {
                 $this->plain_user_name = (string) $this->user->name_support;
             }
             return $this->plain_user_name;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'number_in_queue':
             $this->number_in_queue = 1;
             if ($this->status == self::STATUS_PENDING_CHAT) {
                 $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1;
             }
             return $this->number_in_queue;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
             /**
              * @desc Returns user status based on the following logic
              * 1. Green - if widget is not closed
              * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
              * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
              *
              * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
              * 5. Yellow - from last user message has passed 5 minutes but user still on site
              *
              * 6. Widget is closed and we could not determine online user || None of above conditions are met.
              *
              * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
              *
              * @param array $params
              *
              * 1 GREEN user has activity in last 5 minutes and ping respond
              * 2 ORANGE user has no activity in last 5 minutes and ping respond
              * 3 GREY Offline user fails to respond pings for X number of times in a row
              *
              * @return int
              */
         /**
          * @desc Returns user status based on the following logic
          * 1. Green - if widget is not closed
          * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
          * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
          *
          * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
          * 5. Yellow - from last user message has passed 5 minutes but user still on site
          *
          * 6. Widget is closed and we could not determine online user || None of above conditions are met.
          *
          * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
          *
          * @param array $params
          *
          * 1 GREEN user has activity in last 5 minutes and ping respond
          * 2 ORANGE user has no activity in last 5 minutes and ping respond
          * 3 GREY Offline user fails to respond pings for X number of times in a row
          *
          * @return int
          */
         case 'user_status_front':
             $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1;
             if ($this->user_status_front == self::USER_STATUS_CLOSED_CHAT && $this->online_user !== false || erLhcoreClassChat::$onlineCondition == 1 && $this->online_user !== false) {
                 $timeout = (int) erLhcoreClassChat::$trackTimeout || 10;
                 if (erLhcoreClassChat::$trackActivity == true) {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && $this->online_user->user_active == 1) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif ($this->online_user->user_active == 0 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 } else {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && time() - $this->last_user_msg_time < 300) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif (time() - $this->last_user_msg_time >= 300 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 }
             }
             return $this->user_status_front;
             break;
         default:
             break;
     }
 }
コード例 #7
0
 public static function _make_url_file($matches)
 {
     if (isset($matches[1])) {
         list($fileID, $hash) = explode('_', $matches[1]);
         try {
             $file = erLhcoreClassModelChatFile::fetch($fileID);
             // Check that user has permission to see the chat. Let say if user purposely types file bbcode
             if ($hash == md5($file->name . '_' . $file->chat_id)) {
                 return "<a href=\"" . erLhcoreClassDesign::baseurl('file/downloadfile') . "/{$file->id}/{$hash}\" class=\"link\" >" . erTranslationClassLhTranslation::getInstance()->getTranslation('file/file', 'Download file') . ' - ' . htmlspecialchars($file->upload_name) . ' [' . $file->extension . ']' . "</a>";
             }
         } catch (Exception $e) {
         }
         return '';
     }
     return '';
 }
コード例 #8
0
 public function __get($var)
 {
     switch ($var) {
         case 'last_visit_front':
             return $this->last_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->last_visit);
             break;
         case 'first_visit_front':
             return $this->first_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->first_visit);
             break;
         case 'invitation':
             $this->invitation = false;
             if ($this->invitation_id > 0) {
                 try {
                     $this->invitation = erLhAbstractModelProactiveChatInvitation::fetch($this->invitation_id);
                 } catch (Exception $e) {
                     $this->invitation = false;
                 }
             }
             return $this->invitation;
             break;
         case 'has_message_from_operator':
             return $this->message_seen == 0 && $this->operator_message != '';
             break;
         case 'chat':
             $this->chat = false;
             if ($this->chat_id > 0) {
                 try {
                     $this->chat = erLhcoreClassModelChat::fetch($this->chat_id);
                 } catch (Exception $e) {
                     //
                 }
             }
             return $this->chat;
             break;
         case 'can_view_chat':
             $this->can_view_chat = false;
             $currentUser = erLhcoreClassUser::instance();
             if ($this->operator_user_id == $currentUser->getUserID()) {
                 $this->can_view_chat = true;
                 // Faster way
             } else {
                 if ($this->chat instanceof erLhcoreClassModelChat) {
                     $this->can_view_chat = erLhcoreClassChat::hasAccessToRead($this->chat);
                 }
             }
             return $this->can_view_chat;
             break;
         case 'operator_user':
             $this->operator_user = false;
             if ($this->operator_user_id > 0) {
                 try {
                     $this->operator_user = erLhcoreClassModelUser::fetch($this->operator_user_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->operator_user;
             break;
         case 'operator_user_send':
             $this->operator_user_send = $this->operator_user !== false;
             return $this->operator_user_send;
             break;
         case 'operator_user_string':
             $this->operator_user_string = (string) $this->operator_user;
             return $this->operator_user_string;
             break;
         case 'time_on_site_front':
             $this->time_on_site_front = gmdate(erLhcoreClassModule::$dateHourFormat, $this->time_on_site);
             return $this->time_on_site_front;
             break;
         case 'tt_time_on_site_front':
             $this->tt_time_on_site_front = null;
             $diff = $this->tt_time_on_site;
             $days = floor($diff / (3600 * 24));
             $hours = floor(($diff - $days * 3600 * 24) / 3600);
             $minits = floor(($diff - $hours * 3600 - $days * 3600 * 24) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60 - $days * 3600 * 24;
             if ($days > 0) {
                 $this->tt_time_on_site_front = $days . ' d.';
             } elseif ($hours > 0) {
                 $this->tt_time_on_site_front = $hours . ' h.';
             } elseif ($minits > 0) {
                 $this->tt_time_on_site_front = $minits . ' m.';
             } elseif ($seconds >= 0) {
                 $this->tt_time_on_site_front = $seconds . ' s.';
             }
             return $this->tt_time_on_site_front;
             break;
         case 'last_visit_seconds_ago':
             $this->last_visit_seconds_ago = time() - $this->last_visit;
             return $this->last_visit_seconds_ago;
             break;
         case 'last_check_time_ago':
             $this->last_check_time_ago = time() - $this->last_check_time;
             return $this->last_check_time_ago;
             break;
         case 'visitor_tz_time':
             $this->visitor_tz_time = '-';
             if ($this->visitor_tz != '') {
                 $date = new DateTime(null, new DateTimeZone($this->visitor_tz));
                 $this->visitor_tz_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             }
             return $this->visitor_tz_time;
             break;
         case 'lastactivity_ago':
             $this->lastactivity_ago = '';
             if ($this->last_visit > 0) {
                 $periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec.");
                 $lengths = array("60", "60", "24", "7", "4.35", "12", "10");
                 $difference = time() - $this->last_visit;
                 for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
                     $difference /= $lengths[$j];
                 }
                 $difference = round($difference);
                 $this->lastactivity_ago = "{$difference} {$periods[$j]}";
             }
             return $this->lastactivity_ago;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         default:
             break;
     }
 }