コード例 #1
0
 public function expireCache()
 {
     if (isset($_SESSION['lhc_chat_config'])) {
         unset($_SESSION['lhc_chat_config']);
     }
     if ($this->expiredInRuntime == false) {
         $this->expiredInRuntime = true;
         foreach ($this->expireOptions as $option) {
             $this->setSetting('cachetimestamps', $option, 0);
         }
         foreach ($this->sessionExpireOptions as $option) {
             if (isset($_SESSION[$option])) {
                 unset($_SESSION[$option]);
             }
         }
         $compiledModules = ezcBaseFile::findRecursive('cache/cacheconfig', array('@\\.cache\\.php@'));
         foreach ($compiledModules as $compiledClass) {
             unlink($compiledClass);
         }
         $compiledTemplates = ezcBaseFile::findRecursive('cache/compiledtemplates', array('@(\\.php|\\.js|\\.css)@'));
         foreach ($compiledTemplates as $compiledTemplate) {
             unlink($compiledTemplate);
         }
         $instance = CSCacheAPC::getMem();
         $instance->increaseImageManipulationCache();
         $this->save();
     }
 }
コード例 #2
0
ファイル: lhsys.php プロジェクト: kenjiro7/livehelperchat
 static function getMem()
 {
     if (self::$m_objMem == NULL) {
         self::$m_objMem = new CSCacheAPC();
     }
     return self::$m_objMem;
 }
コード例 #3
0
ファイル: lhurl.php プロジェクト: sslavescu/livehelperchat
 public static function getTranslatedURL($url, $suburl = '')
 {
     $cache = CSCacheAPC::getMem();
     $cacheKey = md5('site_version_' . $cache->getCacheVersion('site_version') . '_alias_' . $url . '_' . $suburl);
     if (($returnAlias = $cache->restore($cacheKey)) === false) {
         $url = erLhcoreClassCharTransform::TransformToURL($url);
         $returnAlias = false;
         if ($returnAlias !== false) {
             $cache->store($cacheKey, $returnAlias);
         }
     }
     return $returnAlias;
 }
コード例 #4
0
 public static function fetchCache($identifier)
 {
     if (self::$disableCache == false && isset($GLOBALS['lhc_erLhcoreClassModelChatConfig' . $identifier])) {
         return $GLOBALS['lhc_erLhcoreClassModelChatConfig' . $identifier];
     }
     $cache = CSCacheAPC::getMem();
     $configArray = $cache->getArray('lhc_chat_config');
     if (isset($configArray[$identifier])) {
         return $configArray[$identifier];
     } else {
         $_SESSION['lhc_chat_config'][$identifier] = self::fetch($identifier);
         return $_SESSION['lhc_chat_config'][$identifier];
     }
 }
コード例 #5
0
 public static function changeStatus($params)
 {
     $changeStatus = $params['status'];
     $chat = $params['chat'];
     $userData = $params['user'];
     $allowCloseRemote = $params['allow_close_remote'];
     if ($changeStatus == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
         if ($chat->status != erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
             $chat->status = erLhcoreClassModelChat::STATUS_ACTIVE_CHAT;
             $chat->wait_time = time() - $chat->time;
         }
         if ($chat->user_id == 0) {
             $chat->user_id = $userData->id;
         }
         $chat->updateThis();
     } elseif ($changeStatus == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
         $chat->status = erLhcoreClassModelChat::STATUS_PENDING_CHAT;
         $chat->support_informed = 0;
         $chat->has_unread_messages = 1;
         $chat->updateThis();
     } elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CLOSED_CHAT && $chat->user_id == $userData->id || $allowCloseRemote == true) {
         if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
             $chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
             $chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
             $msg = new erLhcoreClassModelmsg();
             $msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
             $msg->chat_id = $chat->id;
             $msg->user_id = -1;
             $chat->last_user_msg_time = $msg->time = time();
             erLhcoreClassChat::getSession()->save($msg);
             $chat->updateThis();
             CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat->id);
             // Execute callback for close chat
             erLhcoreClassChat::closeChatCallback($chat, $userData);
         }
     } elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CHATBOX_CHAT) {
         $chat->status = erLhcoreClassModelChat::STATUS_CHATBOX_CHAT;
         erLhcoreClassChat::getSession()->update($chat);
     } elseif ($changeStatus == erLhcoreClassModelChat::STATUS_OPERATORS_CHAT) {
         $chat->status = erLhcoreClassModelChat::STATUS_OPERATORS_CHAT;
         erLhcoreClassChat::getSession()->update($chat);
     }
     erLhcoreClassChat::updateActiveChats($chat->user_id);
     if ($chat->department !== false) {
         erLhcoreClassChat::updateDepartmentStats($chat->department);
     }
 }
