filemtime($destination.$file)) { unlink($destination.$file); /* extract the file from the archive*/ exec("`which unzip` $source $file -d $destination",$ret_val); /* process it to add the XSL transformation reference, and grab the resulting modified content */ $content=process($destination.$file); } else { /* otherwise the extracted version is current, just read it without trying to extract from archive */ /* open XML feed file */ $fp=fopen($destination.$file,'r'); /* store all of its content */ $content=fread($fp,filesize($destination.$file)); /* close the feed file */ fclose($fp); } } else { /* just extract...the destination file does not appear to be there (first time, or otherwise deleted?) */ exec("`which unzip` $source $file -d $destination",$ret_val); /* process it to add the XSL transformation reference, and grab the resulting modified content */ $content=process($destination.$file); } /* send the correct MIME type */ header("Content-type: application/xml"); /* and output the content of the file */ echo $content; } else { /* archive file doesn't seem to exist? */ echo '

Error: feeds not available

'; } /* this pretty hacky function adds a reference to the XSL transformation to the freshly unzipped XML file */ function process($feed) { /* open plain vanilla XML feed file */ $fp=fopen($feed,'r'); /* store all of its content */ $content=fread($fp,filesize($feed)); /* close the feed file */ fclose($fp); /* define what we're looking for and the extra information we want to add */ $target=''; $payload="\n"; /* do a simple string replacement on the content */ $content=str_replace($target,$target.$payload,$content); /* now re-open it, this time to overwrite it */ $fp=fopen($feed,'w'); /* write out the modified content */ fwrite($fp,$content); /* and close the modified feed */ fclose($fp); /* and return the modified content to the function caller */ return $content; } ?>