PHP forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
March 2024
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Calendar Calendar

Latest topics
» Kabaddi, Kabaddi, Kabaddi, Kabaddi......PHP?
download counter EmptyFri Jul 22, 2011 1:37 pm by shyamsunder

» Thousands of Free PHP Scripts Recommended
download counter EmptyWed May 18, 2011 10:33 am by bizboy12

» PHP form validation problem?
download counter EmptyWed Jan 12, 2011 1:25 pm by simy202

» string wrap
download counter EmptySat Aug 02, 2008 2:06 pm by scvinodkumar

» retrieving current date rows
download counter EmptyTue Jul 15, 2008 3:25 am by scvinodkumar

» number in words
download counter EmptyTue Apr 29, 2008 3:10 pm by scvinodkumar

» Simple PHP Form Field Generator
download counter EmptyFri Apr 25, 2008 12:28 pm by scvinodkumar

» PHP password generator
download counter EmptyFri Apr 18, 2008 7:24 pm by scvinodkumar

» PHP Script to Extract Email Address from any text
download counter EmptyFri Apr 18, 2008 7:18 pm by scvinodkumar

Search
 
 

Display results as :
 


Rechercher Advanced Search

Affiliates
free forum
 


Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

download counter

Go down

download counter Empty download counter

Post  scvinodkumar Tue Apr 15, 2008 7:27 pm

1 <?php
2 $download_dir = 'downloads'; // the folder where the files are stored ('.' if this script is in the same folder)
3 $counter_dir = 'counters'; // the folder where your counter files are stored
4 /*
5 Save this script as download.php
6 each file to download must have a .txt-file called like "filename.ext.txt" in the 'counters' folder -
7 call the counter e.g. like this: <? include("counters/filename.pdf.txt"); ?>
8 download the file [download.php?get=name_of_file]
9 */
10 $path = $download_dir.'/'.$HTTP_GET_VARS['get'];
11 if(file_exists($path))
12 {
13 $file = fopen($counter_dir.'/'.$HTTP_GET_VARS['get'].'.txt','r+');
14 $count = fread($file,100);
15 fclose($file); // closes file
16 $count++;
17 $file = fopen($counter_dir.'/'.$HTTP_GET_VARS['get'].'.txt','w'); // opens file again with 'w'-parameter
18 fwrite($file, $count);
19 fclose($file);
20 $size = filesize($path);
21 header('Content-Type: application/octet-stream');
22 header('Content-Disposition: attachment; filename='.$HTTP_GET_VARS['get']);
23 header('Content-Length: '.$size);
24 readfile($path);
25 }else{
26 echo "<font face=$textfont size=2>";
27 echo "<center><br><br>The file [<b>$get$extension</b>] is not available for download.<br>";
28 echo "Please contact the web administrator <a href='http://www.yoursite.com</a>here";
29 }
30 ?>

scvinodkumar
Admin

Posts : 40
Join date : 2008-01-30

https://solutions.aforumfree.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum