/** * @param Request $request * @return null|RedirectResponse */ public function onLogoutSuccess(Request $request) { // Chamilo logout $request->getSession()->remove('_locale'); $request->getSession()->remove('_locale_user'); if (api_is_global_chat_enabled()) { $chat = new \Chat(); $chat->setUserStatus(0); } $userId = $this->storage->getToken()->getUser()->getId(); $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $sql = "SELECT login_id, login_date\n FROM {$tbl_track_login}\n WHERE login_user_id = {$userId}\n ORDER BY login_date DESC\n LIMIT 0,1"; $row = Database::query($sql); $loginId = null; if (Database::num_rows($row) > 0) { $loginId = Database::result($row, 0, "login_id"); } $loginAs = $this->checker->isGranted('ROLE_PREVIOUS_ADMIN'); if (!$loginAs) { $current_date = api_get_utc_datetime(); $sql = "UPDATE {$tbl_track_login}\n SET logout_date='" . $current_date . "'\n \t\t WHERE login_id='{$loginId}'"; Database::query($sql); } $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); $query = "DELETE FROM " . $online_table . " WHERE login_user_id = {$userId}"; Database::query($query); require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php'; exit_of_chat($userId); $login = $this->router->generate('home'); $response = new RedirectResponse($login); return $response; }
public function getSpecific() { $username = Input::get('username'); $chat = new Chat(); $result = $chat->getChat($username); return json_encode($result); }
function render_chat($league_id){ require_once(APPPATH.'controllers/chat.php'); $chat = new Chat(); $chat->index($league_id); }
/** * @param \Chat\Bundle\CommonBundle\Entity\Chat $chat * @param array $hashList * @return array */ public function getChatMessages(Chat $chat, $hashList = array()) { $messages = $this->_em->getConnection()->fetchAll(' SELECT cm.id, cm.hash, cm.content, cm.createAt, m.username, m.textColor, m.backgroundColor FROM `chat_message` cm LEFT JOIN `chat_member` m ON m.id = cm.member_id WHERE cm.`chat_id` = :chat_id AND cm.hash NOT IN (' . implode(',', $hashList) . ') ORDER BY cm.create_at ASC ', array('chat_id' => $chat->getId())); foreach ($messages as $key => $value) { $createAt = new \DateTime($value['create_at']); $value['create_at'] = $createAt->format('m.d.y g:i a'); $messages[$key] = $value; } return $messages; }
public function get_ticket() { //获取 component_verify_ticket 每十分钟微信服务本服务器请求一次 $wechat = new Chat($this->config); $data = $wechat->request(); // print_r($data);die; if (isset($data['InfoType'])) { if ($data['InfoType'] == 'component_verify_ticket') { if (isset($data['ComponentVerifyTicket']) && $data['ComponentVerifyTicket']) { if ($config = D('Config')->where("`name`='wx_componentverifyticket'")->find()) { D('Config')->where("`name`='wx_componentverifyticket'")->data(array('value' => $data['ComponentVerifyTicket']))->save(); } else { D('Config')->data(array('name' => 'wx_componentverifyticket', 'value' => $data['ComponentVerifyTicket'], 'type' => 'type=text', 'gid' => 0, 'tab_id' => 0))->add(); } S(C('now_city') . 'config', null); exit('success'); } } elseif ($data['InfoType'] == 'unauthorized') { if (isset($data['AuthorizerAppid']) && $data['AuthorizerAppid']) { D('Weixin_bind')->where("`authorizer_appid`='{$data['AuthorizerAppid']}'")->delete(); exit('success'); } } } }
function onDisconnected() { // We reset the Chat view $c = new Chat(); $c->ajaxGet(); $this->refreshRooms(); Notification::append(null, $this->__('chatrooms.disconnected')); }
function save($id = FALSE) { if ($_POST) { $chat = new Chat($id); $_POST['user_id'] = $this->session->userdata('id'); $chat->from_array($_POST); $chat->save(); set_notify('success', lang('save_data_complete')); } redirect('chats/admin/chats'); }
/** * @return void Directly redirects the user or leaves him where he is, but doesn't return anything * @param int $userId * @param bool $logout_redirect * @author Fernando P. García <*****@*****.**> */ public static function logout($user_id = null, $logout_redirect = false) { global $extAuthSource; // Database table definition $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); if (empty($user_id)) { $user_id = api_get_user_id(); } $user_id = intval($user_id); // Changing global chat status to offline if (api_is_global_chat_enabled()) { $chat = new Chat(); $chat->set_user_status(0); } // selecting the last login of the user $sql_last_connection = "SELECT login_id, login_date FROM {$tbl_track_login}\n WHERE login_user_id='{$user_id}' ORDER BY login_date DESC LIMIT 0,1"; $q_last_connection = Database::query($sql_last_connection); $i_id_last_connection = null; if (Database::num_rows($q_last_connection) > 0) { $i_id_last_connection = Database::result($q_last_connection, 0, "login_id"); } if (!isset($_SESSION['login_as']) && !empty($i_id_last_connection)) { $current_date = api_get_utc_datetime(); $s_sql_update_logout_date = "UPDATE {$tbl_track_login} SET logout_date='" . $current_date . "' WHERE login_id = '{$i_id_last_connection}'"; Database::query($s_sql_update_logout_date); } Online::loginDelete($user_id); //from inc/lib/online.inc.php - removes the "online" status //the following code enables the use of an external logout function. //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php // then a function called ldap_logout() inside that file // (using *authent_name*_logout as the function name) and the following code // will find and execute it $uinfo = api_get_user_info($user_id); if (isset($uinfo['auth_source']) && $uinfo['auth_source'] != PLATFORM_AUTH_SOURCE && is_array($extAuthSource)) { if (is_array($extAuthSource[$uinfo['auth_source']])) { $subarray = $extAuthSource[$uinfo['auth_source']]; if (!empty($subarray['logout']) && file_exists($subarray['logout'])) { require_once $subarray['logout']; $logout_function = $uinfo['auth_source'] . '_logout'; if (function_exists($logout_function)) { $logout_function($uinfo); } } } } require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php'; exit_of_chat($user_id); if ($logout_redirect) { header("Location: index.php"); exit; } }
/** * @Route("/editor/filemanager", name="editor_filemanager") * @Method({"GET"}) */ public function editorFileManager(Request $request) { \Chat::setDisableChat(); $courseId = $request->get('course_id'); $sessionId = $request->get('session_id'); return $this->render('@ChamiloCore/default/javascript/editor/ckeditor/elfinder.html.twig', ['course_id' => $courseId, 'session_id' => $sessionId]); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Chat::create([]); } }
/** * Chat offline shortcode * * @access public * @return string */ function sc_chat_shortcode_offline($atts, $content = '') { // Check if all OPs offline if (!Chat::check_if_any_op_online()) { return $content; } }
/** * 单例方法 */ public static function getInstance() { if (!self::$server instanceof Chat) { self::$server = new self(); } return self::$server; }
public function setIsSystem($isSystem = ChatMessageManager::IS_SYSTEM_YES) { if (!in_array($isSystem, Chat::getConstsArray('IS_SYSTEM'))) { throw new InvalidArgumentException("Invalid \$isSystem specified"); } $this->qb->andWhere($this->qb->expr()->equal(new Field("is_system", "chat_msg"), $isSystem)); return $this; }
public function loadModelById($id) { $model = Chat::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } else { return $model; } }
public static function getChatByID($chatID) { include 'connect.php'; $sql = "SELECT * FROM chats WHERE id = {$chatID}"; //echo $sql; $result = mysql_query($sql); $row = mysql_fetch_array($result); mysql_close(); if ($row) { $chat = new Chat(); $chat->setChatID($row['id']); $chat->setUser1($row['user1']); $chat->setUser2($row['user2']); return $chat; } else { return false; } }
public function main() { $room = intval($_POST['room']); $game = intval($_POST['game']); $loggedUser = LoggedUser::whoIsLogged(); $lastActivity = Room::getUserLastActivityInRoom($loggedUser['id'], $room); Room::updateUserLastActivity($loggedUser['id'], $room); MySmarty::assign('messages', Chat::getMessages($room, $loggedUser['id'], 0, $game)); echo MySmarty::fetch('message-box.tpl'); }
public function post($resourceVals, $data, $userId) { global $logger, $warnings_payload; $chatId = $resourceVals['messages']; if (isset($chatId)) { $warnings_payload[] = 'POST call to /messages must not have ' . '/chatID appended i.e. POST /user/messags'; throw new UnsupportedResourceMethodException(); } $nowFormat = date('Y-m-d H:i:s'); $chatObj = new Chat($data['from'], $data['to'], $data['message'], $nowFormat, 0); $logger->debug("POSTed Message Detail: " . $chatObj->toString()); $this->collapDAO->insert($chatObj); $messageDetail = $chatObj->toArray(); if (!isset($messageDetail['id'])) { return array('code' => '2011'); } $this->messageDetail[] = $messageDetail; return array('code' => '2001', 'data' => array('messageDetail' => $this->messageDetail)); }
function ajaxSend($to, $pack, $file) { if (!$this->validateJid($to)) { return; } list($key, $ext) = explode('.', $file); $filepath = dirname(__FILE__) . '/stickers/' . $pack . '/' . $key . '.png'; if (!file_exists($filepath)) { return; } // We get the base64 $base64 = base64_encode(file_get_contents($filepath)); // Caching the picture if (!file_exists(CACHE_PATH . md5($key) . '.png')) { $p = new Picture(); $p->fromBase($base64); $p->set($key, 'png'); } // Creating a message $m = new \Modl\Message(); $m->session = $this->user->getLogin(); $m->jidto = echapJid($to); $m->jidfrom = $this->user->getLogin(); $m->sticker = $key; $m->body = $this->__('sticker.sent'); $m->published = gmdate('Y-m-d H:i:s'); $session = \Session::start(); $m->id = Uuid::uuid4(); $m->type = 'chat'; $m->resource = $session->get('resource'); // Sending the sticker $html = "<p><img alt='Sticker' src='cid:sha1+" . $key . "@bob.xmpp.org'/></p>"; $p = new Publish(); $p->setTo($m->jidto)->setContent($m->body)->setHTML($html)->setId($m->id)->request(); $md = new \Modl\MessageDAO(); $md->set($m); // Sending it to Chat $packet = new Moxl\Xec\Payload\Packet(); $packet->content = $m; $c = new Chat(); $c->onMessage($packet); }
public function say() { if ($this->isPost()) { $message = new ChatMessage(); $message->set_model($this->vars()); $message->save(); C($message)->commit(); self::$static_flag = true; } exit; }
function __construct() { // Check if chat already exists $user_one = getLoggedInUserGuid(); $user_two = pageArray(2); $chat = getEntity(array("type" => "Chat", "metadata_name_value_pairs" => array(array("name" => "user_one", "value" => $user_one), array("name" => "user_two", "value" => $user_two)))); if (!$chat) { $chat = getEntity(array("type" => "Chat", "metadata_name_value_pairs" => array(array("name" => "user_one", "value" => $user_two), array("name" => "user_two", "value" => $user_one)))); } if (!$chat) { $chat = new Chat(); $chat->user_one = $user_one; $chat->user_two = $user_two; $chat->save(); } $chat->user_one_closed = false; $chat->user_two_closed = false; $chat->save(); forward(); }
public static function getChats($lastID) { $lastID = (int) $lastID; $result = DB::query('SELECT * FROM webchat_lines WHERE id > ' . $lastID . ' ORDER BY id ASC'); $chats = array(); while ($chat = $result->fetch_object()) { $chat->time = array('hours' => gmdate('H', strtotime($chat->ts)), 'minutes' => gmdate('i', strtotime($chat->ts))); $chat->gravatar = Chat::gravatarFromHash($chat->gravatar); $chats[] = $chat; } return array('chats' => $chats); }
public function retrieveTypingStatus() { $username = Input::get('username'); $chat = Chat::find(1); if ($chat->user1 == $username) { if ($chat->user2_is_typing) { return $chat->user2; } } else { if ($chat->user1_is_typing) { return $chat->user1; } } }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if ($this->room !== NULL) { Room::addUser($loggedUser['id'], $this->room['id']); $messages = Chat::getMessages($this->room['id'], $loggedUser['id'], 0, $this->game['id']); MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('messages', $messages); MySmarty::assign('users', Room::getUsers($this->room['id'])); MySmarty::assign('emoticonDir', EMOTICONS_DIR); MySmarty::assign('emoticons', Emoticons::getEmoticons()); MySmarty::assign('room', $this->room); } }
public static function formatMessages($messages, $set_last = true) { foreach ($messages as &$message) { $date = date('g:ia', $message['timestamp']); $message['date'] = substr($date, 0, -1); // converts "am" to "a", etc $message['message'] = self::formatMessage($message['message'], $message['type']); $message['name'] = Tools::stripHTML($message['name']); } if ($set_last) { self::$last_message_id = $message['message_id']; error_log(self::$last_message_id); } return $messages; }
/** * Обновление сообщений в чате */ public function actionUpdateListChat() { if (Yii::app()->request->isAjaxRequest) { $listChat = ''; if (isset($_POST['lastMsgId'])) { // $lastId = (int)Chat::getLastId(); // if ($lastId != (int)$_POST['lastMsgId']) { $result = Chat::getListChat(); $listChat = $this->renderPartial('//chat/_listChat', array('dataProvider' => $result), true); // } } echo CJSON::encode(array('listChat' => $listChat)); exit; } }
/** * Find all conversations between 2 users * * @return JSON Ajax */ public function find() { if (Request::ajax()) { $array = array(Auth::id(), new MongoId(Input::get('receiver_id'))); $chat = Chat::whereIn('participants', $array)->first(); if (isset($chat->_id)) { $sender = UserController::getUser(Auth::user()); $receiver = UserController::getUser(User::first(Input::get('receiver_id'))); $sender_name = $sender->name . ' ' . $sender->last_name; $receiver_name = $receiver->name . ' ' . $receiver->last_name; return Response::json(array('chat' => $chat, 'sender' => array('_id' => $sender->_id, 'name' => $sender_name), 'receiver' => array('_id' => $receiver->_id, 'name' => $receiver_name))); } else { return Response::json(array('chat' => "")); } } }
/** * Конструктор * @return bool */ protected function beforeAction() { $this->layout = 'start_page'; $this->topMenu = Mainmenu::getMenu('top', 'site'); $this->middleMenu = Mainmenu::getMenu('middle', 'site'); $this->listChat = Chat::getListChat(); $this->randomArt = Articles::getRandomArticles(10); $this->tags = Tags::getMenu(Tags::model()->findAll()); $settingChat = Settings::model()->findByAttributes(array('parameter' => Yii::app()->params['parameter']['chat'])); $this->stateChat = null != $settingChat ? (int) $settingChat->value : 0; if (!Yii::app()->user->isGuest) { $this->_user = Users::model()->findByPk(Yii::app()->user->id); } else { $this->_loginModel = new LoginForm(); } return true; }
protected function run() { if ($this->check === self::OK) { $messageParams = array('text' => $this->params['text'], 'room' => $this->room['id'], 'game' => $this->game['id']); Chat::addMessage($messageParams); if ($this->game->getIsHNGag()) { if ($this->actualPlayer['actual_lifes'] == 1) { // TODO nejaky priznak ze hrac bol upozorneny a potom mu toto uz nezobrazovat len ho removnut z hry $message = array('text' => 'nesmies hovorit, lebo stratis posledny zivot', 'toUser' => $this->loggedUser['id']); $this->addMessage($message); } else { // TODO info o tom ze hrac stratil zivot kvoli tomu ze keca $this->actualPlayer['actual_lifes'] = $this->actualPlayer['actual_lifes'] - 1; $this->actualPlayer->save(); } } } }
/** * * @param integer $relatedID * @param integer $userID * @param integer $lastID * @param mixed $data * @return Chat[] */ public function yiichat_list_posts($relatedID, $userID, $lastID, $data) { $limit = 3; $rows = array(); if ($lastID == -1) { $chats = Chat::model()->findAll(array('order' => 'datetime ASC', 'condition' => 'relatedID = :relatedID', 'params' => array(':relatedID' => $relatedID))); foreach ($chats as $key => $chat) { $rows[$key] = $this->restructureChat($chat); } } else { $chats = Chat::model()->findAll(array('condition' => 'userID != :userID AND relatedID = :relatedID', 'order' => 'datetime DESC', 'params' => array(':userID' => $userID, ':relatedID' => $relatedID))); $lastChats = $this->getLastPosts($chats, $limit, $lastID); foreach ($lastChats as $key => $lastChat) { $rows[$key] = $this->restructureChat($lastChat); } } return $rows; }
public function actionChat() { $dbOptions = array('db_host' => 'localhost', 'db_user' => 'root', 'db_pass' => '', 'db_name' => 'ot'); session_name('webchat'); session_id(rand(1, 5)); if (get_magic_quotes_gpc()) { // If magic quotes is enabled, strip the extra slashes array_walk_recursive($_GET, create_function('&$v,$k', '$v = stripslashes($v);')); array_walk_recursive($_POST, create_function('&$v,$k', '$v = stripslashes($v);')); } try { // Connecting to the database //$db = new DB; $chat = new Chat(); //DB::init($dbOptions); $response = array(); // Handling the supported actions: switch ($_GET['action']) { case 'login': $response = array('status' => 1, 'name' => Yii::app()->user->name, 'gravatar' => Chat::gravatarFromHash('123')); break; case 'checkLogged': $response = $chat::checkLogged(); break; case 'logout': $response = $chat::logout(); break; case 'submitChat': $response = $chat::submitChat($_POST['chatText']); break; case 'getUsers': $response = $chat::getUsers(); break; case 'getChats': $response = $chat::getChats($_GET['lastID']); break; default: throw new Exception('Wrong action'); } echo json_encode($response); } catch (Exception $e) { die(json_encode(array('error' => $e->getMessage()))); } }