Install wizard rewritten, added uploading COAs during install.
[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/current_user.inc");
56 include_once($path_to_root . "/includes/lang/language.php");
57 include_once($path_to_root . "/includes/ajax.inc");
58 include_once($path_to_root . "/includes/ui/ui_msgs.inc");
59 include_once($path_to_root . "/includes/prefs/sysprefs.inc");
60
61 session_name('FAinstall');
62 session_start();
63
64 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
65 header("Cache-control: private");
66
67 include_once($path_to_root . "/config.default.php");
68 get_text_init();
69
70 // Page Initialisation
71 if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language')) 
72 {
73         $l = array_search_value($dflt_lang, $installed_languages,  'code');
74         $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
75          isset($l['rtl']) ? 'rtl' : 'ltr');
76 }
77
78 $_SESSION['language']->set_language($_SESSION['language']->code);
79
80 include_once($path_to_root . "/version.php");
81 include_once($path_to_root . "/includes/main.inc");
82
83 // Ajax communication object
84 $Ajax = new Ajax();
85
86 // js/php validation rules container
87 $Validate = array();
88 // bindings for editors
89 $Editors = array();
90 // page help. Currently help for function keys.
91 $Pagehelp = array();
92
93 // intercept all output to destroy it in case of ajax call
94 register_shutdown_function('end_flush');
95 ob_start('output_html',0);
96
97 // colect all error msgs
98 set_error_handler('error_handler' /*, errtypes */);
99
100 if (!isset($_SESSION["wa_current_user"]))
101         $_SESSION["wa_current_user"] = new current_user();
102
103 $SysPrefs = &$_SESSION['SysPrefs'];
104
105 // POST vars cleanup needed for direct reuse.
106 // We quote all values later with db_escape() before db update.
107         $_POST = strip_quotes($_POST);
108
109 ?>