I got this freely available php-script to track download statistics. Simple really, it just count downloads and pass it on to a log file and another script uses that log file to display a top 10 list. So it's exactly what I need so I would really like to make this script work. But it doesn't. Of course. I have limited knowledge in php (but have learned a lot since encountering this script!). According to the author, it has been tested on Apache- and php-versions similar to mine, without problems. So I have been hesitant to actually change any code. I have tried to chmod logfile and/or whole subdirectory to 666 and 777 with no success. My own poor detective work leads nowhere and I have really tried. So I resort to the one thing I usually never do, to ask for help.
Bu bağlantı forma sahip olmalıdır:
<a href=http://www.yoursite.com/downloader/download.php?number=1&file=filename.zip>
download.php aşağıdaki gibidir:
$number = $_GET['number'];
$file = $_GET['file'];
$logfile = "ROOT DIRECTORY PATH/logfile.txt";
$array[dir_1] = "URL PATH/DOWNLOADFILESFOLDER";
$download = "dir"."_"."$number";
if ($array[$download]) {
$fp = fopen($logfile,'r');
while (!feof($fp))
{
$data[] = chop(fgets($fp,4096));
}
fclose($fp);
$fp = fopen($logfile,"w");
if (flock($fp,LOCK_EX)) {
// list and split each filename and number of downloads
foreach ($data as $lines){
list($downloads,$filename,$realname) = split("\|",$lines);
// check if file already exists and add one more download if it does
if ($filename == $file){
$downloads++;
}
if ($filename <> ""){
fputs($fp,"$downloads|$filename|$realname\r\n");
}
}
flock($fp,LOCK_UN);
}
fclose($fp);
header("Location: $array[$download]/$file");
}
However one part of the script doesn't make sense to me; where does it obtain the filename and the realname so it can be put into the logfile if the file never has been downloaded before? The list() function and the array of the directory boggles my mind a bit. Though it seems logical. If someone catches some fundamental error or have some tips on how I can continue, it would be highly appreciated.
PS. Ben yardımcı olur eğer pdf dosyalarını izlemek için çalışıyorum.
GÜNCELLEME! Tür önerisiyle ben hata raporlama koştu ve bir hata var. Hatalı komut ben kaldırıldı bunun bir hata vardı. Ben yine hata denetimi koştu ve sadece tanımsız değişkenler hakkında "Bildirimler" var. Ben hata bildirimini değişti
error_reporting(E_ALL ^ E_NOTICE);
Bundan sonra, tüm hiçbir hataları.