Location: PHPKode > projects > SENAYAN Library Automation > senayan3-stable5/admin/default/session_check.inc.php
<?php

/*

VERSION : 3.0
CODENAME : SENAYAN
AUTHOR :
    Code and Programming : ARIE NUGRAHA (hide@address.com)
    Database Design : HENDRO WICAKSONO (hide@address.com) & WARDIYONO (hide@address.com)

SENAYAN Library Automation System
Copyright (C) 2007

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (GPL License.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

// be sure that this file not accessed directly
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
    die();
}

// check session
$unauthorized = !isset($_SESSION['uid']) AND !isset($_SESSION['uname']) AND !isset($_SESSION['realname']);
if ($unauthorized) {
    $msg = '<script type="text/javascript">'."\n";
    $msg .= 'alert(\''.lang_sys_common_unauthorized.'\');'."\n";
    $msg .= 'location.href = \''.SENAYAN_WEB_ROOT_DIR.'index.php?p=login\';'."\n";
    $msg .= '</script>'."\n";
    simbio_security::destroySessionCookie($msg, true);
}

// checking session checksum
$unauthorized = $_SESSION['checksum'] != md5($_SERVER['SERVER_ADDR'].SENAYAN_BASE_DIR);
if ($unauthorized) {
    $msg = '<div style="padding: 5px; border: 1px dotted #FF0000; color: #FF0000;">';
    $msg .= lang_sys_common_unauthorized;
    $msg .= '</div>'."\n";
    simbio_security::destroySessionCookie($msg, true);
}

// check for session timeout
$curr_timestamp = time();
$timeout = ($curr_timestamp-$_SESSION['logintime']) >= $sysconf['session_timeout'];
if ($timeout) {
    $msg = '<div style="padding: 5px; border: 1px dotted #FF0000; color: #FF0000;">';
    $msg .= lang_sys_common_timeout.' <a href="'.SENAYAN_WEB_ROOT_DIR.'index.php?p=login">Re-Login</a>';
    $msg .= '</div>'."\n";
    simbio_security::destroySessionCookie($msg, true);
} else {
    // renew session logintime
    $_SESSION['logintime'] = time();
}
?>
Return current item: SENAYAN Library Automation