X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fsession.inc;h=dad1c1c94f1cca20259e8f77ac2f937a8e7a18da;hb=7e8c90ee7e898a9181f62f387ccb92158f47f59c;hp=d53e9b63e660cd154fd9fcdc5c49f40fb45a53eb;hpb=f018643dc04ce130f1729e16a65458af443308a0;p=fa-stable.git diff --git a/includes/session.inc b/includes/session.inc index d53e9b63..dad1c1c9 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -92,6 +92,20 @@ function strip_quotes($data) return $data; } +//============================================================================ +// +// +function login_timeout() +{ + if ($_SESSION["wa_current_user"]->logged) { + $tout = $_SESSION["wa_current_user"]->timeout; + if ($tout && (time() > $_SESSION["wa_current_user"]->last_act + $tout)) + { + $_SESSION["wa_current_user"]->logged = false; + } + $_SESSION["wa_current_user"]->last_act = time(); + } +} //============================================================================ if (!isset($path_to_root)) { @@ -110,9 +124,13 @@ include_once($path_to_root . "/includes/ajax.inc"); include_once($path_to_root . "/includes/ui/ui_msgs.inc"); /* + Uncomment the setting below when using FA on shared hosting + to avoid unexpeced session timeouts. Make sure this directory exists and is writable! -// $session_save_path = dirname(__FILE__).'/../tmp/'; */ +//ini_set('session.save_path', dirname(__FILE__).'/../tmp/'); + +ini_set('session.gc_maxlifetime', 36000); // 10hrs session_name('FrontAccounting'); session_start(); @@ -145,6 +163,8 @@ $Ajax =& new Ajax(); $Validate = array(); // bindings for editors $Editors = array(); +// page help. Currently help for function keys. +$Pagehelp = array(); // intercept all output to destroy it in case of ajax call register_shutdown_function('end_flush'); @@ -155,15 +175,27 @@ set_error_handler('error_handler' /*, errtypes */); if (!isset($_SESSION["wa_current_user"])) $_SESSION["wa_current_user"] = new current_user(); + set_global_connection(); +login_timeout(); + if (!$_SESSION["wa_current_user"]->logged_in()) { // Show login screen if (!isset($_POST["user_name_entry_field"]) or $_POST["user_name_entry_field"] == "") { - include($path_to_root . "/access/login.php"); - $Ajax->redirect($path_to_root . "/access/login.php"); + if (strstr($_SERVER['PHP_SELF'], 'timeout.php') == false) + $_SESSION['timeout'] = array( 'uri'=> $_SERVER['REQUEST_URI'], + 'post' => $_POST); + + if (!in_ajax()) { + include($path_to_root . "/access/login.php"); + } else { + // ajax update of current page elements - open login window in popup + // to not interfere with ajaxified page. + $Ajax->popup($path_to_root . "/access/timeout.php"); + } exit; } else { $succeed = $_SESSION["wa_current_user"]->login($_POST["company_login_name"],