Location: PHPKode > projects > H-tracker > blocks/latestuploads_block.php
<?
if (!$site_config["MEMBERSONLY"] || $CURUSER) {
begin_block("Latest Torrents");

$file = "".$site_config["cache_dir"]."/cache_latestuploadsblock.txt";
$expire = 600; // time in seconds
if (file_exists($file) &&
    filemtime($file) > (time() - $expire)) {
    $latestuploadsrecords = unserialize(file_get_contents($file));
}else{ 

	$latestuploadsquery = mysql_query("SELECT id, name FROM torrents WHERE banned='no' ORDER BY id DESC LIMIT 5")or die(mysql_error());

	while ($latestuploadsrecord = mysql_fetch_array($latestuploadsquery) ) {
        $latestuploadsrecords[] = $latestuploadsrecord;
    }
    $OUTPUT = serialize($latestuploadsrecords);
    $fp = fopen($file,"w");
    fputs($fp, $OUTPUT);
    fclose($fp);
} // end else 

if ($latestuploadsrecords){
	foreach ($latestuploadsrecords as $id=>$row) { 
				$char1 = 18; //cut length 
				$smallname = CutName(htmlspecialchars($row["name"]), $char1);
				echo "<a href='torrents-details.php?id=$row[id]'>$smallname</A><BR>\n";
		}	
}else{
	print("<CENTER>None uploaded yet</CENTER>\n");
}
end_block();
}
?>
Return current item: H-tracker