From: Janusz Dobrowolski Date: Tue, 24 Feb 2009 21:03:50 +0000 (+0000) Subject: Cleaning startup code. X-Git-Tag: v2.4.2~19^2~1504 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=4cf1c3dbb9ae74e0c47dda456f7ac97c7659b3fa;p=fa-stable.git Cleaning startup code. --- diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index 181651ff..fa57b678 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -9,7 +9,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -set_global_connection(); function set_global_connection() { diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index 7bdb69a8..4c4f1633 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -94,9 +94,9 @@ class get_text } elseif (!isset($support_obj)) { - trigger_error("get_text not initialized !". endl. + trigger_error("get_text not initialized !". '\n'. "Please call get_text::init() before calling ". - "any get_text function !" . endl , E_USER_ERROR); + "any get_text function !" . '\n' , E_USER_ERROR); } return $support_obj; } @@ -216,7 +216,7 @@ class get_text } function raise_error($str) { - //echo "$str"; +// echo "$str"; return 1; } diff --git a/includes/lang/language.php b/includes/lang/language.php index 62866f0b..059901cf 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -9,8 +9,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) - die(_("Restricted access")); include_once($path_to_root . "/lang/installed_languages.inc"); include_once($path_to_root . "/includes/lang/gettext.php"); @@ -36,7 +34,6 @@ class language return "lang/" . $this->code; } - function get_current_language_dir() { $lang = $_SESSION['language']; @@ -46,9 +43,9 @@ class language function set_language($code) { global $comp_path, $path_to_root; - - if (isset($_SESSION['languages'][$code]) && - $_SESSION['language'] != $_SESSION['languages'][$code]) + + $changed = $_SESSION['language']->code != $code; + if (isset($_SESSION['languages'][$code]) && $changed) { // flush cache as we can use several languages in one account flush_dir($comp_path.'/'.user_company().'/js_cache'); @@ -57,6 +54,17 @@ class language // check id file exists only once for session $_SESSION['language']->is_locale_file = file_exists($locale); } + + $lang = $_SESSION['language']; + get_text::set_language($lang->code, $lang->encoding); + get_text::add_domain($lang->code, $path_to_root . "/lang"); + + // Necessary for ajax calls. Due to bug in php 4.3.10 for this + // version set globally in php.ini + ini_set('default_charset', $lang->encoding); + + if (isset($_SESSION['App']) && $changed) + $_SESSION['App']->init(); // refresh menu } /** @@ -106,26 +114,6 @@ function _set($key,$value) get_text::set_var($key,$value); } -function reload_page($msg) -{ - global $Ajax; -// header("Location: $_SERVER['PHP_SELF'].""); -// exit; - echo ""; - echo ""; - echo "Changing Languages"; - echo ''; - echo ''; - echo ''; - echo '
'; - if ($msg != "") - echo $msg . " " . $_SERVER['PHP_SELF']; - echo "
"; - echo ""; - echo ""; - $Ajax->redirect($_SERVER['PHP_SELF']); -} - if (!function_exists("_")) { function _($text) diff --git a/includes/session.inc b/includes/session.inc index 4a67da7a..a6662a7e 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -103,6 +103,8 @@ include_once($path_to_root . "/includes/current_user.inc"); include_once($path_to_root . "/includes/lang/language.php"); include_once($path_to_root . "/config_db.php"); include_once($path_to_root . "/includes/ajax.inc"); +include_once($path_to_root . "/includes/main.inc"); +include_once($path_to_root . "/includes/ui/ui_msgs.inc"); /* Make sure this directory exists and is writable! @@ -114,31 +116,23 @@ session_start(); // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks header("Cache-control: private"); +get_text::init(); + // Page Initialisation if (!isset($_SESSION['languages'])) { - language::load_languages(); + language::load_languages(); // sets also default $_SESSION['language'] } -$lang = $_SESSION['language']; - -// get_text support -get_text::init(); -get_text::set_language($lang->code, $lang->encoding); -//get_text::add_domain("wa", $path_to_root . "/lang"); -get_text::add_domain($lang->code, $path_to_root . "/lang"); - -// Necessary for ajax calls. Due to bug in php 4.3.10 for this -// version set globally in php.ini -ini_set('default_charset', $_SESSION['language']->encoding); +language::set_language($_SESSION['language']->code); include_once($path_to_root . "/config.php"); $Ajax =& new Ajax(); -include_once($path_to_root . "/includes/main.inc"); +//include_once($path_to_root . "/includes/main.inc"); -include_once($path_to_root . "/includes/ui/ui_msgs.inc"); +//include_once($path_to_root . "/includes/ui/ui_msgs.inc"); // intercept all output to destroy it in case of ajax call register_shutdown_function('ob_end_flush'); @@ -149,6 +143,7 @@ set_error_handler('error_handler' /*, errtypes */); if (!isset($_SESSION["wa_current_user"])) $_SESSION["wa_current_user"] = new current_user(); +set_global_connection(); if (!$_SESSION["wa_current_user"]->logged_in()) { @@ -170,10 +165,14 @@ if (!$_SESSION["wa_current_user"]->logged_in()) login_fail(); } $lang = $_SESSION['language']; - get_text::set_language($lang->code, $lang->encoding); + language::set_language($_SESSION['language']->code); } } +if (!isset($_SESSION["App"])) { + $_SESSION["App"] = new front_accounting(); + $_SESSION["App"]->init(); +} // Run with debugging messages for the system administrator(s) but not anyone else /*if (in_array(15, $security_groups[$_SESSION["AccessLevel"]])) { diff --git a/index.php b/index.php index 5074e174..269636a0 100644 --- a/index.php +++ b/index.php @@ -14,8 +14,6 @@ ini_set('xdebug.auto_trace',1); include_once("includes/session.inc"); - if (!isset($_SESSION["App"])) - $_SESSION["App"] = new front_accounting(); $app = &$_SESSION["App"]; if (isset($_GET['application'])) $app->selected_application = $_GET['application'];