public function showWelcome() { $message = ''; //getting a flash message when a new chat room is created if (Session::has('message')) { $message = Session::get('message', 'default'); Session::forget('message'); } if (Auth::user()) { $chat_rooms = $this->getJoinedChatRooms(); $unread_messages_counts = $this->getUnreadMessagesCount($chat_rooms); $online_members_per_room = $this->getOnlineMembers($chat_rooms); $available_chat_rooms = $this->getAvailableChatRooms(); $invited_chatrooms = $this->getInvitedChatRoomDetails(); $registered = Online::registered()->distinct('user_id')->get(); $online_users = ''; foreach ($registered as $register) { $online_users[] = $register->user_id; } //$online_users = array_unique($online_users); var_dump($online_users);die(); $user_names = User::select('first_name')->whereIn('id', array_unique($online_users))->lists('first_name'); return View::make('home', array('chatrooms' => $chat_rooms, 'online_members' => $online_members_per_room, 'user_names' => $user_names, 'message' => $message, 'available_chat_rooms' => $available_chat_rooms, 'unread_messages_counts' => $unread_messages_counts, 'invited_chatrooms' => $invited_chatrooms)); } else { Online::updateCurrent(); } return View::make('home'); }
/** * Get the list of user_ids of users who are online. */ public static function users_connected_by_id() { $count = Online::who_is_online_count(); $user_connect = Online::who_is_online(0, $count, null, null, 30, true); $user_id_list = array(); for ($i = 0; $i < count($user_connect); $i++) { $user_id_list[$i] = $user_connect[$i][0]; } return $user_id_list; }
/** * @param Request $request * @return null|RedirectResponse */ public function onLogoutSuccess(Request $request) { $session = $request->getSession(); \ChamiloSession::setSession($session); // Chamilo logout $userId = api_get_user_id(); \Online::logout($userId, false); $login = $this->router->generate('index'); $response = new RedirectResponse($login); return $response; }
/** * @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; } }
function __construct() { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); if ($_POST) { if (Online::send($tree['id'])) { $this->redirect('/online/thanks/'); } } if (Funcs::$uri[1] == '') { View::render('online/form', $tree); } else { View::render('site/page', $tree); } }
/** * void Online::updateUser (&$user, &$target) * Update's $user's status to $target */ function updateUser(&$user, &$target) { $dbh = Planworld::_connect(); $query = "UPDATE online SET last_access=" . mktime() . ", what='"; if (is_object($target)) { $query .= $target->getUsername(); } else { $query .= addslashes($target); } $query .= "' WHERE uid=" . $user->getUserID(); $result = $dbh->query($query); if (isset($result) && !DB::isError($result)) { if ($dbh->affectedRows() < 1) { return Online::addUser($user, $target); } else { return true; } } else { return PLANWORLD_ERROR; } }
function setArr() { self::$arr = array($this->id, $this->sessionId, time()); }
<?php /* For licensing terms, see /license.txt */ //require_once '../inc/global.inc.php'; if (api_get_setting('platform_unsubscribe_allowed') != 'true') { api_not_allowed(); } $tool_name = get_lang('Unsubscribe'); $message = Display::return_message(get_lang('UnsubscribeFromPlatform'), 'warning'); $form = new FormValidator('user_add'); $form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm"))) . "')) return false;")); $content = $form->return_form(); if ($form->validate()) { $user_info = api_get_user_info(); $result = UserManager::delete_user($user_info['user_id']); if ($result) { $message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username']))); $content = null; Online::logout($user_info['user_id'], false); api_not_allowed(true, $message); } } $app['title'] = $tool_name; $tpl = $app['template']; $tpl->assign('actions', $actions); $tpl->assign('message', $message); $tpl->assign('content', $content); $tpl->display_one_col_template();
/** * Finds all the information about a user. If no paramater is passed you find all the information about the current user. * @param $user_id (integer): the id of the user * @return $user_info (array): user_id, lastname, firstname, username, email, ... * @author Patrick Cool <*****@*****.**> * @version 21 September 2004 */ function api_get_user_info($user_id = '', $check_if_user_is_online = false, $show_password = false, $add_extra_values = false) { if (empty($user_id)) { $_user = Session::read('_user'); return api_format_user($_user); } $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " WHERE user_id = '" . Database::escape_string($user_id) . "'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $result_array = Database::fetch_array($result); if ($check_if_user_is_online) { $use_status_in_platform = Online::user_is_online($user_id); $result_array['user_is_online'] = $use_status_in_platform; $user_online_in_chat = 0; if ($use_status_in_platform) { $user_status = UserManager::get_extra_user_data_by_field($user_id, 'user_chat_status', false, true); if (intval($user_status['user_chat_status']) == 1) { $user_online_in_chat = 1; } } $result_array['user_is_online_in_chat'] = $user_online_in_chat; } $user = api_format_user($result_array, $show_password); if ($add_extra_values) { $extra_field_values = new ExtraField('user'); $user['extra_fields'] = $extra_field_values->get_handler_extra_data($user_id); } return $user; } return false; }
<div class="clear"></div> <div id="useronline"> <div class="tab-left">Thống kê</div> <ul class="cont-menu"> <p> <span>Online : </span> <span> <?php echo Online::DemSoNguoiOnline(); ?> </span> </p> <p> <span>Lượt xem : </span> <span> <?php echo Online::DemLuotTruyCap(); ?> </span> </p> <p> <span>Tài liệu : </span> <span> <?php echo TaiLieu::DemTatCaTaiLieu(); ?> </span> </p> </ul> </div>
function xmlrpc_clientPlanRead($method_name, $params) { $planText = "Could not retrieve plan."; /* Grab arguments and generate variables and objects from them. */ $argToken =& $params[0]; $argUsernameToGet =& $params[1]; $argPlanDate =& $params[2]; $tokenObject = new NodeToken(); $tokenObject->retrieveToken($argToken); $sourceUsername = $tokenObject->usernameFromUid($tokenObject->uid); $sourceUser = User::factory($sourceUsername); $targetUser = User::factory($argUsernameToGet); /* Do a bunch of housekeeping that would otherwise be in prepend.php Check that file for commentary. */ $sourceUser->setLastLogin(mktime()); $sourceUser->save(); if (is_object($targetUser) && $targetUser->getType() == 'planworld') { $targetUser->forceUpdate(); } Online::clearIdle(); Online::updateUser($sourceUser, $targetUser); /* Real work: Get plan and send to user (snitch handled by call). */ $planText = $sourceUser->getPlan($targetUser, $argPlanDate); return $planText; }
/** * Method called to associate a Online object to this object * through the Online foreign key attribute * * @param Online $l Online * @return void * @throws PropelException */ public function addOnline(Online $l) { $this->collOnlines[] = $l; $l->setUser($this); }
/* update this user's last login */ $_user->setLastLogin(mktime()); /* update this user's last known ip address */ $_user->setLastIP($_SERVER['REMOTE_ADDR']); /* save it to prevent planwatch weirdness */ $_user->save(); /* create an object representing the target user (or a string representing the page) */ if (isset($_GET['id'])) { $section = str_replace(' ', '', $_GET['id']); if ($section == $_user->getUsername()) { $_target =& $_user; } else { if (Planworld::isValidUser($section)) { $_target = User::factory($section); } else { if ($section == 'random') { $_target = User::factory(Planworld::getRandomUser()); } else { $_target = $section; } } } /* force fetching of update / login times if the target user is remote */ if (is_object($_target) && $_target->getType() == 'planworld') { $_target->forceUpdate(); } } /* update the current status of online users (including this one) */ Online::clearIdle(); Online::updateUser($_user, $_target); }
function escape() { unset($_SESSION['email']); $url = explode("?", $_SERVER['HTTP_REFERER']); if ($url[0] == "http://" . $_SERVER['HTTP_HOST'] . "/page.php" || $url[0] == "http://" . $_SERVER['HTTP_HOST'] . "/edit.php" || $url[0] == "http://" . $_SERVER['HTTP_HOST'] . "/friends.php" || $url[0] == "http://" . $_SERVER['HTTP_HOST'] . "/im.php") { $url = "/"; } else { $url = $_SERVER['HTTP_REFERER']; } $online = new Online($this->id, null, $this->db); $online->del(); die("<html><head>\n\t\t<meta http-equiv='refresh' content='0; url=" . $url . "'>\n\t\t</head>\n\t\t</html>"); }
function planGet($params) { $planText = "Could not retrieve plan."; /* Grab arguments and generate variables and objects from them. */ $argToken =& $params[0]; $argUsernameToGet =& $params[1]; $argPlanDate =& $params[2]; $tokenObject = new NodeToken(); $tokenObject->retrieveToken($argToken); if ($tokenObject->valid && $argUsernameToGet != null) { $sourceUsername = $tokenObject->usernameFromUid($tokenObject->uid); $sourceUser = User::factory($sourceUsername); $targetUser = User::factory($argUsernameToGet); /* Do a bunch of housekeeping that would otherwise be in prepend.php Check that file for commentary. */ $sourceUser->setLastLogin(mktime()); $sourceUser->save(); if (is_object($targetUser) && $targetUser->getType() == 'planworld') { $targetUser->forceUpdate(); } Online::clearIdle(); Online::updateUser($sourceUser, $targetUser); /* Real work: Get plan and send to user (snitch handled by call). */ $planText = $targetUser->getPlan($sourceUser, $argPlanDate); /* Do the work necessary to mark the target user's plan as read. Note that this is harder because of Object Orientation. Also note this section as a good reference for how to drill deep into the planworld libraries to make sure everything happens correctly. */ $sourceUser->loadPlanwatch(); $sourceUser->planwatch->markSeen($targetUser); $sourceUser->save(); statusCode(200); } else { statusCode(401); $planText = "Could not retrieve plan."; } return $planText; }
echo '<a href="javascript: window.back();" ">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="javascript: void(0);" onclick="javascript: window.print();">' . Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="' . api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">' . Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM) . '</a> '; if (!empty($user_info['email'])) { $send_mail = '<a href="mailto:' . $user_info['email'] . '">' . Display::return_icon('mail_send.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { $send_mail = Display::return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM); } echo $send_mail; if (!empty($student_id) && !empty($_GET['course'])) { //only show link to connection details if course and student were defined in the URL echo '<a href="access_details.php?student=' . $student_id . '&course=' . $courseId . '&origin=' . Security::remove_XSS($_GET['origin']) . '&cidReq=' . Security::remove_XSS($_GET['course']) . '&id_session=' . $session_id . '">' . Display::return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM) . '</a>'; } echo '</div>'; // is the user online ? if (Online::user_is_online($_GET['student'])) { $online = get_lang('Yes'); } else { $online = get_lang('No'); } // get average of score and average of progress by student $avg_student_progress = $avg_student_score = 0; $courseId = $courseInfo['real_id']; if (!CourseManager::is_user_subscribed_in_course($user_info['user_id'], $courseId, true)) { unset($courses[$key]); } else { $avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseId, array(), $session_id); //the score inside the Reporting table $avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $courseId, array(), $session_id); //var_dump($avg_student_score); }
/** * Method called to associate a Online object to this object * through the Online foreign key attribute * * @param Online $l Online * @return void * @throws PropelException */ public function addOnline(Online $l) { $this->collOnlines[] = $l; $l->setProduction($this); }
<?php // Home Online::updateCurrent(); Route::get('/', array('as' => 'home', 'uses' => 'HomeController@showWelcome')); // Unauthenticated group Route::group(array('before' => 'guest'), function () { // CSRF protection group Route::group(array('before' => 'csrf'), function () { // Sign In post Route::post('account/sign-in', array('as' => 'sign-in-post', 'uses' => 'AccountController@postSignIn')); // Sign Up post Route::post('account/sign-up', array('as' => 'sign-up-post', 'uses' => 'AccountController@postSignUp')); // Forgot password post Route::post('account/forgot-password', array('as' => 'forgot-password-post', 'uses' => 'AccountController@postForgotPassword')); }); // Sign In Route::get('account/sign-in', array('as' => 'sign-in', 'uses' => 'AccountController@getSignIn')); // Sign Up Route::get('account/sign-up', array('as' => 'sign-up', 'uses' => 'AccountController@getSignUp')); // Activate account Route::get('account/activate/{code}', array('as' => 'activate-account', 'uses' => 'AccountController@getActivateAccount')); // Forgot password Route::get('account/forgot-password', array('as' => 'forgot-password', 'uses' => 'AccountController@getForgotPassword')); // Activate temporary password Route::get('account/forgot-password/{user}/{code}', array('as' => 'forgot-password-activate', 'uses' => 'AccountController@getForgotPasswordActivate')); }); // Authenticated group Route::group(array('before' => 'auth'), function () { // CSRF protection group Route::group(array('before' => 'csrf'), function () {
*/ require_once '../global.inc.php'; $action = $_GET['a']; switch ($action) { case 'load_online_user': if (isset($_SESSION['who_is_online_counter'])) { $_SESSION['who_is_online_counter']++; } else { $_SESSION['who_is_online_counter'] = 2; } $images_to_show = 9; $page = intval($_REQUEST['online_page_nr']); $max_page = round(Online::who_is_online_count() / $images_to_show); $page_rows = ($page - 1) * 9 + 1; if (!empty($max_page) && $page <= $max_page) { if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { $user_list = Online::who_is_online_in_this_course($page_rows, $images_to_show, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']); } else { $user_list = Online::who_is_online($page_rows, $images_to_show); } if (!empty($user_list)) { echo SocialManager::display_user_list($user_list); exit; } } echo 'end'; break; default: break; } exit;
/** * @return string */ public function returnNotificationMenu() { $_course = api_get_course_info(); $course_id = api_get_course_id(); $user_id = api_get_user_id(); $html = ''; if (api_get_setting('showonline', 'world') == 'true' and !$user_id or api_get_setting('showonline', 'users') == 'true' and $user_id or api_get_setting('showonline', 'course') == 'true' and $user_id and $course_id) { $number = Online::who_is_online_count(api_get_setting('time_limit_whosonline')); $number_online_in_course = 0; if (!empty($_course['id'])) { $number_online_in_course = Online::who_is_online_in_this_course_count($user_id, api_get_setting('time_limit_whosonline'), $_course['id']); } // Display the who's online of the platform if ($number) { if (api_get_setting('showonline', 'world') == 'true' and !$user_id or api_get_setting('showonline', 'users') == 'true' and $user_id) { $html .= '<li><a href="' . SocialManager::getUserOnlineLink() . '" target="_top" title="' . get_lang('UsersOnline') . '" >' . Display::return_icon('user.png', get_lang('UsersOnline'), array(), ICON_SIZE_TINY) . ' ' . $number . '</a></li>'; } } // Display the who's online for the course if ($number_online_in_course) { if (is_array($_course) and api_get_setting('showonline', 'course') == 'true' and isset($_course['sysCode'])) { $html .= '<li><a href="' . SocialManager::getUserOnlineLink($_course['sysCode']) . '" target="_top">' . Display::return_icon('course.png', get_lang('UsersOnline') . ' ' . get_lang('InThisCourse'), array(), ICON_SIZE_TINY) . ' ' . $number_online_in_course . ' </a></li>'; } } // Display the who's online for the session if (api_get_setting('showonline', 'session') == 'true') { if (isset($user_id) && api_get_session_id() != 0) { if (api_is_allowed_to_edit()) { $html .= '<li><a href="' . SocialManager::getUserOnlineLink(null, api_get_session_id()) . '&id_coach=' . $user_id . '" >' . Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY) . ' </a></li>'; } } } } if (api_get_setting('accessibility_font_resize') == 'true') { $html .= '<li class="resize_font">'; $html .= '<span class="decrease_font" title="' . get_lang('DecreaseFontSize') . '">A</span> <span class="reset_font" title="' . get_lang('ResetFontSize') . '">A</span> <span class="increase_font" title="' . get_lang('IncreaseFontSize') . '">A</span>'; $html .= '</li>'; } return $html; }
public function onlineAction() { $ip = $_SERVER['REMOTE_ADDR']; $date = new \DateTime(); $em = $this->getDoctrine()->getManager(); $user_ip = $em->getRepository('NewsMainBundle:Online')->findOneBy(array('user_ip' => $ip)); if (!$user_ip) { $last_visit = new Online(); $last_visit->setUserIp($ip); $last_visit->setLastVisit($date); $em->persist($last_visit); $em->flush(); } else { $user_ip->setLastVisit($date); $em->flush(); } $offline = $this->getDoctrine()->getRepository('NewsMainBundle:Online')->deleteUsersOfflineFromDb(); $online = $this->getDoctrine()->getRepository('NewsMainBundle:OnLine')->getUsersOnline(); if ($online) { $count_users_online = count($online); } else { $count_users_online = 0; } return $this->render('NewsMainBundle:Default:online.html.twig', array('count_users_online' => $count_users_online)); }
function logout() { $_SESSION['_user'] = array(); Online::logout(null, false); }
$session->start(); // Setting session obj Session::setSession($session); UserManager::setEntityManager($app['orm.em']); /** @var ChamiloLMS\Component\DataFilesystem\DataFilesystem $filesystem */ $filesystem = $app['chamilo.filesystem']; if ($app['debug']) { // Creates data/temp folders for every request if debug is on. $filesystem->createFolders($app['temp.paths']->folders); } // If Assetic is enabled copy folders from theme inside "web/" if ($app['assetic.auto_dump_assets']) { $filesystem->copyFolders($app['temp.paths']->copyFolders); } // Check and modify the date of user in the track.e.online table Online::loginCheck(api_get_user_id()); // Setting access_url id (multiple url feature) if (api_get_multiple_access_url()) { $_configuration = $app['configuration']; $_configuration['access_url'] = 1; $access_urls = api_get_access_urls(); $protocol = $request->getScheme() . '://'; $request_url1 = $protocol . $_SERVER['SERVER_NAME'] . '/'; $request_url2 = $protocol . $_SERVER['HTTP_HOST'] . '/'; foreach ($access_urls as &$details) { if ($request_url1 == $details['url'] or $request_url2 == $details['url']) { $_configuration['access_url'] = $details['id']; } } Session::write('url_id', $_configuration['access_url']); Session::write('url_info', api_get_current_access_url_info($_configuration['access_url']));
$chatid = intval($_GET['chatid']); if ($_GET['chatid'] == strval(intval($_GET['chatid']))) { $sql = "UPDATE {$track_user_table} SET chatcall_user_id = '" . Database::escape_string($_user['user_id']) . "', chatcall_date = '" . Database::escape_string($time) . "', chatcall_text = '' where (user_id = " . (int) Database::escape_string($chatid) . ")"; $result = Database::query($sql); //redirect caller to chat header("Location: " . api_get_path(WEB_CODE_PATH) . "chat/chat.php?" . api_get_cidreq() . "&origin=whoisonline&target=" . Security::remove_XSS($chatid)); exit; } } $social_right_content = null; // This if statement prevents users accessing the who's online feature when it has been disabled. if (api_get_setting('showonline', 'world') == 'true' && !$_user['user_id'] || (api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id']) { if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { $user_list = Online::who_is_online_in_this_course(0, 9, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']); } else { $user_list = Online::who_is_online(0, 9); } if (!isset($_GET['id'])) { if (api_get_setting('allow_social_tool') == 'true') { if (!api_is_anonymous()) { //this include the social menu div $social_left_content = SocialManager::show_social_menu('whoisonline'); } } } if ($user_list) { if (!isset($_GET['id'])) { if (api_get_setting('allow_social_tool') == 'true') { if (!api_is_anonymous()) { $query = isset($_GET['q']) ? $_GET['q'] : null; $social_right_content .= '<div class="span9">' . UserManager::get_search_form($query) . '</div>';
<input type="text" name="keywords" class="formInput" placeholder="Что ищем?"> <input name="search" type="submit" value="Искать"> </form> </div> <div class="leftBlockFooter"></div> </div> </div> <div class='leftBlock'> <div class="leftBlockHeader">Статистика посещений</div> <div class="leftBlockContent"> <div class="leftBlockContentOpacity"></div> <div class="leftContent"> <p>Сейчас онлайн:</p> <div id="visited"> <? $online = new Online($user->id,session_id(),$db); if (isset($_SESSION['email'])) { $online->setArr(); $online->set(); } $online->loginsOnline(); $online->get(); ?> </div> <p>Нас сегодня посетили:</p> <div id="visited"> <? $visited = new Visited($user->id,null,$db); if (isset($_SESSION['email'])) { $visited->setArr(); $visited->set();