Файл: foto.php
Строк: 122
<?
///////////////////////////////////////////////////////////////////////////////
///Скрипт доски объявлений WAP ADS от BORDO |||
///Вы не имеете права на продажу данного скрипта! |||
///Купить скрипт можно только у автора связавшись по ICQ: 599733235 |||
///////////////////////////////////////////////////////////////////////////////
include ('inc/db.php');
include 'inc/functions.php';
$title = 'Загрузить фото';
include 'inc/head.php';
function foto($name_temp, $name) {
$time=time();
$mtime=microtime();
$mtime=str_replace(" ",'',$mtime);
$filename=$_SERVER['DOCUMENT_ROOT']."/temp/$time.$mtime.tmp";
move_uploaded_file($name_temp,$filename) or die('Невозможно скопировать файл');;
$info=pathinfo($name);
$rash = $info['extension'];
if(preg_match("/jpg/",$rash) OR preg_match("/JPG/",$rash) OR preg_match("/JPEG/",$rash) OR preg_match("/jpeg/",$rash))
{
$cop = imagecreatefromJpeg($filename);
}
elseif(preg_match("/png/",$rash) OR preg_match("/PNG/",$rash))
{
$cop = imagecreatefrompng($filename);
}
elseif(preg_match("/gif/",$rash) OR preg_match("/GIF/",$rash))
{
$cop = imagecreatefromgif($filename);
}
$size = getimagesize($filename);
$max_width='240';
$max_height='320';
$width=$size[0];
$height=$size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) )
{
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height)
{
$tn_height = $x_ratio * $height;
$tn_width = $max_width;
}
else
{
$tn_width = $y_ratio * $width;
$tn_height = $max_height;
}
$time=time();
$mtime=microtime();
$mtime=str_replace(" ",'',$mtime);
$filename211="$time.$mtime.jpg";
$trumb = imagecreatetruecolor($tn_width, $tn_height);
$image=imagecopyresized($trumb, $cop, 0, 0, 0, 0, $tn_width, $tn_height, $width,$height);
ImageJpeg($trumb,$_SERVER['DOCUMENT_ROOT']."/foto/$filename211",-1);
ImageDestroy($trumb);
ImageDestroy($cop);
@chmod($filaneme,0777);
@unlink($filename);
return $filename211;
}
if (!$_POST) {
?>
<div class="menu"><b>Пароль можно вводить только один раз. Поэтому сразу выбирайте сколько фото Вам надо и добавляйте их!</b>
<form action="foto.php" enctype="multipart/form-data" method="post" >
Пароль:<br/>
<input type="text" name="pass" /><br/>
Фото:<br/>
<input type="file" name="picture"><br/>
Фото 2:<br/>
<input type="file" name="picture1"><br/>
Фото 3:<br/>
<input type="file" name="picture2"><br/>
Фото 4:<br/>
<input type="file" name="picture3"><br/>
<input type="submit" value="Добавить" />
</form>
</div>
<?
} else {
$foto = $_FILES['picture']['name'];
$foto1 = $_FILES['picture1']['name'];
$foto2 = $_FILES['picture2']['name'];
$foto3 = $_FILES['picture3']['name'];
$pass = my_htmlspecialchats($_POST['pass']);
$name_tempp = $_FILES['picture']['tmp_name'];
$name1_temp = $_FILES['picture1']['tmp_name'];
$name2_temp = $_FILES['picture2']['tmp_name'];
$name3_temp = $_FILES['picture3']['tmp_name'];
$error = false;
$errort = '';
if (empty($pass))
{
$error = true;
$errort .= 'Введите пароль!<br/>';
}
$query = mysql_query("SELECT * FROM `ads` WHERE `code`='$pass' LIMIT 1");
$vip = mysql_fetch_array($query);
if (mysql_num_rows($query) == 0)
{
$error = true;
$errort .= 'Данный код не подходит!<br/>';
}
if (!empty($vip['foto']))
{
$error = true;
$errort .= 'Фото к этому объявлению уже добавленно!<br/>';
}
if (strlen($foto) == 0 AND strlen($foto1) == 0 AND strlen($foto2) == 0 AND strlen($foto3) == 0) {
$error = true;
$errort .= 'Выбирите изображение!<br/>';
}
if (strlen($foto) != 0) {
$info=pathinfo($_FILES['picture']['name']);
$rashh = $info['extension'];
if($rashh != "GIF" AND $rashh != "PNG" AND $rashh != "JPG" AND $rashh != "gif" AND $rashh != "png" AND $rashh != "jpg" AND $rashh != "jpeg" AND $rashh != "JPEG")
{
$error = true;
$errort .= 'Неправильный формат изображения!<br/>';
}
}
if (strlen($foto1) != 0) {
$info=pathinfo($_FILES['picture1']['name']);
$rashh = $info['extension'];
if($rashh != "GIF" AND $rashh != "PNG" AND $rashh != "JPG" AND $rashh != "gif" AND $rashh != "png" AND $rashh != "jpg" AND $rashh != "jpeg" AND $rashh != "JPEG")
{
$error = true;
$errort .= 'Неправильный формат изображения 2!<br/>';
}
}
if (strlen($foto2) != 0) {
$info=pathinfo($_FILES['picture2']['name']);
$rashh = $info['extension'];
if($rashh != "GIF" AND $rashh != "PNG" AND $rashh != "JPG" AND $rashh != "gif" AND $rashh != "png" AND $rashh != "jpg" AND $rashh != "jpeg" AND $rashh != "JPEG")
{
$error = true;
$errort .= 'Неправильный формат изображения 3!<br/>';
}
}
if (strlen($foto3) != 0) {
$info=pathinfo($_FILES['picture3']['name']);
$rashh = $info['extension'];
if($rashh != "GIF" AND $rashh != "PNG" AND $rashh != "JPG" AND $rashh != "gif" AND $rashh != "png" AND $rashh != "jpg" AND $rashh != "jpeg" AND $rashh != "JPEG")
{
$error = true;
$errort .= 'Неправильный формат изображения 4!<br/>';
}
}
if (!$error)
{
if (strlen($foto) != 0) {
$foto = foto($name_tempp, $foto);
}
if (strlen($foto1) != 0) {
$foto1 = foto($name1_temp, $foto1);
}
if (strlen($foto2) != 0) {
$foto2 = foto($name2_temp, $foto2);
}
if (strlen($foto3) != 0) {
$foto3 = foto($name3_temp, $foto3);
}
$query = "UPDATE `ads` SET `foto` = '{$foto}', `foto1` = '{$foto1}', `foto2` = '{$foto2}', `foto3` = '{$foto3}' WHERE `code` = '{$pass}' LIMIT 1";
$sql = mysql_query($query) or die(mysql_error());
echo '<div class="menu">Фото добавлены!</div>';
} else {
?>
<div class="menu">
Возникли следующие ошибки:<br/>
<?
print $errort;
?>
</div>
<?
}
}
include 'inc/foot.php';
?>