Merge ../butv10/core/framework
[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 * Sets the debug state
91 *
92 * @param bool Debug mode on?
93 */
94 public static function set_debug($debug)
95 {
96 self::$debug = $debug;
97 }
98
99 /**
100 * Gets the debug mode state
101 *
102 * @return bool Debug mode on?
103 */
104 public static function get_debug()
105 {
106 return self::$debug;
107 }
108
109 /**
110 * Adds a debug message to the array. This only works when debug mode
111 * is enabled.
112 *
113 * @param string Debug message
114 */
115 public static function debug($msg)
116 {
117 if (self::$debug)
118 {
119 self::$debugInfo[] = $msg;
120 }
121 }
122
123 /**
124 * Returns a <select> menu of all the debug notices
125 *
126 * @return string Debug list
127 */
128 public static function get_debug_list()
129 {
130 $output = '<select><option>Debug Notices (' . sizeof(self::$debugInfo) . ')</option>';
131 foreach (self::$debugInfo as $notice)
132 {
133 $output .= "<option>--- $notice</option>";
134 }
135 return "$output</select>";
136 }
137
138 // ###################################################################
139 // modules
140
141 /**
142 * BSDate
143 * @var object
144 */
145 public static $date;
146
147 /**
148 * BSDb
149 * @var object
150 */
151 public static $db;
152
153 /**
154 * BSInput
155 * @var object
156 */
157 public static $input;
158
159 /**
160 * BSTemplate
161 * @var object
162 */
163 public static $template;
164 }
165
166 ?>