Beispiel #1
0
function validate_session($conn, $token, $workerId, $userAgent)
{
    $results = get_session_data($conn, $token);
    // If no results, fail. If results, check
    // If token is expired.
    if (!$results) {
        echo 'false';
        return false;
    } else {
        $timeStart = $results[0]['timeStart'];
        $timeExpire = $results[0]['timeExpire'];
        $token_truth = validate_token($token, $workerId, $userAgent, $timeStart);
        $time_truth = $timeExpire > time();
        if ($token_truth && $time_truth) {
            return true;
        }
    }
    return false;
}
Beispiel #2
0
<?php

require "../common.php";
require "../global.php";
require "../mysql/mysql.php";
require "../mysql/commonmysql.php";
require "../localization/language.php";
require "admins.php";
$debug = false;
$action = 'none';
//
// start session and check login
//
start_nonametv_session();
$dadmin = get_session_data();
if (!$dadmin) {
    notlogged_redirect();
}
//
// read global config
//
citajconfig();
if ($debug) {
    dbg("dconf", $dconf);
}
//
// connect to main database
//
switch ($dconf[maindbtype]) {
    case 'mysql':
        $myc = sql_spojise();
Beispiel #3
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I am an example function to view a user.
If "this" user is viewing (indicated by propper password hash along with another key, all data is shown), otherwise, just basic info is returned.
I contain example useage of the session functions
***********************************************/
if ($ERROR == 100) {
    $AuthResp = AuthenticateUser();
    if ($AuthResp[0] !== true) {
        $ERROR = $AuthResp[1];
        $OUTPUT['LOGIN'] = "******";
    } else {
        $ReturnedUser = $AuthResp[1];
        $OUTPUT['LOGIN'] = "******";
        $OUTPUT['SessionKey'] = create_session();
        $SessionData = array();
        $SessionData["login_time"] = time();
        $userData = $ReturnedUser;
        foreach ($userData as $k => $v) {
            $SessionData[$k] = $v;
        }
        update_session($OUTPUT['SessionKey'], $SessionData);
        $OUTPUT['SESSION'] = get_session_data($OUTPUT['SessionKey']);
    }
}
    echo '<br />';
    // return code for include
    return -1;
}
/************************************ Add session multiple slots form ****************************************/
if ($action == 'addsession') {
    // if there is some error from controller, display it
    if (!empty($errors)) {
        $errorstr = '';
        foreach ($errors as $anError) {
            $errorstr .= $anError->message;
        }
        print_simple_box($errorstr, 'center', '70%', '', 5, 'errorbox');
    }
    if (!empty($errors)) {
        get_session_data($data);
        $form =& $data;
    } else {
        $form->rangestart = time();
        $form->rangeend = time();
        $form->timestart = time();
        $form->timeend = time() + HOURSECS;
        $form->hideuntil = $scheduler->timemodified;
        $form->duration = $scheduler->defaultslotduration;
        $form->forcewhenoverlap = 0;
        $form->teacherid = $USER->id;
        $form->exclusivity = 1;
        $form->duration = $scheduler->defaultslotduration;
        $form->reuse = 1;
        $form->monday = 1;
        $form->tuesday = 1;
}
if (empty($user)) {
    echo "failed, user name can not be blank";
    exit;
}
if ($_POST['online']) {
    $state = "online";
} else {
    $state = "offline";
}
$id = get_session_data($user, "id", $state);
$user_name = get_session_data($user, "user_name", $state);
$id_server = get_session_data($user, "id_server", $state);
$ip_address = get_session_data($user, "ip_address", $state);
$start_time = get_session_data($user, "start_time", $state);
$end_time = get_session_data($user, "end_time", $state);
?>
		
		<table align="center" border="1" cellpadding="5">
			<tr>
				<td align="center"><a href="portal_sessionsmanagement.php">Session Management Menu</a></td>
				<td align="center"><a href="logout.php">Logout</a></td>
			</tr>
			<tr><td>Name:</td><td><?php 
echo $user_name;
?>
</td></tr>
			<tr><td>ID Server:</td><td><?php 
echo $id_server;
?>
</td></tr>