PX : code

Dtheatre.com Headline Grabber by joe lumbroso
Download this code


<?php

$link_prefix    
=    "&nbsp;&nbsp;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(0600);

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($fpread256)));

                if ((
$buffer == "<item>") && ($items $max_items)) {
                    
$title ltrim(Chop(fgets($fpread256)));
                    
$url ltrim(Chop(fgets($fpread256)));

                    
$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.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.