]>
src.bluestatic.org Git - isso.git/blob - kernel.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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.
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
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 \*=====================================================================*/
23 * Blue Static ISSO Framework Kernel
29 if (!function_exists('stripos'))
31 trigger_error('You need PHP version 5.0.0 or newer to run ISSO', E_USER_ERROR
);
35 if ((bool)ini_get('register_globals') === true)
37 $superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
38 foreach ($superglobals AS $global)
40 if (is_array(${$global}))
42 foreach (${$global} AS $_key => $_val)
64 * Blue Static ISSO Framework (ISSO)
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.
71 * ISSO_MT_START - Define the microtime() value at the top of your
72 * script and this will calculate the total execution
74 * SVN - Place SVN keywords (like $Id) to display the information on output
77 * @copyright Copyright ©2002 - [#]year[#], Blue Static
88 private $version = '[#]issoversion[#]';
91 * List of loaded modules
94 private $modules = array();
96 // ###################################################################
98 * Prints a list of all currently loaded framework modules
100 * @param bool Return the data as an array?
102 * @return mixed HTML output or an array of loaded modules
104 public function show_modules($return = false)
107 foreach ($this->modules
AS $object)
109 $module = get_class($object);
110 if (method_exists($object, 'init_as_package') AND in_array($module, $modules))
112 $module = $object->init_as_package() . " - ($module)";
115 $modules[] = $module;
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);
131 // ###################################################################
133 * Constructs a debug information box that contains various debugging
136 * @param bool Show template information?
138 * @return string Debugging block
140 public function construct_debug_block($dotemplates)
153 foreach ($this->modules
['template']->usage
AS $name => $count)
155 if (in_array($name, $this->modules
['template']->uncached
))
157 $optlist[] = $name . '[' . $count . ']';
159 $usage[] = $name . " ($count)";
162 $sizeof = sizeof($this->modules
['template']->uncached
);
165 $debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' ', $optlist) . " )</li>";
170 $scinfo = 'Not Under Source Control';
173 $scinfo = constant('SVN');
175 if (preg_match('#\$Id:?\s*\$#', $scinfo))
177 $scinfo = 'Not Under Source Control';
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);
187 $scinfo = trim($scinfo);
188 $debug .= "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
191 if (is_object($this->modules
[ISSO_DB_LAYER
]))
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) ? '&query=1' : '?query=1') . "\">?</a>)</li>";
196 // total execution time
197 if (defined('ISSO_MT_START'))
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>";
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)
207 $debug .= "\n\t\t\t<option>--- $msg</option>";
209 $debug .= "\n\t\t</select>\n\t</li>";
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)
216 $debug .= "\n\t\t\t<option>--- $mod</option>";
218 $debug .= "\n\t\t</select>\n\t</li>";
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)
226 $debug .= "\n\t\t\t<option>--- $tpl</option>";
228 $debug .= "\n\t\t</select>\n\t</li>";
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";
240 /*=====================================================================*\
241 || ###################################################################
244 || ###################################################################
245 \*=====================================================================*/