base_path}"); exit(); } $id = FALSE; if (!is_numeric(e_QUERY)) { if ($sql->db_Select("download", "download_id", "download_url='".$tp -> toDB(e_QUERY)."'")) { $row = $sql->db_Fetch(); $type = "file"; $id = $row['download_id']; } else if(strstr(e_QUERY, "http://") || strstr(e_QUERY, "ftp://" || strstr(e_QUERY, "https://"))) { header("location: ".e_QUERY); exit(); } else if(file_exists($DOWNLOADS_DIRECTORY.e_QUERY)) { send_file($DOWNLOADS_DIRECTORY.e_QUERY); exit(); } } if(strstr(e_QUERY, "mirror")) { list($action, $download_id, $mirror_id) = explode(".", e_QUERY); $download_id = intval($download_id); $mirror_id = intval($mirror_id); $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$download_id}"; if ($sql->db_Select_gen($qry)) { $row = $sql->db_Fetch(); extract($row); if (check_class($download_category_class) && check_class($download_class)) { if($pref['download_limits'] && $download_active == 1) { check_download_limits(); } $mirrorList = explode(chr(1), $download_mirror); $mstr = ""; foreach($mirrorList as $mirror) { if($mirror) { $tmp = explode(",", $mirror); $mid = intval($tmp[0]); $address = $tmp[1]; $requests = $tmp[2]; if($tmp[0] == $mirror_id) { $gaddress = trim($address); $requests ++; } $mstr .= $mid.",".$address.",".$requests.chr(1); } } $sql->db_Update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '".intval($download_id)."'"); $sql->db_Update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '".intval($mirror_id)."'"); header("Location: {$gaddress}"); exit(); } header("Location: ".e_BASE."download.php?error.{$download_id}.1"); exit; } } $tmp = explode(".", e_QUERY); if (!$tmp[1] || strstr(e_QUERY, "pub_")) { $id = intval($tmp[0]); $type = "file"; } else { $table = preg_replace("#\W#", "", $tp -> toDB($tmp[0], true)); $id = intval($tmp[1]); $type = "image"; } if (preg_match("#.*\.[a-z,A-Z]{3,4}#", e_QUERY)) { if(strstr(e_QUERY, "pub_")) { $bid = str_replace("pub_", "", e_QUERY); if (file_exists(e_FILE."public/".$bid)) { send_file(e_FILE."public/".$bid); exit(); } } if (file_exists($DOWNLOADS_DIRECTORY.e_QUERY)) { send_file($DOWNLOADS_DIRECTORY.e_QUERY); exit(); } require_once(HEADERF); $ns->tablerender(LAN_dl_61, "
"); require_once(FOOTERF); exit(); } if ($type == "file") { $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$id}"; if ($sql->db_Select_gen($qry)) { $row = $sql->db_Fetch(); if (check_class($row['download_category_class']) && check_class($row['download_class'])) { if($pref['download_limits'] && $row['download_active'] == 1) { check_download_limits(); } extract($row); if($download_mirror) { $array = explode(chr(1), $download_mirror); $c = (count($array)-1); for ($i=1; $i < $c; $i++) { $d = mt_rand(0, $i); $tmp = $array[$i]; $array[$i] = $array[$d]; $array[$d] = $tmp; } $tmp = explode(",", $array[0]); $mirror_id = $tmp[0]; $mstr = ""; foreach($array as $mirror) { if($mirror) { $tmp = explode(",", $mirror); $mid = $tmp[0]; $address = $tmp[1]; $requests = $tmp[2]; if($tmp[0] == $mirror_id) { $gaddress = trim($address); $requests ++; } $mstr .= $mid.",".$address.",".$requests.chr(1); } } $sql -> db_Update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '".intval($download_id)."'"); $sql -> db_Update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '".intval($mirror_id)."'"); header("Location: ".$gaddress); exit(); } // increment download count $sql->db_Update("download", "download_requested = download_requested + 1 WHERE download_id = '{$id}'"); $user_id = USER ? USERID : 0; $ip = $e107->getip(); $request_data = "'0', '{$user_id}', '{$ip}', '{$id}', '".time()."'"; //add request info to db $sql->db_Insert("download_requests", $request_data, FALSE); if (preg_match("/Binary\s(.*?)\/.*/", $download_url, $result)) { $bid = $result[1]; $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); $binary_data = @mysql_result($result, 0, "binary_data"); $binary_filetype = @mysql_result($result, 0, "binary_filetype"); $binary_name = @mysql_result($result, 0, "binary_name"); header("Content-type: {$binary_filetype}"); header("Content-length: {$download_filesize}"); header("Content-Disposition: attachment; filename={$binary_name}"); header("Content-Description: PHP Generated Data"); echo $binary_data; exit(); } if (strstr($download_url, "http://") || strstr($download_url, "ftp://") || strstr($download_url, "https://")) { header("Location: {$download_url}"); exit(); } else { if (file_exists($DOWNLOADS_DIRECTORY.$download_url)) { send_file($DOWNLOADS_DIRECTORY.$download_url); exit(); } else if(file_exists(e_FILE."public/{$download_url}")) { send_file(e_FILE."public/{$download_url}"); exit(); } } } else { // Download Access Denied. if((!strpos($pref['download_denied'],".php") && !strpos($pref['download_denied'],".htm") && !strpos($pref['download_denied'],".html") && !strpos($pref['download_denied'],".shtml") || (strpos($pref['download_denied'],"signup.php") && USER == TRUE) )) { header("Location: ".e_BASE."download.php?error.{$id}.1"); exit; /* require_once(HEADERF); $denied_message = ($pref['download_denied'] && !strpos($pref['download_denied'],"signup.php")) ? $tp->toHTML($pref['download_denied'],"","defs") : LAN_dl_63; $ns -> tablerender(LAN_dl_61, $denied_message); require_once(FOOTERF); exit(); */ } else { header("Location: ".trim($pref['download_denied'])); exit; } } } else if(strstr(e_QUERY, "pub_")) { /* check to see if public upload and not in download table ... */ $bid = str_replace("pub_", "", e_QUERY); if($result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '$bid' ")) { $binary_data = @mysql_result($result, 0, "binary_data"); $binary_filetype = @mysql_result($result, 0, "binary_filetype"); $binary_name = @mysql_result($result, 0, "binary_name"); header("Content-type: {$binary_filetype}"); header("Content-length: {$download_filesize}"); header("Content-Disposition: attachment; filename={$binary_name}"); header("Content-Description: PHP Generated Data"); echo $binary_data; exit(); } } require_once(HEADERF); $ns -> tablerender(LAN_dl_61, ""); require_once(FOOTERF); exit(); } $sql->db_Select($table, "*", "{$table}_id = '{$id}'"); $row = $sql->db_Fetch(); extract($row); $image = ($table == "upload" ? $upload_ss : $download_image); if (preg_match("/Binary\s(.*?)\/.*/", $image, $result)) { $bid = $result[1]; $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); $binary_data = @mysql_result($result, 0, "binary_data"); $binary_filetype = @mysql_result($result, 0, "binary_filetype"); $binary_name = @mysql_result($result, 0, "binary_name"); header("Content-type: {$binary_filetype}"); header("Content-Disposition: inline; filename={$binary_name}"); echo $binary_data; exit(); } $image = ($table == "upload" ? $upload_ss : $download_image); if (strpos($image, "http") !== FALSE) { header("Location: {$image}"); exit(); } else { if ($table == "download") { require_once(HEADERF); if (file_exists(e_FILE."download/{$image}")) { $disp = ""; } else if(file_exists(e_FILE."downloadimages/{$image}")) { $disp = ""; } else { $disp = ""; } $disp .= "