コード例 #6
0
ファイル: account.php プロジェクト: sudogitguy/livehelperchat
     exit;
 }
 $form = new ezcInputForm(INPUT_POST, $definition);
 $Errors = array();
 if (!$form->hasValidData('Username')) {
     $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Please enter a username!');
 } elseif ($form->hasValidData('Username') && $form->Username != $UserData->username && !erLhcoreClassModelUser::userExists($form->Username)) {
     $UserData->username = $form->Username;
 } elseif ($form->hasValidData('Username') && $form->Username != $UserData->username) {
     $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'User exists!');
 }
 if ($form->hasValidData('UserTimeZone') && $form->UserTimeZone != '') {
     $UserData->time_zone = $form->UserTimeZone;
     CSCacheAPC::getMem()->setSession('lhc_user_timezone', $UserData->time_zone, true);
 } else {
     CSCacheAPC::getMem()->setSession('lhc_user_timezone', '', true);
     $UserData->time_zone = '';
 }
 if (!$form->hasValidData('Email')) {
     $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Wrong email address');
 }
 if (!$form->hasValidData('Name') || $form->Name == '') {
     $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Please enter a name');
 }
 if ($form->hasValidData('Surname') && $form->Surname != '') {
     $UserData->surname = $form->Surname;
 } else {
     $UserData->surname = '';
 }
 if ($form->hasValidData('JobTitle') && $form->JobTitle != '') {
     $UserData->job_title = $form->JobTitle;
コード例 #7
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhchat/adminchat.tpl.php');
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
$tpl->set('chat', $chat);
if (erLhcoreClassChat::hasAccessToRead($chat)) {
    $userData = $currentUser->getUserData();
    if ($Params['user_parameters_unordered']['remember'] == 'true') {
        CSCacheAPC::getMem()->appendToArray('lhc_open_chats', $chat->id);
    }
    if ($userData->invisible_mode == 0) {
        $operatorAccepted = false;
        $chatDataChanged = false;
        if ($chat->user_id == 0) {
            $currentUser = erLhcoreClassUser::instance();
            $chat->user_id = $currentUser->getUserID();
            $chatDataChanged = true;
        }
        // If status is pending change status to active
        if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
            $chat->status = erLhcoreClassModelChat::STATUS_ACTIVE_CHAT;
            if ($chat->wait_time == 0) {
                $chat->wait_time = time() - $chat->time;
            }
            $chat->user_id = $currentUser->getUserID();
            $operatorAccepted = true;
            $chatDataChanged = true;
        }
        if ($chat->support_informed == 0 || $chat->has_unread_messages == 1 || $chat->unread_messages_informed == 1) {
            $chatDataChanged = true;
        }
コード例 #8
0
ファイル: lhdbtrait.php プロジェクト: sirromas/medical
 public static function getList($paramsSearch = array())
 {
     $paramsDefault = array('limit' => 500, 'offset' => 0);
     $params = array_merge($paramsDefault, $paramsSearch);
     if (isset($params['enable_sql_cache']) && $params['enable_sql_cache'] == true) {
         $sql = self::multi_implode(',', $params);
         $cache = CSCacheAPC::getMem();
         $cacheKey = isset($params['cache_key']) ? md5($sql . $params['cache_key']) : md5('objects_list_' . strtolower(__CLASS__) . '_v_' . $cache->getCacheVersion('site_attributes_version_' . strtolower(__CLASS__)) . $sql);
         if (($result = $cache->restore($cacheKey)) !== false) {
             return $result;
         }
     }
     $session = self::getSession();
     $q = $session->createFindQuery(__CLASS__);
     $conditions = self::getConditions($params, $q);
     if (count($conditions) > 0) {
         $q->where($conditions);
     }
     if ($params['limit'] !== false) {
         $q->limit($params['limit'], $params['offset']);
     }
     if (!isset($params['sort']) || $params['sort'] !== false) {
         if (isset(self::$dbDefaultSort)) {
             $q->orderBy(isset($params['sort']) ? $params['sort'] : self::$dbDefaultSort);
         } else {
             $q->orderBy(isset($params['sort']) ? $params['sort'] : self::$dbTable . "." . self::$dbTableId . " " . self::$dbSortOrder);
         }
     }
     $objects = $session->find($q);
     if (isset($params['prefill_attributes'])) {
         foreach ($params['prefill_attributes'] as $attr => $prefillOptions) {
             $teamsId = array();
             foreach ($objects as $object) {
                 $teamsId[] = $object->{$prefillOptions}['attr_id'];
             }
             if (!empty($teamsId)) {
                 $teams = call_user_func($object->{$prefillOptions}['function'], array('limit' => false, 'sort' => false, 'filterin' => array('id' => $teamsId)));
                 foreach ($objects as &$object) {
                     if (isset($teams[$object->{$prefillOptions}['attr_id']])) {
                         $object->{$prefillOptions}['attr_name'] = $teams[$object->{$prefillOptions}['attr_id']];
                     }
                 }
             }
         }
     }
     if (isset($params['enable_sql_cache']) && $params['enable_sql_cache'] == true) {
         if (isset($params['sql_cache_timeout'])) {
             $cache->store($cacheKey, $objects, $params['sql_cache_timeout']);
         } else {
             $cache->store($cacheKey, $objects);
         }
     }
     return $objects;
 }
コード例 #9
0
ファイル: lhchat.php プロジェクト: sudogitguy/livehelperchat
 public static function canReopenDirectly($params = array())
 {
     if (($chatPart = CSCacheAPC::getMem()->getSession('chat_hash_widget_resume', true)) !== false) {
         try {
             $parts = explode('_', $chatPart);
             $chat = erLhcoreClassModelChat::fetch($parts[0]);
             if (($chat->last_user_msg_time > time() - 600 || $chat->last_user_msg_time == 0) && (!isset($params['reopen_closed']) || $params['reopen_closed'] == 1 || $params['reopen_closed'] == 0 && $chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT)) {
                 return array('id' => $parts[0], 'hash' => $parts[1]);
             } else {
                 return false;
             }
         } catch (Exception $e) {
             return false;
         }
     }
     return false;
 }
        }
    }
    ?>
</div></div></div><script>$( document ).ready(function() {lhinst.attachTabNavigator();$('#right-column-page').removeAttr('id');$('#tabs a:first').tab('show')});<?php 
    $chatsOpen = CSCacheAPC::getMem()->getArray('lhc_open_chats');
    if (!empty($chatsOpen)) {
        $chats = erLhcoreClassChat::getList(array('filterin' => array('id' => $chatsOpen)));
        $deleteKeys = array_diff($chatsOpen, array_keys($chats));
        foreach ($deleteKeys as $chat_id) {
            CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat_id);
        }
        foreach ($chats as $chat) {
            if (erLhcoreClassChat::hasAccessToRead($chat)) {
                echo "lhinst.startChat('{$chat->id}',\$('#tabs'),'" . erLhcoreClassDesign::shrt($chat->nick, 10, '...', 30, ENT_QUOTES) . "');";
            } else {
                CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat->id);
            }
        }
    }
    ?>
</script><?php 
} else {
    ?>
<h1>System configuration</h1><?php 
    $currentUser = erLhcoreClassUser::instance();
    ?>
<div role="tabpanel"><ul class="nav nav-tabs" role="tablist"><li role="presentation" class="active"><a href="#system" aria-controls="system" role="tab" data-toggle="tab">System</a></li><?php 
    $system_configuration_tabs_generate_js_enabled = true;
    if ($system_configuration_tabs_generate_js_enabled == true && $currentUser->hasAccessTo('lhsystem', 'generate_js_tab')) {
        ?>
<li role="presentation"><a href="#embed" aria-controls="embed" role="tab" data-toggle="tab">Embed code</a></li><?php 
コード例 #11
0
ファイル: addmsguser.php プロジェクト: detain/livehelperchat
        // Set last message ID
        if ($Chat->last_msg_id < $msg->id) {
            $Chat->last_msg_id = $msg->id;
        }
        // Delete legacy messages, propability 1 of 100
        if (1 == mt_rand(1, 100)) {
            erLhcoreClassChatbox::cleanupChatbox($Chat);
        }
        $Chat->last_user_msg_time = $msg->time = time();
        $Chat->has_unread_messages = 1;
        $Chat->updateThis();
        if ($Params['user_parameters_unordered']['render'] == 'true') {
            $tpl = erLhcoreClassTemplate::getInstance('lhchatbox/render.tpl.php');
            $tpl->set('msg', $msg);
            $tpl->set('chat', $Chat);
            $content = $tpl->fetch();
            $parts = explode('{{SPLITTER}}', $content);
            $partsReturn['or'] = $parts[0];
            $partsReturn['ur'] = $parts[1];
        }
        // Just increase cache version upon message ad
        CSCacheAPC::getMem()->increaseCacheVersion('chatbox_' . erLhcoreClassChatbox::getIdentifierByChatId($Chat->id));
        echo json_encode(array('error' => $error, 'id' => $msg->id, 'or' => $partsReturn['or'], 'ur' => $partsReturn['ur'], 'sender' => $sender));
        exit;
    }
} else {
    $error = 't';
    $partsReturn['or'] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Please enter a message, max characters') . ' - ' . (int) erLhcoreClassModelChatConfig::fetch('max_message_length')->current_value;
    echo json_encode(array('error' => $error, 'or' => $partsReturn['or']));
    exit;
}
コード例 #12
0
ファイル: delete.php プロジェクト: Adeelgill/livehelperchat
<?php

