0){ while($Row = @mysql_fetch_array($GetConfig)){ $config[$Row["site_option"]] = NumToBool($Row["site_value"]); } } if($config["Site_Download"]){ $FID = addslashes($_REQUEST["ID"]); $allowed_ext = array ( 'zip' => 'application/zip', 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'exe' => 'application/octet-stream', 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo', 'deb' => 'application/octet-stream' ); set_time_limit(0); if (!isset($FID) || empty($FID) || !is_numeric($FID)) { print "ERROR - Incorrect File ID."; } else { $q = mysql_query("SELECT * from download where ID=$FID"); if(mysql_num_rows($q) == 0){ print "ERROR - File ID is incorrect!"; } else { $r = mysql_fetch_array($q); $url = $r["link"]; $hits = $r["hits"] + 1; $parts=explode("/",$url); $fname=$parts[sizeof($parts)-1]; //$file_path = str_replace("$file_to_download", "", $url); // get full file path (including subfolders) $file_path = ''; $file_path = str_replace("http://beyondgaming.org/","../",$url); //OLD = $path_to_download if (!is_file($file_path)) { print "ERROR - Could not get file"; } else { // 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)) { print "ERROR - Invalid File Extention! "; } else { // 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); } elseif (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]; } // 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=\"$fname\""); 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*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } mysql_query("UPDATE download set hits=$hits WHERE ID=$FID"); @fclose($file); } } //End ext check } //End Check For File } //End Check DB FID } //End Check for FID } else { print "Downloads are currently Disabled."; } ?>