public function __get($var)
 {
     switch ($var) {
         case 'chat':
             $this->chat = false;
             if ($this->chat_id > 0) {
                 try {
                     $this->chat = erLhcoreClassModelChat::fetch($this->chat_id);
                 } catch (Exception $e) {
                     erLhcoreClassChatbox::getSession()->delete($this);
                 }
             } else {
                 $this->chat = new erLhcoreClassModelChat();
                 $this->chat->hash = erLhcoreClassChat::generateHash();
             }
             return $this->chat;
             break;
         default:
             break;
     }
 }
Beispiel #2
0
        <th width="1%">ID</th>
        <th><?php 
    echo erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/list', 'Name');
    ?>
</th>
        <th><?php 
    echo erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/list', 'Identifier');
    ?>
</th>
        <th></th>
        <th></th>
        <th></th>
    </tr>
</thead>
    <?php 
    foreach (erLhcoreClassChatbox::getList(array('limit' => $pages->items_per_page, 'offset' => $pages->low)) as $chat) {
        ?>
    <tr>
        <td><?php 
        echo $chat->id;
        ?>
</td>
        <td><?php 
        echo htmlspecialchars($chat->name);
        ?>
</td>
        <td><?php 
        echo htmlspecialchars($chat->identifier);
        ?>
</td>
        <td class="small-1" nowrap>
 public static function getSession()
 {
     if (!isset(self::$persistentSession)) {
         self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhchatbox'));
     }
     return self::$persistentSession;
 }
            ?>
	    <input class="form-control" type="text" class="mt5 mb0" placholder="Nick" title="Nick" value="<?php 
            echo htmlspecialchars(erLhcoreClassChatbox::getVisitorName(), ENT_QUOTES);
            ?>
" id="CSChatNick" />
	    <?php 
        }
        ?>
	</div>

    <div class="pt5">
    	<?php 
        if (isset($_GET['dnc']) && $_GET['dnc'] == 'true') {
            ?>
    		<span><?php 
            echo htmlspecialchars(erLhcoreClassChatbox::getVisitorName(), ENT_QUOTES);
            ?>
</span>
    	<?php 
        }
        ?>
        <textarea class="form-control" rows="4" name="ChatMessage" placeholder="<?php 
        echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chat', 'Enter your message');
        ?>
" id="CSChatMessage"></textarea>
        <script type="text/javascript">
        jQuery('#CSChatMessage').bind('keydown', 'return', function (evt){
            lhinst.addmsguserchatbox();
            return false;
        });
        </script>
Beispiel #5
0
<?php

