<?php
/*
	DEBUG_VAR
	
	usage:    D = new DEBUG();
			D->DEBUG_VAR($var1,"var1");
	
			second parameter is optional     
	
	(c) by DATABAY AG 2001 -  [email protected]
*/
class DEBUG {
function DEBUG() {}
function debug_var2($V,$Name="") {
	
	$TYPE_COLOR = "RED";
	$NAME_COLOR = "BLUE";
	$VALUE_COLOR = "BLACK";
	$D = "";
	
	if (is_int($V)) {
		$D = "<FONT COLOR=$TYPE_COLOR><B>Integer: </B></FONT>";
		if ($Name!="") $D .= "( <FONT COLOR=$NAME_COLOR>$Name</FONT> ) ";
		$D .= " [ <FONT COLOR=$VALUE_COLOR>$V</FONT> ]";
	}
	if (is_string($V)) {
		$D = "<FONT COLOR=$TYPE_COLOR><B>String: </B></FONT>";
		if ($Name!="") $D .= "( <FONT COLOR=$NAME_COLOR>$Name</FONT> ) ";
		$D .= " [ <FONT COLOR=$VALUE_COLOR>"$V"</FONT> ]";
	}
	if (is_array($V)) {
		$D = "<FONT COLOR=$TYPE_COLOR><B>Array: </B></FONT>";
		if ($Name!="") $D .= "( <FONT COLOR=$NAME_COLOR>$Name</FONT> ) ";
		$D .= "<FONT COLOR=$VALUE_COLOR><UL>";
		while(list($key, $val) = each($V)) {
			$D .= DEBUG_VAR2($val,$key); 
		}
		$D .= "</UL></FONT>";
	}
	$D .= "<BR>";
	return($D);
}
function DEBUG_VAR($V,$Name="") {
	$D = $this->DEBUG_VAR2($V,$Name);
	$D .= "<TABLE SIZE=100% CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD><HR SIZE=1></TD><TD WIDTH=1%><FONT FACE='Verdana,arial' SIZE=1>".date("d.m.Y")." ".date("H:i:s")."</FONT></TD></TR></TABLE>";
	$alt = @file("./DEBUG_VAR.html");
	$alt[] = "";
	$alt = implode($alt,"");
	$fp = @fopen("./DEBUG_VAR.html","w");
	if ($fp=="") {
		?>
		<SCRIPT>
		alert("DEBUG_VAR need a file at\n./DEBUG_VAR.html\nto write the debug-information into.\nPlease create this file and give writeaccess.");
		</SCRIPT>
		<?php
		exit;
	} else {
		fwrite($fp,$D."\n");
		fwrite($fp,$alt);
		fclose($fp);
	}
	?>
	<SCRIPT>
		w=window.open("DEBUG_VAR.html","DEBUGVAR","WIDTH=450,HEIGHT=500,scrollbars=yes,resizable=yes");
		w.focus();
	</SCRIPT>
	<?php
}              
}
?> 
  |