Вверх ↑
Ответов: 95
Рейтинг: 10
#1: 2010-02-09 23:16:26 ЛС | профиль | цитата
Gеnius
Потому что на хостинге есть скрытые за ненадобностью пункты настройки при загрузке, раньше были галки создать превью и т.д.... но я их скрыл за ненадобностью
Вот содержимое файла 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");
$xxx = $_REQUEST['xxx'];
$upload_url = $_REQUEST['url'];
$thumb_size = $_REQUEST['thumb_size'];
$upl = $_FILES['upl'];
if (!is_numeric($thumb_size))
die("Ошибка, размер превью должен быть числом <a href='index.php' class='text2'> Назад</a>");
if (!is_numeric($xxx) and $xxx!="")
die("Ошибка <a href='index.php' class='text2'> Назад</a>");
$ext = array("jpg", "jpeg", "JPG", "JPEG", "gif", "GIF", "png", "PNG");
$file_name=$upl['name'];
if ($upload_url!="")
$file_name=$upload_url;
if (!in_array(end(explode(".", $file_name)), $ext))
die("Это не картинка! <a href='index.php' class='text2'> Назад</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;
}

$http_url = "http://".$_SERVER['HTTP_HOST'].$http."upload_image/".$url;
$http_thumb_url = "http://".$_SERVER['HTTP_HOST'].$http."upload_image/thumb/".$url;
if (copy ($file_to_upload, "upload_image/".$url)) {
resizeimаgе("upload_image/".$url, "upload_image/thumb/".$url, $thumb_size, $thumb_size) or die("Error!");
$result = "<center><p>Ваше изображение успешно загружено <br> <a href='index.php' class='text2'> Загрузить еще</a> <br><center> <!--Frame WMbonus.org-->
<iframe src='http://www.wmbonus.org/frame.php?pid=2033' width='100' height='80' vspace='0' hspace='0' marginwidth='0' marginheight='0' scrolling='no' frameborder='0'></iframe>
<!--End Frame WMbonus.org--></center></p>";
$result .= "<a rel='lightbox' href='$http_url'><img src='$http_thumb_url' border=0></a><br><br>";
if ($xxx==1)
$result = "<p>Изображение доступно только для лиц достигших 18 лет <br> <a href='index.php' class='text2'> Загрузить еще</a></p><a rel='lightbox' 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=\"[url=".$http_url."][img]".$http_thumb_url."[/img][/url]\"><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>Прямой адрес картинки:</font><br>";
$result .= "<input class='form' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"$http_url\"><br><br> </center>";
echo $result;
}
else
die("Ошибка!)");

?>
А вот скрытые коды "куда ставится галка" в index.php


<td colspan="4" id = "settings">
<br>

<p style="font-size: 14px;"><input class="form" TYPE="text" id="thumb_size" size="5 " value="500" style="display:none"></p>
<p style="font-size: 14px;" style=" display:none "><input class="form" style="display:none" TYPE="checkbox" id="xxx" value="0" onclick="if(this.value==1) {this.value=0} else {this.value=1}"></p>
<p style="font-size: 12px;"></p>
<br>
</td>
карма: 1

0
файлы: 1code_16854.txt [399B] [126]