header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');
header('Content-type: text/javascript');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 8) . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
$theme = false;
if (isset($Params['user_parameters_unordered']['theme']) && (int) $Params['user_parameters_unordered']['theme'] > 0) {
    $theme = (int) $Params['user_parameters_unordered']['theme'];
} else {
    $defaultTheme = erLhcoreClassModelChatConfig::fetch('default_theme_id')->current_value;
    if ($defaultTheme > 0) {
        $theme = (int) $defaultTheme;
    }
}
$tpl = erLhcoreClassTemplate::getInstance('lhchatbox/embed.tpl.php');
$tpl->set('heightchatcontent', !is_null($Params['user_parameters_unordered']['chat_height']) && (int) $Params['user_parameters_unordered']['chat_height'] > 0 ? (int) $Params['user_parameters_unordered']['chat_height'] : 220);
$tpl->set('nick', erLhcoreClassChatbox::getVisitorName());
$tpl->set('theme', $theme);
echo $tpl->fetch();
exit;
Beispiel #6
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhchatbox/list.tpl.php');
$pages = new lhPaginator();
$pages->items_total = erLhcoreClassChatbox::getCount();
$pages->serverURL = erLhcoreClassDesign::baseurl('chatbox/list');
$pages->paginate();
$tpl->set('pages', $pages);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('chatbox/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/configuration', 'Chatbox')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/list', 'Chatbox list')));
Beispiel #7
0
         $prevNick = '';
         if ($Params['user_parameters']['message_id'] > 0 && count($Messages) > 1) {
             $lastMessage = array_shift($Messages);
             if ($lastMessage['id'] == $Params['user_parameters']['message_id']) {
                 $prevNick = $lastMessage['user_id'] == 0 ? $lastMessage['name_support'] : $chat->nick;
             } else {
                 array_unshift($Messages, $lastMessage);
             }
         }
         $tpl = erLhcoreClassTemplate::getInstance('lhchatbox/syncuser.tpl.php');
         $tpl->set('messages', $Messages);
         $tpl->set('chat', $chat);
         $tpl->set('prev_nick', $prevNick);
         $tpl->set('sync_mode', isset($Params['user_parameters_unordered']['mode']) ? $Params['user_parameters_unordered']['mode'] : '');
         $content = $tpl->fetch();
         $visitorName = erLhcoreClassChatbox::getVisitorName();
         foreach ($Messages as $msg) {
             if ($msg['name_support'] != $visitorName) {
                 $userOwner = 'false';
                 break;
             }
         }
         $LastMessageIDs = array_pop($Messages);
         $LastMessageID = $LastMessageIDs['id'];
         $breakSync = true;
     }
 }
 if ($chat->is_operator_typing == true && $Params['user_parameters_unordered']['ot'] != 't') {
     $ott = $chat->operator_typing_user !== false ? $chat->operator_typing_user->name_support . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chat', 'is typing now...') : erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chat', 'Operator is typing now...');
     $breakSync = true;
 } elseif ($Params['user_parameters_unordered']['ot'] == 't' && $chat->is_operator_typing == false) {
$themeID = isset($Params['user_parameters_unordered']['theme']) && (int) $Params['user_parameters_unordered']['theme'] > 0 ? (int) $Params['user_parameters_unordered']['theme'] : 0;
if ($themeID == 0) {
    $defaultTheme = erLhcoreClassModelChatConfig::fetch('default_theme_id')->current_value;
    if ($defaultTheme > 0) {
        $themeID = $defaultTheme;
    }
}
$cacheKey = md5('chatbox_version_' . $cache->getCacheVersion('chatbox_' . (string) $Params['user_parameters_unordered']['identifier']) . '_theme_' . $themeID . '_identifier_' . (string) $Params['user_parameters_unordered']['identifier'] . '_hash_' . (string) $Params['user_parameters_unordered']['hashchatbox'] . $visitorName . '_height_' . (int) $Params['user_parameters_unordered']['chat_height'] . '_sound_' . (int) $Params['user_parameters_unordered']['sound'] . '_mode_' . (string) $Params['user_parameters_unordered']['mode'] . '_siteaccess_' . erLhcoreClassSystem::instance()->SiteAccess);
if (($Result = $cache->restore($cacheKey)) === false) {
    $referer = '';
    $tpl = erLhcoreClassTemplate::getInstance('lhchatbox/chatwidget.tpl.php');
    $tpl->set('chatbox_chat_height', !is_null($Params['user_parameters_unordered']['chat_height']) && (int) $Params['user_parameters_unordered']['chat_height'] > 0 ? (int) $Params['user_parameters_unordered']['chat_height'] : 220);
    if ($Params['user_parameters_unordered']['sound'] !== null && is_numeric($Params['user_parameters_unordered']['sound'])) {
        erLhcoreClassModelUserSetting::setSetting('chat_message', (int) $Params['user_parameters_unordered']['sound'] == 1 ? 1 : 0);
    }
    $chatbox = erLhcoreClassChatbox::getInstance((string) $Params['user_parameters_unordered']['identifier'], (string) $Params['user_parameters_unordered']['hashchatbox']);
    $tpl->set('chatbox', $chatbox);
    $tpl->set('referer', $referer);
    if (isset($_GET['URLReferer'])) {
        $referer = $_GET['URLReferer'];
        $tpl->set('referer', $referer);
    }
    if (isset($_POST['URLRefer'])) {
        $referer = $_POST['URLRefer'];
        $tpl->set('referer', $_POST['URLRefer']);
    }
    $embedMode = false;
    $modeAppend = '';
    if ((string) $Params['user_parameters_unordered']['mode'] == 'embed') {
        $embedMode = true;
        $modeAppend = '/(mode)/embed';
Beispiel #9
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhchatbox/new.tpl.php');
$chatbox = new erLhcoreClassModelChatbox();
if (isset($_POST['Save'])) {
    $Errors = erLhcoreClassChatbox::validateChatbox($chatbox);
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect();
        exit;
    }
    if (count($Errors) == 0) {
        // Predefine some default variables
        $departments = erLhcoreClassModelDepartament::getList();
        $ids = array_keys($departments);
        $id = array_shift($ids);
        $chatbox->chat->dep_id = $id;
        $chatbox->chat->time = time();
        $chatbox->chat->saveThis();
        $chatbox->chat_id = $chatbox->chat->id;
        $chatbox->saveThis();
        erLhcoreClassModule::redirect('chatbox/list');
        exit;
    } else {
        $tpl->set('errors', $Errors);
    }
}
if (isset($_POST['Cancel'])) {
    erLhcoreClassModule::redirect('chatbox/list');
    exit;
}
$tpl->set('chatbox', $chatbox);
Beispiel #10
0
        // 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;
}