Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdebug.php
Go to the documentation of this file.
1 <?php
56 class eZDebug
57 {
58 public $StoreLog;
59 const LEVEL_NOTICE = 1;
60 const LEVEL_WARNING = 2;
61 const LEVEL_ERROR = 3;
62 const LEVEL_TIMING_POINT = 4;
63 const LEVEL_DEBUG = 5;
64 const LEVEL_STRICT = 6;
65
66 const SHOW_NOTICE = 1; // 1 << (EZ_LEVEL_NOTICE - 1)
67 const SHOW_WARNING = 2; // 1 << (EZ_LEVEL_WARNING - 1)
68 const SHOW_ERROR = 4; // 1 << (EZ_LEVEL_ERROR - 1)
69 const SHOW_TIMING_POINT = 8; // 1 << (EZ_LEVEL_TIMING_POINT - 1)
70 const SHOW_DEBUG = 16; // 1 << (EZ_LEVEL_DEBUG - 1)
71 const SHOW_STRICT = 32; // 1 << (EZ_LEVEL_STRICT - 1)
72 const SHOW_ALL = 63; // EZ_SHOW_NOTICE | EZ_SHOW_WARNING | EZ_SHOW_ERROR | EZ_SHOW_TIMING_POINT | EZ_SHOW_DEBUG | EZ_SHOW_STRICT
73
74 const HANDLE_NONE = 0;
75 const HANDLE_FROM_PHP = 1;
76 const HANDLE_TO_PHP = 2;
77 const HANDLE_EXCEPTION = 3;
78
79 const OUTPUT_MESSAGE_SCREEN = 1;
80 const OUTPUT_MESSAGE_STORE = 2;
81
82 const MAX_LOGFILE_SIZE = 204800; // 200*1024
83 const MAX_LOGROTATE_FILES = 3;
84
85 const XDEBUG_SIGNATURE = '--XDEBUG--';
86
90 function __construct( )
91 {
92 $this->TmpTimePoints = array( self::LEVEL_NOTICE => array(),
93 self::LEVEL_WARNING => array(),
94 self::LEVEL_ERROR => array(),
95 self::LEVEL_DEBUG => array(),
96 self::LEVEL_STRICT => array() );
97
98 $this->OutputFormat = array( self::LEVEL_NOTICE => array( "color" => "green",
99 'style' => 'notice',
100 'xhtml-identifier' => 'ezdebug-first-notice',
101 "name" => "Notice" ),
102 self::LEVEL_WARNING => array( "color" => "orange",
103 'style' => 'warning',
104 'xhtml-identifier' => 'ezdebug-first-warning',
105 "name" => "Warning" ),
106 self::LEVEL_ERROR => array( "color" => "red",
107 'style' => 'error',
108 'xhtml-identifier' => 'ezdebug-first-error',
109 "name" => "Error" ),
110 self::LEVEL_DEBUG => array( "color" => "brown",
111 'style' => 'debug',
112 'xhtml-identifier' => 'ezdebug-first-debug',
113 "name" => "Debug" ),
114 self::LEVEL_TIMING_POINT => array( "color" => "blue",
115 'style' => 'timing',
116 'xhtml-identifier' => 'ezdebug-first-timing-point',
117 "name" => "Timing" ),
118 self::LEVEL_STRICT => array( "color" => "purple",
119 'style' => 'strict',
120 'xhtml-identifier' => 'ezdebug-first-strict',
121 'name' => 'Strict' ) );
122 $this->LogFiles = array( self::LEVEL_NOTICE => array( "var/log/",
123 "notice.log" ),
124 self::LEVEL_WARNING => array( "var/log/",
125 "warning.log" ),
126 self::LEVEL_ERROR => array( "var/log/",
127 "error.log" ),
128 self::LEVEL_DEBUG => array( "var/log/",
129 "debug.log" ),
130 self::LEVEL_STRICT => array( 'var/log/',
131 'strict.log' ) );
132 $this->MessageTypes = array( self::LEVEL_NOTICE,
133 self::LEVEL_WARNING,
134 self::LEVEL_ERROR,
135 self::LEVEL_TIMING_POINT,
136 self::LEVEL_DEBUG,
137 self::LEVEL_STRICT );
138 $this->MessageNames = array( self::LEVEL_NOTICE => 'Notice',
139 self::LEVEL_WARNING => 'Warning',
140 self::LEVEL_ERROR => 'Error',
141 self::LEVEL_TIMING_POINT => 'TimingPoint',
142 self::LEVEL_DEBUG => 'Debug',
143 self::LEVEL_STRICT => 'Strict' );
144 $this->LogFileEnabled = array( self::LEVEL_NOTICE => true,
145 self::LEVEL_WARNING => true,
146 self::LEVEL_ERROR => true,
147 self::LEVEL_TIMING_POINT => true,
148 self::LEVEL_DEBUG => true,
149 self::LEVEL_STRICT => true );
150 $this->AlwaysLog = array( self::LEVEL_NOTICE => false,
151 self::LEVEL_WARNING => false,
152 self::LEVEL_ERROR => true, // Error is on by default, due to its importance
153 self::LEVEL_TIMING_POINT => false,
154 self::LEVEL_DEBUG => false,
155 self::LEVEL_STRICT => false );
156 $this->GlobalLogFileEnabled = true;
157 if ( isset( $GLOBALS['eZDebugLogFileEnabled'] ) )
158 {
159 $this->GlobalLogFileEnabled = $GLOBALS['eZDebugLogFileEnabled'];
160 }
161 $this->ShowTypes = self::SHOW_ALL;
162 $this->HandleType = self::HANDLE_NONE;
163 $this->OldHandler = false;
164 $this->UseCSS = false;
165 $this->MessageOutput = self::OUTPUT_MESSAGE_STORE;
166 $this->ScriptStart = microtime( true );
167 $this->TimeAccumulatorList = array();
168 $this->TimeAccumulatorGroupList = array();
169 $this->OverrideList = array();
170 $this->topReportsList = array();
171 $this->bottomReportsList = array();
172 }
173
174 function reset()
175 {
176 $this->DebugStrings = array();
177 $this->TmpTimePoints = array( self::LEVEL_NOTICE => array(),
178 self::LEVEL_WARNING => array(),
179 self::LEVEL_ERROR => array(),
180 self::LEVEL_DEBUG => array(),
181 self::LEVEL_STRICT => array() );
182 $this->TimeAccumulatorList = array();
183 $this->TimeAccumulatorGroupList = array();
184 $this->topReportsList = array();
185 $this->bottomReportsList = array();
186 }
187
191 function messageName( $messageType )
192 {
193 return $this->MessageNames[$messageType];
194 }
195
201 static function instance( )
202 {
203 if ( empty( $GLOBALS["eZDebugGlobalInstance"] ) )
204 {
205 $GLOBALS["eZDebugGlobalInstance"] = new eZDebug();
206 }
207 return $GLOBALS["eZDebugGlobalInstance"];
208 }
209
214 static function showMessage( $type )
215 {
216 $debug = eZDebug::instance();
217 return $debug->ShowTypes & $type;
218 }
219
223 static function alwaysLogMessage( $level )
224 {
225 $instance = eZDebug::instance();
226 // If there is a global setting for this get the value
227 // and unset it globally
228 if ( isset( $GLOBALS['eZDebugAlwaysLog'] ) )
229 {
230 $instance->AlwaysLog = $GLOBALS['eZDebugAlwaysLog'] + $instance->AlwaysLog;
231 unset( $GLOBALS['eZDebugAlwaysLog'] );
232 }
233
234 if ( !isset( $instance->AlwaysLog[$level] ) )
235 {
236 return false;
237 }
238 return $instance->AlwaysLog[$level];
239 }
240
247 static function setHandleType( $type )
248 {
249 $instance = eZDebug::instance();
250
251 if ( $type != self::HANDLE_TO_PHP and
252 $type != self::HANDLE_FROM_PHP and
253 $type != self::HANDLE_EXCEPTION )
254 $type = self::HANDLE_NONE;
255 if ( extension_loaded( 'xdebug' ) and
256 $type == self::HANDLE_FROM_PHP )
257 $type = self::HANDLE_NONE;
258 if ( $type == $instance->HandleType )
259 return $instance->HandleType;
260
261 if ( $instance->HandleType == self::HANDLE_FROM_PHP or $instance->HandleType == self::HANDLE_EXCEPTION )
262 restore_error_handler();
263 switch ( $type )
264 {
265 case self::HANDLE_FROM_PHP:
266 {
267 set_error_handler( array( $instance, 'recursionProtectErrorHandler' ) );
268 } break;
269
270 case self::HANDLE_TO_PHP:
271 {
272 restore_error_handler();
273 } break;
274
275 case self::HANDLE_EXCEPTION:
276 {
277 set_error_handler( array( $instance, 'exceptionErrorHandler' ) );
278 } break;
279
280 case self::HANDLE_NONE:
281 {
282 }
283 }
284 $oldHandleType = $instance->HandleType;
285 $instance->HandleType = $type;
286 return $oldHandleType;
287 }
288
296 static function showTypes( $types = false )
297 {
298 $instance = eZDebug::instance();
299
300 if ( $types === false )
301 {
302 return $instance->ShowTypes;
303 }
304 $old_types = $instance->ShowTypes;
305 $instance->ShowTypes = $types;
306 return $old_types;
307 }
308
309 public function recursionProtectErrorHandler( $errno, $errstr, $errfile, $errline )
310 {
311 if ( $this->recursionFlag )
312 {
313 print( "Fatal debug error: A recursion in debug error handler was detected, aborting debug message.<br/>" );
314 $this->recursionFlag = false;
315 return;
316 }
317
318 $this->recursionFlag = true;
319
320 $result = $this->errorHandler( $errno, $errstr, $errfile, $errline );
321 $this->recursionFlag = false;
322 return $result;
323 }
324
329 function errorHandler( $errno, $errstr, $errfile, $errline )
330 {
331 if ( error_reporting() == 0 ) // @ error-control operator is used
332 return;
333 if ( !eZDebug::isDebugEnabled() )
334 return;
335 $str = "$errstr in $errfile on line $errline";
336 if ( empty( $GLOBALS['eZDebugPHPErrorNames'] ) )
337 {
338 $GLOBALS['eZDebugPHPErrorNames'] =
339 array( E_ERROR => 'E_ERROR',
340 E_PARSE => 'E_PARSE',
341 E_CORE_ERROR => 'E_CORE_ERROR',
342 E_COMPILE_ERROR => 'E_COMPILE_ERROR',
343 E_USER_ERROR => 'E_USER_ERROR',
344 E_WARNING => 'E_WARNING',
345 E_CORE_WARNING => 'E_CORE_WARNING',
346 E_COMPILE_WARNING => 'E_COMPILE_WARNING',
347 E_USER_WARNING => 'E_USER_WARNING',
348 E_NOTICE => 'E_NOTICE',
349 E_USER_NOTICE => 'E_USER_NOTICE',
350 // E_STRICT => 'E_STRICT'
351 );
352 // Since PHP 5.2
353 if ( defined('E_RECOVERABLE_ERROR') )
354 $GLOBALS['eZDebugPHPErrorNames'][E_RECOVERABLE_ERROR] = 'E_RECOVERABLE_ERROR';
355 // Since PHP 5.3
356 if ( defined('E_DEPRECATED') )
357 $GLOBALS['eZDebugPHPErrorNames'][E_DEPRECATED] = 'E_DEPRECATED';
358 if ( defined('E_USER_DEPRECATED') )
359 $GLOBALS['eZDebugPHPErrorNames'][E_USER_DEPRECATED] = 'E_USER_DEPRECATED';
360
361 }
362 $errname = "Unknown error code ($errno)";
363 if ( isset( $GLOBALS['eZDebugPHPErrorNames'][$errno] ) )
364 {
365 $errname = $GLOBALS['eZDebugPHPErrorNames'][$errno];
366 }
367 switch ( $errname )
368 {
369 case 'E_ERROR':
370 case 'E_PARSE':
371 case 'E_CORE_ERROR':
372 case 'E_COMPILE_ERROR':
373 case 'E_USER_ERROR':
374 case 'E_RECOVERABLE_ERROR':
375 {
376 $this->writeError( $str, 'PHP: ' . $errname );
377 } break;
378
379 case 'E_WARNING':
380 case 'E_CORE_WARNING':
381 case 'E_COMPILE_WARNING':
382 case 'E_USER_WARNING':
383 case 'E_DEPRECATED':
384 case 'E_USER_DEPRECATED':
385 {
386 $this->writeWarning( $str, 'PHP: ' . $errname );
387 } break;
388
389 case 'E_NOTICE':
390 case 'E_USER_NOTICE':
391 {
392 $this->writeNotice( $str, 'PHP: ' . $errname );
393 } break;
394
395 case 'E_STRICT':
396 {
397 return $this->writeStrict( $str, 'PHP: ' . $errname );
398 } break;
399 default:
400 {
401 $this->writeError( $str, 'PHP: ' . $errname );
402 } break;
403 }
404 }
405
414 static function writeStrict( $string, $label = "", $backgroundClass = "" )
415 {
416 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_STRICT );
417 $enabled = eZDebug::isDebugEnabled();
418 if ( !$alwaysLog and !$enabled )
419 return;
420
421 $show = eZDebug::showMessage( self::SHOW_STRICT );
422 if ( !$alwaysLog and !$show )
423 return;
424
425 if ( is_object( $string ) || is_array( $string ) )
426 $string = eZDebug::dumpVariable( $string );
427
428 $GLOBALS['eZDebugStrict'] = true;
429 if ( !isset( $GLOBALS['eZDebugStrictCount'] ) )
430 $GLOBALS['eZDebugStrictCount'] = 0;
431 ++$GLOBALS['eZDebugStrictCount'];
432
433 $debug = eZDebug::instance();
434 if ( $debug->HandleType == self::HANDLE_TO_PHP )
435 {
436 // If we get here only because of $alwaysLog we should not trigger a PHP error
437 if ( $enabled and $show )
438 {
439 // we can't trigger E_STRICT but we can let the default error handler handle it
440 // see http://www.php.net/manual/en/function.set-error-handler.php#69218
441 return false;
442 }
443 }
444 else
445 {
446 $debug->write( $string, self::LEVEL_STRICT, $label, $backgroundClass, $alwaysLog );
447 return true;
448 }
449 }
450
459 static function writeNotice( $string, $label = "", $backgroundClass = "" )
460 {
461 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_NOTICE );
462 $enabled = eZDebug::isDebugEnabled();
463 if ( !$alwaysLog and !$enabled )
464 return;
465
466 $show = eZDebug::showMessage( self::SHOW_NOTICE );
467 if ( !$alwaysLog and !$show )
468 return;
469
470 if ( is_object( $string ) || is_array( $string ) )
471 $string = eZDebug::dumpVariable( $string );
472
473 $GLOBALS['eZDebugNotice'] = true;
474 if ( !isset( $GLOBALS['eZDebugNoticeCount'] ) )
475 $GLOBALS['eZDebugNoticeCount'] = 0;
476 ++$GLOBALS['eZDebugNoticeCount'];
477
478 $debug = eZDebug::instance();
479 if ( $debug->HandleType == self::HANDLE_TO_PHP )
480 {
481 // If we get here only because of $alwaysLog we should not trigger a PHP error
482 if ( $enabled and $show )
483 {
484 if ( $label )
485 $string = "$label: $string";
486 trigger_error( $string, E_USER_NOTICE );
487 }
488 }
489 else
490 {
491 $debug->write( $string, self::LEVEL_NOTICE, $label, $backgroundClass, $alwaysLog );
492 }
493 }
494
502 static function writeWarning( $string, $label = "", $backgroundClass = "" )
503 {
504 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_WARNING );
505 $enabled = eZDebug::isDebugEnabled();
506 if ( !$alwaysLog and !$enabled )
507 return;
508
509 $show = eZDebug::showMessage( self::SHOW_WARNING );
510 if ( !$alwaysLog and !$show )
511 return;
512
513 if ( is_object( $string ) || is_array( $string ) )
514 $string = eZDebug::dumpVariable( $string );
515
516 $GLOBALS['eZDebugWarning'] = true;
517 if ( !isset( $GLOBALS['eZDebugWarningCount'] ) )
518 $GLOBALS['eZDebugWarningCount'] = 0;
519 ++$GLOBALS['eZDebugWarningCount'];
520
521 $debug = eZDebug::instance();
522 if ( $debug->HandleType == self::HANDLE_TO_PHP )
523 {
524 // If we get here only because of $alwaysLog we should not trigger a PHP error
525 if ( $enabled and $show )
526 {
527 if ( $label )
528 $string = "$label: $string";
529 trigger_error( $string, E_USER_WARNING );
530 }
531 }
532 else
533 {
534 $debug->write( $string, self::LEVEL_WARNING, $label, $backgroundClass, $alwaysLog );
535 }
536 }
537
545 static function writeError( $string, $label = "", $backgroundClass = "" )
546 {
547 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_ERROR );
548 $enabled = eZDebug::isDebugEnabled();
549 if ( !$alwaysLog and !$enabled )
550 return;
551
552 $show = eZDebug::showMessage( self::SHOW_ERROR );
553 if ( !$alwaysLog and !$show )
554 return;
555
556 if ( is_object( $string ) || is_array( $string ) )
557 $string = eZDebug::dumpVariable( $string );
558
559 $GLOBALS['eZDebugError'] = true;
560 if ( !isset( $GLOBALS['eZDebugErrorCount'] ) )
561 $GLOBALS['eZDebugErrorCount'] = 0;
562 ++$GLOBALS['eZDebugErrorCount'];
563
564 $debug = eZDebug::instance();
565 if ( $debug->HandleType == self::HANDLE_TO_PHP )
566 {
567 // If we get here only because of $alwaysLog we should not trigger a PHP error
568 if ( $enabled and $show )
569 {
570 if ( $label )
571 $string = "$label: $string";
572 trigger_error( $string, E_USER_ERROR );
573 }
574 }
575 else
576 {
577 $debug->write( $string, self::LEVEL_ERROR, $label, $backgroundClass, $alwaysLog );
578 }
579 }
580
588 static function writeDebug( $string, $label = "", $backgroundClass = "" )
589 {
590 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_DEBUG );
591 $enabled = eZDebug::isDebugEnabled();
592 if ( !$alwaysLog and !$enabled )
593 return;
594
595 $show = eZDebug::showMessage( self::SHOW_DEBUG );
596 if ( !$alwaysLog and !$show )
597 return;
598
599 if ( is_object( $string ) || is_array( $string ) )
600 $string = eZDebug::dumpVariable( $string );
601
602 $GLOBALS['eZDebugDebug'] = true;
603 if ( !isset( $GLOBALS['eZDebugDebugCount'] ) )
604 $GLOBALS['eZDebugDebugCount'] = 0;
605 ++$GLOBALS['eZDebugDebugCount'];
606
607 $debug = eZDebug::instance();
608 if ( $debug->HandleType == self::HANDLE_TO_PHP )
609 {
610 // If we get here only because of $alwaysLog we should not trigger a PHP error
611 if ( $enabled and $show )
612 {
613 if ( $label )
614 $string = "$label: $string";
615 trigger_error( $string, E_USER_NOTICE );
616 }
617 }
618 else
619 {
620 $debug->write( $string, self::LEVEL_DEBUG, $label, $backgroundClass, $alwaysLog );
621 }
622 }
623
629 static function dumpVariable( $var )
630 {
631 // If we have var_export (PHP >= 4.2.0) we use the instead
632 // provides better output, doesn't require output buffering
633 // and doesn't get mangled by Xdebug
634
635 // dl: we should always use 'var_dump' since 'var_export' is
636 // unable to handle recursion properly.
637 //if ( function_exists( 'var_export' ) )
638 // return var_export( $var, true );
639
640 ob_start();
641 var_dump( $var );
642 $variableContents = '';
643 if ( extension_loaded( 'xdebug' ) )
644 $variableContents = self::XDEBUG_SIGNATURE;
645 $variableContents .= ob_get_contents();
646 ob_end_clean();
647 return $variableContents;
648 }
649
654 static function setUseExternalCSS( $use )
655 {
656 eZDebug::instance()->UseCSS = $use;
657 }
658
663 function setMessageOutput( $output )
664 {
665 $this->MessageOutput = $output;
666 }
667
668 function setStoreLog( $store )
669 {
670 $this->StoreLog = $store;
671 }
672
676 static function addTimingPoint( $description = "" )
677 {
678 if ( !eZDebug::isDebugEnabled() )
679 return;
680 if ( !eZDebug::showMessage( self::SHOW_TIMING_POINT ) )
681 return;
682
683 $time = microtime( true );
684 $debug = eZDebug::instance();
685
686 $usedMemory = 0;
687 if ( function_exists( "memory_get_usage" ) )
688 $usedMemory = memory_get_usage();
689 $tp = array( "Time" => $time,
690 "Description" => $description,
691 "MemoryUsage" => $usedMemory );
692 $debug->TimePoints[] = $tp;
693 $desc = "Timing Point: $description";
694 foreach ( array( self::LEVEL_NOTICE, self::LEVEL_WARNING, self::LEVEL_ERROR, self::LEVEL_DEBUG, self::LEVEL_STRICT ) as $lvl )
695 {
696 if ( isset( $debug->TmpTimePoints[$lvl] ) )
697 $debug->TmpTimePoints[$lvl] = array();
698 if ( $debug->TmpTimePoints[$lvl] === false and
699 $debug->isLogFileEnabled( $lvl ) )
700 {
701 $files = $debug->logFiles();
702 $file = $files[$lvl];
703 $debug->writeFile( $file, $desc, $lvl );
704 }
705 else
706 array_push( $debug->TmpTimePoints[$lvl], $tp );
707 }
708 $debug->write( $description, self::LEVEL_TIMING_POINT );
709 }
710
715 function write( $string, $verbosityLevel = self::LEVEL_NOTICE, $label = "", $backgroundClass = "", $alwaysLog = false )
716 {
717 $enabled = eZDebug::isDebugEnabled();
718 if ( !$alwaysLog and !$enabled )
719 return;
720 switch ( $verbosityLevel )
721 {
722 case self::LEVEL_NOTICE:
723 case self::LEVEL_WARNING:
724 case self::LEVEL_ERROR:
725 case self::LEVEL_DEBUG:
726 case self::LEVEL_TIMING_POINT:
727 case self::LEVEL_STRICT:
728 break;
729
730 default:
731 $verbosityLevel = self::LEVEL_ERROR;
732 break;
733 }
734 if ( $this->MessageOutput & self::OUTPUT_MESSAGE_SCREEN and $enabled )
735 {
736 print( "$verbosityLevel: $string ($label)\n" );
737 }
738 $files = $this->logFiles();
739 $fileName = false;
740 if ( isset( $files[$verbosityLevel] ) )
741 $fileName = $files[$verbosityLevel];
742 if ( $this->MessageOutput & self::OUTPUT_MESSAGE_STORE or $alwaysLog )
743 {
744 if ( ! eZDebug::isLogOnlyEnabled() and $enabled )
745 {
746 $ip = eZSys::clientIP();
747 if ( !$ip )
748 $ip = eZSys::serverVariable( 'HOSTNAME', true );
749 $this->DebugStrings[] = array( "Level" => $verbosityLevel,
750 "IP" => $ip,
751 "Time" => time(),
752 "Label" => $label,
753 "String" => $string,
754 "BackgroundClass" => $backgroundClass );
755 }
756
757 if ( $fileName !== false )
758 {
759 $timePoints = $this->TmpTimePoints[$verbosityLevel];
760 if ( is_array( $timePoints ) )
761 {
762 if ( $this->isLogFileEnabled( $verbosityLevel ) )
763 {
764 foreach ( $timePoints as $tp )
765 {
766 $desc = "Timing Point: " . $tp["Description"];
767 $this->writeFile( $fileName, $desc, $verbosityLevel, $alwaysLog );
768 }
769 }
770 $this->TmpTimePoints[$verbosityLevel] = false;
771 }
772 if ( $this->isLogFileEnabled( $verbosityLevel ) )
773 {
774 $string = "$label:\n$string";
775 $this->writeFile( $fileName, $string, $verbosityLevel, $alwaysLog );
776 }
777 }
778 }
779 }
780
785 static function maxLogSize()
786 {
787 if ( isset( $GLOBALS['eZDebugMaxLogSize'] ) )
788 {
789 return $GLOBALS['eZDebugMaxLogSize'];
790 }
791 else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
792 {
793 self::setMaxLogSize( (int)EZPUBLISH_LOG_MAX_FILE_SIZE );
794 return (int)EZPUBLISH_LOG_MAX_FILE_SIZE;
795 }
796 return self::MAX_LOGFILE_SIZE;
797 }
798
803 static function setMaxLogSize( $size )
804 {
805 $GLOBALS['eZDebugMaxLogSize'] = $size;
806 }
807
812 static function maxLogrotateFiles()
813 {
814 if ( isset( $GLOBALS['eZDebugMaxLogrotateFiles'] ) )
815 {
816 return $GLOBALS['eZDebugMaxLogrotateFiles'];
817 }
818 else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
819 {
820 self::setLogrotateFiles( (int)EZPUBLISH_LOG_ROTATE_FILES );
821 return (int)EZPUBLISH_LOG_ROTATE_FILES;
822 }
823 return self::MAX_LOGROTATE_FILES;
824 }
825
830 static function setLogrotateFiles( $files )
831 {
832 $GLOBALS['eZDebugMaxLogrotateFiles'] = $files;
833 }
834
842 static function rotateLog( $fileName )
843 {
844 $maxLogrotateFiles = eZDebug::maxLogrotateFiles();
845 if ( $maxLogrotateFiles == 0 )
846 {
847 return;
848 }
849 for ( $i = $maxLogrotateFiles; $i > 0; --$i )
850 {
851 $logRotateName = $fileName . '.' . $i;
852 if ( file_exists( $logRotateName ) )
853 {
854 if ( $i == $maxLogrotateFiles )
855 {
856 @unlink( $logRotateName );
857 }
858 else
859 {
860 $newLogRotateName = $fileName . '.' . ($i + 1);
861 eZFile::rename( $logRotateName, $newLogRotateName );
862 }
863 }
864 }
865 if ( file_exists( $fileName ) )
866 {
867 $newLogRotateName = $fileName . '.' . 1;
868 eZFile::rename( $fileName, $newLogRotateName );
869 return true;
870 }
871 return false;
872 }
873
878 function writeFile( &$logFileData, &$string, $verbosityLevel, $alwaysLog = false )
879 {
880 $enabled = eZDebug::isDebugEnabled();
881 if ( !$alwaysLog and !$enabled )
882 return;
883 if ( !$alwaysLog and !$this->isLogFileEnabled( $verbosityLevel ) )
884 return;
885 $oldHandleType = eZDebug::setHandleType( self::HANDLE_TO_PHP );
886 $logDir = $logFileData[0];
887 $logName = $logFileData[1];
888 $fileName = $logDir . $logName;
889 if ( !file_exists( $logDir ) )
890 {
891 eZDir::mkdir( $logDir, false, true );
892 }
893 $oldumask = @umask( 0 );
894 clearstatcache( true, $fileName );
895 $fileExisted = file_exists( $fileName );
896 if ( $fileExisted and
897 filesize( $fileName ) > eZDebug::maxLogSize() )
898 {
899 if ( eZDebug::rotateLog( $fileName ) )
900 $fileExisted = false;
901 }
902 $logFile = @fopen( $fileName, "a" );
903 if ( $logFile )
904 {
905 $time = date( "M d Y H:i:s", strtotime( "now" ) );
906 $ip = eZSys::clientIP();
907 if ( !$ip )
908 $ip = eZSys::serverVariable( 'HOSTNAME', true );
909 $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n";
910 @fwrite( $logFile, $notice );
911 @fclose( $logFile );
912 if ( !$fileExisted )
913 {
914 $ini = eZINI::instance();
915 $permissions = octdec( $ini->variable( 'FileSettings', 'LogFilePermissions' ) );
916 @chmod( $fileName, $permissions );
917 }
918 @umask( $oldumask );
919 }
920 else
921 {
922 @umask( $oldumask );
923 $logEnabled = $this->isLogFileEnabled( $verbosityLevel );
924 $this->setLogFileEnabled( false, $verbosityLevel );
925 if ( $verbosityLevel != self::LEVEL_ERROR or
926 $logEnabled )
927 {
928 eZDebug::setHandleType( $oldHandleType );
929 $this->writeError( "Cannot open log file '$fileName' for writing\n" .
930 "The web server must be allowed to modify the file.\n" .
931 "File logging for '$fileName' is disabled." , 'eZDebug::writeFile' );
932 }
933 }
934 eZDebug::setHandleType( $oldHandleType );
935 }
936
942 static function setLogFileEnabled( $enabled, $types = false )
943 {
944 $instance = eZDebug::instance();
945 if ( $types === false )
946 {
947 $types = $instance->messageTypes();
948 }
949 if ( !is_array( $types ) )
950 {
951 $types = array( $types );
952 }
953 foreach ( $types as $type )
954 {
955 $instance->LogFileEnabled[$type] = $enabled;
956 }
957 }
958
963 function isLogFileEnabled( $type )
964 {
965 if ( !$this->isGlobalLogFileEnabled() )
966 return false;
967 return $this->LogFileEnabled[$type];
968 }
969
974 function isGlobalLogFileEnabled()
975 {
976 return $this->GlobalLogFileEnabled;
977 }
978
983 function setIsLogFileEnabled( $type, $enabled )
984 {
985 $this->LogFileEnabled[$type] = $enabled;
986 }
987
992 function setIsGlobalLogFileEnabled( $enabled )
993 {
994 $this->GlobalLogFileEnabled = $enabled;
995 }
996
1000 function setLogOnly( $enabled )
1001 {
1002 $GLOBALS['eZDebugLogOnly'] = $enabled;
1003 }
1004
1008 function messageTypes()
1009 {
1010 return $this->MessageTypes;
1011 }
1012
1017 function logFiles()
1018 {
1019 return $this->LogFiles;
1020 }
1021
1027 static function isDebugEnabled()
1028 {
1029 if ( isset( $GLOBALS['eZDebugEnabled'] ) )
1030 {
1031 return $GLOBALS['eZDebugEnabled'];
1032 }
1033
1034 return false;
1035 }
1036
1042 static function isLogOnlyEnabled()
1043 {
1044 if ( isset( $GLOBALS['eZDebugLogOnly'] ) )
1045 {
1046 return $GLOBALS['eZDebugLogOnly'];
1047 }
1048
1049 return false;
1050 }
1051
1057 static function isIPInNet( $ipaddress, $network, $mask = 24 )
1058 {
1059 $lnet = ip2long( $network );
1060 $lip = ip2long( $ipaddress );
1061 $binnet = str_pad( decbin( $lnet ), 32, '0', STR_PAD_LEFT );
1062 $firstpart = substr( $binnet, 0, $mask );
1063 $binip = str_pad( decbin( $lip ), 32, '0', STR_PAD_LEFT );
1064 $firstip = substr( $binip, 0, $mask );
1065 return( strcmp( $firstpart, $firstip ) == 0 );
1066 }
1067
1075 private static function isIPInNetIPv6( $ipAddress, $ipAddressRange )
1076 {
1077 // Split the ip addres range into network part and netmask number
1078 list( $ipAddressRangeNetworkPrefix, $networkMaskBits ) = explode( '/', $ipAddressRange );
1079
1080 // Convert ip addresses to their binary representations, truncate to the specified network mask length
1081 $binaryIpAddressRangeNetworkPrefix = substr( self::packedToBin( inet_pton( $ipAddressRangeNetworkPrefix ) ), 0, $networkMaskBits );
1082 $binaryIpAddressNetworkPrefix = substr( self::packedToBin( inet_pton( $ipAddress ) ), 0, $networkMaskBits );
1083
1084 return $binaryIpAddressRangeNetworkPrefix === $binaryIpAddressNetworkPrefix;
1085 }
1086
1093 private static function packedToBin( $packedIPAddress )
1094 {
1095 $binaryIPAddress = '';
1096
1097 // In PHP v5.5 (and up) the unpack function's returned value formats behavior differs
1098 if ( version_compare( PHP_VERSION, '5.5.0-dev', '>=' ) )
1099 {
1100 // Turns the space padded string into an array of the unpacked in_addr representation
1101 // In PHP v5.5 format 'a' retains trailing null bytes
1102 $unpackedIPAddress = unpack( 'a16', $packedIPAddress );
1103 }
1104 else
1105 {
1106 // Turns the space padded string into an array of the unpacked in_addr representation
1107 // In PHP v5.4 <= format 'A' retains trailing null bytes
1108 $unpackedIPAddress = unpack( 'A16', $packedIPAddress );
1109 }
1110 $unpackedIPAddressArray = str_split( $unpackedIPAddress[1] );
1111
1112 // Get each characters ascii number, then turn that number into a binary
1113 // and pad it with 0's to the left if it isn't 8 digits long
1114 foreach( $unpackedIPAddressArray as $character )
1115 {
1116 $binaryIPAddress .= str_pad( decbin( ord( $character ) ), 8, '0', STR_PAD_LEFT );
1117 }
1118
1119 return $binaryIPAddress;
1120 }
1121
1132 static function updateSettings( $settings )
1133 {
1134 // Make sure errors are handled by PHP when we read, including our own debug output.
1135 $oldHandleType = eZDebug::setHandleType( self::HANDLE_TO_PHP );
1136
1137 if ( isset( $settings['debug-log-files-enabled'] ) )
1138 {
1139 $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled'];
1140 if ( isset( $GLOBALS["eZDebugGlobalInstance"] ) )
1141 $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled'];
1142 }
1143
1144 if ( isset( $settings['debug-styles'] ) )
1145 {
1146 $GLOBALS['eZDebugStyles'] = $settings['debug-styles'];
1147 }
1148
1149 if ( isset( $settings['always-log'] ) and
1150 is_array( $settings['always-log'] ) )
1151 {
1152 $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log'];
1153 }
1154
1155 if ( isset( $settings['log-only'] ) )
1156 {
1157 $GLOBALS['eZDebugLogOnly'] = ( $settings['log-only'] == 'enabled' );
1158 }
1159
1160 $GLOBALS['eZDebugAllowedByIP'] = ( isset( $settings['debug-by-ip'] ) && $settings['debug-by-ip'] ) ? self::isAllowedByCurrentIP( $settings['debug-ip-list'] ) : true;
1161
1162 // updateSettings is meant to be called before the user session is started
1163 // so we do not take debug-by-user into account yet, but store the debug-user-list in $GLOBALS
1164 // so it can be used in the final check, done by checkDebugByUser()
1165 if ( isset( $settings['debug-by-user'] ) && $settings['debug-by-user'] )
1166 {
1167 $GLOBALS['eZDebugUserIDList'] = $settings['debug-user-list'] ? $settings['debug-user-list'] : array();
1168 }
1169
1170 $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByIP'];
1171 $GLOBALS['eZDebugEnabled'] = $settings['debug-enabled'] && $GLOBALS['eZDebugAllowedByIP'];
1172
1173 eZDebug::setHandleType( $oldHandleType );
1174 }
1175
1184 static function checkDebugByUser()
1185 {
1186 if ( !isset( $GLOBALS['eZDebugUserIDList'] ) ||
1187 !is_array( $GLOBALS['eZDebugUserIDList'] ) )
1188 {
1189 return false;
1190 }
1191 else
1192 {
1193 $currentUserID = eZUser::currentUserID();
1194
1195 if ( !$currentUserID )
1196 {
1197 return false;
1198 }
1199 else
1200 {
1201 $GLOBALS['eZDebugAllowedByUser'] = in_array( $currentUserID, $GLOBALS['eZDebugUserIDList'] );
1202
1203 if ( $GLOBALS['eZDebugAllowed'] )
1204 {
1205 $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByUser'];
1206 }
1207
1208 if ( $GLOBALS['eZDebugEnabled'] )
1209 {
1210 $GLOBALS['eZDebugEnabled'] = $GLOBALS['eZDebugAllowedByUser'];
1211 }
1212
1213 unset( $GLOBALS['eZDebugUserIDList'] );
1214
1215 return true;
1216 }
1217 }
1218 }
1219
1224 static function printReport( $newWindow = false, $as_html = true, $returnReport = false,
1225 $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false )
1226 {
1227 if ( !self::isDebugEnabled() )
1228 return null;
1229
1230 $debug = self::instance();
1231 $report = $debug->printReportInternal( $as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles );
1232
1233 if ( $newWindow == true )
1234 {
1235 $debugFilePath = eZDir::path( array( eZSys::varDirectory(), 'cache', 'debug.html' ) );
1236 $debugFileURL = $debugFilePath;
1237 eZURI::transformURI( $debugFileURL, true );
1238 print( "
1239 <script type='text/javascript'>
1240 <!--
1241
1242 (function()
1243 {
1244 var debugWindow;
1245
1246 if (navigator.appName == \"Microsoft Internet Explorer\")
1247 {
1248 //Microsoft Internet Explorer
1249 debugWindow = window.open( '$debugFileURL', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1250 debugWindow.document.close();
1251 debugWindow.location.reload();
1252 }
1253 else if (navigator.appName == \"Opera\")
1254 {
1255 //Opera
1256 debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1257 debugWindow.location.href=\"$debugFileURL\";
1258 debugWindow.navigate(\"$debugFileURL\");
1259 }
1260 else
1261 {
1262 //Mozilla, Firefox, etc.
1263 debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1264 debugWindow.document.location.href=\"$debugFileURL\";
1265 };
1266 })();
1267
1268 // -->
1269 </script>
1270 " );
1271 $header = "<!DOCTYPE html><html><head><title>eZ debug</title></head><body>";
1272 $footer = "</body></html>";
1273 $fullPage = ezpEvent::getInstance()->filter( 'response/output', $header . $report . $footer );
1274 file_put_contents( $debugFilePath, $fullPage );
1275 }
1276 else
1277 {
1278 if ( $returnReport )
1279 return $report;
1280 }
1281 return null;
1282 }
1283
1289 static function setScriptStart( $time = false )
1290 {
1291 if ( $time == false )
1292 $time = microtime( true );
1293 $debug = eZDebug::instance();
1294 $debug->ScriptStart = $time;
1295 }
1296
1302 static function setScriptStop( $time = false )
1303 {
1304 if ( $time === false )
1305 $time = microtime( true );
1306 $debug = eZDebug::instance();
1307 $debug->ScriptStop = $time;
1308 }
1309
1314 static function createAccumulatorGroup( $key, $name = false )
1315 {
1316 if ( !eZDebug::isDebugEnabled() )
1317 return;
1318 if ( $name == '' or
1319 $name === false )
1320 $name = $key;
1321 $debug = eZDebug::instance();
1322 if ( !array_key_exists( $key, $debug->TimeAccumulatorList ) )
1323 $debug->TimeAccumulatorList[$key] = array( 'name' => $name, 'time' => 0, 'count' => 0, 'is_group' => true, 'in_group' => false );
1324 if ( !array_key_exists( $key, $debug->TimeAccumulatorGroupList ) )
1325 $debug->TimeAccumulatorGroupList[$key] = array();
1326 }
1327
1333 static function createAccumulator( $key, $inGroup = false, $name = false )
1334 {
1335 if ( !eZDebug::isDebugEnabled() )
1336 return;
1337 if ( $name == '' or
1338 $name === false )
1339 $name = $key;
1340 $debug = eZDebug::instance();
1341 $isGroup = false;
1342 if ( array_key_exists( $key, $debug->TimeAccumulatorList ) and
1343 array_key_exists( $key, $debug->TimeAccumulatorGroupList ) )
1344 $isGroup = true;
1345 $debug->TimeAccumulatorList[$key] = array( 'name' => $name, 'time' => 0, 'count' => 0, 'is_group' => $isGroup, 'in_group' => $inGroup );
1346 if ( $inGroup !== false )
1347 {
1348 $groupKeys = array();
1349 if ( array_key_exists( $inGroup, $debug->TimeAccumulatorGroupList ) )
1350 $groupKeys = $debug->TimeAccumulatorGroupList[$inGroup];
1351 $debug->TimeAccumulatorGroupList[$inGroup] = array_unique( array_merge( $groupKeys, array( $key ) ) );
1352 if ( array_key_exists( $inGroup, $debug->TimeAccumulatorList ) )
1353 $debug->TimeAccumulatorList[$inGroup]['is_group'] = true;
1354 }
1355 }
1356
1361 static function accumulatorStart( $key, $inGroup = false, $name = false, $recursive = false )
1362 {
1363 if ( !eZDebug::isDebugEnabled() )
1364 return;
1365 $startTime = microtime( true );
1366 $debug = eZDebug::instance();
1367 $key = $key === false ? 'Default Debug-Accumulator' : $key;
1368 if ( ! array_key_exists( $key, $debug->TimeAccumulatorList ) )
1369 {
1370 $debug->createAccumulator( $key, $inGroup, $name );
1371 }
1372
1373 if ( $recursive )
1374 {
1375 if ( isset( $debug->TimeAccumulatorList[$key]['recursive_counter'] ) )
1376 {
1377 $debug->TimeAccumulatorList[$key]['recursive_counter']++;
1378 return;
1379 }
1380 $debug->TimeAccumulatorList[$key]['recursive_counter'] = 0;
1381 }
1382
1383 $debug->TimeAccumulatorList[$key]['temp_time'] = $startTime;
1384 }
1385
1389 static function accumulatorStop( $key, $recursive = false )
1390 {
1391 if ( !eZDebug::isDebugEnabled() )
1392 return;
1393 $stopTime = microtime( true );
1394 $debug = eZDebug::instance();
1395 $key = $key === false ? 'Default Debug-Accumulator' : $key;
1396 if ( ! array_key_exists( $key, $debug->TimeAccumulatorList ) )
1397 {
1398 eZDebug::writeWarning( "Accumulator '$key' does not exist, run eZDebug::accumulatorStart first", __METHOD__ );
1399 return;
1400 }
1401 $accumulator = $debug->TimeAccumulatorList[$key];
1402 if ( $recursive )
1403 {
1404 if ( isset( $accumulator['recursive_counter'] ) )
1405 {
1406 if ( $accumulator['recursive_counter'] > 0 )
1407 {
1408 $accumulator['recursive_counter']--;
1409 return;
1410 }
1411 }
1412 }
1413 $diffTime = $stopTime - $accumulator['temp_time'];
1414 $accumulator['time'] = $accumulator['time'] + $diffTime;
1415 ++$accumulator['count'];
1416 $debug->TimeAccumulatorList[$key] = $accumulator;
1417 }
1418
1419
1424 function printReportInternal( $as_html = true, $returnReport = true, $allowedDebugLevels = false,
1425 $useAccumulators = true, $useTiming = true, $useIncludedFiles = false )
1426 {
1427 $reportStart = microtime( true );
1428
1429 if ( isset( $GLOBALS['eZDebugStyles'] ) )
1430 {
1431 $styles = $GLOBALS['eZDebugStyles'];
1432 }
1433 else
1434 {
1435 $styles = array( 'strict' => false,
1436 'strict-end' => false,
1437 'warning' => false,
1438 'warning-end' => false,
1439 'error' => false,
1440 'error-end' => false,
1441 'debug' => false,
1442 'debug-end' => false,
1443 'notice' => false,
1444 'notice-end' => false,
1445 'timing' => false,
1446 'timing-end' => false,
1447 'mark' => false,
1448 'mark-end' => false,
1449 'emphasize' => false,
1450 'emphasize-end' => false,
1451 'bold' => false,
1452 'bold-end' => false );
1453 }
1454 if ( !$allowedDebugLevels )
1455 {
1456 $allowedDebugLevels = array( self::LEVEL_NOTICE, self::LEVEL_WARNING, self::LEVEL_ERROR,
1457 self::LEVEL_DEBUG, self::LEVEL_TIMING_POINT, self::LEVEL_STRICT );
1458 }
1459
1460 $startTime = $this->ScriptStart;
1461 if ( $this->ScriptStop == null )
1462 {
1463 $endTime = $reportStart;
1464 }
1465 else
1466 {
1467 $endTime = $this->ScriptStop;
1468 }
1469 $totalElapsed = $endTime - $startTime;
1470 if ( function_exists( 'memory_get_peak_usage' ) )
1471 {
1472 $peakMemory = memory_get_peak_usage( true );
1473 }
1474
1475 if ( $returnReport )
1476 {
1477 ob_start();
1478 }
1479
1480 if ( $as_html )
1481 {
1482 $ini = eZINI::instance();
1483
1484 if( $ini->variable( 'DebugSettings', 'DebugByUser' ) == 'enabled' )
1485 {
1486 $byUser = " (By User)";
1487 } else {
1488 $byUser = false;
1489 }
1490 if( $ini->variable( 'DebugSettings', 'DebugByIP' ) == 'enabled' )
1491 {
1492 $byIP = " (By IP Address)";
1493 } else {
1494 $byIP = false;
1495 }
1496
1497 echo "<div id=\"debug\"><h2><a href=\"#debug-end\">eZ debug " . $byUser . $byIP . "</a></h2>";
1498 echo "<div id=\"debug-details\">";
1499
1500 if ( !$this->UseCSS )
1501 {
1502 echo "<style type='text/css'>
1503 <!--
1504 ";
1505 readfile( 'design/standard/stylesheets/debug.css' );
1506 echo "
1507 -->
1508 </style>";
1509 }
1510 echo "<table id='main-debug-table' title='Table for actual debug output, shows notices, warnings and errors'>";
1511 }
1512
1513 $this->printTopReportsList();
1514
1515 $hasLevel = array( self::LEVEL_NOTICE => false,
1516 self::LEVEL_WARNING => false,
1517 self::LEVEL_ERROR => false,
1518 self::LEVEL_TIMING_POINT => false,
1519 self::LEVEL_DEBUG => false,
1520 self::LEVEL_STRICT => false );
1521
1522 foreach ( $this->DebugStrings as $debug )
1523 {
1524 if ( !in_array( $debug['Level'], $allowedDebugLevels ) )
1525 continue;
1526 $time = date( "M d Y H:i:s", $debug['Time'] );
1527
1528 $outputData = $this->OutputFormat[$debug["Level"]];
1529 if ( is_array( $outputData ) )
1530 {
1531 $identifierText = '';
1532 if ( !$hasLevel[$debug['Level']] )
1533 {
1534 $hasLevel[$debug['Level']] = true;
1535 $identifierText = ' id="' . $outputData['xhtml-identifier'] . '"';
1536 }
1537 $style = $outputData["style"];
1538 $name = $outputData["name"];
1539 $label = $debug["Label"];
1540 $bgclass = $debug["BackgroundClass"];
1541 $pre = ($bgclass != '' ? " class='$bgclass'" : '');
1542 if ( $as_html )
1543 {
1544 $label = htmlspecialchars( $label );
1545
1546 $contents = '';
1547 if ( extension_loaded( 'xdebug' ) && ( strncmp( self::XDEBUG_SIGNATURE, $debug['String'], strlen( self::XDEBUG_SIGNATURE ) ) === 0 ) )
1548 $contents = substr( $debug['String'], strlen( self::XDEBUG_SIGNATURE ) );
1549 else
1550 $contents = htmlspecialchars( $debug['String'] );
1551
1552 echo "<tr class='$style'><td class='debugheader'$identifierText><b><span>$name:</span> $label</b></td>
1553 <td class='debugheader' style=\"text-align:right;\">$time</td></tr>
1554 <tr><td colspan='2'><pre$pre>" . $contents . "</pre></td></tr>";
1555 }
1556 else
1557 {
1558 echo $styles[$outputData['style']] . "$name:" . $styles[$outputData['style'].'-end'] . " ";
1559 echo $styles['bold'] . "($label)" . $styles['bold-end'] . "\n" . $debug["String"] . "\n\n";
1560 }
1561 }
1562 }
1563 if ( $as_html )
1564 {
1565 echo "</table>";
1566
1567 // Resources we always print out, just like log messages
1568
1569 echo "<div id='main-resources'><h3>Main resources:</h3>";
1570 echo "<table id='debug_resources' title='Most important resource consumption indicators'>";
1571 }
1572 if ( $as_html )
1573 {
1574 echo "<tr class='data'><td>Total runtime</td><td>" .
1575 number_format( $totalElapsed, $this->TimingAccuracy ) . " sec</td></tr>";
1576 }
1577 else
1578 {
1579 echo "Total runtime: " .
1580 number_format( $totalElapsed, $this->TimingAccuracy ) . " sec\n";
1581 }
1582 if ( isset( $peakMemory ) )
1583 {
1584 if ( $as_html )
1585 {
1586 echo "<tr class='data'><td>Peak memory usage</td><td>" .
1587 number_format( $peakMemory / 1024, $this->TimingAccuracy ) . " KB</td></tr>";
1588 }
1589 else
1590 {
1591 echo "Peak memory usage: " .
1592 number_format( $peakMemory / 1024, $this->TimingAccuracy ) . " KB\n";
1593 }
1594 }
1595 $dbini = eZINI::instance();
1596 // note: we cannot use $db->databasename() because we get the same for mysql and mysqli
1597 $type = preg_replace( '/^ez/', '', $dbini->variable( 'DatabaseSettings', 'DatabaseImplementation' ) );
1598 $type .= '_query';
1599 if ( isset( $this->TimeAccumulatorList[$type] ) )
1600 {
1601 if ( $as_html )
1602 {
1603 echo "<tr class='data'><td>Database Queries</td><td>" .
1604 $this->TimeAccumulatorList[$type]['count'] . "</td></tr>";
1605 }
1606 else
1607 {
1608 echo "Database Queries: " .
1609 $this->TimeAccumulatorList[$type]['count'] . "\n";
1610 }
1611 }
1612 if ( $as_html )
1613 {
1614 echo "</table></div>";
1615 }
1616
1617 if ( $useTiming )
1618 {
1619 if ( $as_html )
1620 {
1621 echo "<div id='timing-points'><h3>Timing points:</h3>";
1622 echo "<table id='timingpoints' title='Timing point stats'><tr><th>Checkpoint</th><th>Start (sec)</th><th>Duration (sec)</th><th>Memory at start (KB)</th><th>Memory used (KB)</th></tr>";
1623 }
1624
1625 for ( $i = 0, $l = count( $this->TimePoints ); $i < $l; ++$i )
1626 {
1627 $point = $this->TimePoints[$i];
1628 $nextPoint = false;
1629 if ( isset( $this->TimePoints[$i + 1] ) )
1630 $nextPoint = $this->TimePoints[$i + 1];
1631 $time = $point["Time"];
1632 $nextTime = false;
1633 $elapsed = $time - $startTime;
1634
1635 $relMemory = 0;
1636 $memory = $point["MemoryUsage"];
1637 // Calculate relative time and memory usage
1638 if ( $nextPoint !== false )
1639 {
1640 $nextTime = $nextPoint["Time"];
1641 $relElapsed = $nextTime - $time;
1642 $relElapsed = number_format( $relElapsed, $this->TimingAccuracy );
1643
1644 $nextMemory = $nextPoint["MemoryUsage"];
1645 $relMemory = $nextMemory - $memory;
1646 $relMemory = number_format( $relMemory / 1024, $this->TimingAccuracy );
1647 }
1648 else
1649 {
1650 $relElapsed = $as_html ? '&nbsp;' : '';
1651 $relMemory = $as_html ? '&nbsp;' : '';
1652 }
1653
1654 // Convert memory usage to human readable
1655 $memory = number_format( $memory / 1024, $this->TimingAccuracy );
1656 $elapsed = number_format( $elapsed, $this->TimingAccuracy );
1657
1658 if ( $as_html )
1659 {
1660 echo "<tr class='data'><td>" . $point["Description"] . "</td>
1661 <td style=\"text-align:right;\">$elapsed</td><td style=\"text-align:right;\">$relElapsed</td>
1662 <td style=\"text-align:right;\">$memory</td><td style=\"text-align:right;\">$relMemory</td></tr>";
1663 }
1664 else
1665 {
1666 echo $point["Description"] . ' ' . $elapsed . $relElapsed . "\n";
1667 }
1668 }
1669
1670 if ( $as_html )
1671 {
1672 echo "</table></div>";
1673 }
1674 }
1675
1676 if ( $useAccumulators )
1677 {
1678 $timeList = $this->TimeAccumulatorList;
1679 $groups = $this->TimeAccumulatorGroupList;
1680 $groupList = array();
1681 foreach ( $groups as $groupKey => $keyList )
1682 {
1683 if ( count( $keyList ) == 0 and
1684 !array_key_exists( $groupKey, $timeList ) )
1685 continue;
1686 $groupList[$groupKey] = array( 'name' => $groupKey );
1687 if ( array_key_exists( $groupKey, $timeList ) )
1688 {
1689 if ( $timeList[$groupKey]['time'] != 0 )
1690 $groupList[$groupKey]['time_data'] = $timeList[$groupKey];
1691 $groupList[$groupKey]['name'] = $timeList[$groupKey]['name'];
1692 unset( $timeList[$groupKey] );
1693 }
1694 $groupChildren = array();
1695 foreach ( $keyList as $timeKey )
1696 {
1697 if ( array_key_exists( $timeKey, $timeList ) )
1698 {
1699 $groupChildren[] = $timeList[$timeKey];
1700 unset( $timeList[$timeKey] );
1701 }
1702 }
1703 $groupList[$groupKey]['children'] = $groupChildren;
1704 }
1705 if ( count( $timeList ) > 0 )
1706 {
1707 $groupList['general'] = array( 'name' => 'General',
1708 'children' => $timeList );
1709 }
1710
1711 if ( $as_html )
1712 {
1713 echo "<div id='time-accumulators'><h3>Time accumulators:</h3>";
1714 echo "<table id='timeaccumulators' title='Detailed list of time accumulators'><tr><th>&nbsp;Accumulator</th><th>&nbsp;Duration (sec)</th><th>&nbsp;Duration (%)</th><th>&nbsp;Count</th><th>&nbsp;Average (sec)</th></tr>";
1715 }
1716
1717 foreach ( $groupList as $group )
1718 {
1719 $groupName = $group['name'];
1720 $groupChildren = $group['children'];
1721 if ( count( $groupChildren ) == 0 and
1722 !array_key_exists( 'time_data', $group ) )
1723 continue;
1724 if ( $as_html )
1725 echo "<tr class='group'><td><b>$groupName</b></td>";
1726 else
1727 echo "Group " . $styles['mark'] . "$groupName:" . $styles['mark-end'] . " ";
1728 if ( array_key_exists( 'time_data', $group ) )
1729 {
1730 $groupData = $group['time_data'];
1731 $groupElapsed = number_format( ( $groupData['time'] ), $this->TimingAccuracy );
1732 $groupPercent = number_format( ( $groupData['time'] * 100.0 ) / $totalElapsed, 1 );
1733 $groupCount = $groupData['count'];
1734 $groupAverage = number_format( ( $groupData['time'] / $groupData['count'] ), $this->TimingAccuracy );
1735 if ( $as_html )
1736 {
1737 echo ( "<td style=\"text-align:right;\"><i>$groupElapsed</i></td>".
1738 "<td style=\"text-align:right;\"><i>$groupPercent</i></td>".
1739 "<td style=\"text-align:right;\"><i>$groupCount</i></td>".
1740 "<td style=\"text-align:right;\"><i>$groupAverage</i></td>" );
1741 }
1742 else
1743 {
1744 echo $styles['emphasize'] . "$groupElapsed" . $styles['emphasize-end'] . " sec ($groupPercent%), $groupAverage avg sec ($groupCount)";
1745 }
1746 }
1747 else if ( $as_html )
1748 {
1749 echo ( "<td></td>".
1750 "<td></td>".
1751 "<td></td>".
1752 "<td></td>" );
1753 }
1754 if ( $as_html )
1755 echo "</tr>";
1756 else
1757 echo "\n";
1758
1759 foreach ( $groupChildren as $child )
1760 {
1761 $childName = $child['name'];
1762 $childElapsed = number_format( ( $child['time'] ), $this->TimingAccuracy );
1763 $childPercent = number_format( ( $child['time'] * 100.0 ) / $totalElapsed, $this->PercentAccuracy );
1764 $childCount = $child['count'];
1765 $childAverage = 0.0;
1766 if ( $childCount > 0 )
1767 {
1768 $childAverage = $child['time'] / $childCount;
1769 }
1770 $childAverage = number_format( $childAverage, $this->PercentAccuracy );
1771
1772 if ( $as_html )
1773 {
1774 echo ( "<tr class='data'>" .
1775 "<td>$childName</td>" .
1776 "<td style=\"text-align:right;\">$childElapsed</td>" .
1777 "<td style=\"text-align:right;\">$childPercent</td>" .
1778 "<td style=\"text-align:right;\">$childCount</td>" .
1779 "<td style=\"text-align:right;\">$childAverage</td>" .
1780 "</tr>" );
1781 }
1782 else
1783 {
1784 echo "$childName: " . $styles['emphasize'] . $childElapsed . $styles['emphasize-end'] . " sec ($childPercent%), $childAverage avg sec ($childCount)\n";
1785 }
1786 }
1787 }
1788
1789 if ( $as_html )
1790 {
1791 echo "<tr><td colspan=\"5\">Note: percentages do not add up to 100% because some accumulators overlap</td></tr>";
1792 echo "</table></div>";
1793 }
1794 }
1795
1796 if ( $useIncludedFiles )
1797 {
1798 if ( $as_html )
1799 {
1800 echo "<div id='included-files'><h3>Included files:</h3><table id=\"debug_includes\" title='List of included php files used in the processing of this page'><tr><th>File</th></tr>";
1801 }
1802 else
1803 {
1804 echo $styles['emphasize'] . "Includes" . $styles['emphasize-end'] . "\n";
1805 }
1806 $phpFiles = get_included_files();
1807 $currentPathReg = preg_quote( realpath( "." ) );
1808 foreach ( $phpFiles as $phpFile )
1809 {
1810 if ( preg_match( "#^$currentPathReg/(.+)$#", $phpFile, $matches ) )
1811 $phpFile = $matches[1];
1812 if ( $as_html )
1813 {
1814 echo "<tr class='data'><td>$phpFile</td></tr>";
1815 }
1816 else
1817 {
1818 echo "$phpFile\n";
1819 }
1820 }
1821 if ( $as_html )
1822 {
1823 echo "<tr><td><b>&nbsp;Number of files included: " . count( $phpFiles ) . "</b></td></tr>";
1824 echo "</table></div>";
1825 }
1826 }
1827
1828 $this->printBottomReportsList( $as_html );
1829
1830 if ( $as_html )
1831 {
1832 $reportStop = microtime( true );
1833 $reportTime = number_format( $reportStop - $reportStart, 4 );
1834 echo "<p><b>Time used to render debug report: $reportTime secs</b></p>";
1835
1836 echo "</div>";
1837 echo "</div>";
1838 echo "<a id=\"debug-end\"></a>";
1839
1840 echo "<script>
1841 const header = document.querySelector('#debug h2 a');
1842 const content = document.querySelector('#debug-details');
1843 const anchor = document.querySelector('#debug-end');
1844 header.addEventListener('click', () => {
1845 header.classList.toggle('active');
1846 content.classList.toggle('active');
1847 if (content.classList.contains('active') && anchor) {
1848 anchor.scrollIntoView({ behavior: 'smooth', block: 'start' });
1849 }
1850 });
1851 </script>";
1852
1853 }
1854
1855 if ( $returnReport )
1856 {
1857 $returnText = ob_get_contents();
1858 ob_end_clean();
1859 return $returnText;
1860 }
1861 else
1862 {
1863 return NULL;
1864 }
1865 }
1866
1870 static function appendTopReport( $reportName, $reportContent )
1871 {
1872 $debug = eZDebug::instance();
1873 $debug->topReportsList[$reportName] = $reportContent;
1874 }
1875
1879 static function printTopReportsList()
1880 {
1881 $debug = eZDebug::instance();
1882 $reportNames = array_keys( $debug->topReportsList );
1883 foreach ( $reportNames as $reportName )
1884 {
1885 echo $debug->topReportsList[$reportName];
1886 }
1887 }
1888
1892 static function appendBottomReport( $reportName, $reportContent )
1893 {
1894 $debug = eZDebug::instance();
1895 $debug->bottomReportsList[$reportName] = $reportContent;
1896 }
1897
1904 static function printBottomReportsList( $as_html = true )
1905 {
1906 $debug = eZDebug::instance();
1907 $reportNames = array_keys( $debug->bottomReportsList );
1908 foreach ( $reportNames as $reportName )
1909 {
1910 if ( is_callable( $debug->bottomReportsList[$reportName] ) )
1911 {
1912 echo call_user_func_array( $debug->bottomReportsList[$reportName], array( $as_html ) );
1913 }
1914 else
1915 {
1916 echo $debug->bottomReportsList[$reportName];
1917 }
1918 }
1919 }
1920
1924 function isDebugAllowed()
1925 {
1926
1927 }
1928
1935 private static function isAllowedByCurrentIP( $allowedIpList )
1936 {
1937 $ipAddresIPV4Pattern = "/^(([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+))(\/([0-9]+)$|$)/";
1938 $ipAddressIPV6Pattern = "/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))(\/([0-9]+)$|$)$/";
1939
1940 $ipAddress = eZSys::clientIP();
1941 if ( $ipAddress )
1942 {
1943 foreach( $allowedIpList as $itemToMatch )
1944 {
1945 // Test for IPv6 Addresses first instead of IPv4 addresses as IPv6
1946 // addresses can contain dot separators within them
1947 if ( preg_match( "/:/", $ipAddress ) )
1948 {
1949 if ( preg_match( $ipAddressIPV6Pattern, $itemToMatch, $matches ) )
1950 {
1951 if ( $matches[69] )
1952 {
1953 if ( self::isIPInNetIPv6( $ipAddress, $itemToMatch ) )
1954 {
1955 return true;
1956 }
1957
1958 }
1959 else
1960 {
1961 if ( $matches[1] == $itemToMatch )
1962 {
1963 return true;
1964 }
1965 }
1966 }
1967 }
1968 elseif ( preg_match( "/\./", $ipAddress) )
1969 {
1970 if ( preg_match( $ipAddresIPV4Pattern, $itemToMatch, $matches ) )
1971 {
1972 if ( $matches[6] )
1973 {
1974 if ( self::isIPInNet( $ipAddress, $matches[1], $matches[7] ) )
1975 {
1976 return true;
1977 }
1978 }
1979 else
1980 {
1981 if ( $matches[1] == $ipAddress )
1982 {
1983 return true;
1984 }
1985 }
1986 }
1987 }
1988 }
1989
1990 return false;
1991 }
1992 else
1993 {
1994 return eZSys::isShellExecution() && in_array( 'commandline', $allowedIpList );
1995 }
1996 }
1997
2003 public static function exceptionErrorHandler( $errno, $errstr, $errfile, $errline )
2004 {
2005 throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
2006 }
2007
2010 public $DebugStrings = array();
2011
2013 public $TimePoints = array();
2014
2016 public $TmpTimePoints;
2017
2019 public $TimeAccumulatorList = array();
2020
2022 public $ShowTypes;
2023
2025 public $HandleType;
2026
2028 public $OutputFormat;
2029
2031 public $LogFiles;
2032
2034 public $TimingAccuracy = 4;
2035
2037 public $PercentAccuracy = 4;
2038
2040 public $UseCSS;
2041
2043 public $MessageOutput;
2044
2046 public $MessageTypes;
2047
2049 public $LogFileEnabled;
2050
2052 public $GlobalLogFileEnabled;
2053
2055 public $ScriptStart;
2056
2059 public $ScriptStop;
2060
2062 public $OverrideList;
2063
2065 public $bottomReportsList;
2066
2068 public $topReportsList;
2069
2070 private $recursionFlag = false;
2071
2072 public $MessageNames;
2073
2074 public $AlwaysLog;
2075
2076 public $OldHandler;
2077
2078 public $TimeAccumulatorGroupList;
2079
2080
2081 }
2082
2083 ?>
eZDebug
Advanced debug/log system.
Definition: ezdebug.php:57
eZDebug\isIPInNet
static isIPInNet( $ipaddress, $network, $mask=24)
Definition: ezdebug.php:1057
eZDebug\maxLogSize
static maxLogSize()
Definition: ezdebug.php:785
eZDebug\HANDLE_TO_PHP
const HANDLE_TO_PHP
Definition: ezdebug.php:76
eZDebug\writeStrict
static writeStrict( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:414
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZDebug\SHOW_ERROR
const SHOW_ERROR
Definition: ezdebug.php:68
eZDebug\$GlobalLogFileEnabled
$GlobalLogFileEnabled
Controls whether logfiles are used at all.
Definition: ezdebug.php:2052
eZDebug\isLogFileEnabled
isLogFileEnabled( $type)
Definition: ezdebug.php:963
eZDebug\$MessageNames
$MessageNames
Definition: ezdebug.php:2072
eZDebug\SHOW_WARNING
const SHOW_WARNING
Definition: ezdebug.php:67
eZDebug\createAccumulator
static createAccumulator( $key, $inGroup=false, $name=false)
Definition: ezdebug.php:1333
eZDebug\LEVEL_ERROR
const LEVEL_ERROR
Definition: ezdebug.php:61
eZDebug\XDEBUG_SIGNATURE
const XDEBUG_SIGNATURE
Definition: ezdebug.php:85
eZDebug\$recursionFlag
$recursionFlag
Definition: ezdebug.php:2070
eZDebug\alwaysLogMessage
static alwaysLogMessage( $level)
Definition: ezdebug.php:223
eZDebug\printReport
static printReport( $newWindow=false, $as_html=true, $returnReport=false, $allowedDebugLevels=false, $useAccumulators=true, $useTiming=true, $useIncludedFiles=false)
Definition: ezdebug.php:1224
eZDebug\packedToBin
static packedToBin( $packedIPAddress)
Definition: ezdebug.php:1093
eZDebug\$HandleType
$HandleType
Determines what to do with php errors, ignore, fetch or output.
Definition: ezdebug.php:2025
eZDebug\reset
reset()
Definition: ezdebug.php:174
eZDebug\$TimeAccumulatorGroupList
$TimeAccumulatorGroupList
Definition: ezdebug.php:2078
eZDebug\errorHandler
errorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:329
eZDebug\setScriptStop
static setScriptStop( $time=false)
Definition: ezdebug.php:1302
eZDebug\setUseExternalCSS
static setUseExternalCSS( $use)
Definition: ezdebug.php:654
eZDebug\$ShowTypes
$ShowTypes
Determines which debug messages should be shown.
Definition: ezdebug.php:2022
eZDebug\printTopReportsList
static printTopReportsList()
Definition: ezdebug.php:1879
eZDebug\isDebugEnabled
static isDebugEnabled()
Definition: ezdebug.php:1027
eZDebug\$TimeAccumulatorList
$TimeAccumulatorList
Array wich contains time accumulators.
Definition: ezdebug.php:2019
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZDebug\$TimePoints
$TimePoints
Array which contains the time points.
Definition: ezdebug.php:2013
eZDebug\HANDLE_EXCEPTION
const HANDLE_EXCEPTION
Definition: ezdebug.php:77
eZDebug\LEVEL_STRICT
const LEVEL_STRICT
Definition: ezdebug.php:64
eZDebug\$StoreLog
$StoreLog
Definition: ezdebug.php:58
eZDebug\$AlwaysLog
$AlwaysLog
Definition: ezdebug.php:2074
eZDebug\$bottomReportsList
$bottomReportsList
A list of debug reports that appears at the bottom of debug output.
Definition: ezdebug.php:2065
eZDebug\writeNotice
static writeNotice( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:459
eZDebug\OUTPUT_MESSAGE_STORE
const OUTPUT_MESSAGE_STORE
Definition: ezdebug.php:80
eZDebug\$ScriptStop
$ScriptStop
Definition: ezdebug.php:2059
eZDebug\$OutputFormat
$OutputFormat
An array of the outputformats for the different debug levels.
Definition: ezdebug.php:2028
eZDebug\$OverrideList
$OverrideList
A list of override directories.
Definition: ezdebug.php:2062
eZDebug\instance
static instance()
Definition: ezdebug.php:201
eZDebug\messageTypes
messageTypes()
Definition: ezdebug.php:1008
eZDebug\SHOW_TIMING_POINT
const SHOW_TIMING_POINT
Definition: ezdebug.php:69
eZDebug\setLogFileEnabled
static setLogFileEnabled( $enabled, $types=false)
Definition: ezdebug.php:942
eZDebug\HANDLE_FROM_PHP
const HANDLE_FROM_PHP
Definition: ezdebug.php:75
eZDebug\maxLogrotateFiles
static maxLogrotateFiles()
Definition: ezdebug.php:812
eZDebug\createAccumulatorGroup
static createAccumulatorGroup( $key, $name=false)
Definition: ezdebug.php:1314
eZDebug\LEVEL_WARNING
const LEVEL_WARNING
Definition: ezdebug.php:60
eZDebug\MAX_LOGROTATE_FILES
const MAX_LOGROTATE_FILES
Definition: ezdebug.php:83
eZDebug\setHandleType
static setHandleType( $type)
Definition: ezdebug.php:247
eZDebug\$UseCSS
$UseCSS
Whether to use external CSS or output own CSS. True if external is to be used.
Definition: ezdebug.php:2040
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZDebug\LEVEL_TIMING_POINT
const LEVEL_TIMING_POINT
Definition: ezdebug.php:62
eZDebug\exceptionErrorHandler
static exceptionErrorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:2003
eZDebug\$MessageOutput
$MessageOutput
Determines how messages are output (screen/log)
Definition: ezdebug.php:2043
eZDebug\$PercentAccuracy
$PercentAccuracy
How many places behind . should be displayed when showing percentages.
Definition: ezdebug.php:2037
eZDebug\__construct
__construct()
Definition: ezdebug.php:90
eZDebug\updateSettings
static updateSettings( $settings)
Definition: ezdebug.php:1132
eZDebug\setMessageOutput
setMessageOutput( $output)
Definition: ezdebug.php:663
eZDebug\appendTopReport
static appendTopReport( $reportName, $reportContent)
Definition: ezdebug.php:1870
eZDebug\$TmpTimePoints
$TmpTimePoints
Array which contains the temporary time points.
Definition: ezdebug.php:2016
eZDebug\isAllowedByCurrentIP
static isAllowedByCurrentIP( $allowedIpList)
Definition: ezdebug.php:1935
eZDebug\isIPInNetIPv6
static isIPInNetIPv6( $ipAddress, $ipAddressRange)
Definition: ezdebug.php:1075
eZDebug\setLogrotateFiles
static setLogrotateFiles( $files)
Definition: ezdebug.php:830
eZDebug\printBottomReportsList
static printBottomReportsList( $as_html=true)
Definition: ezdebug.php:1904
eZDebug\$LogFiles
$LogFiles
An array of logfiles used by the debug class with each key being the debug level.
Definition: ezdebug.php:2031
eZDebug\setIsLogFileEnabled
setIsLogFileEnabled( $type, $enabled)
Definition: ezdebug.php:983
eZDebug\messageName
messageName( $messageType)
Definition: ezdebug.php:191
eZDebug\appendBottomReport
static appendBottomReport( $reportName, $reportContent)
Definition: ezdebug.php:1892
eZDebug\setIsGlobalLogFileEnabled
setIsGlobalLogFileEnabled( $enabled)
Definition: ezdebug.php:992
eZDebug\showTypes
static showTypes( $types=false)
Definition: ezdebug.php:296
eZDebug\SHOW_NOTICE
const SHOW_NOTICE
Definition: ezdebug.php:66
eZDebug\SHOW_STRICT
const SHOW_STRICT
Definition: ezdebug.php:71
eZDebug\addTimingPoint
static addTimingPoint( $description="")
Definition: ezdebug.php:676
eZDebug\setScriptStart
static setScriptStart( $time=false)
Definition: ezdebug.php:1289
eZDebug\setStoreLog
setStoreLog( $store)
Definition: ezdebug.php:668
eZDebug\showMessage
static showMessage( $type)
Definition: ezdebug.php:214
eZDebug\LEVEL_NOTICE
const LEVEL_NOTICE
Definition: ezdebug.php:59
eZDebug\$topReportsList
$topReportsList
A list of debug reports that appears at the top of debug output.
Definition: ezdebug.php:2068
eZDebug\isDebugAllowed
isDebugAllowed()
Definition: ezdebug.php:1924
eZDebug\MAX_LOGFILE_SIZE
const MAX_LOGFILE_SIZE
Definition: ezdebug.php:82
eZDebug\$ScriptStart
$ScriptStart
The time when the script was started.
Definition: ezdebug.php:2055
eZDebug\isLogOnlyEnabled
static isLogOnlyEnabled()
Definition: ezdebug.php:1042
eZDebug\SHOW_DEBUG
const SHOW_DEBUG
Definition: ezdebug.php:70
eZDebug\OUTPUT_MESSAGE_SCREEN
const OUTPUT_MESSAGE_SCREEN
Definition: ezdebug.php:79
eZDebug\recursionProtectErrorHandler
recursionProtectErrorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:309
eZDebug\accumulatorStart
static accumulatorStart( $key, $inGroup=false, $name=false, $recursive=false)
Definition: ezdebug.php:1361
eZDebug\write
write( $string, $verbosityLevel=self::LEVEL_NOTICE, $label="", $backgroundClass="", $alwaysLog=false)
Definition: ezdebug.php:715
eZDebug\checkDebugByUser
static checkDebugByUser()
Definition: ezdebug.php:1184
eZDebug\writeFile
writeFile(&$logFileData, &$string, $verbosityLevel, $alwaysLog=false)
Definition: ezdebug.php:878
eZDebug\logFiles
logFiles()
Definition: ezdebug.php:1017
eZDebug\setLogOnly
setLogOnly( $enabled)
Definition: ezdebug.php:1000
eZDebug\$MessageTypes
$MessageTypes
A list of message types.
Definition: ezdebug.php:2046
eZDebug\accumulatorStop
static accumulatorStop( $key, $recursive=false)
Definition: ezdebug.php:1389
eZDebug\HANDLE_NONE
const HANDLE_NONE
Definition: ezdebug.php:74
eZDebug\LEVEL_DEBUG
const LEVEL_DEBUG
Definition: ezdebug.php:63
eZDebug\$TimingAccuracy
$TimingAccuracy
How many places behind . should be displayed when showing times.
Definition: ezdebug.php:2034
eZDebug\rotateLog
static rotateLog( $fileName)
Definition: ezdebug.php:842
eZDebug\setMaxLogSize
static setMaxLogSize( $size)
Definition: ezdebug.php:803
eZDebug\printReportInternal
printReportInternal( $as_html=true, $returnReport=true, $allowedDebugLevels=false, $useAccumulators=true, $useTiming=true, $useIncludedFiles=false)
Definition: ezdebug.php:1424
eZDebug\$DebugStrings
$DebugStrings
Definition: ezdebug.php:2010
eZDebug\SHOW_ALL
const SHOW_ALL
Definition: ezdebug.php:72
eZDebug\isGlobalLogFileEnabled
isGlobalLogFileEnabled()
Definition: ezdebug.php:974
eZDebug\$OldHandler
$OldHandler
Definition: ezdebug.php:2076
eZDebug\$LogFileEnabled
$LogFileEnabled
A map with message types and whether they should do file logging.
Definition: ezdebug.php:2049
eZDebug\dumpVariable
static dumpVariable( $var)
Definition: ezdebug.php:629
eZDir\mkdir
static mkdir( $dir, $perm=false, $recursive=false)
Definition: ezdir.php:73
eZDir\path
static path( $names, $includeEndSeparator=false, $type=self::SEPARATOR_UNIX)
Definition: ezdir.php:237
eZFile\rename
static rename( $srcFile, $destFile, $mkdir=false, $flags=0)
Definition: ezfile.php:152
eZSys\serverVariable
static serverVariable( $variableName, $quiet=false)
Definition: ezsys.php:856
eZSys\isShellExecution
static isShellExecution()
Definition: ezsys.php:265
eZSys\clientIP
static clientIP()
Definition: ezsys.php:714
eZSys\varDirectory
static varDirectory()
Definition: ezsys.php:503
eZURI\transformURI
static transformURI(&$href, $ignoreIndexDir=false, $serverURL=null, $htmlEscape=true)
Definition: ezuri.php:599
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.