uawdijnntqw1x1x1
IP : 3.144.200.28
Hostname : axolotl
Kernel : Linux axolotl 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
OS : Linux
PATH:
/
var
/
www
/
axolotl
/
data
/
www
/
b24.axolotl.ru
/
.
/
public_html
/
bitrix
/
modules
/
imopenlines
/
lib
/
im.php
/
/
<?php namespace Bitrix\ImOpenLines; use \Bitrix\Main\Loader, \Bitrix\Main\UserTable, \Bitrix\Main\Data\Cache, \Bitrix\Main\Application, \Bitrix\Main\Type\DateTime, \Bitrix\Im\Model\ChatTable, \Bitrix\Main\ORM\Query\Query, \Bitrix\Main\Localization\Loc, \Bitrix\Main\DB\SqlExpression, \Bitrix\Main\Entity\ReferenceField, \Bitrix\Main\ORM\Fields\ExpressionField; Loc::loadMessages(__FILE__); class Im { /** Time to cache online operator status. */ const CACHE_TIME_IM_USER_ONLINE = 5; /** Path for online operator status cache. */ const CACHE_DIR_IM_USER_ONLINE = '/imopenlines/im_user_online/'; /** * @param $fields * @return bool|int */ public static function addMessage($fields) { $result = false; if(Loader::includeModule('im')) { $fields['MESSAGE_TYPE'] = IM_MESSAGE_OPEN_LINE; $result = \CIMMessenger::Add($fields); if (!$result) { $errorMessage = 'Unknown error'; if ($e = $GLOBALS['APPLICATION']->GetException()) { $errorMessage = $e->GetString(); } \Bitrix\ImOpenLines\Log::write([$fields, $errorMessage], 'DEBUG SESSION'); } } return $result; } /** * @param $chatId * @param $message * @return bool|int */ public static function addAutomaticSystemMessage($chatId, $message) { return self::addMessage([ 'TO_CHAT_ID' => $chatId, 'MESSAGE' => $message, 'SYSTEM' => 'Y', 'URL_PREVIEW' => 'N', 'IMPORTANT_CONNECTOR' => 'Y', 'PARAMS' => [ 'CLASS' => 'bx-messenger-content-item-ol-output', ] ]); } /** * @param $chatId * @param int $timeLimitVote * @return bool|int */ public static function addCloseVoteMessage($chatId, $timeLimitVote = 0) { $timeLimitVote = (int)$timeLimitVote; $message = Loc::getMessage('IMOL_IM_CLOSE_VOTE_MESSAGE_NO_DAY'); if( !empty($timeLimitVote) && $timeLimitVote > 0 ) { $message = Loc::getMessage('IMOL_IM_CLOSE_VOTE_MESSAGE', ['#DAYS#' => \FormatDate('ddiff', time() - $timeLimitVote)]); } return self::addMessage([ 'TO_CHAT_ID' => $chatId, 'MESSAGE' => $message, 'SYSTEM' => 'Y', 'IMPORTANT_CONNECTOR' => 'Y', 'NO_SESSION_OL' => 'Y', 'RECENT_ADD' => 'N', 'PARAMS' => [ 'CLASS' => 'bx-messenger-content-item-ol-output', ] ]); } /** * @param $messages * @return array */ public static function addMessagesNewsletter($messages): array { $result = array(); $userCodes = array(); if (is_array($messages) && Loader::includeModule('im')) { foreach ($messages as $code => $message) { $result[$code] = false; $userCodes[] = $code; } $rawChat = ChatTable::getList(array( 'select' => array('ID', 'ENTITY_ID', 'RECENT_MID' => 'RECENT.ITEM_MID', 'ENTITY_DATA_1'), 'filter' => array( '=ENTITY_TYPE' => 'LINES', '=ENTITY_ID' => $userCodes ), 'runtime' => array( new ReferenceField( 'RECENT', '\Bitrix\Im\Model\RecentTable', array( '=this.ID' => 'ref.ITEM_ID', '=this.AUTHOR_ID' => 'ref.USER_ID', 'ref.ITEM_TYPE' => new SqlExpression('?i', IM_MESSAGE_OPEN_LINE) ) ) ) )); while($rowChat = $rawChat->fetch()) { //TODO: Replace with the method \Bitrix\ImOpenLines\Chat::parseLinesChatEntityId or \Bitrix\ImOpenLines\Chat::parseLiveChatEntityId $chatFieldData = explode('|', $rowChat['ENTITY_DATA_1']); $blockTimestamp = (int)$chatFieldData[8]; if ($blockTimestamp !== 0 && $blockTimestamp < (new DateTime())->getTimestamp()) { continue; } $fields = $messages[$rowChat['ENTITY_ID']]; $fields['MESSAGE_TYPE'] = IM_MESSAGE_OPEN_LINE; $fields['TO_CHAT_ID'] = $rowChat['ID']; $fields['FROM_USER_ID'] = 0; $fields['SYSTEM'] = 'Y'; $fields['SKIP_USER_CHECK'] = 'Y'; $fields['IMPORTANT_CONNECTOR'] = 'Y'; $fields['INCREMENT_COUNTER'] = 'N'; $fields['PUSH'] = 'N'; if(empty($rowChat['RECENT_MID'])) $fields['RECENT_ADD'] = 'N'; else $fields['RECENT_ADD'] = 'Y'; $fields['NO_SESSION_OL'] = 'Y'; $result[$rowChat['ENTITY_ID']] = \CIMMessenger::Add($fields); } } return $result; } /** * @param $fields * @return bool|int */ public static function addMessageLiveChat($fields) { $result = false; if(Loader::includeModule('im')) { $fields['MESSAGE_TYPE'] = IM_MESSAGE_CHAT; $result = \CIMMessenger::Add($fields); if (!$result) { $errorMessage = 'Unknown error'; if ($e = $GLOBALS['APPLICATION']->GetException()) { $errorMessage = $e->GetString(); } \Bitrix\ImOpenLines\Log::write([$fields, $errorMessage], 'DEBUG SESSION'); } } return $result; } /** * @param int $chatId * @return bool */ public static function chatHide($chatId) { if (Loader::includeModule('im')) { return \CIMChat::hide($chatId); } return false; } /** * Determining the status of an online operator using the messenger functionality. * * @param $id * @return bool */ public static function userIsOnline($id) { $result = false; if(Loader::includeModule('im')) { $id = intval($id); if ($id > 0) { $cache = Cache::createInstance(); if ($cache->initCache(self::CACHE_TIME_IM_USER_ONLINE, $id, self::CACHE_DIR_IM_USER_ONLINE)) { $result = $cache->getVars(); } elseif ($cache->startDataCache()) { $lastActivityDate = Queue::getTimeLastActivityOperator(); $timeHelper = Application::getConnection()->getSqlHelper()->addSecondsToDateTime('(-'.$lastActivityDate.')'); $query = new Query(UserTable::getEntity()); $query->setSelect(['IS_ONLINE_CUSTOM']); $query->registerRuntimeField('', new ReferenceField( 'IM_STATUS', '\Bitrix\Im\Model\StatusTable', ['=ref.USER_ID' => 'this.ID'], ['join_type'=>'left'] )); $query->registerRuntimeField('', new ExpressionField( 'IS_ONLINE_CUSTOM', 'CASE WHEN %1$s > '.$timeHelper.' && (%2$s IS NULL || %1$s > %2$s) THEN \'Y\' ELSE \'N\' END', ['LAST_ACTIVITY_DATE', 'IM_STATUS.IDLE']) ); $query->setFilter(['ID' => $id]); $resultQuery = $query->exec(); if ($resultQuery->fetch()['IS_ONLINE_CUSTOM'] == 'Y') { $result = true; } $cache->endDataCache($result); } } } return $result; } }
/var/www/axolotl/data/www/b24.axolotl.ru/./public_html/bitrix/modules/imopenlines/lib/im.php