Results 1 to 9 of 9

Thread: download page with anti-hotlinking and track counter.. not working..

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default download page with anti-hotlinking and track counter.. not working..

    I am trying to make a custom download page. Seems pretty simple. A link on my HTML page (index.html) that goes to a php page that is supposed to auto download the file. But it's not working.

    Here are the scripts:

    downloads.php
    PHP Code:
    <?php
    /*
    This download script can send an email and/or log the download
    There are two variables below - one for the email address and one for a download log file
    Set both vraiables to the values you want
    If you do not want either an email or log entry, comment out the respective line
    So for example of you do not want an email sent, put a // in front of the $emailAddress line - same for the $downloadLogFile line
    */
    //$emailAddress = "mail@yourdomain.com";
    $downloadLogFile "downloads.dat";
    $directory "/FrozenCoyoteLabs/Flash/Programs";    // the relative directory that has the downloads - can be ./ for the current directory
    putenv('TZ=EST5EDT'); // eastern time
    // nothing should be changed below this line
    $filename $_GET['file'];
    $path "$directory$filename";
    if(
    file_exists($path) AND substr_count($filename,"/") == "0") {
      
    header("Content-type: application/octet-stream"); 
      
    header("Content-Disposition: attachment; filename=$filename"); 
      
    header("Content-Length: ".filesize($path));
      
    readfile("$path");
      if (isset(
    $emailAddress)) {
        
    $message "File name: " $filename "\n\n";
        
    $message .= "Time of the download: " date(" F d h:ia") . "\n\n";
        
    $message .= "Browser: " $_SERVER['HTTP_USER_AGENT'] . "\n\n";
        
    $message .= "Page Requested: " $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n\n";
        
    $message .= "Referer: " $_SERVER['HTTP_REFERER'] . "\n\n";
        
    $message .= "IP Address: "$_SERVER['REMOTE_ADDR'] . "\n\n";
        
    $message .= "Hostname: " gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n\n";
        
    mail($emailAddress,"Download notification",$message"From: Website <>");
      }
      if (isset(
    $downloadLogFile)) {
        
    $downloadLogRecord $filename "||" $_SERVER['REMOTE_ADDR'] . "||" gethostbyaddr($_SERVER['REMOTE_ADDR']) . "||" date('Y-m-d H:i:s') . "\r\n";
        
    $file_pointer fopen($downloadLogFile,"a");
        
    fwrite($file_pointer,$downloadLogRecord);
        
    fclose($file_pointer);
      }
    }
    ?>

    Now when I go to this page through the html link i get "download.php?file=filename.zip" in the URL. but it's a blank page with "done" in the status bar and filename.zip does not download. ideas?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    What if you put an extra slash at the end of this line:

    Code:
    $directory = "/FrozenCoyoteLabs/Flash/Programs/";    // the relative directory that has the downloads - can be ./ for the current directory
    That would be the only thing that I can think of.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Tried that. it started that way. Same thing. I have also done absolute URLs and ./ directories and everything.

    Perhaps it helps to mention this is NOT at root: /public_html/files here <~~ no

    instead, they are in folders in folders in folders...

    /public_html/1stfolder/2ndfolder/3rdfolder/files here <~~ yes

    Maybe that has something to do with it?

    I feel I am missing something easy as well...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Try removing the first slash:

    PHP Code:
    $directory "FrozenCoyoteLabs/Flash/Programs"
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Nope.. doesn't work either. I even just tried redoing the whole thing in the /root/ folder instead of 3 levels down and it still didn't do anything. No errors, no log created no file downloaded.

    I guess I will have to make my own. I think I would like that anyway.. make it more "me" more personal.. more annoying.. yeah... that's what I'll do.

    Edit:
    Of course I just made us ALL look stupid. This is the hint to actually READ the comment tags. (//relative path...) should be /home/usr/server/path/to/file/

    God I feel like an idiot!
    Last edited by BLiZZaRD; 11-05-2007 at 02:51 PM.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <?php
    
    $pages = Array(
    
    
    'myzipfile.zip' => 'zipfiles/yourfilehere.zip',
    
    'error' => 'index.php',
    
    );
    
    if (isset($_GET['page']) && array_key_exists($_GET['page'],$pages)) {
       include($pages[$_GET['page']]);
    }
    ?>
    you can change the page to like zip
    mydomain.com/index.php?zd=yourfile.zip
    this should work, try using arrays.. in a away then when the array is clicked have it put a counting system or something whatever you are trying to do,
    also, I am a beginner dso i dont know how if this will work
    Hey new design new look, goto xudas for personal webdsign help.. (:

  7. #7
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post

    Of course I just made us ALL look stupid. This is the hint to actually READ the comment tags. (//relative path...) should be /home/usr/server/path/to/file/

    God I feel like an idiot!
    thats not as uncommon as you think. I have had this "brain fart" if you will a couple times before

  8. #8
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Quote Originally Posted by insanemonkey View Post
    Code:
    <?php
    
    $pages = Array(
    
    
    'myzipfile.zip' => 'zipfiles/yourfilehere.zip',
    
    'error' => 'index.php',
    
    );
    
    if (isset($_GET['page']) && array_key_exists($_GET['page'],$pages)) {
       include($pages[$_GET['page']]);
    }
    ?>
    you can change the page to like zip
    mydomain.com/index.php?zd=yourfile.zip
    this should work, try using arrays.. in a away then when the array is clicked have it put a counting system or something whatever you are trying to do,
    also, I am a beginner dso i dont know how if this will work
    You can't include a ZIP file.
    (Well, unless you want complete rubbish appearing on your screen)
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    readfile() sends that directly to the output buffer.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •