Ups... Glemte at skrive de to scripts.
count-script:
<?php
$fil = "taellefil.txt";
if($_GET["hent"] == "hej") {
$fp = fopen("$fil", "r+");
flock($fp, 1);
$count = fgets($fp, 4096);
$count += 1;
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
}
?>
<? include("taellefil.txt");?> gange er denne fil downloadet
<a href="<? echo $_SERVER["PHP_SELF"];?>?hent=hej" onClick="window.open('
http://www.fil.dk','win1','height=300,width=290,scrollbars=yes')">Download fil</a>
Upload:
<?
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = ""; //url where files are uploaded
$absolute_path = ""; //Absolute path to where files are uploaded
$websiteurl = ""; //Url to you website
$websitename = "Start";
switch($action) {
default:
echo"
<p>
<a href=$PHP_SELF?action=upload>Upload et Billed</a>
<a href=$PHP_SELF?action=download>Download et Billed</a>
<a href=$websiteurl>Gå tilbage til $websitename</a>
<p>";
break;
case "download":
echo "
<p><a href=$PHP_SELF?action=upload>Upload et Billed</a> <a href=$websiteurl>Gå tilbage til $websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Kilk på et billede for at se det</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
//Sjovert.dk Styrer
$list .= "<tr><td width=700><a href='$dl/$file' target='_blank'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<p>";
break;
case "upload":
echo"
<form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>
<p>Vælg et Billed:<br>
<input type=file name=file size=30>
<p><button name=submit type=submit>
Upload
</button>
</form>
Fil-navnet må indeholde 0-9, a-z, ingen specialtegn eller æøå!
";
break;
//Fil Upload
case "doupload":
$dir = "dir";
if ($file != "") {
if (file_exists("$absolute_path/$file_name")) {
die("Billedet eksisterer allerede");
}
if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("Billedet er for stort. Det må højest fylde $sizebytes bytes.");
}
$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("Filen er en forkert filtype.");
}
@copy($file, "$absolute_path/$file_name") or die("Filen kunne ikke kopieres til serveren");
} else {
die("Husk at vælge et Billede");
}
echo "
<p>";
echo $file_name." blev uploaded";
echo "<br>
<a href=$PHP_SELF?action=upload>Upload et nyt Billede</a>
<a href=$PHP_SELF?action=download> Download et Billed</a>
<a href=$websiteurl> Gå tilbage til $websitename</a>
<p>";
break;
}
?>