Ejemplo n.º 1
0
function w2PsessionGC($maxlifetime)
{
    global $AppUI;
    $now = time();
    $max = w2PsessionConvertTime('max_lifetime');
    $idle = w2PsessionConvertTime('idle_time');
    // First pass is to kill any users that are logged in at the time of the session.
    $where = 'UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) > ' . $idle . ' OR UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) > ' . $max;
    $q = new w2p_Database_Query();
    $q->addTable('user_access_log');
    $q->addUpdate('date_time_out', date('Y-m-d H:i:s'));
    $q2 = new w2p_Database_Query();
    $q2->addTable('sessions');
    $q2->addQuery('session_user');
    $q2->addWhere($where);
    $q->addWhere('user_access_log_id IN ( ' . $q2->prepare() . ' )');
    $q->exec();
    $q->clear();
    $q2->clear();
    // Now we simply delete the expired sessions.
    $q->setDelete('sessions');
    $q->addWhere($where);
    $q->exec();
    $q->clear();
    if (w2PgetConfig('session_gc_scan_queue')) {
        // We need to scan the event queue.  If $AppUI isn't created yet
        // And it isn't likely that it will be, we create it and run the
        // queue scanner.
        if (!isset($AppUI)) {
            $AppUI = new CAppUI();
            $queue = new w2p_Core_EventQueue();
            $queue->scan();
        }
    }
    return true;
}
Ejemplo n.º 2
0
<?php

// Function to scan the event queue and execute any functions required.
require_once 'base.php';
require_once W2P_BASE_DIR . '/includes/config.php';
require_once W2P_BASE_DIR . '/includes/main_functions.php';
require_once W2P_BASE_DIR . '/includes/db_adodb.php';
$defaultTZ = w2PgetConfig('system_timezone', 'Europe/London');
date_default_timezone_set($defaultTZ);
$AppUI = new CAppUI();
$AppUI->setUserLocale();
$queue = new w2p_Core_EventQueue();
$queue->scan();
/*
 This is the first piece of a simple hook system to allow for regularly
 scheduled maintenance tasks to occur.  This could be data validation and
 cleanup, sending email notifications, or workflow related tasks.

 The model for this functionality was based on Drupal's methods for laying
 out and interacting with hooks.  It should not be considered complete at
 this time.
*/
$moduleList = $AppUI->getLoadableModuleList();
foreach ($moduleList as $module) {
    if (!in_array($module['mod_main_class'], get_declared_classes())) {
        require_once $AppUI->getModuleClass($module['mod_directory']);
    }
    $object = new $module['mod_main_class']();
    if (is_callable(array($object, 'hook_cron'))) {
        $object->hook_cron();
    }