Smolik

Рейтинг
1
Регистрация
17.01.2010

Уважаемые модераторы! Прошу удалить эту тему!

Просто понимаете.. я начинающий.. пока еще плохо разбираюсь. Помогите пожалуйста вставить данный скрипт в мой файл upload.php. Вот его содержимое:

<?php
require_once "lib/JsHttpRequest.php";
function resizeimаgе($filename, $newfile, $newwidth, $newheight) {
$exp=strrchr($filename, ".");
list($width, $height) = getimagesize($filename);
if($width > $height && $newheight < $height){
$newheight = $height / ($width / $newwidth);
} else if ($width < $height && $newwidth < $width) {
$newwidth = $width / ($height / $newheight);
} else {
$newwidth = $width;
$newheight = $height;
}

$thumb = imagecreatetruecolor($newwidth, $newheight);
if ($exp==".jpg" or $exp==".JPG" or $exp==".jpeg" or $exp==".JPEG")
$source = imagecreatefromjpeg($filename);
if ($exp==".png" or $exp==".PNG")
$source = imagecreatefrompng($filename);
if ($exp==".gif" or $exp==".GIF")
$source = imagecreatefromgif($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $newfile);
return true;
imagedestroy($thumb);
imagedestroy($source);
}
$JsHttpRequest =& new JsHttpRequest("windows-1251");
include("admin/config.php");
include ("lang/".$language."/language.php");
$xxx = $_REQUEST['xxx'];
$upload_url = $_REQUEST['url'];
$thumb_size = $_REQUEST['thumb_size'];
$upl = $_FILES['upl'];
if (!is_numeric($thumb_size))
die($lerror1." <br> <a href='index.php' class='text1'>".$nazi."/a>");
if (!is_numeric($xxx) and $xxx!="")
die($lerror2." <a href='index.php' class='text1'> ".$nazi."</a>");
$ext = array("jpg", "jpeg", "JPG", "JPEG", "gif", "GIF", "png", "PNG", "ico", "bmp");
$file_name=$upl['name'];
if ($upload_url!="")
$file_name=$upload_url;
if (!in_array(end(explode(".", $file_name)), $ext))
die($lerror3." <a href='index.php' class='text1'> ".$nazi."</a>");
$file_name=md5(time().rand().time());
if ($upload_url!="")
$file_ext=explode(".", $upload_url);
else
$file_ext=explode(".", $upl['name']);
if ($xxx==1)
$url = $file_name."_xxx.".end($file_ext);
else
$url = $file_name.".".end($file_ext);
$http_url = explode("/", $_SERVER['REQUEST_URI']);
foreach($http_url as $key => $val) {
if (end($http_url)!=$val)
$http .= $val."/";
}
$file_to_upload = $upl['tmp_name'];
if (isset($upload_url)){
$file_to_upload = $upload_url;
}

include("admin/config.php");
if($js==1)
{
$jsc="rel='lightbox'";
}
else
{
$jsc="";
}

$http_url = "http://".$_SERVER['HTTP_HOST'].$http."imgs/".$url;
$http_thumb_url = "http://".$_SERVER['HTTP_HOST'].$http."imgs/thumb/".$url;
if (copy ($file_to_upload, "imgs/".$url)) {
resizeimаgе("imgs/".$url, "imgs/thumb/".$url, $thumb_size, $thumb_size) or die("Error!");
$result = "<center><p>".$lyzezagry." <br> <a href='index.php' class='text1'> ".$leve."</a></p>";
$result .= "<div style=' background: #FAFCFE; border: 1px dotted #000; color: #465584; padding: 2px; width: 98%;'><a ".$jsc." href='$http_url'><img src='$http_thumb_url' border=0></a></div><br><br>";
if ($xxx==1)
$result = "<p>Изображение доступно только для лиц лет <br> <a href='index.php' class='text1'> Загрузить еще</a></p><a ".$jsc." href='$http_url'><img src='$http_thumb_url' border=0></a><br><br>";
$result .= "<font>BBCode:</font><br>";
$result .= "<input class='form' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"\"><br><br>";
$result .= "<font>BBCode (".$bbcode.") :</font><br>";
$result .= "<input class='form' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"\"><br><br>";
$result .= "<font>HTML:</font><br>";
$result .= "<input class='form' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"<a href='$http_url' target=_blank><img src='$http_thumb_url' border=0></a>\"><br><br>";
$result .= "<font>".$ladressiii.":</font><br>";
$result .= "<input class='form' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"$http_url\"><br><br> </center>";
echo $result;
}
else
die($lerror2);

?>

Буду очень благодарен!

'[umka:
;6157506']Отдавать файлы не напрямую клиенту, а через скрипт.
Чтобы не грузить базу данных, скрипт ставит запрошенным файлам дату mtime на текущую.
Периодически удаляете файлы со временем mtime, старее определенного.

мм.. А где я могу взять такой скрипт?