Jump to content

slumbermann

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

slumbermann's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi iaow, I guess, what you need to do, is to add up the code to check the session only, meaning, the url will be function only when the session true. what i would do, is just to add up another function to process the session before they can process the url...
  2. okay... i fixed the problem... after reading some articles in the net... here is the code i'm using [code=php:0] switch($_GET['action']) {     case "free": if ($_SERVER['HTTP_REFERER'] !== "http://mydomain.com/") {       header("HTTP/1.1 404 Not Found");   } $dir="/var/www/vhosts/mydomain.com/httpdocs/storage/files/"; $filename = $dir.$_GET['file']; if (isset($_REQUEST['file']) && file_exists($filename) ) { header("HTTP/1.1 200 OK"); header("Status: 200 OK"); header('Pragma: private'); header('Cache-control: private, must-revalidate'); header('Content-type: application/force-download');     header( "Content-Disposition: attachment; filename=".basename($filename)); header('Content-Length: ' . filesize($filename)); header( "Content-Description: File Transfer"); readfile($filename); } else {    echo 'No file with this name for download.'; } break;        } [/code] it was the IE bug after all... so at least this one work with my browser...
  3. actually... about the pg thing... it was for HTTP_REFERER only... from where the file requested. so the case not included on download.php like i said before... the  code do work already... only thing... it work only on Firefox and Opera browser only, but not working on Internet Explorer... i edited the case too... but seems the output still the same. I can download the file nicely using Firefox and Opera.... but not IE... is it because of the header thing?
  4. okay... i got the path to work on Firefox and Opera... but using the same code, i'm  having trouble to get the file using Maxthon or IE. this is the code i use. [code] <?php switch($_GET['op']){ case "free"; if ($_SERVER['HTTP_REFERER'] !== "http://mydomain.com/?p=download&pg=free") {           header("HTTP/1.1 404 Not Found");       }   $filename = "/var/www/vhosts/mydomain.com/httpdocs/storage/files/" . strip_tags($_GET['file']); header("Pragma: public");             header("Expires: 0");             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");             header("Content-Type: application/force-download");             header( "Content-Disposition: attachment; filename=".basename($filename));             header( "Content-Description: File Transfer");             header('Accept-Ranges: bytes');     header('Content-Length: ' . filesize($filename));     @readfile($filename); echo $filename; break; } ?> [/code] this code is in download.php i use http://mydomain.com/download.php?op=free&file=file.zip as the link to get this function. thanks a lot  up front.. p.s: I hope i'm using this forum correctly by opening old topic that reflect to my problem.
  5. [quote author=tomfmason link=topic=104071.msg414974#msg414974 date=1155473882] Thanks guys here is a copy of the working code. I have yet to add the paid case but it works just fine. [code] <?php session_start(); function getaction($action) {      switch($action) {            case "download":     function getdownload($type) {          switch($type) {   case "free":       /*This checks to see if the request for this file came from your site and if not it will through up a File not found error*/       if ($_SERVER['HTTP_REFERER'] !== "http://yoursite.com/somepage.php") {           header("HTTP/1.1 404 Not Found");       }       //this checks to see if the user is logged in or not       if (!$_SESSION['username']) {            echo "You must be a member to download this file<br />";            include("test.html");            exit;       }       $filename =  $_GET['filename'];       header("Pragma: public");                                header("Expires: 0");                                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");                                header("Content-Type: application/force-download");                                header( "Content-Disposition: attachment; filename=".basename($filename));                                header( "Content-Description: File Transfer");                                header('Accept-Ranges: bytes');      header('Content-Length: ' . filesize($filename));     @readfile($filename);              break;          }     }     getdownload($_GET['type']);            break;      } } getaction($_GET['action']);     ?>[/code] Thanks again, Tom [b]#Edit[/b] Why does the layout get all screwed up when I post it? This looks like a blind man coded it. [/quote] how can I define the location of the file using this code? cause  i can't see anything defining the location of the file. for example i want to put it in http://mydomain.com/storage/files/file.zip thanks  a lot.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.