示例#1
0
/**
 * retrieve a list of all online users
 *
 * @global object $user
 * @global array  $_fullname_sql
 *
 * @param int    $active_time filter: the time in minutes until last life-sign
 * @param string $name_format format the fullname shall have
 *
 * @return array
 */
function get_users_online($active_time = 5, $name_format = 'full_rev')
{
    if (!isset($GLOBALS['_fullname_sql'][$name_format])) {
        $name_format = reset(array_keys($GLOBALS['_fullname_sql']));
    }
    $query = "SELECT a.username AS temp, a.username, {$GLOBALS['_fullname_sql'][$name_format]} AS name,\n                     ABS(CAST(UNIX_TIMESTAMP() AS SIGNED) - CAST(last_lifesign AS SIGNED)) AS last_action,\n                     a.user_id, IF(owner_id IS NOT NULL, 1, 0) AS is_buddy, " . get_vis_query('a', 'online') . " AS is_visible\n              FROM user_online uo\n              JOIN auth_user_md5 a ON (a.user_id = uo.user_id)\n              LEFT JOIN user_info ON (user_info.user_id = uo.user_id)\n              LEFT JOIN user_visibility ON (user_visibility.user_id = uo.user_id)\n              LEFT JOIN contact ON (owner_id = ? AND contact.user_id = a.user_id)\n              WHERE last_lifesign > ? AND uo.user_id <> ?\n              ORDER BY {$GLOBALS['_fullname_sql'][$name_format]} ASC";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($GLOBALS['user']->id, time() - $active_time * 60, $GLOBALS['user']->id));
    $online = $statement->fetchGrouped();
    // measure users online
    if ($active_time === 10) {
        Metrics::gauge('core.users_online', sizeof($online));
    }
    return $online;
}
示例#2
0
 // Messy file names
 StudipAutoloader::addClassLookups(array('email_validation_class' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/phplib/email_validation.class.php', 'cssClassSwitcher' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/classes/cssClassSwitcher.inc.php', 'MediaProxy' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/media_proxy.php', 'MyRealmModel' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/my_realm.php', 'StudygroupModel' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/studygroup.php', 'StudipPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/StudIPPlugin.class.php', 'AbstractStudipPortalPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPPortalPlugin.class.php', 'AbstractStudipSystemPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPSystemPlugin.class.php', 'AbstractStudipHomepagePlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPHomepagePlugin.class.php', 'AbstractStudipAdministrationPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPAdministrationPlugin.class.php'));
 // Trails
 $trails_classes = array('Trails_Dispatcher', 'Trails_Response', 'Trails_Controller', 'Trails_Inflector', 'Trails_Flash', 'Trails_Exception', 'Trails_DoubleRenderError', 'Trails_MissingFile', 'Trails_RoutingError', 'Trails_UnknownAction', 'Trails_UnknownController', 'Trails_SessionRequiredException');
 StudipAutoloader::addClassLookup($trails_classes, $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/trails/trails.php');
 StudipAutoloader::addClassLookup('StudipController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/studip_controller.php');
 StudipAutoloader::addClassLookup('AuthenticatedController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/authenticated_controller.php');
 StudipAutoloader::addClassLookup('PluginController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/plugin_controller.php');
 // Vendor
 StudipAutoloader::addClassLookups(array('PasswordHash' => $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/phpass/PasswordHash.php', 'TCPDF' => $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/tcpdf/tcpdf.php'));
 StudipAutoloader::addAutoloadPath($GLOBALS['STUDIP_BASE_PATH'] . '/vendor/mishal-iless/lib/ILess', 'ILess');
 // sample the request time and number of db queries every tenth time
 register_shutdown_function(function ($timer) {
     $timer('core.request_time', 0.1);
     $query_count = DBManager::get()->query_count;
     Metrics::gauge('core.database.queries', $query_count, 0.1);
 }, Metrics::startTimer());
 require 'lib/phplib/page_open.php';
 StudipFileloader::load('config_local.inc.php', $GLOBALS, compact('STUDIP_BASE_PATH'));
 require 'config.inc.php';
 require_once 'lib/functions.php';
 require_once 'lib/language.inc.php';
 require_once 'lib/visual.inc.php';
 require_once 'lib/deputies_functions.inc.php';
 //setup default logger
 Log::get()->setHandler($GLOBALS['TMP_PATH'] . '/studip.log');
 if (Studip\ENV == 'development') {
     Log::get()->setLogLevel(Log::DEBUG);
 } else {
     Log::get()->setLogLevel(Log::ERROR);
 }