Documenting constants
[isso.git] / kernel.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 * Iris Studios Shared Object Framework Kernel
24 * kernel.php
25 *
26 * @package ISSO
27 */
28
29 if (!function_exists('version_compare'))
30 {
31 trigger_error('You need PHP version 4.1.0 or newer to run ISSO', E_USER_ERROR);
32 exit;
33 }
34
35 if (version_compare(PHP_VERSION, '5.0.0', '>='))
36 {
37 if (ini_get('error_reporting') & E_NOTICE)
38 {
39 error_reporting(ini_get('error_reporting') - E_NOTICE);
40 }
41 if (ini_get('error_reporting') & E_USER_NOTICE)
42 {
43 error_reporting(ini_get('error_reporting') - E_USER_NOTICE);
44 }
45 }
46
47 $oldlevel = ini_get('error_reporting');
48 $newlevel = $oldlevel;
49 $levels = array(E_ERROR => E_USER_ERROR, E_WARNING => E_USER_WARNING, E_NOTICE => E_USER_NOTICE);
50 foreach ($levels AS $php => $isso)
51 {
52 if ($oldlevel & $php)
53 {
54 if (!($oldlevel & $isso))
55 {
56 $newlevel += $isso;
57 }
58 }
59 else
60 {
61 if ($oldlevel & $isso)
62 {
63 $newlevel -= $isso;
64 }
65 }
66 }
67 error_reporting($newlevel);
68
69 if ((bool)ini_get('register_globals') === true)
70 {
71 $superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
72 foreach ($superglobals AS $global)
73 {
74 if (is_array(${$global}))
75 {
76 foreach (${$global} AS $_key => $_val)
77 {
78 if (isset(${$_key}))
79 {
80 unset(${$_key});
81 }
82 }
83 }
84 }
85 }
86
87 /**#@+
88 * Input cleaning type constant
89 */
90 /**
91 * Integer type
92 */
93 define('TYPE_INT', 1);
94
95 /**
96 * Unsigned integer
97 */
98 define('TYPE_UINT', 2);
99
100 /**
101 * Float type
102 */
103 define('TYPE_FLOAT', 4);
104
105 /**
106 * Boolean type
107 */
108 define('TYPE_BOOL', 8);
109
110 /**
111 * String - cleaned
112 */
113 define('TYPE_STR', 16);
114
115 /**
116 * String - deliberate unclean
117 */
118 define('TYPE_STRUN', 32);
119
120 /**
121 * No cleaning - here for use in API
122 */
123 define('TYPE_NOCLEAN', 64);
124 /**#@-*/
125
126 /**
127 * Iris Studios Shared Object Framework (ISSO)
128 *
129 * This framework allows a common backend to be used amongst all Iris
130 * Studios applications and is built to be abstract and flexible.
131 * The base framework handles all loading and module management.
132 *
133 * Constants:
134 * ISSO_NO_INPUT_SANITIZE - Disables the automatic input sanitizer
135 * ISSO_CHECK_POST_REFERER - Will check to make sure that on POSTed
136 * data, the referer matches the host
137 *
138 * @author Iris Studios, Inc.
139 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
140 * @version $Revision$
141 * @package ISSO
142 *
143 */
144 class Shared_Object_Framework
145 {
146 /**
147 * ISSO version
148 * @var string
149 */
150 var $version = '[#]version[#]';
151
152 /**
153 * Location of ISSO, used for internal linking
154 * @var string
155 */
156 var $sourcepath = '';
157
158 /**
159 * Path of the current application
160 * @var string
161 */
162 var $apppath = '';
163
164 /**
165 * Web path used to get the web location of the installation of ISSO; only used for Printer module
166 * @var string
167 */
168 var $webpath = '';
169
170 /**
171 * Name of the current application
172 * @var string
173 */
174 var $application = '';
175
176 /**
177 * Version of the current application
178 * @var string
179 */
180 var $appversion = '';
181
182 /**
183 * Whether debug mode is on or off
184 * @var bool
185 */
186 var $debug = false;
187
188 /**
189 * List of all active debug messages
190 * @var array
191 */
192 var $debuginfo = array();
193
194 /**
195 * List of loaded modules
196 * @var array
197 */
198 var $modules = array();
199
200 /**
201 * An array of sanitized variables that have been cleaned for HTML tag openers and double quotes
202 * @var array
203 */
204 var $in = array();
205
206 /**
207 * If we are running with magic_quotes_gpc on or off
208 * @var int
209 */
210 var $magicquotes = 0;
211
212 // ###################################################################
213 /**
214 * Constructor
215 */
216 function __construct()
217 {
218 $GLOBALS['isso:null-framework'] = null;
219
220 // error reporting
221 set_error_handler(array(&$this, '_error_handler'));
222
223 // magic quotes
224 $this->magicquotes = get_magic_quotes_gpc();
225 set_magic_quotes_runtime(0);
226
227 // start input sanitize using variable_order GPC
228 if (!defined('ISSO_NO_INPUT_SANITIZE'))
229 {
230 $this->exec_sanitize_data();
231 }
232
233 if (defined('ISSO_CHECK_POST_REFERER'))
234 {
235 $this->exec_referer_check();
236 }
237 }
238
239 // ###################################################################
240 /**
241 * (PHP 4) Constructor
242 */
243 function Shared_Object_Framework()
244 {
245 $this->__construct();
246 }
247
248 // ###################################################################
249 /**
250 * Prepares a path for being set as the sourcepath
251 *
252 * @access public
253 *
254 * @param string Source path or URL
255 *
256 * @return string Prepared source path
257 */
258 function fetch_sourcepath($source)
259 {
260 if (substr($source, strlen($source) - 1) != DIRECTORY_SEPARATOR)
261 {
262 $source .= DIRECTORY_SEPARATOR;
263 }
264 return $source;
265 }
266
267 // ###################################################################
268 /**
269 * Loads a framework module
270 *
271 * @access public
272 *
273 * @param string Name of the framework file to load
274 * @param string Internal variable to initialize as; to not instantiate (just require) leave it as NULL
275 * @param bool Globalize the internal variable?
276 *
277 * @return object Instantiated instance
278 */
279 function &load($framework, $asobject, $globalize = false)
280 {
281 // set the object interlock
282 if (!method_exists($GLOBALS['isso:null-framework'], 'load'))
283 {
284 $GLOBALS['isso:null-framework'] =& $this;
285 }
286
287 if ($this->is_loaded($framework))
288 {
289 return $this->modules["$framework"];
290 }
291
292 if ($this->sourcepath == '')
293 {
294 trigger_error('Invalid sourcepath specified', E_USER_ERROR);
295 }
296
297 if (file_exists($this->sourcepath . $framework . '.php'))
298 {
299 require_once($this->sourcepath . $framework . '.php');
300 }
301 else
302 {
303 trigger_error('Could not find the framework ' . $this->sourcepath . $framework . '.php', E_USER_ERROR);
304 }
305
306 if ($asobject === null)
307 {
308 return;
309 }
310
311 if (isset($this->$asobject))
312 {
313 trigger_error('Cannot instantiate framework `' . $framework . '` into `' . $asobject . '`', E_USER_ERROR);
314 }
315
316 $this->$asobject = new $framework($this);
317
318 $this->modules["$framework"] =& $this->$asobject;
319
320 if ($globalize)
321 {
322 $GLOBALS["$asobject"] =& $this->$asobject;
323 }
324
325 return $this->$asobject;
326 }
327
328 // ###################################################################
329 /**
330 * Prints a list of all currently loaded framework modules
331 *
332 * @access public
333 *
334 * @param bool Return the data as an array?
335 *
336 * @return mixed HTML output or an array of loaded modules
337 */
338 function show_modules($return = false)
339 {
340 foreach ($this->modules AS $object)
341 {
342 $modules[] = get_class($object);
343 }
344
345 if ($return)
346 {
347 return $modules;
348 }
349 else
350 {
351 $output = "\n\n<ul>\n\t<li>";
352 $output .= implode("</li>\n\t<li>", $modules);
353 $output .= "</li>\n</ul>\n\n";
354 $this->message('Loaded Modules', $output, 1);
355 }
356 }
357
358 // ###################################################################
359 /**
360 * Verifies to see if a framework has been loaded
361 *
362 * @access public
363 *
364 * @param string Framework name
365 *
366 * @return bool Whether or not the framework has been loaded
367 */
368 function is_loaded($framework)
369 {
370 if (isset($this->modules["$framework"]))
371 {
372 return true;
373 }
374 else
375 {
376 return false;
377 }
378 }
379
380 // ###################################################################
381 /**
382 * Prints an ISSO message
383 *
384 * @access public
385 *
386 * @param string The title of the message
387 * @param string The content of the message
388 * @param integer Type of message to be printed
389 * @param bool Return the output?
390 * @param bool Show the debug stack?
391 *
392 * @return mixed Output or null
393 */
394 function message($title, $message, $type, $return = false, $stack = true)
395 {
396 switch ($type)
397 {
398 // Message
399 case 1:
400 $prefix = 'Message';
401 $color = '#669900';
402 $font = '#000000';
403 break;
404
405 // Warning
406 case 2:
407 $prefix = 'Warning';
408 $color = '#003399';
409 $font = '#FFFFFF';
410 break;
411
412 case 3:
413 $prefix = 'Error';
414 $color = '#990000';
415 $font = '#EFEFEF';
416 break;
417 }
418
419 $backtrace = debug_backtrace();
420 unset($backtrace[0]);
421
422 $output = "\n<br />\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"500\" style=\"background-color: $color; color: black; font-family: Verdana, sans-serif; font-size: 12px;\">";
423 $output .= "\n<tr style=\"color: $font; text-align: left\">\n\t<td><strong>$prefix: $title</strong></td>\n</tr>";
424 $output .= "\n<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td>$message</td>\n</tr>";
425 $output .= (($stack AND $GLOBALS['isso:null-framework']->debug) ? "\n<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td><strong>Debug Stack:</strong> <pre>" . print_r($backtrace, true) . "</pre></td>\n</tr>" : '');
426 $output .= "\n</table>\n<br />\n";
427
428 if ($return)
429 {
430 return $output;
431 }
432 else
433 {
434 print($output);
435 }
436 }
437
438 // ###################################################################
439 /**
440 * Custom error handler for ISSO; only handle E_WARNING, E_NOTICE,
441 * E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE
442 *
443 * @access private
444 *
445 * @param integer Error number
446 * @param string Error message string
447 * @param string File that contains the error
448 * @param string The line number of the error
449 * @param string The active symbol table at which point the error occurred
450 */
451 function _error_handler($errno, $errstr, $errfile, $errline)
452 {
453 switch ($errno)
454 {
455 // Fatal
456 case E_USER_ERROR:
457 $title = 'Fatal';
458 $level = 3;
459 if (!(ini_get('error_reporting') & E_USER_ERROR))
460 {
461 return;
462 }
463 break;
464
465 // Error
466 case E_USER_WARNING:
467 $title = 'Warning';
468 $level = 2;
469 if (!(ini_get('error_reporting') & E_USER_WARNING) AND !(ini_get('error_reporting') & E_WARNING))
470 {
471 return;
472 }
473 break;
474
475 // Warning
476 case E_USER_NOTICE:
477 default:
478 $title = 'Notice';
479 $level = 1;
480 if (!(ini_get('error_reporting') & E_USER_NOTICE) AND !(ini_get('error_reporting') & E_NOTICE))
481 {
482 return;
483 }
484 break;
485 }
486
487 $errstr .= " in <strong>$errfile</strong> on line <strong>$errline</strong>";
488
489 $errstr = str_replace(array(getcwd(), dirname(getcwd())), '', $errstr);
490
491 $this->message($title, $errstr, $level);
492
493 if ($errno == E_USER_ERROR)
494 {
495 exit;
496 }
497 }
498
499 // ###################################################################
500 /**
501 * Creates a table that explains the error reporting levels and their
502 * state
503 *
504 * @access public
505 */
506 function explain_error_reporting()
507 {
508 $levels = array(
509 'E_ERROR' => E_ERROR,
510 'E_WARNING' => E_WARNING,
511 'E_PARSE' => E_PARSE,
512 'E_NOTICE' => E_NOTICE,
513 'E_CORE_ERROR' => E_CORE_ERROR,
514 'E_CORE_WARNING' => E_CORE_WARNING,
515 'E_COMPILE_ERROR' => 64,
516 'E_COMPILE_WARNING' => 128,
517 'E_USER_ERROR' => E_USER_ERROR,
518 'E_USER_WARNING' => E_USER_WARNING,
519 'E_USER_NOTICE' => E_USER_NOTICE,
520 'E_ALL' => E_ALL,
521 'E_STRICT' => 2048
522 );
523
524 $table = '<table cellspacing="0" cellpadding="2" border="0">';
525
526 foreach ($levels AS $name => $value)
527 {
528 $table .= '
529 <tr>
530 <td>' . $name . '</td>
531 <td>' . (ini_get('error_reporting') & $value) . '</td>
532 </tr>';
533 }
534
535 $table .= '
536 </table>';
537
538 $this->message('Error Reporting', $table, 1);
539 }
540
541 // ###################################################################
542 /**
543 * Logs a debug message for verbose output
544 *
545 * @access public
546 *
547 * @param string Message
548 */
549 function debug($message)
550 {
551 $this->debuginfo[] = $message;
552 }
553
554 // ###################################################################
555 /**
556 * Recursive XSS cleaner
557 *
558 * @access private
559 *
560 * @param mixed Unsanitized REQUEST data
561 *
562 * @return mixed Sanitized data
563 */
564 function _sanitize_input_recursive($data)
565 {
566 foreach ($data AS $key => $value)
567 {
568 if (is_array($value))
569 {
570 $data["$key"] = $this->_sanitize_input_recursive($value);
571 }
572 else
573 {
574 $data["$key"] = $this->sanitize($value);
575 }
576 }
577 return $data;
578 }
579
580 // ###################################################################
581 /**
582 * Simple way to protect against HTML attacks with Unicode support
583 *
584 * @access public
585 *
586 * @param string Unsanitzed text
587 *
588 * @return string Properly protected text that only encodes potential threats
589 */
590 function sanitize($text)
591 {
592 if ($this->magicquotes)
593 {
594 return str_replace(array('<', '>', '\"', '"'), array('&lt;', '&gt;', '&quot;', '&quot;'), $text);
595 }
596 else
597 {
598 return str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $text);
599 }
600 }
601
602 // ###################################################################
603 /**
604 * Unicode-safe entity encoding system; similar to sanitize()
605 *
606 * @access public
607 *
608 * @param string Unsanitized text
609 *
610 * @return string Unicode-safe sanitized text with entities preserved
611 */
612 function entity_encode($text)
613 {
614 $text = str_replace('&', '&amp;', $text);
615 $text = $this->sanitize($text);
616 return $text;
617 }
618
619 // ###################################################################
620 /**
621 * Takes text that has been processed for HTML and unsanitizes it
622 *
623 * @access public
624 *
625 * @param string Text that needs to be turned back into HTML
626 *
627 * @return string Unsanitized text
628 */
629 function unsanitize($text)
630 {
631 return str_replace(array('&lt;', '&gt;', '&quot;'), array('<', '>', '"'), $text);
632 }
633
634 // ###################################################################
635 /**
636 * Smart addslashes() that only applies itself it the Magic Quotes GPC
637 * is off. This should only be run on database query values.
638 *
639 * @access public
640 *
641 * @param string Some string
642 * @param bool If the data is binary; if so it'll be run through DB::escape_stringing()
643 * @param bool Force magic quotes to be off
644 *
645 * @return string String that has slashes added
646 */
647 function escape($str, $binary = false, $force = true)
648 {
649 if ($this->magicquotes AND !$force)
650 {
651 if (isset($this->modules[ISSO_DB_LAYER]) AND $binary)
652 {
653 return $this->modules[ISSO_DB_LAYER]->escape_string(str_replace(array("\'", '\"'), array("'", '"'), $str));
654 }
655 return $str;
656 }
657 else
658 {
659 if (isset($this->modules[ISSO_DB_LAYER]) AND $binary)
660 {
661 return $this->modules[ISSO_DB_LAYER]->escape_string($str);
662 }
663 return addslashes($str);
664 }
665 }
666
667 // ###################################################################
668 /**
669 * Runs through all of the input data and sanitizes it.
670 *
671 * @access public
672 */
673 function exec_sanitize_data()
674 {
675 $this->in = $this->_sanitize_input_recursive(array_merge($_GET, $_POST, $_COOKIE));
676 }
677
678 // ###################################################################
679 /**
680 * Sanitize function for something other than a string (which
681 * everything is sanitized for if you use exec_sanitize_data(). Cleaned
682 * data is placed back into $isso->in; this makes it so you don't have
683 * to constantly intval() [etc.] data.
684 *
685 * @access public
686 *
687 * @param array Array of elements to clean as varname => type
688 */
689 function input_clean_array($vars)
690 {
691 foreach ($vars AS $varname => $type)
692 {
693 $this->input_clean($varname, $type);
694 }
695 }
696
697 // ###################################################################
698 /**
699 * Sanitize function that does a single variable as oppoesd to an array
700 * (see input_clean_array() for more details)
701 *
702 * @access public
703 *
704 * @param string Variable name in $isso->in[]
705 * @param integer Sanitization type constant
706 */
707 function input_clean($varname, $type)
708 {
709 if (isset($this->in["$varname"]))
710 {
711 $this->in["$varname"] = $this->clean($this->in["$varname"], $type);
712 }
713 else
714 {
715 $this->in["$varname"] = null;
716 }
717
718 return $this->in["$varname"];
719 }
720
721 // ###################################################################
722 /**
723 * Cleaning function that does the work for input_clean(); this is
724 * moved here so it can be used to clean things that aren't in
725 * $isso->in[]
726 *
727 * @access public
728 *
729 * @param mixed Data
730 * @param integer Sanitization type constant
731 *
732 * @return mixed Cleaned data
733 */
734 function clean($value, $type)
735 {
736 if ($type == TYPE_INT)
737 {
738 $value = intval($value);
739 }
740 else if ($type == TYPE_UINT)
741 {
742 $value = abs(intval($value));
743 }
744 else if ($type == TYPE_FLOAT)
745 {
746 $value = floatval($value);
747 }
748 else if ($type == TYPE_BOOL)
749 {
750 $value = (bool)$value;
751 }
752 else if ($type == TYPE_STR)
753 {
754 $value = $value;
755 }
756 else if ($type == TYPE_STRUN)
757 {
758 $value = $this->unsanitize($value);
759 }
760 else if ($type == TYPE_NOCLEAN)
761 {
762 $value = $value;
763 }
764 else
765 {
766 trigger_error('Invalid clean type `' . $type . '` specified', E_USER_ERROR);
767 }
768
769 return $value;
770 }
771
772 // ###################################################################
773 /**
774 * Checks to see if a POST refer is actually from us
775 *
776 * @access public
777 */
778 function exec_referer_check()
779 {
780 if ($_SERVER['REQUEST_METHOD'] == 'POST')
781 {
782 $host = ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
783
784 if ($host AND $_SERVER['HTTP_REFERER'])
785 {
786 $parts = parse_url($_SERVER['HTTP_REFERER']);
787 $ourhost = $parts['host'] . (isset($parts['port']) ? ":$parts[port]" : '');
788
789 if ($ourhost != $host)
790 {
791 trigger_error('No external hosts are allowed to POST to this application', E_USER_ERROR);
792 }
793 $this->debug('remote post check = ok');
794 }
795 else
796 {
797 $this->debug('remote post check = FAILED');
798 }
799 }
800 }
801
802 // ###################################################################
803 /**
804 * Constructs a debug information box that contains various debugging
805 * information points
806 *
807 * @access public
808 *
809 * @param bool Show template information?
810 *
811 * @return string Debugging block
812 */
813 function construct_debug_block($dotemplates)
814 {
815 $debug = '';
816
817 if ($this->debug)
818 {
819 $debug = "\n<ul>";
820
821 // templates
822 if ($dotemplates)
823 {
824 // both template and template_fs are viable, so we need to determine the right one
825 if ($this->is_loaded('template'))
826 {
827 $tpl_obj =& $this->modules['template'];
828 }
829 else if ($this->is_loaded('template_fs'))
830 {
831 $tpl_obj =& $this->modules['template_fs'];
832 }
833 else
834 {
835 $tpl_obj = null;
836 }
837
838 $optlist = array();
839 $usage = array();
840 foreach ($tpl_obj->usage AS $name => $count)
841 {
842 if (in_array($name, $tpl_obj->uncached))
843 {
844 $optlist[] = $name . '[' . $count . ']';
845 }
846 $usage[] = $name . " ($count)";
847 }
848
849 $sizeof = sizeof($tpl_obj->uncached);
850 if ($sizeof > 0)
851 {
852 $debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' &nbsp; ', $optlist) . " )</li>";
853 }
854 }
855
856 // source control
857 $scinfo = 'Not Under Source Control';
858 if (defined('SVN'))
859 {
860 $scinfo = constant('SVN');
861
862 if (preg_match('#\$Id:?\s*\$#', $scinfo))
863 {
864 $scinfo = 'Not Under Source Control';
865 }
866 else
867 {
868 $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo);
869 $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo);
870 $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);
871 }
872 }
873
874 $scinfo = trim($scinfo);
875 $debug .= "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
876
877 // query information
878 if (is_object($this->modules[ISSO_DB_LAYER]))
879 {
880 $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>";
881 }
882
883 // total execution time
884 if (defined('ISSO_MT_START'))
885 {
886 $this->load('functions', 'functions');
887 $debug .= "\n\t<li><strong>Total Execution Time:</strong> " . round($this->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "</li>";
888 }
889
890 // debug notices
891 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Debug Notices (" . sizeof($this->debuginfo) . ")</option>";
892 foreach ((array)$this->debuginfo AS $msg)
893 {
894 $debug .= "\n\t\t\t<option>--- $msg</option>";
895 }
896 $debug .= "\n\t\t</select>\n\t</li>";
897
898 // loaded modules
899 $modules = $this->show_modules(true);
900 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Loaded Modules (" . sizeof($modules) . ")</option>";
901 foreach ($modules AS $mod)
902 {
903 $debug .= "\n\t\t\t<option>--- $mod</option>";
904 }
905 $debug .= "\n\t\t</select>\n\t</li>";
906
907 // template usage
908 if ($dotemplates)
909 {
910 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Template Usage (" . array_sum($tpl_obj->usage) . ")</option>";
911 foreach ($usage AS $tpl)
912 {
913 $debug .= "\n\t\t\t<option>--- $tpl</option>";
914 }
915 $debug .= "\n\t\t</select>\n\t</li>";
916 }
917
918 $debug .= "\n</ul>";
919
920 $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";
921 }
922
923 return $debug;
924 }
925 }
926
927 /*=====================================================================*\
928 || ###################################################################
929 || # $HeadURL$
930 || # $Id$
931 || ###################################################################
932 \*=====================================================================*/
933 ?>