Exception->getTrace() function DEBUG_S($DEBUG_LEVEL,$DESCRIPTION,$DEBUG_STRING = null,$FILE=null,$FUNCTION=null,$LINE=null) { static $debug_rand_color; if(isset($_SESSION['DEBUG'])) $SESSION['DEBUG']=$_SESSION['DEBUG']; // narzucamy zmienna session dla celowych wyzwolen DEBUG_S , bez ich koniecznego deklarowania jej jako SESSION , aby tylko raz uzyc else $SESSION['DEBUG']=null; if($DEBUG_LEVEL<0) $SESSION['DEBUG']=abs($DEBUG_LEVEL); //jezeli podamy w parametr $DEBUG_LEVEL=-3 , to funkcja dziala tak, jakby zmienna sesji byla na $_SESSION['DEBUG']=3 if (empty($SESSION['DEBUG'])) return; if ($FILE) $FILE = end(explode('/', $FILE)); if (!is_array($debug_rand_color)) { $debug_rand_color = array(); for($i=1;$i<2;$i++) { $debug_rand_color []= "#".dechex(rand(16, 64)).'00'.'00'; $debug_rand_color []= "#".dechex(rand(64, 128)).'00'.'00'; $debug_rand_color []= "#00".dechex(rand(16, 64)).dechex(rand(16, 128)); $debug_rand_color []= "#".dechex(rand(64, 128)).dechex(rand(16, 64)).dechex(rand(16, 128)); $debug_rand_color []= "#".dechex(rand(16, 64)).dechex(rand(64, 128)).dechex(rand(16, 128)); $debug_rand_color []= "#".dechex(rand(64, 128)).dechex(rand(16, 128)).dechex(rand(16, 128)); $debug_rand_color []= "#".dechex(rand(16, 64)).'00'.dechex(rand(64, 128)); $debug_rand_color []= "#".dechex(rand(64, 128)).'00'.dechex(rand(16, 128)); $debug_rand_color []= "#".dechex(rand(16, 64)).dechex(rand(64, 128)).dechex(rand(16, 128)); } } if (next($debug_rand_color)); else reset($debug_rand_color); $color = current($debug_rand_color); $dbg_trace = ''; /* if ($_SESSION['DEBUG'] > 0) { try { throw new Exception('DEBUG_S ...'); } catch (Exception $e) { $first = true; $dbg_trace_arr = $e->getTrace(); foreach ($dbg_trace_arr as $v) { $tmp_dbg_file = end(explode('/',$v['file'])); $dbg_trace .= $tmp_dbg_file.'('.$v['line'].')'.':'; if ($first) { $dbg_trace .= $DESCRIPTION; if (!$FILE) $FILE = $tmp_dbg_file; if (!$LINE) $LINE = $v['line']; $first = false; } else { $dbg_trace .= $v['function']; } $dbg_trace .= "\n"; }//end foreach } } */ if ($SESSION['DEBUG'] <= 1) { echo"\n".''."\n"; } else { if ($SESSION['DEBUG'] >= $DEBUG_LEVEL) { $_SESSION['DEBUG_BOX_ID'] = (isset($_SESSION['DEBUG_BOX_ID']))? $_SESSION['DEBUG_BOX_ID'] + 1 : 1; $js = "var a=this.nextSibling;if(a.style.display=='none'){a.style.display='';}else{a.style.display='none';}return false;"; echo'
+DEBUG'; echo':'; echo "$FILE($LINE):$FUNCTION: $DESCRIPTION"; echo'
'; echo str_replace("\n", '
', $dbg_trace); if ($DEBUG_STRING) { echo'
'; if (is_string($DEBUG_STRING)) { if($SESSION['DEBUG']==3) echo''.$DEBUG_STRING; //jezeli typ 3 to robimy normalny html else echo''.htmlspecialchars($DEBUG_STRING); } else { echo'
';
					htmlspecialchars(print_r($DEBUG_STRING));
					echo'
'; } } if($SESSION['DEBUG']>6) { echo'
'; echo"enviroment:\n".'
'; if(isset($_SERVER['REQUEST_URI'])) echo "REQUEST_URI:".$_SERVER['REQUEST_URI']."
\n"; if(isset($_SERVER['SCRIPT_NAME'])) echo "SCRIPT_NAME:".$_SERVER['SCRIPT_NAME']."
\n"; if(isset($_SERVER['SCRIPT_FILENAME'])) echo "SCRIPT_FILENAME:".$_SERVER['SCRIPT_FILENAME']."
\n"; if(isset($_SERVER['REQUEST_METHOD'])) echo "REQUEST_METHOD:".$_SERVER['REQUEST_METHOD']."
\n"; if(isset($_SERVER['QUERY_STRING'])) echo "QUERY_STRING:".$_SERVER['QUERY_STRING']."
\n"; if(isset($_SERVER['HTTP_HOST'])) echo "HTTP_HOST:".$_SERVER['HTTP_HOST']." "; if(isset($_SERVER['SERVER_ADDR'])) echo "SERVER_ADDR:".$_SERVER['SERVER_ADDR']." "; if(isset($_SERVER['SERVER_PORT'])) echo "SERVER_PORT:".$_SERVER['SERVER_PORT']."
\n"; } echo'
'."\n"; }// if($_SESSION['DEBUG']>=$DEBUG_LEVEL) } }