I get stuff like this:
PK*YI/àñûfbé readme.txt•UÙnÛ8}¶
from this code:
<?
include('dbinfo.inc.php');
$name = $_GET['id'];
$file = $_GET['file'];
$q = mysql_query("SELECT * FROM scripts WHERE name='$name' AND file='$file'") or die(mysql_error());
$r = mysql_num_rows($q);
if($r != 1) { echo "ERROR!"; } else {
extract(mysql_fetch_array($q));
$downloads++;
mysql_query("UPDATE scripts SET downloads='$downloads' WHERE name='$name'") or die(mysql_error());
$dir = '/XXXXX/XXXXX/XXXXX/XXXXX/';
$download = $dir.$file;
$ext = substr($download,-3 );
if($download == "" )
{
echo "<html><body>ERROR: Empty file to download. </body></html>";
exit;
}
elseif ( ! file_exists( $download ) )
{
echo "<html><body>ERROR: File not found.</body></html>";
exit;
};
switch( $ext )
{
case "csv": $ctype="application/octet-stream"; break;
case "xml": $ctype="application/octet-stream"; break;
case "txt": $ctype="text/plain"; break;
case "dat": $ctype="text/plain"; break;
case "zip": $ctype="application/zip"; break;
default: $ctype="application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: $ctype");
$user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
if ((is_integer (strpos($user_agent, "msie"))) && (is_integer (strpos($user_agent, "win"))))
{
header( "Content-Disposition: filename=".basename($download).";" );
}
else
{
header( "Content-Disposition: attachment; filename=".basename($download).";" );
}
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($download));
readfile("$download");
exit();
}
?>
Do anyone tell me how to get my file to DL? THANKS!