if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
    die('Invalid CSFR Token');
    exit;
}
$ObjectData = erLhcoreClassAbstract::getSession()->load('erLhAbstractModel' . $Params['user_parameters']['identifier'], (int) $Params['user_parameters']['object_id']);
$object_trans = $ObjectData->getModuleTranslations();
if (isset($object_trans['permission']) && !$currentUser->hasAccessTo($object_trans['permission']['module'], $object_trans['permission']['function'])) {
    erLhcoreClassModule::redirect();
    exit;
}
if (method_exists($ObjectData, 'checkPermission')) {
    if ($ObjectData->checkPermission() === false) {
        erLhcoreClassModule::redirect();
        exit;
    }
}
$ObjectData->removeThis();
$cache = CSCacheAPC::getMem();
$cache->increaseCacheVersion('site_attributes_version');
erLhcoreClassModule::redirect('abstract/list', '/' . $Params['user_parameters']['identifier']);
exit;
コード例 #13
0
ファイル: tpl.php プロジェクト: mdb-webdev/livehelperchat
 function storeCache()
 {
     if (is_null($this->cacheWriter)) {
         $this->cacheWriter = new erLhcoreClassCacheStorage('cache/cacheconfig/');
     }
     try {
         $this->cacheWriter->store('templateCache', $this->cacheTemplates);
     } catch (Exception $e) {
         // Do nothing, this happens on a lot of requests
     }
     $cacheObj = CSCacheAPC::getMem();
     $cacheObj->store('templateCacheArray_version_' . $cacheObj->getCacheVersion('site_version'), $this->cacheTemplates);
 }
コード例 #14
0
 public static function validateAccount(&$userData)
 {
     $definition = array('Password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Password1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'validate_email'), 'Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'Surname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'Username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'JobTitle' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Skype' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'XMPPUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ChatNickname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserTimeZone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserInvisible' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'ReceivePermissionRequest' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'));
     $form = new ezcInputForm(INPUT_POST, $definition);
     $Errors = array();
     if (!$form->hasValidData('Username') || $form->Username == '') {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Please enter a username');
     } else {
         if ($form->Username != $userData->username) {
             $userData->username = $form->Username;
             if (erLhcoreClassModelUser::userExists($userData->username) === true) {
                 $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'User exists');
             }
         }
     }
     if ($form->hasValidData('Password') && $form->hasValidData('Password1')) {
         $userData->password_temp_1 = $form->Password;
         $userData->password_temp_2 = $form->Password1;
     }
     if ($form->hasInputField('Password') && (!$form->hasInputField('Password1') || $form->Password != $form->Password1)) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Passwords mismatch');
     } else {
         if ($form->hasInputField('Password') && $form->hasInputField('Password1') && $form->Password != '' && $form->Password1 != '') {
             $userData->setPassword($form->Password);
             $userData->password_front = $form->Password;
         }
     }
     if ($form->hasValidData('ChatNickname') && $form->ChatNickname != '') {
         $userData->chat_nickname = $form->ChatNickname;
     } else {
         $userData->chat_nickname = '';
     }
     if (!$form->hasValidData('Email')) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Wrong email address');
     } else {
         $userData->email = $form->Email;
     }
     if (!$form->hasValidData('Name') || $form->Name == '') {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Please enter a name');
     } else {
         $userData->name = $form->Name;
     }
     if ($form->hasValidData('Surname') && $form->Surname != '') {
         $userData->surname = $form->Surname;
     } else {
         $userData->surname = '';
     }
     if ($form->hasValidData('JobTitle') && $form->JobTitle != '') {
         $userData->job_title = $form->JobTitle;
     } else {
         $userData->job_title = '';
     }
     if ($form->hasValidData('UserTimeZone') && $form->UserTimeZone != '') {
         $userData->time_zone = $form->UserTimeZone;
         CSCacheAPC::getMem()->setSession('lhc_user_timezone', $userData->time_zone, true);
     } else {
         CSCacheAPC::getMem()->setSession('lhc_user_timezone', '', true);
         $userData->time_zone = '';
     }
     if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'changevisibility')) {
         if ($form->hasValidData('UserInvisible') && $form->UserInvisible == true) {
             $userData->invisible_mode = 1;
         } else {
             $userData->invisible_mode = 0;
         }
     }
     if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'receivepermissionrequest')) {
         if ($form->hasValidData('ReceivePermissionRequest') && $form->ReceivePermissionRequest == true) {
             $userData->rec_per_req = 1;
         } else {
             $userData->rec_per_req = 0;
         }
     }
     if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'changeskypenick')) {
         if ($form->hasValidData('Skype') && $form->Skype != '') {
             $userData->skype = $form->Skype;
         } else {
             $userData->skype = '';
         }
     }
     if ($form->hasValidData('XMPPUsername') && $form->XMPPUsername != '') {
         $userData->xmpp_username = $form->XMPPUsername;
     } else {
         $userData->xmpp_username = '';
     }
     return $Errors;
 }
