Added georgian install wizard translation by Georgi Natsvlishvili, fixed small issue...
[fa-stable.git] / install / isession.inc
1 <?php
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)
13 {
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);
21         }
22         $Ajax->run();
23         return  in_ajax() ? fmt_errors() : ($before_box.fmt_errors().$text);
24 }
25
26 //-----------------------------------------------------------------------------
27 //      Removing magic quotes from nested arrays/variables
28 //
29 function strip_quotes($data)
30 {
31         if(get_magic_quotes_gpc()) {
32                 if(is_array($data)) {
33                         foreach($data as $k => $v) {
34                                 $data[$k] = strip_quotes($data[$k]);
35                         }
36                 } else
37                         return stripslashes($data);
38         }
39         return $data;
40 }
41
42 function check_page_security($page_security)
43 {
44 }
45 //============================================================================
46 if (!isset($path_to_root))
47 {
48         $path_to_root = ".";
49 }
50
51 // Prevent register_globals vulnerability
52 if (isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
53         die("Restricted access");
54
55 include_once($path_to_root . "/includes/errors.inc");
56 // collect all error msgs
57 set_error_handler('error_handler' /*, errtypes */);
58
59 include_once($path_to_root . "/includes/current_user.inc");
60 include_once($path_to_root . "/includes/lang/language.php");
61 include_once($path_to_root . "/includes/ajax.inc");
62 include_once($path_to_root . "/includes/ui/ui_msgs.inc");
63 include_once($path_to_root . "/includes/prefs/sysprefs.inc");
64
65 session_name('FAinstall');
66 session_start();
67
68 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
69 header("Cache-control: private");
70
71 include_once($path_to_root . "/config.default.php");
72
73 $inst_langs = array(
74   'C' => array ( 'name' => 'English',   'code' => 'C',          'encoding' => 'iso-8859-1'),
75   'ar_EG' => array ( 'name' => 'Arabic',        'code' => 'ar_EG',      'encoding' => 'utf-8', 'rtl' => true),
76   'da_DK' => array ( 'name' => 'Dansk', 'code' => 'da_DK',      'encoding' => 'iso-8859-1'),
77   'de_DE' => array ( 'name' => 'Deutsch',       'code' => 'de_DE',      'encoding' => 'iso-8859-1'),
78   'el_GR' => array ( 'name' => 'Greek', 'code' => 'el_GR',      'encoding' => 'utf-8'),
79   'es_MX' => array ( 'name' => 'Spanish',       'code' => 'es_MX',      'encoding' => 'iso-8859-1'),
80   'fr_FR' => array ( 'name' => 'Français',      'code' => 'fr_FR',      'encoding' => 'iso-8859-1'),
81   'id_ID' => array ( 'name' => 'Indonesian','code' => 'id_ID',  'encoding' => 'iso-8859-1'),
82   'it_IT' => array ( 'name' => 'Italian','code' => 'it_IT',     'encoding' => 'iso-8859-1'),
83   'ka_GE' => array ( 'name' => 'Georgian','code' => 'ka_GE',    'encoding' => 'utf-8'),
84   'nl_BE' => array ( 'name' => 'Nederlands','code' => 'nl_BE',  'encoding' => 'iso-8859-1'),
85   'pl_PL' => array ( 'name' => 'Polski',        'code' => 'pl_PL',      'encoding' => 'iso-8859-2'),
86   'pt_BR' => array ( 'name' => 'Português','code' => 'pt_BR',   'encoding' => 'iso-8859-1'),
87   'sv_SE' => array ( 'name' => 'Svenska',       'code' => 'sv_SE',      'encoding' => 'iso-8859-1'),
88   'zh_CN' => array ( 'name' => 'Chinese Simplifed',     'code' => 'zh_CN',      'encoding' => 'utf-8'),
89 );
90
91 $Ajax = new Ajax();
92
93 get_text_init();
94
95 $i_lang = isset($_POST['inst_lang']) ? $_POST['inst_lang'] : 
96         (isset($_SESSION['inst_set']['inst_lang']) ? $_SESSION['inst_set']['inst_lang'] : 'C');
97
98 // Page Initialisation
99 if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language')
100         || $_SESSION['language']->code != $i_lang) 
101 {
102         $l = array_search_value($i_lang, $inst_langs,  'code');
103         $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
104          isset($l['rtl']) ? 'rtl' : 'ltr');
105 }
106
107 $_SESSION['language']->set_language($_SESSION['language']->code);
108 $_SESSION['get_text']->add_domain( $_SESSION['language']->code, $path_to_root."/install/lang");
109
110 include_once($path_to_root . "/version.php");
111 include_once($path_to_root . "/includes/main.inc");
112
113 // js/php validation rules container
114 $Validate = array();
115 // bindings for editors
116 $Editors = array();
117 // page help. Currently help for function keys.
118 $Pagehelp = array();
119
120 //$Ajax = new Ajax();
121
122 // intercept all output to destroy it in case of ajax call
123 register_shutdown_function('end_flush');
124 ob_start('output_html',0);
125
126 if (!isset($_SESSION["wa_current_user"]))
127         $_SESSION["wa_current_user"] = new current_user();
128
129 $SysPrefs = &$_SESSION['SysPrefs'];
130
131 // POST vars cleanup needed for direct reuse.
132 // We quote all values later with db_escape() before db update.
133         $_POST = strip_quotes($_POST);
134
135 ?>