delirious1230 Posted October 13, 2008 Share Posted October 13, 2008 I have problem with filesize 0 of file i want to download... i got script that direct downloads etc ... and than i have htacces file that check user how much he downloaded yet, i think i have all headers for download included, but dont know what would be wrong, if anyone can help me with this, please do ... here is file htacces: IndexIgnore */* RewriteEngine on RewriteRule (.*)(ace|avi|bin|bmp|doc|exe|gif|iso|jpg|mid|mp3|mpg|pdf|png|ppt|rar|txt|ttf|wav|xls|zip)$ /downloads/download.php?file= [QSA] downloader.php <? require "../include/down.php"; // Get File Name, IP Address Today's Date $file = $_GET['file']; $ip = addslashes($_SERVER['REMOTE_ADDR']); $todaysdate = date("Y-m-d"); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } //////////////////////////////////////// if(isset($_GET['file'])){ // SETTING MY OWN VARIABLES include("sets.php"); //$filex = filesize($file); //$path = addslashes($_SERVER['REQUEST_URI']); // DB connect $con = mysql_connect($hostName, $userName, $password); mysql_select_db($databaseName,$con); // Retrieve data $query = "SELECT ipaddress,lastaccess,download,filepath FROM download WHERE ipaddress='".$ip."' AND lastaccess='".$todaysdate."'"; $result = mysql_query($query,$con)or die(mysql_error()); if(is_resource($result)) { // CHECK FOR MAXDOWNLOADS if(mysql_num_rows($result)>=1){ $data = mysql_fetch_assoc($result); if($data['download']>=$max_downloads) { header( 'Location: ../limited.php' ) ; } else { @mysql_query("UPDATE download SET filepath='".$data['filepath'].",".$file."' ,download=".($data['download']+1)); downLoadFile($file); } } else { // If no results, input new IP & DATE @mysql_query("INSERT INTO download (ipaddress,lastaccess,download,filepath) VALUES('".$ip."','".$todaysdate."',1,'".$file."')"); downLoadFile($file); } } else { echo "<b>No resource</b>"; } // store the record into $row } else { echo "<b>You dont have permmision to download file!</b>"; } function downLoadFile($file){ header("Cache-control: private"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-length:".filesize($file).""); header("Content-Type: application/zip"); header("Content-Transfer-Encoding: binary"); readfile($file); header($headerStr); } ?> I hope i told good enough, thanks in advance... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.