\n"; }else if($name=="PLAYEDAT"){ $in_date=1; $rssOutput.=" "; }else if($name=="TITLE"){ $rssOutput.=" "; } $lastelem='start'; } function endElement($parser, $name) { global $lastelem,$in_date,$rssOutput,$streamurl; if($name=="SONG"){ $rssOutput.= " </item>\n"; }else if($name=="PLAYEDAT"){ $in_date=0; $rssOutput.= "</pubDate>\n"; }else if($name=="TITLE"){ $rssOutput.= "\n"; $rssOutput.= " $streamurl\n"; //add any other item specific elements here } } function characterData($parser, $data) { global $lastelem,$in_date,$rssOutput,$lastModifiedTimeStamp; $data=trim($data); if ($data) { if($in_date){ if($lastModifiedTimeStamp==0){ $lastModifiedTimeStamp=$data; } $data = date('r',$data); } $rssOutput.= htmlspecialchars($data); $lastelem='data'; } } // here we go $lastelem=""; // connect to sc_serv error_reporting(0); $sp=fsockopen($host,$port,&$errno,&$errstr,20); if(!$sp){ //hide error output from non-hax0rs $rssOutput=""; }else{ set_socket_blocking($sp,false); // send request fputs($sp,"GET /admin.cgi?pass=$password&mode=viewxml&page=4 HTTP/1.1\nUser-Agent:Mozilla\n\n"); while (!feof($sp)) { $sp_data.=fgets($sp, 1024); } // strip HTTP headers so all we have is XML data $sp_data=ereg_replace("^.*<\?xml ","", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); /* Feel free to edit things below here. This is the output. However, try not to break the RSS compliance. http://blogs.law.harvard.edu/tech/rss */ } // close up rss //provide header so this is interpreted as xml header( "Content-Type: text/xml" ); header( "Last-Modified: ".gmdate('r',$lastModifiedTimeStamp)); header( "ETag: \"".gmdate('r',$lastModifiedTimeStamp)."\""); // set up rss echo "\n"; echo "\n"; echo " \n"; // add aditional tags here if you'd like // see http://blogs.law.harvard.edu/tech/rss for specifications echo " ".htmlspecialchars($streamtitle)."\n"; echo " ".htmlspecialchars($streamdescription)."\n"; echo " $homelink\n"; echo " $email\n"; echo " SHOUTcast\n"; echo " ",date('r',$lastModifiedTimeStamp),"\n"; echo " en-us\n"; echo $rssOutput; echo " \n"; ?>