Hey ik heb een scripje op men site voor iets te downloaden.
Het werkt zo
een link linkt naar download.php?id=
en de id is dan de download id
de bron code van die pagina is dan -->
<?php
$host = ""; //host, meestal localhost
$user = ""; //gebruikersnaam
$pass = ""; //database wachtwoord
$db = ""; //database naam
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db);
if($table==""){
$table="downloads";
}
if($_GET[id]!=""){
$sql="SELECT * FROM `$table` where id='$_GET[id]'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
}
if($count==1){
$sql="SELECT * FROM `$table` where id='$_GET[id]'";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$row[downloads]++;
$sql="Update `$table` set downloads='$row[downloads]' where id='$_GET[id]'";
$res=mysql_query($sql);
if($res){
echo "<iframe name=\"frame\"></iframe>";
echo "<script>window.open('$row[download_url]','frame');setTimeout('window.close()','500');</script>";
}
else{
$headers = "Content-type: text/html; charset=\"iso-8859-1\"\r\nfrom: [email protected]";
$to="[email protected]";
$subject="Error $_SERVER[REQUEST_URI]";
$message="There was a error downloading the file with id : $_SERVER[REQUEST_URI]";
mail($to, $subject, $message, $headers);
echo "Error: There was a error downloading the file a email was sended to the webmaster with the error information";
}}
?>
Dus hij opent pagina doet aantal downlaods plus 1
en laadt de download in een iframe en sluit het venster.
Bij mij werkt het goed, maar zal het goed werken als de server verbinding trager is en het venster te vroeg dicht gedaan word ???
744 views