$cacheTime ) { // oh it's not there okay, let's see if the xml is there if( file_exists($rssfile) && (time() - filemtime($rssfile)) < $cacheTime ) { // create new DOM... php5 baby $doc = new DOMDocument(); // load the xml cache $doc->load( $rssfile ); // set valid, we are good $valid=true; } else if( $fp= fsockopen( "rss.melative.com", 80 ) ){ // // this is just crazy... socket downloading // this bypasses the disabled URL file access // // this is IMPORANT $out = "GET /user/aloe/reflections/anime HTTP/1.1\r\n"; $out .= "Host: rss.melative.com\r\n"; $out .= "Connection: Close\r\n\r\n"; // write to the socket fwrite($fp, $out); // holds the response $txml=""; // get the response while (!feof($fp)) { $tmp = fgets($fp, 256); $txml.= $tmp; } // find the beginning and end of xml $front = strpos($txml, '')+6; $xml = substr($txml, $front, $end-$front); // don't forget the ninnies, close the socket fclose($fp); } // test if the doc is assigned if( !isset($doc) ) { // // this exception block does not work with the DOMDocument // probably since it is a module // try { // test if there is "good" rss form if( preg_match('/^<\?xml/', $xml)==1 && preg_match('/<\/rss>$/', $xml)==1 ) { // load the string $doc = DOMDocument::loadXML( $xml ); // save the rss for later if( $doc ){ $doc->save($rssfile); $valid=true; } } } catch( Exeception $e ) { // nogo $valid=false; } } // // do we have something to transform or no? // if( $valid && $doc ) { // // uses xsl the xsl file // $xsl = new DOMDocument(); $xsl->load( $xslFile ); // ooo XSL processor $proc = new XSLTProcessor(); // standard load stylesheet $proc->importStylesheet($xsl); // start buffering for xhtml cache ob_start(); // transform to output, caught by buffer $proc->transformToURI($doc,"php://output"); // the buffer $transform = ob_get_contents(); // cleanup ob_end_clean(); // save the transform cache file_put_contents($rssfile . '.html', $transform); // output echo $transform; } } else { // just use the cache echo file_get_contents($rssfile . '.html'); } ?>