Example #1
0
# (jEdit options) :folding=explicit:collapseFolds=1:
/*****************************************************************************
Summarizes MolProbity usage over a specified date range.
*****************************************************************************/
// EVERY *top-level* page must start this way:
// 1. Define it's relationship to the root of the MolProbity installation.
// Pages in subdirectories of lib/ or public_html/ will need more "/.." 's.
if (!defined('MP_BASE_DIR')) {
    define('MP_BASE_DIR', realpath(dirname(__FILE__) . '/../..'));
}
// 2. Include core functionality - defines constants, etc.
require_once MP_BASE_DIR . "/lib/core.php";
require_once MP_BASE_DIR . "/lib/browser.php";
// 3. Restore session data. If you don't want to access the session
// data for some reason, you must call mpInitEnvirons() instead.
mpInitEnvirons();
// Have to do this for big log files ... we'll need a better solution one day.
ini_set('memory_limit', '2048M');
$exec_time = time();
#{{{ class LogIter
############################################################################
class LogIter
{
    var $totalRecords = 0;
    var $uniqueSessions = 0;
    var $uniqueIPs = 0;
    var $actions = array();
    var $uniqueActions = array();
    var $endTime = 0;
    var $startTime = 1.0E+99;
    var $platforms = array();
Example #2
0
/** Returns true if a new session was created, false otherwise. */
function mpStartSession($createIfNeeded = false)
{
    // First set up constants, env. variables, etc.
    mpInitEnvirons();
    // Cookies cause more trouble than they're worth
    ini_set("session.use_cookies", 0);
    ini_set("session.use_only_cookies", 0);
    // We want to control garbage collection more carefully
    // (MP_SESSION_LIFETIME is a dummy -- lifetime is determined per-session)
    ini_set("session.gc_maxlifetime", MP_SESSION_LIFETIME);
    #ini_set("session.gc_probability", 100);
    // Set up our session name
    session_name(MP_SESSION_NAME);
    // Establish custom routines for persisting session data
    session_set_save_handler("mpSessOpen", "mpSessClose", "mpSessRead", "mpSessWrite", "mpSessDestroy", "mpSessGC");
    // Restore the session data
    @session_start();
    // we get meaningless error msgs when used from a script env.
    mpCheckSessionID(session_id());
    // just in case
    // Check to make sure we have a working directory for this user.
    //$dataDir = MP_BASE_DIR."/public_html/data/".session_id();
    $dataDir = MP_JOB_DATA_DIR . session_id();
    if (!file_exists($dataDir)) {
        if ($createIfNeeded) {
            // Always do cleanup before starting a new session
            // (MP_SESSION_LIFETIME is a dummy -- lifetime is determined per-session)
            mpSessGC(MP_SESSION_LIFETIME);
            // Main data directories
            mkdir($dataDir, 0770);
            // Default mode; is modified by UMASK too.
            mkdir("{$dataDir}/" . MP_DIR_SYSTEM, 0770);
            mkdir("{$dataDir}/tmp", 0770);
            // Others specified in config.php must be created on demand.
            // Set up some session variables. See docs for explanation.
            $_SESSION['dataDir'] = $dataDir;
            $_SESSION['dataURL'] = "data/" . session_id();
            $_SESSION['sessTag'] = session_name() . "=" . session_id();
            $_SESSION['userIP'] = getVisitorIP();
            $_SESSION['timeZone'] = MP_DEFAULT_TIMEZONE;
            $_SESSION['kingSize'] = "default";
            $_SESSION['currEventID'] = 1;
            // used by (optional) MVC/event architecture
            $_SESSION['models'] = array();
            // no models to start with
            $_SESSION['ensembles'] = array();
            // no ensembles to start with
            $_SESSION['reduce_blength'] = "ecloud";
            // x-H distance
            $_SESSION['useSEGID'] = false;
            // TODO: perform other tasks to start a session
            // Create databases, etc, etc.
            //mpLog("new-session:New user session started");
            $sessionCreated = true;
        } else {
            mpLog("badsession:Unknown session with ID '" . session_id() . "'");
            die("Specified session '" . session_id() . "' does not exist.");
        }
    } else {
        $sessionCreated = false;
    }
    // Mark the lifetime of this session
    mpSessSetTTL(session_id(), MP_SESSION_LIFETIME);
    // Also set location of Reduce's heterogen dictionary,
    // overriding the value set up by mpInitEnvirons().
    // Better here than on command line b/c it affects e.g. flipkin too
    if (isset($_SESSION['hetdict'])) {
        putenv("REDUCE_HET_DICT=" . $_SESSION['hetdict']);
    } else {
        putenv("REDUCE_HET_DICT=" . MP_REDUCE_HET_DICT);
    }
    return $sessionCreated;
}