]> src.bluestatic.org Git - isso.git/blob - kernel.php
Forgot to change this instance of a method name that was changed
[isso.git] / kernel.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 * Blue Static ISSO Framework Kernel
24 * kernel.php
25 *
26 * @package ISSO
27 */
28
29 if (!function_exists('stripos'))
30 {
31 trigger_error('You need PHP version 5.0.0 or newer to run ISSO', E_USER_ERROR);
32 exit;
33 }
34
35 if ((bool)ini_get('register_globals') === true)
36 {
37 $superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
38 foreach ($superglobals AS $global)
39 {
40 if (is_array(${$global}))
41 {
42 foreach (${$global} AS $_key => $_val)
43 {
44 if (isset(${$_key}))
45 {
46 unset(${$_key});
47 }
48 }
49 }
50 }
51 }
52
53 /**
54 * Yes, required
55 */
56 define('REQ_YES', 1);
57
58 /**
59 * No, not required
60 */
61 define('REQ_NO', 0);
62
63 /**
64 * Blue Static ISSO Framework (ISSO)
65 *
66 * This framework allows a common backend to be used amongst all Blue
67 * Static applications and is built to be abstract and flexible.
68 * The base framework handles all loading and module management.
69 *
70 * Constants:
71 * ISSO_MT_START - Define the microtime() value at the top of your
72 * script and this will calculate the total execution
73 * time
74 * SVN - Place SVN keywords (like $Id) to display the information on output
75 *
76 * @author Blue Static
77 * @copyright Copyright ©2002 - [#]year[#], Blue Static
78 * @version $Revision$
79 * @package ISSO
80 *
81 */
82 class ISSO
83 {
84 /**
85 * ISSO version
86 * @var string
87 */
88 private $version = '[#]issoversion[#]';
89
90 /**
91 * List of loaded modules
92 * @var array
93 */
94 private $modules = array();
95
96 // ###################################################################
97 /**
98 * Prints a list of all currently loaded framework modules
99 *
100 * @param bool Return the data as an array?
101 *
102 * @return mixed HTML output or an array of loaded modules
103 */
104 public function show_modules($return = false)
105 {
106 $modules = array();
107 foreach ($this->modules AS $object)
108 {
109 $module = get_class($object);
110 if (method_exists($object, 'init_as_package') AND in_array($module, $modules))
111 {
112 $module = $object->init_as_package() . " - ($module)";
113 }
114
115 $modules[] = $module;
116 }
117
118 if ($return)
119 {
120 return $modules;
121 }
122 else
123 {
124 $output = "\n\n<ul>\n\t<li>";
125 $output .= implode("</li>\n\t<li>", $modules);
126 $output .= "</li>\n</ul>\n\n";
127 $this->message('Loaded Modules', $output, 1);
128 }
129 }
130
131 // ###################################################################
132 /**
133 * Constructs a debug information box that contains various debugging
134 * information points
135 *
136 * @param bool Show template information?
137 *
138 * @return string Debugging block
139 */
140 public function construct_debug_block($dotemplates)
141 {
142 $debug = '';
143
144 if ($this->debug)
145 {
146 $debug = "\n<ul>";
147
148 // templates
149 if ($dotemplates)
150 {
151 $optlist = array();
152 $usage = array();
153 foreach ($this->modules['template']->usage AS $name => $count)
154 {
155 if (in_array($name, $this->modules['template']->uncached))
156 {
157 $optlist[] = $name . '[' . $count . ']';
158 }
159 $usage[] = $name . " ($count)";
160 }
161
162 $sizeof = sizeof($this->modules['template']->uncached);
163 if ($sizeof > 0)
164 {
165 $debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' &nbsp; ', $optlist) . " )</li>";
166 }
167 }
168
169 // source control
170 $scinfo = 'Not Under Source Control';
171 if (defined('SVN'))
172 {
173 $scinfo = constant('SVN');
174
175 if (preg_match('#\$Id:?\s*\$#', $scinfo))
176 {
177 $scinfo = 'Not Under Source Control';
178 }
179 else
180 {
181 $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo);
182 $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo);
183 $scinfo = preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo);
184 }
185 }
186
187 $scinfo = trim($scinfo);
188 $debug .= "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
189
190 // query information
191 if (is_object($this->modules[ISSO_DB_LAYER]))
192 {
193 $debug .= "\n\t<li><strong>Total Queries:</strong> " . sizeof($this->modules[ISSO_DB_LAYER]->history) . " (<a href=\"" . $this->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;query=1' : '?query=1') . "\">?</a>)</li>";
194 }
195
196 // total execution time
197 if (defined('ISSO_MT_START'))
198 {
199 $this->load('functions', 'functions');
200 $debug .= "\n\t<li><strong>Total Execution Time:</strong> " . round($this->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "</li>";
201 }
202
203 // debug notices
204 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Debug Notices (" . sizeof($this->debuginfo) . ")</option>";
205 foreach ((array)$this->debuginfo AS $msg)
206 {
207 $debug .= "\n\t\t\t<option>--- $msg</option>";
208 }
209 $debug .= "\n\t\t</select>\n\t</li>";
210
211 // loaded modules
212 $modules = $this->show_modules(true);
213 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Loaded Modules (" . sizeof($modules) . ")</option>";
214 foreach ($modules AS $mod)
215 {
216 $debug .= "\n\t\t\t<option>--- $mod</option>";
217 }
218 $debug .= "\n\t\t</select>\n\t</li>";
219
220 // template usage
221 if ($dotemplates)
222 {
223 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Template Usage (" . array_sum($this->modules['template']->usage) . ")</option>";
224 foreach ($usage AS $tpl)
225 {
226 $debug .= "\n\t\t\t<option>--- $tpl</option>";
227 }
228 $debug .= "\n\t\t</select>\n\t</li>";
229 }
230
231 $debug .= "\n</ul>";
232
233 $debug = "\n\n<!-- dev debug -->\n<div align=\"center\">\n\n<hr />\n" . $this->message('Debug Information', $debug, 1, true, false) . "\n</div>\n<!-- / dev debug -->\n\n";
234 }
235
236 return $debug;
237 }
238 }
239
240 /*=====================================================================*\
241 || ###################################################################
242 || # $HeadURL$
243 || # $Id$
244 || ###################################################################
245 \*=====================================================================*/
246 ?>