function showAdminStats() { //the option to only show a single group of users is not implemented yet $stats = '<br> <STYLE> <!-- .y a { color: #000000; font-size:38px;font-weight:bold; color:white; text-decoration:none;} </style> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr style="background-color:yellow; color:red; text-align:center;"> <th>Demo Users</th> <th>Active Users</th> <th>Demo Devs</th> <th>Active Devs</th> </tr> <tr class="y" style="text-align:center;"> <td style="background-color:#2E2E2E;"><a href="admin.php?admp=users">' . getDemoUsers() . '</a></td> <td style="background-color:#474A47;"><a href="admin.php?admp=users">' . getActiveUsers() . '</a></td> <td style="background-color:#2E2E2E;"><a href="admin.php?admp=users">' . getDemoDevelopers() . '</a></td> <td style="background-color:#474A47;"><a href="admin.php?admp=users">' . getActiveDevelopers() . '</a></td> </tr> </table> '; return $stats; }
function getOnlineUsersInfo($sUserId, $bInit) { global $aXmlTemplates; $aSaved = getSavedUsers(); $aActive = getActiveUsers($sUserId); $aFriends = getFriends($sUserId); saveUsers($aActive); $sContents = ""; if ($bInit) { $aFullUsers = array_unique(array_merge($aActive['online'], $aFriends)); } else { $aFullUsers = array_diff($aActive['online'], $aSaved['online'], $aFriends); $aNewOfflineUsers = array_intersect($aSaved['online'], $aActive['offline']); $aNewOnlineUsers = array_intersect($aSaved['offline'], $aActive['online'], $aFriends); for ($i = 0; $i < count($aNewOfflineUsers); $i++) { $sContents .= parseXml($aXmlTemplates['user'], $aNewOfflineUsers[$i], FALSE_VAL); } for ($i = 0; $i < count($aNewOnlineUsers); $i++) { $sContents .= parseXml($aXmlTemplates['user'], $aNewOnlineUsers[$i], TRUE_VAL); } } $rResult = getUsersMedia($aFullUsers); if ($rResult != null) { for ($i = 0; $i < mysql_num_rows($rResult); $i++) { $aUser = mysql_fetch_assoc($rResult); $aUserInfo = getUserInfo($aUser['ID']); $sOnline = in_array($aUser['ID'], $aActive['online']) ? TRUE_VAL : FALSE_VAL; $sFriend = in_array($aUser['ID'], $aFriends) ? TRUE_VAL : FALSE_VAL; $sMusic = $aUser['CountMusic'] > 0 ? TRUE_VAL : FALSE_VAL; $sVideo = $aUser['CountVideo'] > 0 ? TRUE_VAL : FALSE_VAL; $sContents .= parseXml($aXmlTemplates['user'], $aUser['ID'], $aUserInfo['nick'], $aUserInfo['sex'], $aUserInfo['age'], $aUserInfo['photo'], $aUserInfo['profile'], $sOnline, $sFriend, $sMusic, $sVideo); } } return makeGroup($sContents, "users"); }
function tracker_run() { global $tweetQueue; $tweetQueue = new TweetQueue(); $tweetQueue->setoption('replace', false); if (defined('USE_INSERT_DELAYED') && USE_INSERT_DELAYED) { $tweetQueue->setoption('delayed', true); } if (defined('DISABLE_INSERT_IGNORE') && DISABLE_INSERT_IGNORE) { $tweetQueue->setoption('ignore', false); } else { $tweetQueue->setoption('ignore', true); } if (!defined("CAPTURE")) { /* logged to no file in particular, because we don't know which one. this should not happen. */ error_log("tracker_run() called without defining CAPTURE. have you set up config.php ?"); die; } $roles = unserialize(CAPTUREROLES); if (!in_array(CAPTURE, $roles)) { /* incorrect script execution, report back error to user */ error_log("tracker_run() role " . CAPTURE . " is not configured to run"); die; } // log execution environment $phpstring = phpversion() . " in mode " . php_sapi_name() . " with extensions "; $extensions = get_loaded_extensions(); $first = true; foreach ($extensions as $ext) { if ($first) { $first = false; } else { $phpstring .= ','; } $phpstring .= "{$ext}"; } $phpstring .= " (ini file: " . php_ini_loaded_file() . ")"; logit(CAPTURE . ".error.log", "running php version {$phpstring}"); // install the signal handler if (function_exists('pcntl_signal')) { // tick use required as of PHP 4.3.0 declare (ticks=1); // See signal method discussion: // http://darrendev.blogspot.nl/2010/11/php-53-ticks-pcntlsignal.html logit(CAPTURE . ".error.log", "installing term signal handler for this script"); // setup signal handlers pcntl_signal(SIGTERM, "capture_signal_handler_term"); } else { logit(CAPTURE . ".error.log", "your php installation does not support signal handlers. graceful reload will not work"); } // sanity check for geo bins functions if (geophp_sane()) { logit(CAPTURE . ".error.log", "geoPHP library is fully functional"); } elseif (geobinsActive()) { logit(CAPTURE . ".error.log", "refusing to track until geobins are stopped or geo is functional"); exit(1); } else { logit(CAPTURE . ".error.log", "geoPHP functions are not yet available, see documentation for instructions"); } global $ratelimit, $exceeding, $ex_start, $last_insert_id; $ratelimit = 0; // rate limit counter since start of script $exceeding = 0; // are we exceeding the rate limit currently? $ex_start = 0; // time at which rate limit started being exceeded $last_insert_id = -1; global $twitter_consumer_key, $twitter_consumer_secret, $twitter_user_token, $twitter_user_secret, $lastinsert; $pid = getmypid(); logit(CAPTURE . ".error.log", "started script " . CAPTURE . " with pid {$pid}"); $lastinsert = time(); $procfilename = BASE_FILE . "proc/" . CAPTURE . ".procinfo"; if (file_put_contents($procfilename, $pid . "|" . time()) === FALSE) { logit(CAPTURE . ".error.log", "cannot register capture script start time (file \"{$procfilename}\" is not WRITABLE. make sure the proc/ directory exists in your webroot and is writable by the cron user)"); die; } $networkpath = isset($GLOBALS["HOSTROLE"][CAPTURE]) ? $GLOBALS["HOSTROLE"][CAPTURE] : 'https://stream.twitter.com/'; // prepare queries if (CAPTURE == "track") { // check for geolocation bins $locations = geobinsActive() ? getActiveLocationsImploded() : false; // assemble query $querylist = getActivePhrases(); if (empty($querylist) && !geobinsActive()) { logit(CAPTURE . ".error.log", "empty query list, aborting!"); return; } $method = $networkpath . '1.1/statuses/filter.json'; $track = implode(",", $querylist); $params = array(); if (geobinsActive()) { $params['locations'] = $locations; } if (!empty($querylist)) { $params['track'] = $track; } } elseif (CAPTURE == "follow") { $querylist = getActiveUsers(); if (empty($querylist)) { logit(CAPTURE . ".error.log", "empty query list, aborting!"); return; } $method = $networkpath . '1.1/statuses/filter.json'; $params = array("follow" => implode(",", $querylist)); } elseif (CAPTURE == "onepercent") { $method = $networkpath . '1.1/statuses/sample.json'; $params = array('stall_warnings' => 'true'); } logit(CAPTURE . ".error.log", "connecting to API socket"); $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_consumer_key, 'consumer_secret' => $twitter_consumer_secret, 'token' => $twitter_user_token, 'secret' => $twitter_user_secret, 'host' => 'stream.twitter.com')); $tmhOAuth->request_settings['headers']['Host'] = 'stream.twitter.com'; if (CAPTURE == "track" || CAPTURE == "follow") { logit(CAPTURE . ".error.log", "connecting - query " . var_export($params, 1)); } elseif (CAPTURE == "onepercent") { logit(CAPTURE . ".error.log", "connecting to sample stream"); } $capturebucket = array(); $tmhOAuth->streaming_request('POST', $method, $params, 'tracker_streamCallback', array('Host' => 'stream.twitter.com')); // output any response we get back AFTER the Stream has stopped -- or it errors logit(CAPTURE . ".error.log", "stream stopped - error " . var_export($tmhOAuth, 1)); logit(CAPTURE . ".error.log", "processing buffer before exit"); processtweets($capturebucket); }
<? $class = "sidebar"; ?> <div class="title"> <?php echo ucf(i18n("information")); ?> </div> <div class="container"> <?php echo count(getActiveUsers()); ?> <?php echo i18n("logged in user(s)"); ?> <br/> <?php echo date("Y-m-d H:i:s"); ?> </div>
<?php require_once __DIR__ . '/../phplib/util.php'; $TODAY = date("Y-m-d"); $TODAY_TIMESTAMP = strtotime("{$TODAY} 00:00:00"); $REMOTE_FOLDER = 'download/xmldump'; $STATIC_FILES = file(Config::get('static.url') . 'fileList.txt'); $LAST_DUMP = getLastDumpDate($REMOTE_FOLDER); $LAST_DUMP_TIMESTAMP = $LAST_DUMP ? strtotime("{$LAST_DUMP} 00:00:00") : null; $USERS = getActiveUsers(); $FTP = new FtpUtil(); log_scriptLog("generating dump for {$TODAY}; previous dump is " . ($LAST_DUMP ? $LAST_DUMP : '-never-')); if ($LAST_DUMP == $TODAY) { log_scriptLog("a dump already exists for {$TODAY}; aborting"); die("a dump already exists for {$TODAY}; aborting\n"); } dumpSources("{$REMOTE_FOLDER}/{$TODAY}-sources.xml.gz"); dumpInflections("{$REMOTE_FOLDER}/{$TODAY}-inflections.xml.gz"); dumpAbbrevs("{$REMOTE_FOLDER}/{$TODAY}-abbrevs.xml.gz"); dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) AND status = 0 AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-definitions.xml.gz", 'dumping definitions'); dumpLexems("SELECT * FROM Lexem where modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-lexems.xml.gz", 'dumping lexems and inflected forms'); dumpLdm("SELECT M.lexemId, M.definitionId FROM LexemDefinitionMap M, Definition D " . "WHERE D.id = M.definitionId AND D.sourceId in (SELECT id FROM Source WHERE canDistribute) " . "AND D.status = 0 AND M.modDate < {$TODAY_TIMESTAMP} ORDER BY M.lexemId, M.definitionId", "{$REMOTE_FOLDER}/{$TODAY}-ldm.xml.gz", 'dumping lexem-definition map'); if ($LAST_DUMP) { dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) " . "AND modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-definitions-diff.xml.gz", 'dumping definitions diff'); dumpLexems("SELECT * FROM Lexem where modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-lexems-diff.xml.gz", 'dumping lexems and inflected forms diff'); dumpLdmDiff("{$REMOTE_FOLDER}/{$LAST_DUMP}-ldm.xml.gz", "{$REMOTE_FOLDER}/{$TODAY}-ldm.xml.gz", "{$REMOTE_FOLDER}/{$TODAY}-ldm-diff.xml.gz"); } removeOldDumps($REMOTE_FOLDER, $TODAY, $LAST_DUMP); /**************************************************************************/ function getActiveUsers() {
$pageVars['year'] = $dateArray['0']; $pageVars['month'] = $dateArray['1']; $pageVars['day'] = $dateArray['2']; $pageVars['previousDate'] = date('Y-m-d', mktime(0, 0, 0, $pageVars['month'], $pageVars['day'] - 1, $pageVars['year'])); $pageVars['nextDate'] = date('Y-m-d', mktime(0, 0, 0, $pageVars['month'], $pageVars['day'] + 1, $pageVars['year'])); $pageVars['previousWeek'] = date('Y-m-d', mktime(0, 0, 0, $pageVars['month'], $pageVars['day'] - 7, $pageVars['year'])); $pageVars['nextWeek'] = date('Y-m-d', mktime(0, 0, 0, $pageVars['month'], $pageVars['day'] + 7, $pageVars['year'])); if (isset($_REQUEST['hostiplong']) && $_REQUEST['hostiplong']) { $pageVars['host'] = getHostFromIP($link, $_REQUEST['hostiplong'], $pageVars['date']); $pageVars['hostiplong'] = $_REQUEST['hostiplong']; } if (isset($_REQUEST['sitesID']) && $_REQUEST['sitesID']) { $pageVars['sitesID'] = $_REQUEST['sitesID']; $pageVars['site'] = getSiteFromSiteID($link, $pageVars['sitesID'], $pageVars['date']); } $pageVars['activeUsers'] = getActiveUsers($link); if (isset($_REQUEST['usersID'])) { $pageVars['user'] = getUserFromUsersID($link, $_REQUEST['usersID'], $pageVars['date']); $pageVars['usersID'] = $_REQUEST['usersID']; } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'setDefaultView') { setDefaultView(); } if (isset($_REQUEST['a'])) { $a_switch = $_REQUEST['a']; } else { $a_switch = ""; } switch ($a_switch) { case 'IPSummary': // create the urls for the users,date, bytes and cachePercent
** ACH is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** ACH is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with Open Source ACH. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////////////// */ include_once "code/includes.php"; $project_id = $_REQUEST['project_id']; $active_users = getActiveUsers($project_id); print_r($active_users); if (empty($active_users)) { echo "No active users."; } ?> <ul> <?php for ($i = 0; $i < count($active_users); $i++) { $this_user = new User(); $this_user->populateFromId($active_users[$i]); echo "<li><p><a class='name' href='" . $base_URL . "profile/" . $this_user->username . "' style='color: #" . $this_user->color . ";'>" . $this_user->name . "</a><br />Viewing: <a href='" . $this_user->last_page . "'>" . $this_user->last_page . "</a></p></li>"; } ?>