[ Index ] |
|
Code source de Horde 3.1.3 |
1 #!/usr/bin/php 2 <?php 3 /** 4 * $Horde: horde/scripts/count_sessions.php,v 1.5.2.3 2006/04/18 16:24:58 jan Exp $ 5 * 6 * This script counts the number of active authenticated user sessions. 7 * 8 * Command line options: 9 * '-l' List the username of active authenticated users 10 * '-ll' List the username and login time of active authenticated users 11 */ 12 13 // No auth. 14 @define('AUTH_HANDLER', true); 15 16 // Find the base file path of Horde. 17 @define('HORDE_BASE', dirname(__FILE__) . '/..'); 18 19 // Do CLI checks and environment setup first. 20 require_once HORDE_BASE . '/lib/core.php'; 21 require_once 'Horde/CLI.php'; 22 23 // Make sure no one runs this from the web. 24 if (!Horde_CLI::runningFromCLI()) { 25 exit("Must be run from the command line\n"); 26 } 27 28 // Load the CLI environment - make sure there's no time limit, init 29 // some variables, etc. 30 Horde_CLI::init(); 31 $cli = &new Horde_CLI(); 32 33 require_once HORDE_BASE . '/lib/base.php'; 34 35 /* Make sure there's no compression. */ 36 @ob_end_clean(); 37 38 $type = !empty($conf['sessionhandler']['type']) ? 39 $conf['sessionhandler']['type'] : 'builtin'; 40 41 if ($type == 'external') { 42 Horde::fatal(PEAR::raiseError('Session counting is not supported in the \'external\' SessionHandler at this time.'), __FILE__, __LINE__, false); 43 } else { 44 require_once 'Horde/SessionHandler.php'; 45 $_session_handler = &SessionHandler::singleton($conf['sessionhandler']['type']); 46 if (is_a($_session_handler, 'PEAR_Error')) { 47 Horde::fatal(PEAR::raiseError(sprintf("Horde is unable to load session handler of type \"%s\".", $type)), __FILE__, __LINE__, false); 48 } 49 50 if ($argc < 2 || ($argv[1] != '-l' && $argv[1] != '-ll')) { 51 $count = $_session_handler->countAuthenticatedUsers(); 52 if (is_a($count, 'PEAR_Error')) { 53 Horde::fatal($count, __FILE__, __LINE__, false); 54 } 55 56 $cli->writeln($count); 57 } else { 58 $users = $_session_handler->listAuthenticatedUsers($argv[1] == '-ll'); 59 if (is_a($users, 'PEAR_Error')) { 60 Horde::fatal($users, __FILE__, __LINE__, false); 61 } 62 63 foreach ($users as $user) { 64 $cli->writeln($user); 65 } 66 } 67 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |