Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezdebug.php
Go to the documentation of this file.
1 <?php
57 class eZDebug
58 {
59 public $StoreLog;
60 const LEVEL_NOTICE = 1;
61 const LEVEL_WARNING = 2;
62 const LEVEL_ERROR = 3;
63 const LEVEL_TIMING_POINT = 4;
64 const LEVEL_DEBUG = 5;
65 const LEVEL_STRICT = 6;
66
67 const SHOW_NOTICE = 1; // 1 << (EZ_LEVEL_NOTICE - 1)
68 const SHOW_WARNING = 2; // 1 << (EZ_LEVEL_WARNING - 1)
69 const SHOW_ERROR = 4; // 1 << (EZ_LEVEL_ERROR - 1)
70 const SHOW_TIMING_POINT = 8; // 1 << (EZ_LEVEL_TIMING_POINT - 1)
71 const SHOW_DEBUG = 16; // 1 << (EZ_LEVEL_DEBUG - 1)
72 const SHOW_STRICT = 32; // 1 << (EZ_LEVEL_STRICT - 1)
73 const SHOW_ALL = 63; // EZ_SHOW_NOTICE | EZ_SHOW_WARNING | EZ_SHOW_ERROR | EZ_SHOW_TIMING_POINT | EZ_SHOW_DEBUG | EZ_SHOW_STRICT
74
75 const HANDLE_NONE = 0;
76 const HANDLE_FROM_PHP = 1;
77 const HANDLE_TO_PHP = 2;
78 const HANDLE_EXCEPTION = 3;
79
80 const OUTPUT_MESSAGE_SCREEN = 1;
81 const OUTPUT_MESSAGE_STORE = 2;
82
83 const MAX_LOGFILE_SIZE = 204800; // 200*1024
84 const MAX_LOGROTATE_FILES = 3;
85
86 const XDEBUG_SIGNATURE = '--XDEBUG--';
87
91 function __construct( )
92 {
93 $this->TmpTimePoints = array( self::LEVEL_NOTICE => array(),
94 self::LEVEL_WARNING => array(),
95 self::LEVEL_ERROR => array(),
96 self::LEVEL_DEBUG => array(),
97 self::LEVEL_STRICT => array() );
98
99 $this->OutputFormat = array( self::LEVEL_NOTICE => array( "color" => "green",
100 'style' => 'notice',
101 'xhtml-identifier' => 'ezdebug-first-notice',
102 "name" => "Notice" ),
103 self::LEVEL_WARNING => array( "color" => "orange",
104 'style' => 'warning',
105 'xhtml-identifier' => 'ezdebug-first-warning',
106 "name" => "Warning" ),
107 self::LEVEL_ERROR => array( "color" => "red",
108 'style' => 'error',
109 'xhtml-identifier' => 'ezdebug-first-error',
110 "name" => "Error" ),
111 self::LEVEL_DEBUG => array( "color" => "brown",
112 'style' => 'debug',
113 'xhtml-identifier' => 'ezdebug-first-debug',
114 "name" => "Debug" ),
115 self::LEVEL_TIMING_POINT => array( "color" => "blue",
116 'style' => 'timing',
117 'xhtml-identifier' => 'ezdebug-first-timing-point',
118 "name" => "Timing" ),
119 self::LEVEL_STRICT => array( "color" => "purple",
120 'style' => 'strict',
121 'xhtml-identifier' => 'ezdebug-first-strict',
122 'name' => 'Strict' ) );
123 $this->LogFiles = array( self::LEVEL_NOTICE => array( "var/log/",
124 "notice.log" ),
125 self::LEVEL_WARNING => array( "var/log/",
126 "warning.log" ),
127 self::LEVEL_ERROR => array( "var/log/",
128 "error.log" ),
129 self::LEVEL_DEBUG => array( "var/log/",
130 "debug.log" ),
131 self::LEVEL_STRICT => array( 'var/log/',
132 'strict.log' ) );
133 $this->MessageTypes = array( self::LEVEL_NOTICE,
134 self::LEVEL_WARNING,
135 self::LEVEL_ERROR,
136 self::LEVEL_TIMING_POINT,
137 self::LEVEL_DEBUG,
138 self::LEVEL_STRICT );
139 $this->MessageNames = array( self::LEVEL_NOTICE => 'Notice',
140 self::LEVEL_WARNING => 'Warning',
141 self::LEVEL_ERROR => 'Error',
142 self::LEVEL_TIMING_POINT => 'TimingPoint',
143 self::LEVEL_DEBUG => 'Debug',
144 self::LEVEL_STRICT => 'Strict' );
145 $this->LogFileEnabled = array( self::LEVEL_NOTICE => true,
146 self::LEVEL_WARNING => true,
147 self::LEVEL_ERROR => true,
148 self::LEVEL_TIMING_POINT => true,
149 self::LEVEL_DEBUG => true,
150 self::LEVEL_STRICT => true );
151 $this->AlwaysLog = array( self::LEVEL_NOTICE => false,
152 self::LEVEL_WARNING => false,
153 self::LEVEL_ERROR => true, // Error is on by default, due to its importance
154 self::LEVEL_TIMING_POINT => false,
155 self::LEVEL_DEBUG => false,
156 self::LEVEL_STRICT => false );
157 $this->GlobalLogFileEnabled = true;
158 if ( isset( $GLOBALS['eZDebugLogFileEnabled'] ) )
159 {
160 $this->GlobalLogFileEnabled = $GLOBALS['eZDebugLogFileEnabled'];
161 }
162 $this->ShowTypes = self::SHOW_ALL;
163 $this->HandleType = self::HANDLE_NONE;
164 $this->OldHandler = false;
165 $this->UseCSS = false;
166 $this->MessageOutput = self::OUTPUT_MESSAGE_STORE;
167 $this->ScriptStart = microtime( true );
168 $this->TimeAccumulatorList = array();
169 $this->TimeAccumulatorGroupList = array();
170 $this->OverrideList = array();
171 $this->topReportsList = array();
172 $this->bottomReportsList = array();
173 }
174
175 function reset()
176 {
177 $this->DebugStrings = array();
178 $this->TmpTimePoints = array( self::LEVEL_NOTICE => array(),
179 self::LEVEL_WARNING => array(),
180 self::LEVEL_ERROR => array(),
181 self::LEVEL_DEBUG => array(),
182 self::LEVEL_STRICT => array() );
183 $this->TimeAccumulatorList = array();
184 $this->TimeAccumulatorGroupList = array();
185 $this->topReportsList = array();
186 $this->bottomReportsList = array();
187 }
188
192 function messageName( $messageType )
193 {
194 return $this->MessageNames[$messageType];
195 }
196
202 static function instance( )
203 {
204 if ( empty( $GLOBALS["eZDebugGlobalInstance"] ) )
205 {
206 $GLOBALS["eZDebugGlobalInstance"] = new eZDebug();
207 }
208 return $GLOBALS["eZDebugGlobalInstance"];
209 }
210
215 static function showMessage( $type )
216 {
217 $debug = eZDebug::instance();
218 return $debug->ShowTypes & $type;
219 }
220
224 static function alwaysLogMessage( $level )
225 {
226 $instance = eZDebug::instance();
227 // If there is a global setting for this get the value
228 // and unset it globally
229 if ( isset( $GLOBALS['eZDebugAlwaysLog'] ) )
230 {
231 $instance->AlwaysLog = $GLOBALS['eZDebugAlwaysLog'] + $instance->AlwaysLog;
232 unset( $GLOBALS['eZDebugAlwaysLog'] );
233 }
234
235 if ( !isset( $instance->AlwaysLog[$level] ) )
236 {
237 return false;
238 }
239 return $instance->AlwaysLog[$level];
240 }
241
248 static function setHandleType( $type )
249 {
250 $instance = eZDebug::instance();
251
252 if ( $type != self::HANDLE_TO_PHP and
253 $type != self::HANDLE_FROM_PHP and
254 $type != self::HANDLE_EXCEPTION )
255 $type = self::HANDLE_NONE;
256 if ( extension_loaded( 'xdebug' ) and
257 $type == self::HANDLE_FROM_PHP )
258 $type = self::HANDLE_NONE;
259 if ( $type == $instance->HandleType )
260 return $instance->HandleType;
261
262 if ( $instance->HandleType == self::HANDLE_FROM_PHP or $instance->HandleType == self::HANDLE_EXCEPTION )
263 restore_error_handler();
264 switch ( $type )
265 {
266 case self::HANDLE_FROM_PHP:
267 {
268 set_error_handler( array( $instance, 'recursionProtectErrorHandler' ) );
269 } break;
270
271 case self::HANDLE_TO_PHP:
272 {
273 restore_error_handler();
274 } break;
275
276 case self::HANDLE_EXCEPTION:
277 {
278 set_error_handler( array( $instance, 'exceptionErrorHandler' ) );
279 } break;
280
281 case self::HANDLE_NONE:
282 {
283 }
284 }
285 $oldHandleType = $instance->HandleType;
286 $instance->HandleType = $type;
287 return $oldHandleType;
288 }
289
297 static function showTypes( $types = false )
298 {
299 $instance = eZDebug::instance();
300
301 if ( $types === false )
302 {
303 return $instance->ShowTypes;
304 }
305 $old_types = $instance->ShowTypes;
306 $instance->ShowTypes = $types;
307 return $old_types;
308 }
309
310 public function recursionProtectErrorHandler( $errno, $errstr, $errfile, $errline )
311 {
312 if ( $this->recursionFlag )
313 {
314 print( "Fatal debug error: A recursion in debug error handler was detected, aborting debug message.<br/>" );
315 $this->recursionFlag = false;
316 return;
317 }
318
319 $this->recursionFlag = true;
320
321 $result = $this->errorHandler( $errno, $errstr, $errfile, $errline );
322 $this->recursionFlag = false;
323 return $result;
324 }
325
330 function errorHandler( $errno, $errstr, $errfile, $errline )
331 {
332 if ( error_reporting() == 0 ) // @ error-control operator is used
333 return;
334 if ( !eZDebug::isDebugEnabled() )
335 return;
336 $str = "$errstr in $errfile on line $errline";
337 if ( empty( $GLOBALS['eZDebugPHPErrorNames'] ) )
338 {
339 $GLOBALS['eZDebugPHPErrorNames'] =
340 array( E_ERROR => 'E_ERROR',
341 E_PARSE => 'E_PARSE',
342 E_CORE_ERROR => 'E_CORE_ERROR',
343 E_COMPILE_ERROR => 'E_COMPILE_ERROR',
344 E_USER_ERROR => 'E_USER_ERROR',
345 E_WARNING => 'E_WARNING',
346 E_CORE_WARNING => 'E_CORE_WARNING',
347 E_COMPILE_WARNING => 'E_COMPILE_WARNING',
348 E_USER_WARNING => 'E_USER_WARNING',
349 E_NOTICE => 'E_NOTICE',
350 E_USER_NOTICE => 'E_USER_NOTICE',
351 // E_STRICT => 'E_STRICT'
352 );
353 // Since PHP 5.2
354 if ( defined('E_RECOVERABLE_ERROR') )
355 $GLOBALS['eZDebugPHPErrorNames'][E_RECOVERABLE_ERROR] = 'E_RECOVERABLE_ERROR';
356 // Since PHP 5.3
357 if ( defined('E_DEPRECATED') )
358 $GLOBALS['eZDebugPHPErrorNames'][E_DEPRECATED] = 'E_DEPRECATED';
359 if ( defined('E_USER_DEPRECATED') )
360 $GLOBALS['eZDebugPHPErrorNames'][E_USER_DEPRECATED] = 'E_USER_DEPRECATED';
361
362 }
363 $errname = "Unknown error code ($errno)";
364 if ( isset( $GLOBALS['eZDebugPHPErrorNames'][$errno] ) )
365 {
366 $errname = $GLOBALS['eZDebugPHPErrorNames'][$errno];
367 }
368 switch ( $errname )
369 {
370 case 'E_ERROR':
371 case 'E_PARSE':
372 case 'E_CORE_ERROR':
373 case 'E_COMPILE_ERROR':
374 case 'E_USER_ERROR':
375 case 'E_RECOVERABLE_ERROR':
376 {
377 $this->writeError( $str, 'PHP: ' . $errname );
378 } break;
379
380 case 'E_WARNING':
381 case 'E_CORE_WARNING':
382 case 'E_COMPILE_WARNING':
383 case 'E_USER_WARNING':
384 case 'E_DEPRECATED':
385 case 'E_USER_DEPRECATED':
386 {
387 $this->writeWarning( $str, 'PHP: ' . $errname );
388 } break;
389
390 case 'E_NOTICE':
391 case 'E_USER_NOTICE':
392 {
393 $this->writeNotice( $str, 'PHP: ' . $errname );
394 } break;
395
396 case 'E_STRICT':
397 {
398 return $this->writeStrict( $str, 'PHP: ' . $errname );
399 } break;
400 default:
401 {
402 $this->writeError( $str, 'PHP: ' . $errname );
403 } break;
404 }
405 }
406
415 static function writeStrict( $string, $label = "", $backgroundClass = "" )
416 {
417 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_STRICT );
418 $enabled = eZDebug::isDebugEnabled();
419 if ( !$alwaysLog and !$enabled )
420 return;
421
422 $show = eZDebug::showMessage( self::SHOW_STRICT );
423 if ( !$alwaysLog and !$show )
424 return;
425
426 if ( is_object( $string ) || is_array( $string ) )
427 $string = eZDebug::dumpVariable( $string );
428
429 $GLOBALS['eZDebugStrict'] = true;
430 if ( !isset( $GLOBALS['eZDebugStrictCount'] ) )
431 $GLOBALS['eZDebugStrictCount'] = 0;
432 ++$GLOBALS['eZDebugStrictCount'];
433
434 $debug = eZDebug::instance();
435 if ( $debug->HandleType == self::HANDLE_TO_PHP )
436 {
437 // If we get here only because of $alwaysLog we should not trigger a PHP error
438 if ( $enabled and $show )
439 {
440 // we can't trigger E_STRICT but we can let the default error handler handle it
441 // see http://www.php.net/manual/en/function.set-error-handler.php#69218
442 return false;
443 }
444 }
445 else
446 {
447 $debug->write( $string, self::LEVEL_STRICT, $label, $backgroundClass, $alwaysLog );
448 return true;
449 }
450 }
451
460 static function writeNotice( $string, $label = "", $backgroundClass = "" )
461 {
462 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_NOTICE );
463 $enabled = eZDebug::isDebugEnabled();
464 if ( !$alwaysLog and !$enabled )
465 return;
466
467 $show = eZDebug::showMessage( self::SHOW_NOTICE );
468 if ( !$alwaysLog and !$show )
469 return;
470
471 if ( is_object( $string ) || is_array( $string ) )
472 $string = eZDebug::dumpVariable( $string );
473
474 $GLOBALS['eZDebugNotice'] = true;
475 if ( !isset( $GLOBALS['eZDebugNoticeCount'] ) )
476 $GLOBALS['eZDebugNoticeCount'] = 0;
477 ++$GLOBALS['eZDebugNoticeCount'];
478
479 $debug = eZDebug::instance();
480 if ( $debug->HandleType == self::HANDLE_TO_PHP )
481 {
482 // If we get here only because of $alwaysLog we should not trigger a PHP error
483 if ( $enabled and $show )
484 {
485 if ( $label )
486 $string = "$label: $string";
487 trigger_error( $string, E_USER_NOTICE );
488 }
489 }
490 else
491 {
492 $debug->write( $string, self::LEVEL_NOTICE, $label, $backgroundClass, $alwaysLog );
493 }
494 }
495
503 static function writeWarning( $string, $label = "", $backgroundClass = "" )
504 {
505 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_WARNING );
506 $enabled = eZDebug::isDebugEnabled();
507 if ( !$alwaysLog and !$enabled )
508 return;
509
510 $show = eZDebug::showMessage( self::SHOW_WARNING );
511 if ( !$alwaysLog and !$show )
512 return;
513
514 if ( is_object( $string ) || is_array( $string ) )
515 $string = eZDebug::dumpVariable( $string );
516
517 $GLOBALS['eZDebugWarning'] = true;
518 if ( !isset( $GLOBALS['eZDebugWarningCount'] ) )
519 $GLOBALS['eZDebugWarningCount'] = 0;
520 ++$GLOBALS['eZDebugWarningCount'];
521
522 $debug = eZDebug::instance();
523 if ( $debug->HandleType == self::HANDLE_TO_PHP )
524 {
525 // If we get here only because of $alwaysLog we should not trigger a PHP error
526 if ( $enabled and $show )
527 {
528 if ( $label )
529 $string = "$label: $string";
530 trigger_error( $string, E_USER_WARNING );
531 }
532 }
533 else
534 {
535 $debug->write( $string, self::LEVEL_WARNING, $label, $backgroundClass, $alwaysLog );
536 }
537 }
538
546 static function writeError( $string, $label = "", $backgroundClass = "" )
547 {
548 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_ERROR );
549 $enabled = eZDebug::isDebugEnabled();
550 if ( !$alwaysLog and !$enabled )
551 return;
552
553 $show = eZDebug::showMessage( self::SHOW_ERROR );
554 if ( !$alwaysLog and !$show )
555 return;
556
557 if ( is_object( $string ) || is_array( $string ) )
558 $string = eZDebug::dumpVariable( $string );
559
560 $GLOBALS['eZDebugError'] = true;
561 if ( !isset( $GLOBALS['eZDebugErrorCount'] ) )
562 $GLOBALS['eZDebugErrorCount'] = 0;
563 ++$GLOBALS['eZDebugErrorCount'];
564
565 $debug = eZDebug::instance();
566 if ( $debug->HandleType == self::HANDLE_TO_PHP )
567 {
568 // If we get here only because of $alwaysLog we should not trigger a PHP error
569 if ( $enabled and $show )
570 {
571 if ( $label )
572 $string = "$label: $string";
573 trigger_error( $string, E_USER_ERROR );
574 }
575 }
576 else
577 {
578 $debug->write( $string, self::LEVEL_ERROR, $label, $backgroundClass, $alwaysLog );
579 }
580 }
581
589 static function writeDebug( $string, $label = "", $backgroundClass = "" )
590 {
591 $alwaysLog = eZDebug::alwaysLogMessage( self::LEVEL_DEBUG );
592 $enabled = eZDebug::isDebugEnabled();
593 if ( !$alwaysLog and !$enabled )
594 return;
595
596 $show = eZDebug::showMessage( self::SHOW_DEBUG );
597 if ( !$alwaysLog and !$show )
598 return;
599
600 if ( is_object( $string ) || is_array( $string ) )
601 $string = eZDebug::dumpVariable( $string );
602
603 $GLOBALS['eZDebugDebug'] = true;
604 if ( !isset( $GLOBALS['eZDebugDebugCount'] ) )
605 $GLOBALS['eZDebugDebugCount'] = 0;
606 ++$GLOBALS['eZDebugDebugCount'];
607
608 $debug = eZDebug::instance();
609 if ( $debug->HandleType == self::HANDLE_TO_PHP )
610 {
611 // If we get here only because of $alwaysLog we should not trigger a PHP error
612 if ( $enabled and $show )
613 {
614 if ( $label )
615 $string = "$label: $string";
616 trigger_error( $string, E_USER_NOTICE );
617 }
618 }
619 else
620 {
621 $debug->write( $string, self::LEVEL_DEBUG, $label, $backgroundClass, $alwaysLog );
622 }
623 }
624
630 static function dumpVariable( $var )
631 {
632 // If we have var_export (PHP >= 4.2.0) we use the instead
633 // provides better output, doesn't require output buffering
634 // and doesn't get mangled by Xdebug
635
636 // dl: we should always use 'var_dump' since 'var_export' is
637 // unable to handle recursion properly.
638 //if ( function_exists( 'var_export' ) )
639 // return var_export( $var, true );
640
641 ob_start();
642 var_dump( $var );
643 $variableContents = '';
644 if ( extension_loaded( 'xdebug' ) )
645 $variableContents = self::XDEBUG_SIGNATURE;
646 $variableContents .= ob_get_contents();
647 ob_end_clean();
648 return $variableContents;
649 }
650
655 static function setUseExternalCSS( $use )
656 {
657 eZDebug::instance()->UseCSS = $use;
658 }
659
664 function setMessageOutput( $output )
665 {
666 $this->MessageOutput = $output;
667 }
668
669 function setStoreLog( $store )
670 {
671 $this->StoreLog = $store;
672 }
673
677 static function addTimingPoint( $description = "" )
678 {
679 if ( !eZDebug::isDebugEnabled() )
680 return;
681 if ( !eZDebug::showMessage( self::SHOW_TIMING_POINT ) )
682 return;
683
684 $time = microtime( true );
685 $debug = eZDebug::instance();
686
687 $usedMemory = 0;
688 if ( function_exists( "memory_get_usage" ) )
689 $usedMemory = memory_get_usage();
690 $tp = array( "Time" => $time,
691 "Description" => $description,
692 "MemoryUsage" => $usedMemory );
693 $debug->TimePoints[] = $tp;
694 $desc = "Timing Point: $description";
695 foreach ( array( self::LEVEL_NOTICE, self::LEVEL_WARNING, self::LEVEL_ERROR, self::LEVEL_DEBUG, self::LEVEL_STRICT ) as $lvl )
696 {
697 if ( isset( $debug->TmpTimePoints[$lvl] ) )
698 $debug->TmpTimePoints[$lvl] = array();
699 if ( $debug->TmpTimePoints[$lvl] === false and
700 $debug->isLogFileEnabled( $lvl ) )
701 {
702 $files = $debug->logFiles();
703 $file = $files[$lvl];
704 $debug->writeFile( $file, $desc, $lvl );
705 }
706 else
707 array_push( $debug->TmpTimePoints[$lvl], $tp );
708 }
709 $debug->write( $description, self::LEVEL_TIMING_POINT );
710 }
711
716 function write( $string, $verbosityLevel = self::LEVEL_NOTICE, $label = "", $backgroundClass = "", $alwaysLog = false )
717 {
718 $enabled = eZDebug::isDebugEnabled();
719 if ( !$alwaysLog and !$enabled )
720 return;
721 switch ( $verbosityLevel )
722 {
723 case self::LEVEL_NOTICE:
724 case self::LEVEL_WARNING:
725 case self::LEVEL_ERROR:
726 case self::LEVEL_DEBUG:
727 case self::LEVEL_TIMING_POINT:
728 case self::LEVEL_STRICT:
729 break;
730
731 default:
732 $verbosityLevel = self::LEVEL_ERROR;
733 break;
734 }
735 if ( $this->MessageOutput & self::OUTPUT_MESSAGE_SCREEN and $enabled )
736 {
737 print( "$verbosityLevel: $string ($label)\n" );
738 }
739 $files = $this->logFiles();
740 $fileName = false;
741 if ( isset( $files[$verbosityLevel] ) )
742 $fileName = $files[$verbosityLevel];
743 if ( $this->MessageOutput & self::OUTPUT_MESSAGE_STORE or $alwaysLog )
744 {
745 if ( ! eZDebug::isLogOnlyEnabled() and $enabled )
746 {
747 $ip = eZSys::clientIP();
748 if ( !$ip )
749 $ip = eZSys::serverVariable( 'HOSTNAME', true );
750 $this->DebugStrings[] = array( "Level" => $verbosityLevel,
751 "IP" => $ip,
752 "Time" => time(),
753 "Label" => $label,
754 "String" => $string,
755 "BackgroundClass" => $backgroundClass );
756 }
757
758 if ( $fileName !== false )
759 {
760 $timePoints = $this->TmpTimePoints[$verbosityLevel];
761 if ( is_array( $timePoints ) )
762 {
763 if ( $this->isLogFileEnabled( $verbosityLevel ) )
764 {
765 foreach ( $timePoints as $tp )
766 {
767 $desc = "Timing Point: " . $tp["Description"];
768 $this->writeFile( $fileName, $desc, $verbosityLevel, $alwaysLog );
769 }
770 }
771 $this->TmpTimePoints[$verbosityLevel] = false;
772 }
773 if ( $this->isLogFileEnabled( $verbosityLevel ) )
774 {
775 $string = "$label:\n$string";
776 $this->writeFile( $fileName, $string, $verbosityLevel, $alwaysLog );
777 }
778 }
779 }
780 }
781
786 static function maxLogSize()
787 {
788 if ( isset( $GLOBALS['eZDebugMaxLogSize'] ) )
789 {
790 return $GLOBALS['eZDebugMaxLogSize'];
791 }
792 else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
793 {
794 self::setMaxLogSize( (int)EZPUBLISH_LOG_MAX_FILE_SIZE );
795 return (int)EZPUBLISH_LOG_MAX_FILE_SIZE;
796 }
797 return self::MAX_LOGFILE_SIZE;
798 }
799
804 static function setMaxLogSize( $size )
805 {
806 $GLOBALS['eZDebugMaxLogSize'] = $size;
807 }
808
813 static function maxLogrotateFiles()
814 {
815 if ( isset( $GLOBALS['eZDebugMaxLogrotateFiles'] ) )
816 {
817 return $GLOBALS['eZDebugMaxLogrotateFiles'];
818 }
819 else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
820 {
821 self::setLogrotateFiles( (int)EZPUBLISH_LOG_ROTATE_FILES );
822 return (int)EZPUBLISH_LOG_ROTATE_FILES;
823 }
824 return self::MAX_LOGROTATE_FILES;
825 }
826
831 static function setLogrotateFiles( $files )
832 {
833 $GLOBALS['eZDebugMaxLogrotateFiles'] = $files;
834 }
835
843 static function rotateLog( $fileName )
844 {
845 $maxLogrotateFiles = eZDebug::maxLogrotateFiles();
846 if ( $maxLogrotateFiles == 0 )
847 {
848 return;
849 }
850 for ( $i = $maxLogrotateFiles; $i > 0; --$i )
851 {
852 $logRotateName = $fileName . '.' . $i;
853 if ( file_exists( $logRotateName ) )
854 {
855 if ( $i == $maxLogrotateFiles )
856 {
857 @unlink( $logRotateName );
858 }
859 else
860 {
861 $newLogRotateName = $fileName . '.' . ($i + 1);
862 eZFile::rename( $logRotateName, $newLogRotateName );
863 }
864 }
865 }
866 if ( file_exists( $fileName ) )
867 {
868 $newLogRotateName = $fileName . '.' . 1;
869 eZFile::rename( $fileName, $newLogRotateName );
870 return true;
871 }
872 return false;
873 }
874
879 function writeFile( &$logFileData, &$string, $verbosityLevel, $alwaysLog = false )
880 {
881 $enabled = eZDebug::isDebugEnabled();
882 if ( !$alwaysLog and !$enabled )
883 return;
884 if ( !$alwaysLog and !$this->isLogFileEnabled( $verbosityLevel ) )
885 return;
886 $oldHandleType = eZDebug::setHandleType( self::HANDLE_TO_PHP );
887 $logDir = $logFileData[0];
888 $logName = $logFileData[1];
889 $fileName = $logDir . $logName;
890 if ( !file_exists( $logDir ) )
891 {
892 eZDir::mkdir( $logDir, false, true );
893 }
894 $oldumask = @umask( 0 );
895 clearstatcache( true, $fileName );
896 $fileExisted = file_exists( $fileName );
897 if ( $fileExisted and
898 filesize( $fileName ) > eZDebug::maxLogSize() )
899 {
900 if ( eZDebug::rotateLog( $fileName ) )
901 $fileExisted = false;
902 }
903 $logFile = @fopen( $fileName, "a" );
904 if ( $logFile )
905 {
906 $time = date( "M d Y H:i:s", strtotime( "now" ) );
907 $ip = eZSys::clientIP();
908 if ( !$ip )
909 $ip = eZSys::serverVariable( 'HOSTNAME', true );
910 $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n";
911 @fwrite( $logFile, $notice );
912 @fclose( $logFile );
913 if ( !$fileExisted )
914 {
915 $ini = eZINI::instance();
916 $permissions = octdec( $ini->variable( 'FileSettings', 'LogFilePermissions' ) );
917 @chmod( $fileName, $permissions );
918 }
919 @umask( $oldumask );
920 }
921 else
922 {
923 @umask( $oldumask );
924 $logEnabled = $this->isLogFileEnabled( $verbosityLevel );
925 $this->setLogFileEnabled( false, $verbosityLevel );
926 if ( $verbosityLevel != self::LEVEL_ERROR or
927 $logEnabled )
928 {
929 eZDebug::setHandleType( $oldHandleType );
930 $this->writeError( "Cannot open log file '$fileName' for writing\n" .
931 "The web server must be allowed to modify the file.\n" .
932 "File logging for '$fileName' is disabled." , 'eZDebug::writeFile' );
933 }
934 }
935 eZDebug::setHandleType( $oldHandleType );
936 }
937
943 static function setLogFileEnabled( $enabled, $types = false )
944 {
945 $instance = eZDebug::instance();
946 if ( $types === false )
947 {
948 $types = $instance->messageTypes();
949 }
950 if ( !is_array( $types ) )
951 {
952 $types = array( $types );
953 }
954 foreach ( $types as $type )
955 {
956 $instance->LogFileEnabled[$type] = $enabled;
957 }
958 }
959
964 function isLogFileEnabled( $type )
965 {
966 if ( !$this->isGlobalLogFileEnabled() )
967 return false;
968 return $this->LogFileEnabled[$type];
969 }
970
975 function isGlobalLogFileEnabled()
976 {
977 return $this->GlobalLogFileEnabled;
978 }
979
984 function setIsLogFileEnabled( $type, $enabled )
985 {
986 $this->LogFileEnabled[$type] = $enabled;
987 }
988
993 function setIsGlobalLogFileEnabled( $enabled )
994 {
995 $this->GlobalLogFileEnabled = $enabled;
996 }
997
1001 function setLogOnly( $enabled )
1002 {
1003 $GLOBALS['eZDebugLogOnly'] = $enabled;
1004 }
1005
1009 function messageTypes()
1010 {
1011 return $this->MessageTypes;
1012 }
1013
1018 function logFiles()
1019 {
1020 return $this->LogFiles;
1021 }
1022
1028 static function isDebugEnabled()
1029 {
1030 if ( isset( $GLOBALS['eZDebugEnabled'] ) )
1031 {
1032 return $GLOBALS['eZDebugEnabled'];
1033 }
1034
1035 return false;
1036 }
1037
1043 static function isLogOnlyEnabled()
1044 {
1045 if ( isset( $GLOBALS['eZDebugLogOnly'] ) )
1046 {
1047 return $GLOBALS['eZDebugLogOnly'];
1048 }
1049
1050 return false;
1051 }
1052
1058 static function isIPInNet( $ipaddress, $network, $mask = 24 )
1059 {
1060 $lnet = ip2long( $network );
1061 $lip = ip2long( $ipaddress );
1062 $binnet = str_pad( decbin( $lnet ), 32, '0', STR_PAD_LEFT );
1063 $firstpart = substr( $binnet, 0, $mask );
1064 $binip = str_pad( decbin( $lip ), 32, '0', STR_PAD_LEFT );
1065 $firstip = substr( $binip, 0, $mask );
1066 return( strcmp( $firstpart, $firstip ) == 0 );
1067 }
1068
1076 private static function isIPInNetIPv6( $ipAddress, $ipAddressRange )
1077 {
1078 // Split the ip addres range into network part and netmask number
1079 list( $ipAddressRangeNetworkPrefix, $networkMaskBits ) = explode( '/', $ipAddressRange );
1080
1081 // Convert ip addresses to their binary representations, truncate to the specified network mask length
1082 $binaryIpAddressRangeNetworkPrefix = substr( self::packedToBin( inet_pton( $ipAddressRangeNetworkPrefix ) ), 0, $networkMaskBits );
1083 $binaryIpAddressNetworkPrefix = substr( self::packedToBin( inet_pton( $ipAddress ) ), 0, $networkMaskBits );
1084
1085 return $binaryIpAddressRangeNetworkPrefix === $binaryIpAddressNetworkPrefix;
1086 }
1087
1094 private static function packedToBin( $packedIPAddress )
1095 {
1096 $binaryIPAddress = '';
1097
1098 // In PHP v5.5 (and up) the unpack function's returned value formats behavior differs
1099 if ( version_compare( PHP_VERSION, '5.5.0-dev', '>=' ) )
1100 {
1101 // Turns the space padded string into an array of the unpacked in_addr representation
1102 // In PHP v5.5 format 'a' retains trailing null bytes
1103 $unpackedIPAddress = unpack( 'a16', $packedIPAddress );
1104 }
1105 else
1106 {
1107 // Turns the space padded string into an array of the unpacked in_addr representation
1108 // In PHP v5.4 <= format 'A' retains trailing null bytes
1109 $unpackedIPAddress = unpack( 'A16', $packedIPAddress );
1110 }
1111 $unpackedIPAddressArray = str_split( $unpackedIPAddress[1] );
1112
1113 // Get each characters ascii number, then turn that number into a binary
1114 // and pad it with 0's to the left if it isn't 8 digits long
1115 foreach( $unpackedIPAddressArray as $character )
1116 {
1117 $binaryIPAddress .= str_pad( decbin( ord( $character ) ), 8, '0', STR_PAD_LEFT );
1118 }
1119
1120 return $binaryIPAddress;
1121 }
1122
1133 static function updateSettings( $settings )
1134 {
1135 // Make sure errors are handled by PHP when we read, including our own debug output.
1136 $oldHandleType = eZDebug::setHandleType( self::HANDLE_TO_PHP );
1137
1138 if ( isset( $settings['debug-log-files-enabled'] ) )
1139 {
1140 $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled'];
1141 if ( isset( $GLOBALS["eZDebugGlobalInstance"] ) )
1142 $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled'];
1143 }
1144
1145 if ( isset( $settings['debug-styles'] ) )
1146 {
1147 $GLOBALS['eZDebugStyles'] = $settings['debug-styles'];
1148 }
1149
1150 if ( isset( $settings['always-log'] ) and
1151 is_array( $settings['always-log'] ) )
1152 {
1153 $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log'];
1154 }
1155
1156 if ( isset( $settings['log-only'] ) )
1157 {
1158 $GLOBALS['eZDebugLogOnly'] = ( $settings['log-only'] == 'enabled' );
1159 }
1160
1161 $GLOBALS['eZDebugAllowedByIP'] = ( isset( $settings['debug-by-ip'] ) && $settings['debug-by-ip'] ) ? self::isAllowedByCurrentIP( $settings['debug-ip-list'] ) : true;
1162
1163 // updateSettings is meant to be called before the user session is started
1164 // so we do not take debug-by-user into account yet, but store the debug-user-list in $GLOBALS
1165 // so it can be used in the final check, done by checkDebugByUser()
1166 if ( isset( $settings['debug-by-user'] ) && $settings['debug-by-user'] )
1167 {
1168 $GLOBALS['eZDebugUserIDList'] = $settings['debug-user-list'] ? $settings['debug-user-list'] : array();
1169 }
1170
1171 $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByIP'];
1172 $GLOBALS['eZDebugEnabled'] = $settings['debug-enabled'] && $GLOBALS['eZDebugAllowedByIP'];
1173
1174 eZDebug::setHandleType( $oldHandleType );
1175 }
1176
1185 static function checkDebugByUser()
1186 {
1187 if ( !isset( $GLOBALS['eZDebugUserIDList'] ) ||
1188 !is_array( $GLOBALS['eZDebugUserIDList'] ) )
1189 {
1190 return false;
1191 }
1192 else
1193 {
1194 $currentUserID = eZUser::currentUserID();
1195
1196 if ( !$currentUserID )
1197 {
1198 return false;
1199 }
1200 else
1201 {
1202 $GLOBALS['eZDebugAllowedByUser'] = in_array( $currentUserID, $GLOBALS['eZDebugUserIDList'] );
1203
1204 if ( $GLOBALS['eZDebugAllowed'] )
1205 {
1206 $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByUser'];
1207 }
1208
1209 if ( $GLOBALS['eZDebugEnabled'] )
1210 {
1211 $GLOBALS['eZDebugEnabled'] = $GLOBALS['eZDebugAllowedByUser'];
1212 }
1213
1214 unset( $GLOBALS['eZDebugUserIDList'] );
1215
1216 return true;
1217 }
1218 }
1219 }
1220
1225 static function printReport( $newWindow = false, $as_html = true, $returnReport = false,
1226 $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false )
1227 {
1228 if ( !self::isDebugEnabled() )
1229 return null;
1230
1231 $debug = self::instance();
1232 $report = $debug->printReportInternal( $as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles );
1233
1234 if ( $newWindow == true )
1235 {
1236 $debugFilePath = eZDir::path( array( eZSys::varDirectory(), 'cache', 'debug.html' ) );
1237 $debugFileURL = $debugFilePath;
1238 eZURI::transformURI( $debugFileURL, true );
1239 print( "
1240 <script type='text/javascript'>
1241 <!--
1242
1243 (function()
1244 {
1245 var debugWindow;
1246
1247 if (navigator.appName == \"Microsoft Internet Explorer\")
1248 {
1249 //Microsoft Internet Explorer
1250 debugWindow = window.open( '$debugFileURL', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1251 debugWindow.document.close();
1252 debugWindow.location.reload();
1253 }
1254 else if (navigator.appName == \"Opera\")
1255 {
1256 //Opera
1257 debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1258 debugWindow.location.href=\"$debugFileURL\";
1259 debugWindow.navigate(\"$debugFileURL\");
1260 }
1261 else
1262 {
1263 //Mozilla, Firefox, etc.
1264 debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');
1265 debugWindow.document.location.href=\"$debugFileURL\";
1266 };
1267 })();
1268
1269 // -->
1270 </script>
1271 " );
1272 $header = "<!DOCTYPE html><html><head><title>eZ debug</title></head><body>";
1273 $footer = "</body></html>";
1274 $fullPage = ezpEvent::getInstance()->filter( 'response/output', $header . $report . $footer );
1275 file_put_contents( $debugFilePath, $fullPage );
1276 }
1277 else
1278 {
1279 if ( $returnReport )
1280 return $report;
1281 }
1282 return null;
1283 }
1284
1290 static function setScriptStart( $time = false )
1291 {
1292 if ( $time == false )
1293 $time = microtime( true );
1294 $debug = eZDebug::instance();
1295 $debug->ScriptStart = $time;
1296 }
1297
1303 static function setScriptStop( $time = false )
1304 {
1305 if ( $time === false )
1306 $time = microtime( true );
1307 $debug = eZDebug::instance();
1308 $debug->ScriptStop = $time;
1309 }
1310
1315 static function createAccumulatorGroup( $key, $name = false )
1316 {
1317 if ( !eZDebug::isDebugEnabled() )
1318 return;
1319 if ( $name == '' or
1320 $name === false )
1321 $name = $key;
1322 $debug = eZDebug::instance();
1323 if ( !array_key_exists( $key, $debug->TimeAccumulatorList ) )
1324 $debug->TimeAccumulatorList[$key] = array( 'name' => $name, 'time' => 0, 'count' => 0, 'is_group' => true, 'in_group' => false );
1325 if ( !array_key_exists( $key, $debug->TimeAccumulatorGroupList ) )
1326 $debug->TimeAccumulatorGroupList[$key] = array();
1327 }
1328
1334 static function createAccumulator( $key, $inGroup = false, $name = false )
1335 {
1336 if ( !eZDebug::isDebugEnabled() )
1337 return;
1338 if ( $name == '' or
1339 $name === false )
1340 $name = $key;
1341 $debug = eZDebug::instance();
1342 $isGroup = false;
1343 if ( array_key_exists( $key, $debug->TimeAccumulatorList ) and
1344 array_key_exists( $key, $debug->TimeAccumulatorGroupList ) )
1345 $isGroup = true;
1346 $debug->TimeAccumulatorList[$key] = array( 'name' => $name, 'time' => 0, 'count' => 0, 'is_group' => $isGroup, 'in_group' => $inGroup );
1347 if ( $inGroup !== false )
1348 {
1349 $groupKeys = array();
1350 if ( array_key_exists( $inGroup, $debug->TimeAccumulatorGroupList ) )
1351 $groupKeys = $debug->TimeAccumulatorGroupList[$inGroup];
1352 $debug->TimeAccumulatorGroupList[$inGroup] = array_unique( array_merge( $groupKeys, array( $key ) ) );
1353 if ( array_key_exists( $inGroup, $debug->TimeAccumulatorList ) )
1354 $debug->TimeAccumulatorList[$inGroup]['is_group'] = true;
1355 }
1356 }
1357
1362 static function accumulatorStart( $key, $inGroup = false, $name = false, $recursive = false )
1363 {
1364 if ( !eZDebug::isDebugEnabled() )
1365 return;
1366 $startTime = microtime( true );
1367 $debug = eZDebug::instance();
1368 $key = $key === false ? 'Default Debug-Accumulator' : $key;
1369 if ( ! array_key_exists( $key, $debug->TimeAccumulatorList ) )
1370 {
1371 $debug->createAccumulator( $key, $inGroup, $name );
1372 }
1373
1374 if ( $recursive )
1375 {
1376 if ( isset( $debug->TimeAccumulatorList[$key]['recursive_counter'] ) )
1377 {
1378 $debug->TimeAccumulatorList[$key]['recursive_counter']++;
1379 return;
1380 }
1381 $debug->TimeAccumulatorList[$key]['recursive_counter'] = 0;
1382 }
1383
1384 $debug->TimeAccumulatorList[$key]['temp_time'] = $startTime;
1385 }
1386
1390 static function accumulatorStop( $key, $recursive = false )
1391 {
1392 if ( !eZDebug::isDebugEnabled() )
1393 return;
1394 $stopTime = microtime( true );
1395 $debug = eZDebug::instance();
1396 $key = $key === false ? 'Default Debug-Accumulator' : $key;
1397 if ( ! array_key_exists( $key, $debug->TimeAccumulatorList ) )
1398 {
1399 eZDebug::writeWarning( "Accumulator '$key' does not exist, run eZDebug::accumulatorStart first", __METHOD__ );
1400 return;
1401 }
1402 $accumulator = $debug->TimeAccumulatorList[$key];
1403 if ( $recursive )
1404 {
1405 if ( isset( $accumulator['recursive_counter'] ) )
1406 {
1407 if ( $accumulator['recursive_counter'] > 0 )
1408 {
1409 $accumulator['recursive_counter']--;
1410 return;
1411 }
1412 }
1413 }
1414 $diffTime = $stopTime - $accumulator['temp_time'];
1415 $accumulator['time'] = $accumulator['time'] + $diffTime;
1416 ++$accumulator['count'];
1417 $debug->TimeAccumulatorList[$key] = $accumulator;
1418 }
1419
1420
1425 function printReportInternal( $as_html = true, $returnReport = true, $allowedDebugLevels = false,
1426 $useAccumulators = true, $useTiming = true, $useIncludedFiles = false )
1427 {
1428 $reportStart = microtime( true );
1429
1430 if ( isset( $GLOBALS['eZDebugStyles'] ) )
1431 {
1432 $styles = $GLOBALS['eZDebugStyles'];
1433 }
1434 else
1435 {
1436 $styles = array( 'strict' => false,
1437 'strict-end' => false,
1438 'warning' => false,
1439 'warning-end' => false,
1440 'error' => false,
1441 'error-end' => false,
1442 'debug' => false,
1443 'debug-end' => false,
1444 'notice' => false,
1445 'notice-end' => false,
1446 'timing' => false,
1447 'timing-end' => false,
1448 'mark' => false,
1449 'mark-end' => false,
1450 'emphasize' => false,
1451 'emphasize-end' => false,
1452 'bold' => false,
1453 'bold-end' => false );
1454 }
1455 if ( !$allowedDebugLevels )
1456 {
1457 $allowedDebugLevels = array( self::LEVEL_NOTICE, self::LEVEL_WARNING, self::LEVEL_ERROR,
1458 self::LEVEL_DEBUG, self::LEVEL_TIMING_POINT, self::LEVEL_STRICT );
1459 }
1460
1461 $startTime = $this->ScriptStart;
1462 if ( $this->ScriptStop == null )
1463 {
1464 $endTime = $reportStart;
1465 }
1466 else
1467 {
1468 $endTime = $this->ScriptStop;
1469 }
1470 $totalElapsed = $endTime - $startTime;
1471 if ( function_exists( 'memory_get_peak_usage' ) )
1472 {
1473 $peakMemory = memory_get_peak_usage( true );
1474 }
1475
1476 if ( $returnReport )
1477 {
1478 ob_start();
1479 }
1480
1481 if ( $as_html )
1482 {
1483 $ini = eZINI::instance();
1484
1485 if( $ini->variable( 'DebugSettings', 'DebugByUser' ) == 'enabled' )
1486 {
1487 $byUser = " (By User)";
1488 } else {
1489 $byUser = false;
1490 }
1491 if( $ini->variable( 'DebugSettings', 'DebugByIP' ) == 'enabled' )
1492 {
1493 $byIP = " (By IP Address)";
1494 } else {
1495 $byIP = false;
1496 }
1497
1498 echo "<div id=\"debug\"><h2>eZ debug" . $byUser . $byIP ."</h2>";
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 }
1838
1839 if ( $returnReport )
1840 {
1841 $returnText = ob_get_contents();
1842 ob_end_clean();
1843 return $returnText;
1844 }
1845 else
1846 {
1847 return NULL;
1848 }
1849 }
1850
1854 static function appendTopReport( $reportName, $reportContent )
1855 {
1856 $debug = eZDebug::instance();
1857 $debug->topReportsList[$reportName] = $reportContent;
1858 }
1859
1863 static function printTopReportsList()
1864 {
1865 $debug = eZDebug::instance();
1866 $reportNames = array_keys( $debug->topReportsList );
1867 foreach ( $reportNames as $reportName )
1868 {
1869 echo $debug->topReportsList[$reportName];
1870 }
1871 }
1872
1876 static function appendBottomReport( $reportName, $reportContent )
1877 {
1878 $debug = eZDebug::instance();
1879 $debug->bottomReportsList[$reportName] = $reportContent;
1880 }
1881
1888 static function printBottomReportsList( $as_html = true )
1889 {
1890 $debug = eZDebug::instance();
1891 $reportNames = array_keys( $debug->bottomReportsList );
1892 foreach ( $reportNames as $reportName )
1893 {
1894 if ( is_callable( $debug->bottomReportsList[$reportName] ) )
1895 {
1896 echo call_user_func_array( $debug->bottomReportsList[$reportName], array( $as_html ) );
1897 }
1898 else
1899 {
1900 echo $debug->bottomReportsList[$reportName];
1901 }
1902 }
1903 }
1904
1908 function isDebugAllowed()
1909 {
1910
1911 }
1912
1919 private static function isAllowedByCurrentIP( $allowedIpList )
1920 {
1921 $ipAddresIPV4Pattern = "/^(([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+))(\/([0-9]+)$|$)/";
1922 $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]+)$|$)$/";
1923
1924 $ipAddress = eZSys::clientIP();
1925 if ( $ipAddress )
1926 {
1927 foreach( $allowedIpList as $itemToMatch )
1928 {
1929 // Test for IPv6 Addresses first instead of IPv4 addresses as IPv6
1930 // addresses can contain dot separators within them
1931 if ( preg_match( "/:/", $ipAddress ) )
1932 {
1933 if ( preg_match( $ipAddressIPV6Pattern, $itemToMatch, $matches ) )
1934 {
1935 if ( $matches[69] )
1936 {
1937 if ( self::isIPInNetIPv6( $ipAddress, $itemToMatch ) )
1938 {
1939 return true;
1940 }
1941
1942 }
1943 else
1944 {
1945 if ( $matches[1] == $itemToMatch )
1946 {
1947 return true;
1948 }
1949 }
1950 }
1951 }
1952 elseif ( preg_match( "/\./", $ipAddress) )
1953 {
1954 if ( preg_match( $ipAddresIPV4Pattern, $itemToMatch, $matches ) )
1955 {
1956 if ( $matches[6] )
1957 {
1958 if ( self::isIPInNet( $ipAddress, $matches[1], $matches[7] ) )
1959 {
1960 return true;
1961 }
1962 }
1963 else
1964 {
1965 if ( $matches[1] == $ipAddress )
1966 {
1967 return true;
1968 }
1969 }
1970 }
1971 }
1972 }
1973
1974 return false;
1975 }
1976 else
1977 {
1978 return eZSys::isShellExecution() && in_array( 'commandline', $allowedIpList );
1979 }
1980 }
1981
1987 public static function exceptionErrorHandler( $errno, $errstr, $errfile, $errline )
1988 {
1989 throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
1990 }
1991
1994 public $DebugStrings = array();
1995
1997 public $TimePoints = array();
1998
2000 public $TmpTimePoints;
2001
2003 public $TimeAccumulatorList = array();
2004
2006 public $ShowTypes;
2007
2009 public $HandleType;
2010
2012 public $OutputFormat;
2013
2015 public $LogFiles;
2016
2018 public $TimingAccuracy = 4;
2019
2021 public $PercentAccuracy = 4;
2022
2024 public $UseCSS;
2025
2027 public $MessageOutput;
2028
2030 public $MessageTypes;
2031
2033 public $LogFileEnabled;
2034
2036 public $GlobalLogFileEnabled;
2037
2039 public $ScriptStart;
2040
2043 public $ScriptStop;
2044
2046 public $OverrideList;
2047
2049 public $bottomReportsList;
2050
2052 public $topReportsList;
2053
2054 private $recursionFlag = false;
2055
2056 public $MessageNames;
2057
2058 public $AlwaysLog;
2059
2060 public $OldHandler;
2061
2062 public $TimeAccumulatorGroupList;
2063
2064
2065 }
2066
2067 ?>
$i
$i
Definition: admin/adlist.php:91
$groupList
$groupList
Definition: admin/articleedit.php:800
$group
$group
Definition: admin/articleedit.php:799
$level
$level
Definition: admin/message.php:106
$types
$types
Definition: articlepreview.php:108
$files
$files
Definition: articlepreview.php:91
eZDebug
Advanced debug/log system.
Definition: ezdebug.php:58
eZDebug\isIPInNet
static isIPInNet( $ipaddress, $network, $mask=24)
Definition: ezdebug.php:1058
eZDebug\maxLogSize
static maxLogSize()
Definition: ezdebug.php:786
eZDebug\HANDLE_TO_PHP
const HANDLE_TO_PHP
Definition: ezdebug.php:77
eZDebug\writeStrict
static writeStrict( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:415
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:546
eZDebug\SHOW_ERROR
const SHOW_ERROR
Definition: ezdebug.php:69
eZDebug\$GlobalLogFileEnabled
$GlobalLogFileEnabled
Controls whether logfiles are used at all.
Definition: ezdebug.php:2036
eZDebug\isLogFileEnabled
isLogFileEnabled( $type)
Definition: ezdebug.php:964
eZDebug\$MessageNames
$MessageNames
Definition: ezdebug.php:2056
eZDebug\SHOW_WARNING
const SHOW_WARNING
Definition: ezdebug.php:68
eZDebug\createAccumulator
static createAccumulator( $key, $inGroup=false, $name=false)
Definition: ezdebug.php:1334
eZDebug\LEVEL_ERROR
const LEVEL_ERROR
Definition: ezdebug.php:62
eZDebug\XDEBUG_SIGNATURE
const XDEBUG_SIGNATURE
Definition: ezdebug.php:86
eZDebug\$recursionFlag
$recursionFlag
Definition: ezdebug.php:2054
eZDebug\alwaysLogMessage
static alwaysLogMessage( $level)
Definition: ezdebug.php:224
eZDebug\printReport
static printReport( $newWindow=false, $as_html=true, $returnReport=false, $allowedDebugLevels=false, $useAccumulators=true, $useTiming=true, $useIncludedFiles=false)
Definition: ezdebug.php:1225
eZDebug\packedToBin
static packedToBin( $packedIPAddress)
Definition: ezdebug.php:1094
eZDebug\$HandleType
$HandleType
Determines what to do with php errors, ignore, fetch or output.
Definition: ezdebug.php:2009
eZDebug\reset
reset()
Definition: ezdebug.php:175
eZDebug\$TimeAccumulatorGroupList
$TimeAccumulatorGroupList
Definition: ezdebug.php:2062
eZDebug\errorHandler
errorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:330
eZDebug\setScriptStop
static setScriptStop( $time=false)
Definition: ezdebug.php:1303
eZDebug\setUseExternalCSS
static setUseExternalCSS( $use)
Definition: ezdebug.php:655
eZDebug\$ShowTypes
$ShowTypes
Determines which debug messages should be shown.
Definition: ezdebug.php:2006
eZDebug\printTopReportsList
static printTopReportsList()
Definition: ezdebug.php:1863
eZDebug\isDebugEnabled
static isDebugEnabled()
Definition: ezdebug.php:1028
eZDebug\$TimeAccumulatorList
$TimeAccumulatorList
Array wich contains time accumulators.
Definition: ezdebug.php:2003
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:589
eZDebug\$TimePoints
$TimePoints
Array which contains the time points.
Definition: ezdebug.php:1997
eZDebug\HANDLE_EXCEPTION
const HANDLE_EXCEPTION
Definition: ezdebug.php:78
eZDebug\LEVEL_STRICT
const LEVEL_STRICT
Definition: ezdebug.php:65
eZDebug\$StoreLog
$StoreLog
Definition: ezdebug.php:59
eZDebug\$AlwaysLog
$AlwaysLog
Definition: ezdebug.php:2058
eZDebug\$bottomReportsList
$bottomReportsList
A list of debug reports that appears at the bottom of debug output.
Definition: ezdebug.php:2049
eZDebug\writeNotice
static writeNotice( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:460
eZDebug\OUTPUT_MESSAGE_STORE
const OUTPUT_MESSAGE_STORE
Definition: ezdebug.php:81
eZDebug\$ScriptStop
$ScriptStop
Definition: ezdebug.php:2043
eZDebug\$OutputFormat
$OutputFormat
An array of the outputformats for the different debug levels.
Definition: ezdebug.php:2012
eZDebug\$OverrideList
$OverrideList
A list of override directories.
Definition: ezdebug.php:2046
eZDebug\instance
static instance()
Definition: ezdebug.php:202
eZDebug\messageTypes
messageTypes()
Definition: ezdebug.php:1009
eZDebug\SHOW_TIMING_POINT
const SHOW_TIMING_POINT
Definition: ezdebug.php:70
eZDebug\setLogFileEnabled
static setLogFileEnabled( $enabled, $types=false)
Definition: ezdebug.php:943
eZDebug\HANDLE_FROM_PHP
const HANDLE_FROM_PHP
Definition: ezdebug.php:76
eZDebug\maxLogrotateFiles
static maxLogrotateFiles()
Definition: ezdebug.php:813
eZDebug\createAccumulatorGroup
static createAccumulatorGroup( $key, $name=false)
Definition: ezdebug.php:1315
eZDebug\LEVEL_WARNING
const LEVEL_WARNING
Definition: ezdebug.php:61
eZDebug\MAX_LOGROTATE_FILES
const MAX_LOGROTATE_FILES
Definition: ezdebug.php:84
eZDebug\setHandleType
static setHandleType( $type)
Definition: ezdebug.php:248
eZDebug\$UseCSS
$UseCSS
Whether to use external CSS or output own CSS. True if external is to be used.
Definition: ezdebug.php:2024
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:503
eZDebug\LEVEL_TIMING_POINT
const LEVEL_TIMING_POINT
Definition: ezdebug.php:63
eZDebug\exceptionErrorHandler
static exceptionErrorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:1987
eZDebug\$MessageOutput
$MessageOutput
Determines how messages are output (screen/log)
Definition: ezdebug.php:2027
eZDebug\$PercentAccuracy
$PercentAccuracy
How many places behind . should be displayed when showing percentages.
Definition: ezdebug.php:2021
eZDebug\__construct
__construct()
Definition: ezdebug.php:91
eZDebug\updateSettings
static updateSettings( $settings)
Definition: ezdebug.php:1133
eZDebug\setMessageOutput
setMessageOutput( $output)
Definition: ezdebug.php:664
eZDebug\appendTopReport
static appendTopReport( $reportName, $reportContent)
Definition: ezdebug.php:1854
eZDebug\$TmpTimePoints
$TmpTimePoints
Array which contains the temporary time points.
Definition: ezdebug.php:2000
eZDebug\isAllowedByCurrentIP
static isAllowedByCurrentIP( $allowedIpList)
Definition: ezdebug.php:1919
eZDebug\isIPInNetIPv6
static isIPInNetIPv6( $ipAddress, $ipAddressRange)
Definition: ezdebug.php:1076
eZDebug\setLogrotateFiles
static setLogrotateFiles( $files)
Definition: ezdebug.php:831
eZDebug\printBottomReportsList
static printBottomReportsList( $as_html=true)
Definition: ezdebug.php:1888
eZDebug\$LogFiles
$LogFiles
An array of logfiles used by the debug class with each key being the debug level.
Definition: ezdebug.php:2015
eZDebug\setIsLogFileEnabled
setIsLogFileEnabled( $type, $enabled)
Definition: ezdebug.php:984
eZDebug\messageName
messageName( $messageType)
Definition: ezdebug.php:192
eZDebug\appendBottomReport
static appendBottomReport( $reportName, $reportContent)
Definition: ezdebug.php:1876
eZDebug\setIsGlobalLogFileEnabled
setIsGlobalLogFileEnabled( $enabled)
Definition: ezdebug.php:993
eZDebug\showTypes
static showTypes( $types=false)
Definition: ezdebug.php:297
eZDebug\SHOW_NOTICE
const SHOW_NOTICE
Definition: ezdebug.php:67
eZDebug\SHOW_STRICT
const SHOW_STRICT
Definition: ezdebug.php:72
eZDebug\addTimingPoint
static addTimingPoint( $description="")
Definition: ezdebug.php:677
eZDebug\setScriptStart
static setScriptStart( $time=false)
Definition: ezdebug.php:1290
eZDebug\setStoreLog
setStoreLog( $store)
Definition: ezdebug.php:669
eZDebug\showMessage
static showMessage( $type)
Definition: ezdebug.php:215
eZDebug\LEVEL_NOTICE
const LEVEL_NOTICE
Definition: ezdebug.php:60
eZDebug\$topReportsList
$topReportsList
A list of debug reports that appears at the top of debug output.
Definition: ezdebug.php:2052
eZDebug\isDebugAllowed
isDebugAllowed()
Definition: ezdebug.php:1908
eZDebug\MAX_LOGFILE_SIZE
const MAX_LOGFILE_SIZE
Definition: ezdebug.php:83
eZDebug\$ScriptStart
$ScriptStart
The time when the script was started.
Definition: ezdebug.php:2039
eZDebug\isLogOnlyEnabled
static isLogOnlyEnabled()
Definition: ezdebug.php:1043
eZDebug\SHOW_DEBUG
const SHOW_DEBUG
Definition: ezdebug.php:71
eZDebug\OUTPUT_MESSAGE_SCREEN
const OUTPUT_MESSAGE_SCREEN
Definition: ezdebug.php:80
eZDebug\recursionProtectErrorHandler
recursionProtectErrorHandler( $errno, $errstr, $errfile, $errline)
Definition: ezdebug.php:310
eZDebug\accumulatorStart
static accumulatorStart( $key, $inGroup=false, $name=false, $recursive=false)
Definition: ezdebug.php:1362
eZDebug\write
write( $string, $verbosityLevel=self::LEVEL_NOTICE, $label="", $backgroundClass="", $alwaysLog=false)
Definition: ezdebug.php:716
eZDebug\checkDebugByUser
static checkDebugByUser()
Definition: ezdebug.php:1185
eZDebug\writeFile
writeFile(&$logFileData, &$string, $verbosityLevel, $alwaysLog=false)
Definition: ezdebug.php:879
eZDebug\logFiles
logFiles()
Definition: ezdebug.php:1018
eZDebug\setLogOnly
setLogOnly( $enabled)
Definition: ezdebug.php:1001
eZDebug\$MessageTypes
$MessageTypes
A list of message types.
Definition: ezdebug.php:2030
eZDebug\accumulatorStop
static accumulatorStop( $key, $recursive=false)
Definition: ezdebug.php:1390
eZDebug\HANDLE_NONE
const HANDLE_NONE
Definition: ezdebug.php:75
eZDebug\LEVEL_DEBUG
const LEVEL_DEBUG
Definition: ezdebug.php:64
eZDebug\$TimingAccuracy
$TimingAccuracy
How many places behind . should be displayed when showing times.
Definition: ezdebug.php:2018
eZDebug\rotateLog
static rotateLog( $fileName)
Definition: ezdebug.php:843
eZDebug\setMaxLogSize
static setMaxLogSize( $size)
Definition: ezdebug.php:804
eZDebug\printReportInternal
printReportInternal( $as_html=true, $returnReport=true, $allowedDebugLevels=false, $useAccumulators=true, $useTiming=true, $useIncludedFiles=false)
Definition: ezdebug.php:1425
eZDebug\$DebugStrings
$DebugStrings
Definition: ezdebug.php:1994
eZDebug\SHOW_ALL
const SHOW_ALL
Definition: ezdebug.php:73
eZDebug\isGlobalLogFileEnabled
isGlobalLogFileEnabled()
Definition: ezdebug.php:975
eZDebug\$OldHandler
$OldHandler
Definition: ezdebug.php:2060
eZDebug\$LogFileEnabled
$LogFileEnabled
A map with message types and whether they should do file logging.
Definition: ezdebug.php:2033
eZDebug\dumpVariable
static dumpVariable( $var)
Definition: ezdebug.php:630
eZDir\mkdir
static mkdir( $dir, $perm=false, $recursive=false)
Definition: ezdir.php:74
eZDir\path
static path( $names, $includeEndSeparator=false, $type=self::SEPARATOR_UNIX)
Definition: ezdir.php:238
eZFile\rename
static rename( $srcFile, $destFile, $mkdir=false, $flags=0)
Definition: ezfile.php:153
eZSys\serverVariable
static serverVariable( $variableName, $quiet=false)
Definition: ezsys.php:857
eZSys\isShellExecution
static isShellExecution()
Definition: ezsys.php:266
eZSys\clientIP
static clientIP()
Definition: ezsys.php:715
eZSys\varDirectory
static varDirectory()
Definition: ezsys.php:504
eZURI\transformURI
static transformURI(&$href, $ignoreIndexDir=false, $serverURL=null, $htmlEscape=true)
Definition: ezuri.php:600
$ini
$ini
Definition: classes/admin/linklist.php:64
$type
$type
Definition: classes/admin/linkselect.php:220
ezpEvent\getInstance
static getInstance()
Definition: ezpevent.php:176
$result
$result
Definition: companysearch.php:94
$desc
$desc
Definition: companytypelist.php:195
$name
$name
Definition: companytypelist.php:194
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$str
$str
Definition: ezarticle/modules/content.php:30
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$startTime
$startTime
Definition: ezcalendar/user/dayview.php:139
$stopTime
$stopTime
Definition: ezcalendar/user/dayview.php:140
$fileName
if(eZObjectPermission::hasPermission( $file->id(), "filemanager_file", "r", $user)==false) $fileName
Definition: ezfilemanager/user/filedownload.php:43
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$debug
$debug
Definition: ezstats/admin/cron.php:36
$output
$output
Definition: formpreview.php:81
$time
$time
Definition: homepage.php:327
$instance
$instance
Definition: orderedit.php:667
$header
$header
Definition: paypalnotify.php:141
$currentUserID
$currentUserID
Definition: todolist.php:128
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.