コード例 #1
0
function dPsessionRead($id)
{
    $q = new DBQuery();
    $q->addTable('sessions');
    $q->addQuery('session_data');
    $q->addQuery('UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) as session_lifespan');
    $q->addQuery('UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) as session_idle');
    $q->addWhere("session_id = '{$id}'");
    $qid =& $q->exec();
    if (!$qid || $qid->EOF) {
        dprint(__FILE__, __LINE__, 11, "Failed to retrieve session {$id}");
        $data = "";
    } else {
        $max = dPsessionConvertTime('max_lifetime');
        $idle = dPsessionConvertTime('idle_time');
        dprint(__FILE__, __LINE__, 11, "Found session {$id}, max={$max}/" . $qid->fields['session_lifespan'] . ", idle={$idle}/" . $qid->fields['session_idle']);
        // If the idle time or the max lifetime is exceeded, trash the
        // session.
        if ($max < $qid->fields['session_lifespan'] || $idle < $qid->fields['session_idle']) {
            dprint(__FILE__, __LINE__, 11, "session {$id} expired");
            dPsessionDestroy($id);
            $data = '';
        } else {
            $data = $qid->fields['session_data'];
        }
    }
    $q->clear();
    return $data;
}
コード例 #2
0
            //execute query and fetch results
            $r->exec();
            $boot_query_row = $r->fetchRow();
            if ($boot_query_row) {
                $boot_user_session = $boot_query_row['session_id'];
                $boot_user_log_id = $boot_query_row['user_access_log_id'];
            }
        }
    }
    do {
        if ($boot_user_id == $AppUI->user_id && $boot_user_session == $_COOKIE['PHPSESSID']) {
            $AppUI->resetPlace();
            $AppUI->redirect('logout=-1');
        } else {
            addHistory('login', $boot_user_id, 'logout', $details);
            dPsessionDestroy($boot_user_session, $boot_user_log_id);
        }
        if ($boot_query_row) {
            $boot_query_row = $r->fetchRow();
            if ($boot_query_row) {
                $boot_user_session = $boot_query_row['session_id'];
                $boot_user_log_id = $boot_query_row['user_access_log_id'];
            } else {
                $r->clear();
            }
        }
    } while ($boot_query_row);
    $msg = $boot_user_name . ' logged out by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
    $AppUI->setMsg($msg, UI_MSG_OK);
    $AppUI->redirect('m=admin&tab=3');
}