2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 function output_html($text)
14 global $before_box, $Ajax, $messages;
15 // Fatal errors are not send to error_handler,
16 // so we must check the output
17 if ($text && preg_match('/\bFatal error(<.*?>)?:(.*)/i', $text, $m)) {
18 $Ajax->aCommands = array(); // Don't update page via ajax on errors
19 $text = preg_replace('/\bFatal error(<.*?>)?:(.*)/i','', $text);
20 $messages[] = array(E_ERROR, $m[2], null, null);
23 return in_ajax() ? fmt_errors() : ($before_box.fmt_errors().$text);
26 //-----------------------------------------------------------------------------
27 // Removing magic quotes from nested arrays/variables
29 function strip_quotes($data)
31 if(get_magic_quotes_gpc()) {
33 foreach($data as $k => $v) {
34 $data[$k] = strip_quotes($data[$k]);
37 return stripslashes($data);
42 function html_cleanup(&$parms)
44 foreach($parms as $name => $value) {
45 // $value = @html_entity_decode($value, ENT_QUOTES, $_SESSION['language']->encoding);
47 html_cleanup($parms[$name]);
49 $parms[$name] = @htmlspecialchars($value, ENT_QUOTES, $_SESSION['language']->encoding);
51 reset($parms); // needed for direct key() usage later throughout the sources
55 function check_page_security($page_security)
58 //============================================================================
59 if (!isset($path_to_root))
64 // Prevent register_globals vulnerability
65 if (isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
66 die("Restricted access");
68 include_once($path_to_root . "/includes/errors.inc");
69 // collect all error msgs
70 set_error_handler('error_handler' /*, errtypes */);
72 include_once($path_to_root . "/includes/current_user.inc");
73 include_once($path_to_root . "/includes/lang/language.php");
74 include_once($path_to_root . "/includes/ajax.inc");
75 include_once($path_to_root . "/includes/ui/ui_msgs.inc");
76 include_once($path_to_root . "/includes/prefs/sysprefs.inc");
78 session_name('FAinstall');
81 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
82 header("Cache-control: private");
84 include_once($path_to_root . "/config.default.php");
87 'C' => array ( 'name' => 'English', 'code' => 'C', 'encoding' => 'iso-8859-1'),
88 'ar_EG' => array ( 'name' => 'Arabic', 'code' => 'ar_EG', 'encoding' => 'utf-8', 'rtl' => true),
89 'da_DK' => array ( 'name' => 'Dansk', 'code' => 'da_DK', 'encoding' => 'iso-8859-1'),
90 'de_DE' => array ( 'name' => 'Deutsch', 'code' => 'de_DE', 'encoding' => 'iso-8859-1'),
91 'el_GR' => array ( 'name' => 'Greek', 'code' => 'el_GR', 'encoding' => 'utf-8'),
92 'es_MX' => array ( 'name' => 'Spanish', 'code' => 'es_MX', 'encoding' => 'iso-8859-1'),
93 'fr_FR' => array ( 'name' => 'Français', 'code' => 'fr_FR', 'encoding' => 'iso-8859-1'),
94 'id_ID' => array ( 'name' => 'Indonesian','code' => 'id_ID', 'encoding' => 'iso-8859-1'),
95 'it_IT' => array ( 'name' => 'Italian','code' => 'it_IT', 'encoding' => 'iso-8859-1'),
96 'ka_GE' => array ( 'name' => 'Georgian','code' => 'ka_GE', 'encoding' => 'utf-8'),
97 'nl_BE' => array ( 'name' => 'Nederlands','code' => 'nl_BE', 'encoding' => 'iso-8859-1'),
98 'pl_PL' => array ( 'name' => 'Polski', 'code' => 'pl_PL', 'encoding' => 'iso-8859-2'),
99 'pt_BR' => array ( 'name' => 'Português','code' => 'pt_BR', 'encoding' => 'iso-8859-1'),
100 'sv_SE' => array ( 'name' => 'Svenska', 'code' => 'sv_SE', 'encoding' => 'iso-8859-1'),
101 'zh_CN' => array ( 'name' => 'Chinese Simplifed', 'code' => 'zh_CN', 'encoding' => 'utf-8'),
108 $i_lang = isset($_POST['inst_lang']) ? $_POST['inst_lang'] :
109 (isset($_SESSION['inst_set']['inst_lang']) ? $_SESSION['inst_set']['inst_lang'] : array('C'));
111 // Page Initialisation
112 if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language')
113 || $_SESSION['language']->code != $i_lang)
115 $l = array_search_value($i_lang, $inst_langs, 'code');
116 $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
117 isset($l['rtl']) ? 'rtl' : 'ltr');
119 if (!isset($installed_languages))
120 $installed_languages = array();
122 $_SESSION['language']->set_language($_SESSION['language']->code);
123 $GetText->add_domain( $_SESSION['language']->code, $path_to_root."/install/lang");
125 include_once($path_to_root . "/version.php");
126 include_once($path_to_root . "/includes/main.inc");
128 // js/php validation rules container
130 // bindings for editors
132 // page help. Currently help for function keys.
135 //$Ajax = new Ajax();
137 // intercept all output to destroy it in case of ajax call
138 register_shutdown_function('end_flush');
139 ob_start('output_html',0);
141 if (!isset($_SESSION["wa_current_user"]))
142 $_SESSION["wa_current_user"] = new current_user();
145 html_cleanup($_POST);
146 html_cleanup($_REQUEST);
147 html_cleanup($_SERVER);
149 $SysPrefs = &$_SESSION['SysPrefs'];
151 // POST vars cleanup needed for direct reuse.
152 // We quote all values later with db_escape() before db update.
153 $_POST = strip_quotes($_POST);