if (!$_SESSION["wa_current_user"]->can_access_page($page_security))
{
- page(_("Access denied"));
+ // no_menu parameter guess here is ugly hack, but works for now.
+ // Better solution is to use global switch for menu, set before
+ // session.inc inclusion.
+ page(_("Access denied"), strpos($_SERVER['PHP_SELF'], '/view/'));
+
echo "<center><br><br><br><b>";
echo _("The security settings on your account do not permit you to access this function");
echo "</b>";
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))
{
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();
// js/php validation rules container
$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('ob_end_flush');
+register_shutdown_function('end_flush');
ob_start('output_html',0);
// colect all error msgs
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"],