Ollie
{ MODERATOR }
posts: 8
last: 26-Mar-2008
TITLE: Debug Dump
DESCRIPTION: Dumps all variables to the screen
Submitted: 23-Nov-2007 23:12:09 ( 1yrs 6w 3d 7h ago ) Language: PHP (*.php *.php4 *.php5 *.phtml)
Views: 387 Lines of Code: 23 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
// CODE  
$dump_count=0;$dump_flag=0;
function dumpdata($v="GLOBALS") {
	
	if(!strstr($_COOKIE['pw'],'secret6')){
		return false; // for my eyes only
	}
	
	global $dump_count,$dump_flag;
	$skip=array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_COOKIE_VARS","HTTP_ENV_VARS","HTTP_POST_FILES","HTTP_SERVER_VARS"); // skip those

	// strangely the $_SESSION vars are never made public, but the $HTTP_SESSION_VARS are available.
	echo "<blockquote id=\"dump$dump_count\" style=\"margin:0px 18px;".($dump_flag?"display:none":"")."\">\n";
	$q="while(list(\$key,\$val) = each($".$v.") ) { ".
	" \$dump_count++; ".
	" if( \$key===0 || !in_array(\$key,\$skip) ) ".
	" echo \"<b>&#36;\$key</b> = \".@htmlspecialchars( (string) \$val).\" \".(is_array(\$val)?count(\$val)==0?\"0\":\"<a href=javascript:void((a=document.getElementById(&quot;dump\$dump_count&quot;).style).display=a.display==&quot;none&quot;?&quot;block&quot;:&quot;none&quot;)>\".count(\$val).\"</a>\":\"\").\"<br>\n\"; ".
	" if( is_array(\$val) && \$key != \"GLOBALS\"&& !in_array(\$key,\$skip) ) { ".
	" \$dump_flag=true;dumpdata( \$v.\"[\".\$key.\"]\" ); ".
	"}}";
	eval($q);
	echo "</blockquote>\n";
}