sådan her ser hele filen ud:
<a href="
http://www.web-ting.dk/sim/img/hh.zip">hh</a><?$sti = 'img/'; //Sti til zip-filer
$fil = 'links.txt';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$hits = file_get_contents($fil);
$hits++;
$handle = fopen ($fil,"w");
fputs ($handle, $hits, strlen($hits));
fclose ($handle);
$URL = $sti . $id;
header('Location: '.$URL);
}else{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$zips = Vis($sti);
for ($i=0;$i<count($zips);$i++) {
$arr = explode(".", $zips[$i]);
array_pop($arr);
$adr = implode(".", $arr);
echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?id=" . $zips[$i] . "\">" . $adr . "</a><br />";
}
$hits = file_get_contents($fil);
echo "<br />Downloads: " . $hits;
}
//Hjælpefunktion list zip-filer
function Vis($dir) {
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if (substr($file,-4) == ".zip") {
$filer[] = $file;
}
}
closedir($dh);
return $filer;
} else {
return false;
}
}
?>