| px | top | add code | search | signup | login | help |
<?php
$link_prefix = " o ";
$link_postfix = "<BR>\n";
$cache_file = "/tmp/dtheatre.com.cache";
$cache_time = 3600;
$max_items = 10;
$target = "_top";
// End of customizations
$backend = "http://www.dtheatre.com/backend.php3?xml=yes";
$items = 0;
$time = split(" ", microtime());
srand((double)microtime()*1000000);
$cache_time_rnd = 300 - rand(0, 600);
if ( (!(file_exists($cache_file))) || ((filectime($cache_file) + $cache_time - $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) ) {
$fpread = fopen($backend, 'r');
if(!$fpread) {
// echo "$errstr ($errno)<br>\n";
// exit;
} else {
$fpwrite = fopen($cache_file, 'w');
if(!$fpwrite) {
// echo "$errstr ($errno)<br>\n";
// exit;
} else {
while(! feof($fpread) ) {
$buffer = ltrim(Chop(fgets($fpread, 256)));
if (($buffer == "<item>") && ($items < $max_items)) {
$title = ltrim(Chop(fgets($fpread, 256)));
$url = ltrim(Chop(fgets($fpread, 256)));
$title = ereg_replace( "<title>", "", $title );
$title = ereg_replace( "</title>", "", $title );
$url = ereg_replace( "<url>", "", $url );
$url = ereg_replace( "</url>", "", $url );
fputs($fpwrite, "$link_prefix<A HREF=\"$url\" TARGET=\"$target\">$title</A>$link_postfix");
$items++;
}
}
}
fclose($fpread);
}
fclose($fpwrite);
}
if (file_exists($cache_file)) {
include($cache_file);
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.