Exemplo n.º 1
0
function logout($complete_sess_id)
{
    // Validate the user session
    if (!Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $GLOBALS['bd'])) {
        return "Invalid session ID!";
    }
    // Finishe the session
    $sess_id = substr($complete_sess_id, 32);
    if (Terminate_Session($sess_id, 'logout', $GLOBALS['bd'])) {
        return "System logout successful!";
    }
}
Exemplo n.º 2
0
function Create_Session($username, $exibition, $ip_address, $master_session, $bd)
{
    $query = "SELECT * FROM sessions WHERE (account_id = " . $bd->GetTextFieldValue($username) . " AND (active = 1)";
    $active = $bd->Query($query);
    // Check if there is an unfinished session
    $num_sessions = $bd->NumberOfRows($active);
    if ($num_sessions != 0) {
        if ($master_session == 0) {
            for ($i = 0; $i < $num_sessions; $i++) {
                $sess_id = $bd->FetchResult($active, $i, 'session_id');
                Terminate_Session($sess_id, 'forced_termination', $bd);
            }
        }
    }
    $insert = "INSERT INTO sessions VALUES(NULL, {$master_session}, '{$username}', now(), now(),\n\t\t1, '', '{$ip_address}', '{$exibition}')";
    $bd->Query($insert);
    $res_sess_id = $bd->Query("SELECT * FROM sessions WHERE active=1 AND account_id='{$username}' ORDER\n\t\tBY session_id DESC");
    $sess_id = $bd->FetchResult($res_sess_id, 0, 'session_id');
    return $sess_id;
}
Exemplo n.º 3
0
<?php

if ($already_initialized != 1) {
    require "./inc/script_inicialization.php";
}
if (!isset($num_errors)) {
    $num_errors = 0;
}
if (!isset($num_alerts)) {
    $num_alerts = 0;
}
$master_session = Get_Master_Session($sess_id, $bd);
if ($master_session) {
    $m_complete_sess_id = md5($master_session);
    $m_complete_sess_id .= $master_session;
    Terminate_Session($sess_id, 'logout', $bd);
    header("location: main.php?sess_id={$m_complete_sess_id}");
    exit;
}
if (Terminate_Session($sess_id, 'logout', $bd)) {
    $alert[$num_alerts++] = "System logout successful!";
} else {
    $error[$num_alerts++] = "Invalid session ID!";
}
$result_xsl = "xsl/" . $default_xsl . "/logout.xsl";
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpIndexAlerts", $alert);
$smarty->assign("nrpIndexErrors", $error);
$result_xml = $smarty->fetch("xml/index.xml");
require "./inc/proc_transform.php";