Location: PHPKode > projects > H-tracker > blocks/latestrequest_block.php
<?
begin_block("Latest Requests");

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

$latestrequestsquery = mysql_query("SELECT requests.id, requests.request, categories.name AS cat, categories.id AS catid,
categories.parent_cat AS parent_cat FROM requests INNER JOIN categories ON requests.cat = categories.id ORDER BY
requests.id DESC LIMIT 5") or die(mysql_error());

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

if ($latestrequestsrecords){
foreach ($latestrequestsrecords as $id=>$row) {
$char1 = 18; //cut length
$smallname = CutName(htmlspecialchars($row["request"]), $char1);
echo "<center><a href='reqdetails.php?id=$row[id]'>$smallname</A> in
<a href='viewrequests.php?category=$row[catid]'>" . $row[parent_cat] .": ".$row[cat]."</a><BR>\n";
}
}else{
print("<CENTER>No requests</CENTER>\n");
}
end_block();
?>
Return current item: H-tracker