コード例 #15
0
 public function __get($var)
 {
     switch ($var) {
         case 'is_active':
             $this->is_active = $this->request > 0 && ($this->expires == 0 || $this->expires > time()) && $this->suspended == 0 && $this->reseller_suspended == 0;
             return $this->is_active;
             break;
         case 'sms_used_percentenge':
             return round($this->sms_left / $this->sms_plan * 100, 2);
             break;
         case 'soft_limit_in_effect':
             $soft_limit_in_effect = false;
             if ($this->soft_limit_type == 0 && $this->sms_left / $this->sms_plan * 100 < $this->soft_limit) {
                 $soft_limit_in_effect = true;
             } elseif ($this->soft_limit_type == 1 && $this->sms_left < $this->soft_limit) {
                 $soft_limit_in_effect = true;
             }
             return $soft_limit_in_effect;
             break;
         case 'hard_limit_in_effect':
             $hard_limit_in_effect = false;
             if ($this->hard_limit_type == 0 && $this->sms_left / $this->sms_plan * 100 < $this->hard_limit) {
                 $hard_limit_in_effect = true;
             } elseif ($this->hard_limit_type == 1 && $this->sms_left < $this->hard_limit) {
                 $hard_limit_in_effect = true;
             }
             return $hard_limit_in_effect;
             break;
         case 'can_send_sms':
             $this->can_send_sms = $this->sms_supported == true && $this->hard_limit_in_effect == false;
             return $this->can_send_sms;
             break;
         case 'phone_response':
             $this->phone_response = $this->phone_response_data;
             return $this->phone_response;
             break;
         case 'phone_response_timeout':
             $this->phone_response_timeout = $this->phone_response_timeout_data;
             return $this->phone_response_timeout;
             break;
         case 'phone_number_departments':
             $this->phone_number_departments = array();
             foreach ($this->phone_number as $phoneData) {
                 if ($phoneData['phone'] != '') {
                     $this->phone_number_departments[$phoneData['phone']] = $phoneData['department'];
                 }
             }
             return $this->phone_number_departments;
             break;
         case 'phone_number_first':
             $this->phone_number_first = '';
             foreach ($this->phone_number as $phone) {
                 if ($phone['phone'] != '') {
                     $this->phone_number_first = $phone['phone'];
                     return $this->phone_number_first;
                 }
             }
             return $this->phone_number_first;
             break;
         case 'phone_number':
             $phoneNumber = json_decode($this->phone_number_data, true);
             if ($phoneNumber !== false) {
                 $this->phone_number = $phoneNumber;
             } else {
                 $this->phone_number = array(array('phone' => $this->phone_number_data, 'department' => 0));
             }
             for ($i = count($this->phone_number); $i < 15; $i++) {
                 $this->phone_number = array(array('phone' => '', 'department' => 0));
             }
             return $this->phone_number;
             break;
         case 'translation_config':
             if (($this->translation_config = CSCacheAPC::getMem()->getSession('automatic_translations')) == false) {
                 $db = ezcDbInstance::get();
                 $cfg = erConfigClassLhConfig::getInstance();
                 $db->query('USE ' . $cfg->getSetting('db', 'database'));
                 // Fetches from manager
                 $this->translation_config = erLhcoreClassModelChatConfig::fetch('translation_data')->data;
                 $db->query('USE ' . $cfg->getSetting('db', 'database_user_prefix') . erLhcoreClassInstance::$instanceChat->id);
                 CSCacheAPC::getMem()->setSession('automatic_translations', $this->translation_config);
             }
             return $this->translation_config;
             break;
         case 'reseller_instances_count':
             $db = ezcDbInstance::get();
             $cfg = erConfigClassLhConfig::getInstance();
             $db->query('USE ' . $cfg->getSetting('db', 'database'));
             $this->reseller_instances_count = self::getCount(array('filter' => array('reseller_id' => $this->id)));
             $db->query('USE ' . $cfg->getSetting('db', 'database_user_prefix') . erLhcoreClassInstance::$instanceChat->id);
             return $this->reseller_instances_count;
             break;
         case 'client_attributes_array':
             $this->client_attributes_array = json_decode($this->client_attributes, true);
             if (!is_array($this->client_attributes_array)) {
                 $this->client_attributes_array = array();
             }
             return $this->client_attributes_array;
             break;
         default:
             break;
     }
 }
