These two files need to be swapped
[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 . '/Functions.php');
55
56 /**
57 * Application Class
58 *
59 * This is an ISSO application class. It holds all of the ISSO system variables as well
60 * as serving as an object registry that is avaliable in the global scope to prevent
61 * globalization of variables. There can only be one instance of this existing
62 * at any given time.
63 *
64 * @author Blue Static
65 * @copyright Copyright (c)2005 - 2008, Blue Static
66 * @package ISSO
67 *
68 */
69 class BSApp
70 {
71 /**
72 * Debug mode?
73 * @var bool
74 */
75 private static $debug = false;
76
77 /**
78 * An array of debug messages
79 * @var array
80 */
81 private static $debugInfo = array();
82
83 /**
84 * Constructor
85 */
86 private function __construct()
87 {}
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 /**
102 * Gets the debug mode state
103 *
104 * @return bool Debug mode on?
105 */
106 public static function get_debug()
107 {
108 return self::$debug;
109 }
110
111 // ###################################################################
112 /**
113 * Adds a debug message to the array. This only works when debug mode
114 * is enabled.
115 *
116 * @param string Debug message
117 */
118 public static function debug($msg)
119 {
120 if (self::$debug)
121 {
122 self::$debugInfo[] = $msg;
123 }
124 }
125
126 // ###################################################################
127 /**
128 * Returns a <select> menu of all the debug notices
129 *
130 * @return string Debug list
131 */
132 public static function get_debug_list()
133 {
134 $output = '<select><option>Debug Notices (' . sizeof(self::$debugInfo) . ')</option>';
135 foreach (self::$debugInfo as $notice)
136 {
137 $output .= "<option>--- $notice</option>";
138 }
139 return "$output</select>";
140 }
141
142 // ###################################################################
143 // modules
144
145 /**
146 * BSDate
147 * @var object
148 */
149 public static $date;
150
151 /**
152 * BSDb
153 * @var object
154 */
155 public static $db;
156
157 /**
158 * BSInput
159 * @var object
160 */
161 public static $input;
162
163 /**
164 * BSTemplate
165 * @var object
166 */
167 public static $template;
168 }
169
170 ?>