Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
<?php
// http://www.cyberforum.ru/php-beginners/thread1704308.html
// Не работает скрипт скачивания картинок - PHP
-
function download_image_file($flnm) {
-
// $flnm = "files/gifk-53.gif";
// $flnm = $_SERVER["QUERY_STRING"];
if(ini_get("zlib.output_compression")) ini_set("zlib.output_compression", "Off");
$flxt = strtolower(substr(strrchr($flnm, "."), 1));
// echo "<p>flxt=". $flxt ."</p>\n";
-
-
// if(($flnm=="")||(!file_exists($flnm))){
// echo "Ошибка <i>".$flnm."</i> не найден файл."; exit;
// }
-
-
switch($flxt)
{
case 'gif':
$tpe = 'image/gif';
break;
case 'png':
$tpe = 'image/png';
break;
case 'jpg':
$tpe = 'image/jpg';
break;
default:
$tpe = 'application/force-download';
}
// echo "<p>tpe=". $tpe ."</p>\n";
-
// Запрошеный файл «gifk-53.gif» существует.
// flxt=gif
// tpe=image/gif
-
-
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: ".$tpe);
header("Content-Disposition: attachment; filename="".basename($flnm)."";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($flnm));
readfile("$flnm");
exit();
-
}
-
-
-
-
-
-
if ( isset($_GET['file']) and strlen($_GET['file'])>0 ) { // если запрошено хоть что-то
-
$need_filename = stripinput($_GET['file']); // сколькос права до слева
// echo "<p>strrpos_filename=". $strrpos_filename ."</p>\n";
// _GET['REQUEST_URI']=/download/kp.txt
// $need_filename = str_replace("/","", $need_filename );
$need_filename = preg_replace('/[^a-z0-9_\-=+,.]/', '_', $need_filename);
-
-
if (file_exists("files/".$need_filename)) {
-
// echo "<p>Запрошеный файл «<B>". $need_filename."</B>» существует.</p>\n";
// $flnm = "files/".$need_filename;
download_image_file("files/".$need_filename);
-
} else {
header("Content-type: text/html; charset=utf-8");
echo "<H2>index.php</H2>\n";
echo "<p style='font-size: 30px; background-color: rgb(255,172,172); color: black; padding: 15px; '>Запрошеный файл <br>
«<B style='color: #006600;'>". $need_filename."</B>» <br>
на сервере НЕ существует.<br>
<br>
Вернитесь на <a href='/' style='color: #0000CC;'>главную страницу</a> </p>\n";
}
-
} // ELSE СПИСОК ФАЙЛОВ
-
-
// function stripinput FROM PHP-FSUION
-
-
?>
|
Post Comment Please Login to Post a Comment.
|
|
<a href="https://php-fusion.vveb.ws/php-fusion.php?id=65&lang=en"></a>
[url=https://php-fusion.vveb.ws/php-fusion.php?id=65&lang=en][/url]
|