Example #1
0
    /**
    * Context is not used.
    */
    function display($context)
    {
        // FUNKY: this breaks the general rule of display() not modifying session data.
        // Set session lifetime to a longer value.
        // Will be overwritten each session restart (i.e. when we leave this page).
        mpSessSetTTL(session_id(), MP_SESSION_LIFETIME_EXT);
        echo $this->pageHeader("Save session", "savesession");
        ?>
<p>To make MolProbity more convenient, you can bookmark this page and return to it later.
We will do our best to preserve all your files, but the unexpected does sometimes happen --
so we recommend that you
<a href='<?php 
        echo makeEventURL('onGoto', 'file_browser.php');
        ?>
'>download</a>
anything really important.
</p>

<p>If you're not going to use these files anymore, please
<a href='<?php 
        echo makeEventURL('onGoto', 'logout.php');
        ?>
'>log out</a>
instead.
We appreciate your help in freeing up disk space for other users.
</p>

<center><p>Your data will be kept until:
<br><b><?php 
        echo formatDayTime(time() + mpSessTimeToLive(session_id()));
        ?>
</b>
</p></center>
<?php 
        echo $this->pageFooter();
    }
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;
}