]> src.bluestatic.org Git - isso.git/blob - App.php
Updating the version 3.1.3
[isso.git] / App.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * ISSO Application Root (App.php)
24 *
25 * @package ISSO
26 */
27
28 // we need PHP 5.2.0 to run
29 if (!function_exists('array_fill_keys'))
30 {
31 print('You need PHP version 5.2.0 or newer to run ISSO');
32 exit;
33 }
34
35 // get rid of register_globals
36 if ((bool)ini_get('register_globals') === true)
37 {
38 $superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
39 foreach ($superglobals as $global)
40 {
41 if (is_array(${$global}))
42 {
43 foreach (${$global} as $_key => $_val)
44 {
45 if (isset(${$_key}))
46 {
47 unset(${$_key});
48 }
49 }
50 }
51 }
52 }
53
54 require_once ISSO . '/ExceptionHandler.php';
55 set_exception_handler(array('BSExceptionHandler', 'handle'));
56
57 /**
58 * Application Class
59 *
60 * This is an ISSO application class. It holds all of the ISSO system variables as well
61 * as serving as an object registry that is avaliable in the global scope to prevent
62 * globalization of variables. There can only be one instance of this existing
63 * at any given time.
64 *
65 * @author Blue Static
66 * @copyright Copyright (c)2005 - 2008, Blue Static
67 * @package ISSO
68 *
69 */
70 class BSApp
71 {
72 /**
73 * Debug mode?
74 * @var bool
75 */
76 private static $debug = false;
77
78 /**
79 * An array of debug messages
80 * @var array
81 */
82 private static $debugInfo = array();
83
84 /**
85 * Constructor
86 */
87 private function __construct()
88 {}
89
90 /**
91 * Sets the debug state
92 *
93 * @param bool Debug mode on?
94 */
95 public static function set_debug($debug)
96 {
97 self::$debug = $debug;
98 }
99
100 /**
101 * Gets the debug mode state
102 *
103 * @return bool Debug mode on?
104 */
105 public static function get_debug()
106 {
107 return self::$debug;
108 }
109
110 /**
111 * Adds a debug message to the array. This only works when debug mode
112 * is enabled.
113 *
114 * @param string Debug message
115 */
116 public static function debug($msg)
117 {
118 if (self::$debug)
119 {
120 self::$debugInfo[] = $msg;
121 }
122 }
123
124 /**
125 * Returns a <select> menu of all the debug notices
126 *
127 * @return string Debug list
128 */
129 public static function get_debug_list()
130 {
131 $output = '<select><option>Debug Notices (' . sizeof(self::$debugInfo) . ')</option>';
132 foreach (self::$debugInfo as $notice)
133 {
134 $output .= "<option>--- $notice</option>";
135 }
136 return "$output</select>";
137 }
138
139 // ###################################################################
140 // modules
141
142 /**
143 * BSDate
144 * @var object
145 */
146 public static $date;
147
148 /**
149 * BSDb
150 * @var object
151 */
152 public static $db;
153
154 /**
155 * BSInput
156 * @var object
157 */
158 public static $input;
159
160 /**
161 * BSTemplate
162 * @var object
163 */
164 public static $template;
165 }
166
167 ?>