All pastes #606944 Raw Edit

Perm 4

public php v1 · immutable
·published 2007-07-07 06:55 UTC
rendered paste body
<?phpswitch(isset($_POST['analyze'])) {case true:	function print_error() {    		global $parser;    		die(sprintf("XML Error: %s at line %d", xml_error_string($xml_get_error_code($parser)), xml_get_current_line_number($parser)));	}  		$filename=$_FILES['xmlfile']['name'];	$filetmpname=$_FILES['xmlfile']['tmp_name'];	$parser = xml_parser_create();	xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,1);	xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING,0);	$xmlfile = implode("", file($filetmpname));	xml_parse_into_struct($parser, $xmlfile, $d_ar, $i_ar) or print_error();	$XStart=0;	$YStart=0;	$XEnd=0;	$YEnd=0;	$Colour=array("R"=>255, "G"=>255, "B"=>255);	$ColourList=array(		"blue"=>array("R"=>0, "G"=>0, "B"=>255),		"red"=>array("R"=>255, "G"=>0, "B"=>0),		"green"=>array("R"=>255, "G"=>255, "B"=>0),		"yellow"=>array("R"=>255, "G"=>255, "B"=>0),		"white"=>array("R"=>255, "G"=>255, "B"=>255)	);	$im = @imagecreate(1000, 1000) or die("Unable to create image");		for($i=0; $i<count($i_ar['Line']); $i++) {		if($d_ar[$i_ar['Line'][$i]]['type']='open') {			for($j=$i_ar['Line'][$i]; $j<$i_ar['Line'][$i]; $j++) {				switch($d_ar[$j]['tag']) {				case 'XStart':					$XStart=$d_ar[$j]['value'];					break;				case 'YStart':					$YStart=$d_ar[$j]['value'];					break;				case 'Color':					$Colour=$ColourList[$d_ar[$j]['value']];					break;				case 'XEnd':					$XEnd=$d_ar[$j]['value'];					break;				case 'YEnd':					$YEnd=$d_ar[$j]['value'];					break;				}			}			imageline($im, $XStart, $YStart, $XEnd, $YEnd, imagecolorallocate($im, $Colour["R"], $Colour["G"], $Colour["B"]));			$XStart=0;			$YStart=0;			$XEnd=0;			$YEnd=0;			$Colour=$ColourList["white"];		}	}	$XCenter=0;	$YCenter=0;	$ArcStart=0;	$ArcExtend=0;	$Radius=0;	$Colour=$ColourList["white"];/*	for($i=0; $i<count($i_ar['Arc']); $i++) {		if($d_ar[$i_ar['Arc'][$i]]['type']='open') {			for($j=$i_ar['item'][$i]; $j<$i_ar['Arc'][$i+1]; $j++) {				switch($d_ar[$j]['tag']) {				case 'XCenter':					$XCenter=$d_ar[$j]['value'];					break;				case 'YCenter':					$YCenter=$d_ar[$j]['value'];					break;				case 'ArcStart':					$ArcStart=$d_ar[$j]['value'];					break;				case 'ArcExtend':					$ArcExtend=$d_ar[$j]['value'];					break;				case 'Radius':					$Radius=$d_ar[$j]['value'];					break;				case 'Color':					$Colour=$ColourList[$d_ar[$j]['value']];					break;				}			}			imagearc($im, $XCenter, $YCenter);		}	} */	xml_parser_free($parser);	header("Content-Type: image/png");	imagepng($im);	break;case false:?><form method="POST" enctype="multipart/form-data"><input type="file" name="xmlfile"><input type="submit" name="analyze" value="Analyze It!"></form><?php	break;}?>