Jump to content

alessiaass

Members
  • Posts

    12
  • Joined

  • Last visited

alessiaass's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here is the code I found define('LOG_FILE','wait.log'); define('LOG_DOWNLOADS',true); $fname = basename($_GET['f']); if (!LOG_DOWNLOADS) die(); $f = @fopen(LOG_FILE, 'a+'); if ($f) { @fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n"); @fclose($f); } and the output 03.13.2015 8:28pm 79.106.xxx.xxx download.zip Is it possible to log downloads after link has been clicked, or add another colum if CLICK HERE has been clicked, for ex: 03.13.2015 8:28pm 79.106.xxx.xxx download.zip clicked or 03.13.2015 8:28pm 79.106.xxx.xxx download.zip skipped
  2. I want logs in a file, waitfile.log for example
  3. Is it possible to keep track of users that have clicked on the link? <?php echo "<a href=\"http://site.com/downloads/$_GET[f]\" target=\"_blank\">Click Here to start downloading</a>"; echo "Please do NOT close this page until your file starts downloading!"; echo "\n"; $url = "refresh:5; url=http://youarelazytoclick.com"; header($url) ?> I want to heve logs of user IP, date and $_GET, For example like this one: 03.13.2015 9:57am 41.36.xxx.xxx awp.rar 03.13.2015 10:00am 223.207.xxx.xxx file.rar 03.13.2015 11:44am 202.142.xxx.xxx example.rar 03.13.2015 12:05pm 82.122.xxx.xxx winter_v1.rar 03.13.2015 12:07pm 176.26.xxx.xxx ausscatter.rar 03.13.2015 12:12pm 109.95.xxx.xxx nailgun.rar 03.13.2015 12:33pm 46.63.xxx.xxx lol.rar 03.13.2015 12:51pm 71.104.xxx.xxx kingdom.zip 03.13.2015 1:10pm 92.16.xxx.xxx thunderstorm.rar Setup: Users will click on site1.com/download/download.zip will be redirected to site2.com/waitfile.php?f=site1.com/download/download.zip (.htaccess) where information will be displayed (I want logs of this page) In waitfile.php will be a CLICK HERE button and users will be redirected to site3.com/download/download.zip where download will start.
  4. Exactly like those pages, but users will be redirected with htaccess (code above) and if it could be sth like: wait file: wait.php?f=download.zip (where wait.php will search in subdirectories) and after x seconds wait.php?=download.zip redirects to download link/page which may be download.php?f=download.zip or site.com/downlaods/lol/words/download.zip
  5. I have this script in my website http://www.zubrag.com/scripts/download.php and this code in .htaccess RewriteEngine On # you can add whatever extensions you want routed to your php script RewriteCond %{REQUEST_URI} \.(doc|rar|zip|pdf)$ [NC] RewriteRule ^(.*)$ download.php?f=$1/ [L] I want users to wait 3 seconds before running script and I want them to see this message while waiting "Thanks for downloading". Users will click on www.mysite.com/download.php?f=downloadfile.zip
  6. I actually solved the security problem using this code <?php ############################################################### # File Download 1.31 ############################################################### # Visit http://www.zubrag.com/scripts/ for updates ############################################################### # Sample call: # download.php?f=phptutorial.zip # # Sample call (browser will try to save with new file name): # download.php?f=phptutorial.zip&fc=php123tutorial.zip ############################################################### // Allow direct file download (hotlinking)? // Empty - allow hotlinking // If set to nonempty value (Example: example.com) will only allow downloads when referrer contains this text define('ALLOWED_REFERRER', ''); // Download folder, i.e. folder where you keep all files for download. // MUST end with slash (i.e. "/" ) define('BASE_DIR','/home/user/downloads/'); // log downloads? true/false define('LOG_DOWNLOADS',true); // log file name define('LOG_FILE','downloads.log'); // Allowed extensions list in format 'extension' => 'mime type' // If myme type is set to empty string then script will try to detect mime type // itself, which would only work if you have Mimetype or Fileinfo extensions // installed on server. $allowed_ext = array ( // archives 'zip' => 'application/zip', // documents 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // executables 'exe' => 'application/octet-stream', // images 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', // audio 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', // video 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo' ); #################################################################### ### DO NOT CHANGE BELOW #################################################################### // If hotlinking not allowed then make hackers think there are some server problems if (ALLOWED_REFERRER !== '' && (!isset($_SERVER['HTTP_REFERER']) || strpos(strtoupper($_SERVER['HTTP_REFERER']),strtoupper(ALLOWED_REFERRER)) === false) ) { die("Internal server error. Please contact system administrator."); } // Make sure program execution doesn't time out // Set maximum script execution time in seconds (0 means no limit) set_time_limit(0); if (!isset($_GET['f']) || empty($_GET['f'])) { die("Please specify file name for download."); } // Nullbyte hack fix if (strpos($_GET['f'], "\0") !== FALSE) die(''); // Get real file name. // Remove any path info to avoid hacking by adding relative path, etc. $fname = basename($_GET['f']); // Check if the file exists // Check in subfolders too function find_file ($dirname, $fname, &$file_path) { $dir = opendir($dirname); while ($file = readdir($dir)) { if (empty($file_path) && $file != '.' && $file != '..') { if (is_dir($dirname.'/'.$file)) { find_file($dirname.'/'.$file, $fname, $file_path); } else { if (file_exists($dirname.'/'.$fname)) { $file_path = $dirname.'/'.$fname; return; } } } } } // find_file // get full file path (including subfolders) $file_path = ''; find_file(BASE_DIR, $fname, $file_path); if (!is_file($file_path)) { die("File does not exist. Make sure you specified correct file name."); } // file size in bytes $fsize = filesize($file_path); // file extension $fext = strtolower(substr(strrchr($fname,"."),1)); // check if allowed extension if (!array_key_exists($fext, $allowed_ext)) { die("Not allowed file type."); } // get mime type if ($allowed_ext[$fext] == '') { $mtype = ''; // mime type is not set, get from server settings if (function_exists('mime_content_type')) { $mtype = mime_content_type($file_path); } else if (function_exists('finfo_file')) { $finfo = finfo_open(FILEINFO_MIME); // return mime type $mtype = finfo_file($finfo, $file_path); finfo_close($finfo); } if ($mtype == '') { $mtype = "application/force-download"; } } else { // get mime type defined by admin $mtype = $allowed_ext[$fext]; } // Browser will try to save file with this filename, regardless original filename. // You can override it if needed. if (!isset($_GET['fc']) || empty($_GET['fc'])) { $asfname = $fname; } else { // remove some bad chars $asfname = str_replace(array('"',"'",'\\','/'), '', $_GET['fc']); if ($asfname === '') $asfname = 'NoName'; } // set headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: $mtype"); header("Content-Disposition: attachment; filename=\"$asfname\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); // download // @readfile($file_path); $file = @fopen($file_path,"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } // log downloads if (!LOG_DOWNLOADS) die(); $f = @fopen(LOG_FILE, 'a+'); if ($f) { @fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n"); @fclose($f); } ?> Now i have everything i need, But, is there any way to download file by clicking "DOWNLOAD HERE" and start downloading? because this script downloads file automatically.
  7. When i click on direct link www.mysite.com/downloads/download.zip I get this error Warning: fopen(downloadsdownload.zip): failed to open stream: No such file or directory in /home/username/public_html/gamefiles/download.php on line 11 So, there is no / . when i click on www.mysite.com/downloads/download.php?download_file=download.zip file starts downloading. Here is htaccess RewriteEngine On # you can add whatever extensions you want routed to your php script RewriteCond %{REQUEST_URI} \.(doc|zip|pdf)$ [NC] RewriteRule ^(.*)$ /download.php?download_file=$1/ [L] and here is download.php <?php sleep(3); ignore_user_abort(true); set_time_limit(0); // disable the time limit for this script $path = ""; // change the path to fit your websites document structure $dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '', $_GET['download_file']); // simple file name validation $dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters $fullPath = $path.$dl_file; if ($fd = fopen ($fullPath, "r")) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "pdf": header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a file download break; // add more headers for other content types here default; header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); break; } header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd); exit; EDITED: Found out that if I click on www.mysite.com/downloads/download.php?download_file=downloads/download.zip gives the above error.
  8. Yes, i want for advertising purposes. But users will click in direct link, then they will be redirected in wait time and advertisement page, after x seconds download button appears. I cant make a php, html wait time page for every file. there will be thousands of files in site.com/directory/downloads . And every user who clicks in any file inside this folder or any subfolder (site.com/directory/downloads/movie/horror/archive.zip) will see ads and after sometime he will download file.
  9. Well, first stackoverflow is good, but i dont get the download-file.php and where should .htaccess file should be. And how to make it for 3 seconds. Can i do it with 3 html files where: 1st file: <html> <head> <title>Redirect</title> </head> <body style="background-color:cyan;"> <a href="zz.html">Click here to download file</a> </body> </html> 2nd file <meta http-equiv="refresh" content="5;URL=zzz.html" /> <html> <head> <title>Waiting</title> </head> <body style="background-color:pink;"> Wait 5 seconds before download the file (in the meantime, enjoy our publicity) </body> </html> 3rd file <html> <head> <title>Downloading</title> <script type="text/javascript"> setTimeout( "window.location='myfile'",1000 ); </script> </head> <body style="background-color:yellow;"> Downloading </body> </html> and if yes, how can i get filename a user requested?
  10. Is there any way that every user must wait before clicking on a direct link. For example, they click on mysite.com/downloads/file.zip . With no modification, file.zip will start downloading. But i want to redirect users to a wait time page. And I want this to be on every file inside a folder. For example, I want all files inside public_html/directory/downlaods to have wait time and not affect other files in public_html/directory or public_html/.
  11. Hello, I have submitted a mirror for free to a gaming website, and website is allowed to upload files without my permission, but since its free, and mirror users can download directly from my mirror. Can it be possible to redirect them to a php page before downloading. Like "Please wait x seconds before starting downloading"
×
×
  • 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.