// grabxml 0.1.2 (php) // 1-12-2001 t. pepper // yay i made this // yay i stole some of it off php.net's xml docs pages // SET THESE VARIABLES $password="nofwetuf"; $host="66.54.65.166"; $port=8080; // you can change these event handlers to do whatever // you want upon receiving the XML data. right now, they // just dump the parsed xml in as pretty a way as they can function startElement($parser, $name, $attrs) { global $depth, $lastelem; if($lastelem!='data') echo "\n"; for ($i = 0; $i < $depth[$parser]; $i++) echo " "; echo "+ $name "; $depth[$parser]++; $lastelem='start'; } function endElement($parser, $name) { global $depth, $lastelem; //echo "/$name "; if ($lastelem=='data') echo "\n"; $depth[$parser]--; } function characterData($parser, $data) { global $depth, $lastelem; $data=trim($data); if ($data) { echo $data; $lastelem='data'; } } // here we go $depth = array(); $lastelem=""; // set up html echo "\n
\n";
// connect to sc_serv
$sp=fsockopen($host,$port,&$errno,&$errstr,10);
if(!$sp) die("Could not contact $host:$port - $errstr\n");
set_socket_blocking($sp,false);
// send request
fputs($sp,"GET /admin.cgi?pass=$password&mode=viewxml HTTP/1.1\nUser-Agent:Mozilla\n\n");
// fetch response, timeout if it takes > 15s
for($i=0; $i<30; $i++) {
if(feof($sp)) break; // exit if connection broken
$sp_data.=fread($sp,31337);
usleep(500000);
}
// strip HTTP headers so all we have is XML data
$sp_data=ereg_replace("^.*<\?xml ","";
?>