GO ILLINI
01-03-2006, 12:34 AM
count.php
<?php
if(file_exists("$file.dat")) {
// open for reading
$fp = fopen("$file.dat", "r");
$count = fgets($fp, 1024);
$count++;
fclose($fp);
echo "There have been $count total downloads of this file.";
// open for writing
$fp = fopen("$file.dat", "w");
fwrite($fp, $count);
fclose($fp);
} else {
// create a new file
$fp = fopen("$file.dat", "w"); // open for writing
fwrite($fp, "1");
echo "There has only been one download.";
fclose($fp);
}
?>
index.php
<html>
<head>
<title>Download</title>
</head>
<body>
<h2>Downloads</h2>
<?php
if($f==ktc1-0) {
$file = "ktc1.0";
$name = "Kill the Clown 1.0";
include("count.php");
}
else {
?>
Im sorry there was some sort of error with the download<br>
<?php
if($f=="") {
echo("You didnt enter anything in");
}
else {
echo($f);
echo(" is not a valid file");
}
}
?>
It alwayse does the if. Even if $f isnt anything. So it adds one to the file even though no file was specified. Any help?
EDIT: P.S. it is passed through a static link on the files page not a form in the url(?f=file)
I havent actually made the download part yet i want to get this first.
<?php
if(file_exists("$file.dat")) {
// open for reading
$fp = fopen("$file.dat", "r");
$count = fgets($fp, 1024);
$count++;
fclose($fp);
echo "There have been $count total downloads of this file.";
// open for writing
$fp = fopen("$file.dat", "w");
fwrite($fp, $count);
fclose($fp);
} else {
// create a new file
$fp = fopen("$file.dat", "w"); // open for writing
fwrite($fp, "1");
echo "There has only been one download.";
fclose($fp);
}
?>
index.php
<html>
<head>
<title>Download</title>
</head>
<body>
<h2>Downloads</h2>
<?php
if($f==ktc1-0) {
$file = "ktc1.0";
$name = "Kill the Clown 1.0";
include("count.php");
}
else {
?>
Im sorry there was some sort of error with the download<br>
<?php
if($f=="") {
echo("You didnt enter anything in");
}
else {
echo($f);
echo(" is not a valid file");
}
}
?>
It alwayse does the if. Even if $f isnt anything. So it adds one to the file even though no file was specified. Any help?
EDIT: P.S. it is passed through a static link on the files page not a form in the url(?f=file)
I havent actually made the download part yet i want to get this first.