コード例 #16
0
ファイル: lhchat.php プロジェクト: keenick/livehelperchat
 public static function prefillObjects(&$objects, $attrs = array(), $params = array())
 {
     $cache = CSCacheAPC::getMem();
     foreach ($attrs as $attr) {
         $ids = array();
         foreach ($objects as $object) {
             if (is_array($attr[0])) {
                 if (is_object($object->{$attr[0][0]}) && $object->{$attr[0][0]}->{$attr[0][1]} > 0) {
                     $ids[] = $object->{$attr[0][0]}->{$attr[0][1]};
                 }
             } else {
                 if ($object->{$attr[0]} > 0) {
                     $ids[] = $object->{$attr[0]};
                 }
             }
         }
         $ids = array_unique($ids);
         if (!empty($ids)) {
             // First try to fetch from memory
             if (isset($params['use_cache'])) {
                 list($class) = explode('::', $attr[2]);
                 $class = strtolower($class);
                 $cacheKeyPrefix = $cache->cacheGlobalKey . 'object_' . $class . '_';
                 $cacheKeyPrefixStore = 'object_' . $class . '_';
                 $cacheKeys = array();
                 foreach ($ids as $id) {
                     $cacheKeys[] = $cacheKeyPrefix . $id;
                 }
                 $cachedObjects = $cache->restoreMulti($cacheKeys);
                 if (!empty($cachedObjects)) {
                     foreach ($objects as &$item) {
                         if (is_array($attr[0])) {
                             if (isset($cachedObjects[$cacheKeyPrefix . $item->{$attr[0][0]}->{$attr[0][1]}]) && $cachedObjects[$cacheKeyPrefix . $item->{$attr[0][0]}->{$attr[0][1]}] !== false) {
                                 $item->{$attr[1][0]}->{$attr[1][1]} = $cachedObjects[$cacheKeyPrefix . $item->{$attr[0][0]}->{$attr[0][1]}];
                                 $key = array_search($item->{$attr[0][0]}->{$attr[0][1]}, $ids);
                                 if ($key !== false) {
                                     unset($ids[$key]);
                                 }
                             }
                         } else {
                             if (isset($cachedObjects[$cacheKeyPrefix . $item->{$attr[0]}]) && $cachedObjects[$cacheKeyPrefix . $item->{$attr[0]}] !== false) {
                                 $item->{$attr[1]} = $cachedObjects[$cacheKeyPrefix . $item->{$attr[0]}];
                                 $key = array_search($item->{$attr[0]}, $ids);
                                 if ($key !== false) {
                                     unset($ids[$key]);
                                 }
                             }
                         }
                     }
                 }
             }
             // Check again that ID's were not filled
             if (!empty($ids)) {
                 $filter_attr = 'id';
                 if (isset($attr[3]) && $attr[3]) {
                     $filter_attr = $attr[3];
                 }
                 $objectsPrefill = call_user_func($attr[2], array('limit' => false, 'filterin' => array($filter_attr => $ids)));
                 if ($filter_attr != 'id') {
                     $objectsPrefillNew = array();
                     foreach ($objectsPrefill as $key => $value) {
                         $objectsPrefillNew[$value->{$filter_attr}] = $value;
                     }
                     $objectsPrefill = $objectsPrefillNew;
                 }
                 foreach ($objects as &$item) {
                     if (is_array($attr[0])) {
                         if (is_object($item->{$attr[0][0]}) && isset($objectsPrefill[$item->{$attr[0][0]}->{$attr[0][1]}])) {
                             $item->{$attr[1][0]}->{$attr[1][1]} = $objectsPrefill[$item->{$attr[0][0]}->{$attr[0][1]}];
                             if (isset($params['use_cache']) && $params['use_cache'] == true) {
                                 $cache->store($cacheKeyPrefixStore . $item->{$attr[0][0]}->{$attr[0][1]}, $objectsPrefill[$item->{$attr[0][0]}->{$attr[0][1]}]);
                             }
                         }
                     } else {
                         if (isset($objectsPrefill[$item->{$attr[0]}])) {
                             $item->{$attr[1]} = $objectsPrefill[$item->{$attr[0]}];
                             if (isset($params['fill_cache']) && $params['fill_cache'] == true) {
                                 $GLOBALS[get_class($objectsPrefill[$item->{$attr[0]}]) . '_' . $item->{$attr[0]}] = $item->{$attr[1]};
                             }
                             if (isset($params['use_cache']) && $params['use_cache'] == true) {
                                 $cache->store($cacheKeyPrefixStore . $item->{$attr[0]}, $objectsPrefill[$item->{$attr[0]}]);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #17
0
 public static function moduleInit()
 {
     $url = erLhcoreClassURL::getInstance();
     $cfg = erConfigClassLhConfig::getInstance();
     self::$currentModuleName = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $url->getParam('module'));
     self::$currentView = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $url->getParam('function'));
     self::$cacheInstance = CSCacheAPC::getMem();
     self::$cacheVersionSite = self::$cacheInstance->getCacheVersion('site_version');
     self::$defaultTimeZone = $cfg->getSetting('site', 'time_zone', false);
     self::$dateFormat = $cfg->getSetting('site', 'date_format', false);
     self::$dateHourFormat = $cfg->getSetting('site', 'date_hour_format', false);
     self::$dateDateHourFormat = $cfg->getSetting('site', 'date_date_hour_format', false);
     if (self::$currentModuleName == '' || (self::$currentModule = self::getModule(self::$currentModuleName)) === false) {
         $params = $cfg->getOverrideValue('site', 'default_url');
         if (self::$currentModuleName != '') {
             header("HTTP/1.1 301 Moved Permanently");
             self::redirect();
             exit;
         }
         self::$currentView = $params['view'];
         self::$currentModuleName = $params['module'];
         self::$currentModule = self::getModule(self::$currentModuleName);
     }
     return self::runModule();
 }
コード例 #18
0
 public static function getSetting($identifier, $default_value, $user_id = false, $noSession = false)
 {
     if ($user_id == false) {
         $currentUser = erLhcoreClassUser::instance();
         if ($currentUser->isLogged()) {
             $user_id = $currentUser->getUserID();
         }
     }
     if ($user_id !== false) {
         $value = CSCacheAPC::getMem()->getSession('settings_user_id_' . $user_id . '_' . $identifier, true);
         if ($value === false && ($value = CSCacheAPC::getMem()->restore('settings_user_id_' . $user_id . '_' . $identifier)) === false) {
             $value = $default_value;
             $list = self::getList(array('filter' => array('user_id' => $user_id, 'identifier' => $identifier)));
             if (count($list) > 0) {
                 $item = array_shift($list);
                 $value = $item->value;
             } else {
                 $item = new erLhcoreClassModelUserSetting();
                 $item->value = $default_value;
                 $item->user_id = $user_id;
                 $item->identifier = $identifier;
                 $item->saveThis();
             }
             CSCacheAPC::getMem()->store('settings_user_id_' . $user_id . '_' . $identifier, $value);
             CSCacheAPC::getMem()->setSession('settings_user_id_' . $user_id . '_' . $identifier, $value, true);
         }
     } else {
         $value = $default_value;
         if ($noSession === false && ($value = CSCacheAPC::getMem()->getSession('anonymous_' . $identifier)) === false) {
             $value = $default_value;
             CSCacheAPC::getMem()->setSession('anonymous_' . $identifier, $value);
         }
     }
     return $value;
 }
コード例 #19
0
$inputData->username = isset($_GET['prefill']['username']) ? (string) $_GET['prefill']['username'] : $inputData->username;
$inputData->hash_resume = false;
$inputData->vid = false;
$inputData->question = isset($_GET['prefill']['question']) ? (string) $_GET['prefill']['question'] : $inputData->question;
$inputData->email = isset($_GET['prefill']['email']) ? (string) $_GET['prefill']['email'] : $inputData->email;
$inputData->phone = isset($_GET['prefill']['phone']) ? (string) $_GET['prefill']['phone'] : $inputData->phone;
$inputData->validate_start_chat = false;
$inputData->name_items = array();
$inputData->value_items = array();
$inputData->value_sizes = array();
$inputData->value_types = array();
$inputData->hattr = array();
$inputData->priority = is_numeric($Params['user_parameters_unordered']['priority']) ? (int) $Params['user_parameters_unordered']['priority'] : false;
// Perhaps it's direct argument
if ((string) $Params['user_parameters_unordered']['hash_resume'] != '') {
    CSCacheAPC::getMem()->setSession('chat_hash_widget_resume', (string) $Params['user_parameters_unordered']['hash_resume'], true, true);
    $inputData->hash_resume = (string) $Params['user_parameters_unordered']['hash_resume'];
}
if ((string) $Params['user_parameters_unordered']['vid'] != '') {
    $inputData->vid = (string) $Params['user_parameters_unordered']['vid'];
}
// Reopen chat automatically if possible
if (erLhcoreClassModelChatConfig::fetch('automatically_reopen_chat')->current_value == 1 && erLhcoreClassModelChatConfig::fetch('reopen_chat_enabled')->current_value == 1 && ($reopenData = erLhcoreClassChat::canReopenDirectly(array('reopen_closed' => erLhcoreClassModelChatConfig::fetch('allow_reopen_closed')->current_value))) !== false) {
    $sound = is_numeric($Params['user_parameters_unordered']['sound']) ? '/(sound)/' . $Params['user_parameters_unordered']['sound'] : '';
    erLhcoreClassModule::redirect('chat/reopen', '/' . $reopenData['id'] . '/' . $reopenData['hash'] . '/(mode)/widget' . $modeAppend . $sound);
    exit;
}
$chat = new erLhcoreClassModelChat();
// Assign department instantly
if ($inputData->departament_id > 0) {
    $chat->dep_id = $inputData->departament_id;
コード例 #20
0
ファイル: lhmodule.php プロジェクト: detain/livehelperchat
 public static function moduleInit($params = array())
 {
     $cfg = erConfigClassLhConfig::getInstance();
     self::$debugEnabled = $cfg->getSetting('site', 'debug_output');
     // Enable errors output before extensions intialization
     if (self::$debugEnabled == true) {
         @ini_set('error_reporting', E_ALL);
         @ini_set('display_errors', 1);
     }
     self::$cacheInstance = CSCacheAPC::getMem();
     self::$cacheVersionSite = self::$cacheInstance->getCacheVersion('site_version');
     self::$defaultTimeZone = $cfg->getSetting('site', 'time_zone', false);
     self::$dateFormat = $cfg->getSetting('site', 'date_format', false);
     self::$dateHourFormat = $cfg->getSetting('site', 'date_hour_format', false);
     self::$dateDateHourFormat = $cfg->getSetting('site', 'date_date_hour_format', false);
     $url = erLhcoreClassURL::getInstance();
     if (!isset($params['ignore_extensions'])) {
         // Attatch extension listeners
         self::attatchExtensionListeners();
     }
     self::$currentModuleName = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $url->getParam('module'));
     self::$currentView = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $url->getParam('function'));
     if (self::$currentModuleName == '' || (self::$currentModule = self::getModule(self::$currentModuleName)) === false) {
         $params = $cfg->getOverrideValue('site', 'default_url');
         if (self::$currentModuleName != '') {
             header("HTTP/1.1 301 Moved Permanently");
             self::redirect();
             exit;
         }
         self::$currentView = $params['view'];
         self::$currentModuleName = $params['module'];
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.core.default_url', array('url' => &$url));
         self::$currentModule = self::getModule(self::$currentModuleName);
     }
     return self::runModule();
 }
コード例 #21
0
<?php

// Set new chat owner
$currentUser = erLhcoreClassUser::instance();
$currentUser->getUserID();
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
// Chat can be closed only by owner
if ($chat->user_id == $currentUser->getUserID() || $currentUser->hasAccessTo('lhchat', 'allowcloseremote')) {
    if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
        die('Invalid CSRF Token');
        exit;
    }
    if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
        $chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
        $chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
        $userData = $currentUser->getUserData(true);
        $msg = new erLhcoreClassModelmsg();
        $msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
        $msg->chat_id = $chat->id;
        $msg->user_id = -1;
        $chat->last_user_msg_time = $msg->time = time();
        erLhcoreClassChat::getSession()->save($msg);
        $chat->updateThis();
        erLhcoreClassChat::updateActiveChats($chat->user_id);
        // Execute callback for close chat
        erLhcoreClassChat::closeChatCallback($chat, $userData);
    }
}
CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', (int) $Params['user_parameters']['chat_id']);
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
コード例 #22
0
ファイル: lhuser.php プロジェクト: Adeelgill/livehelperchat
 public function getUserTimeZone()
 {
     if (($cacheTimeZone = CSCacheAPC::getMem()->getSession('lhc_user_timezone', true)) !== false) {
         return $cacheTimeZone;
     }
     try {
         $userData = $this->getUserData(true);
         CSCacheAPC::getMem()->setSession('lhc_user_timezone', $userData->time_zone, true);
         return $userData->time_zone;
     } catch (Exception $e) {
         CSCacheAPC::getMem()->setSession('lhc_user_timezone', '', true);
     }
 }