Просмотр поста

.
Megabit

ДоХтор, вот go.php

спойлер (+/-)
<?php


define('_IN_JOHNCMS', 1);
$headmod = 'schop';
$textl = 'Добавление товара';
require_once ("../incfiles/core.php");
require_once ("../incfiles/mp3.php");
require_once ("../incfiles/class_pclzip.php");
require_once ("../incfiles/class_upload.php");
$froot = "../tov_files";
$load = "$froot/files";
$screen = "screen";
    $loaddir = "../tov_files/files";
$miniscreen = "screen/mini";
require_once ('../incfiles/head.php');
if ($id)
{
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
        $coll = isset($_POST['coll']) ? abs(intval($_POST['coll'])) : '';
        $scena = isset($_POST['scena']) ? abs(intval($_POST['scena'])) : '';
$opis = isset($_POST['opis']) ? trim($_POST['opis']) : 'Нет описания';
$fname = $_FILES['fail']['name']; //имя файла
        $prim = isset($_POST['prim']) ? check(mb_substr($_POST['prim'], 0, 50)) : '';
        $primc = $prim;
        $ftips = format($fname);
if (empty($name)){
    
        $_SESSION['vuvod'] = 'Введите название товара<br/>';
header("location: index.php");
require_once ('../incfiles/end.php');
exit;
        
        }
        if (empty($opis)){
    
        $_SESSION['vuvod'] = 'Введите описание товара<br/>';
header("location: index.php");
require_once ('../incfiles/end.php');
exit;
        
        }
        if (empty($cena)){
    
        $_SESSION['vuvod'] = 'Введите цену товара,вы ведь не хотите его подарить!<br/>';
header("location: index.php");
require_once ('../incfiles/end.php');
exit;
        
        }
        if (empty($scena)){
    
        $_SESSION['vuvod'] = 'Введите старую цену!<br/>';
header("location: index.php");
require_once ('../incfiles/end.php');
exit;
        
        }
        
        
$fsize = $_FILES['fail']['size']; 
$sizz = $fsize / 1024;

$scrname = $_FILES['screens']['name']; 

$scrsize = $_FILES['screens']['size']; 

$scsize = GetImageSize($_FILES['screens']['tmp_name']); 
$scwidth = $scsize[0]; 

$scheight = $scsize[1];
$newname = $realtime;

$newf = md5($realtime);
$ftip = format($fname);
//////////////////////////////////
if (eregi("[^a-z0-9.()+_-]", $scrname))
{

echo "В названии изображения $scrname присутствуют недопустимые символы<br/><a href='?act=select&amp;cat=" .
$cat . "'>Повторить</a><br/>";
require_once ('../incfiles/end.php');
exit;
}
if ($fsize >= 1024 * $flsz)
{

echo "Вес файла превышает $flsz кб<br/>
<a href='?act=select&amp;cat=" . $cat . "'>Повторить</a><br/>";
require_once ('../incfiles/end.php');
exit;
}
if (eregi("[^a-z0-9.()+_-]", $fname))
{
echo "В названии файла <b>$fname</b> присутствуют недопустимые символы<br/>Разрешены только латинские символы, цифры и некоторые знаки ( .()+_- )<br /><a href='?act=select&amp;cat=" .
$cat . "'>Повторить</a><br/>";
require_once ('../incfiles/end.php');
exit;
}

if ((preg_match("/.php/i", $fname)) or (preg_match("/.pl/i", $fname)) or
($fname == ".htaccess") or (preg_match("/php/i", $newname)) or (preg_match
("/.pl/i", $newname)) or ($newname == ".htaccess"))
{
echo "Попытка отправить файл запрещенного типа.<br/><a href='?act=select&amp;cat=" .
$cat . "'>Повторить</a><br/>";
require_once ('../incfiles/end.php');
exit;
}

//загружаем превью и скрин
$handle = new upload($_FILES['screens']);
if ($handle->uploaded)
{
// Обрабатываем фото
$handle->file_new_name_body = $newname;
//$handle->mime_check = false;
$handle->allowed = array(
'image/jpeg',
'image/gif',
'image/png');
$handle->file_max_size = 1024 * $flsz;
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 320;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->process($screen);
if ($handle->processed)
{
// Обрабатываем превьюшку
$handle->file_new_name_body = $newname . '_small';
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 100;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->process($miniscreen);
if ($handle->processed)
{

$target_path = '../tov_files/files/';
//$target_path = $target_path . $fname;

   $newnamef = "$newname.$ftip";
        if ((move_uploaded_file($_FILES["fail"]["tmp_name"], "$loaddir/$newnamef")) == true) {
            $ch = $newnamef;
            @ chmod("$ch", 0777);
            @ chmod("$loaddir/$ch", 0777);
            echo "Файл загружен!<br/>";
            mysql_query("INSERT INTO `tovar` SET
                                    `name` = '" .
mysql_real_escape_string($name) . "',             
                                    `opis` = '" .
mysql_real_escape_string($opis) . "',
                `id_user` = '$id_user',
                `name_s` = '$fname',
                `name_h` = '$ch',
                `skreen` = '$newname',
                `refid` = '" . $id . "',
                `real` = '" . $realtime . "',
                `types` = '$ftip',
                `coll` = '$coll',
                `scena` = '$scena',
                `prim` = '$primc',
                `cena` = '$cena'");
                $_SESSION['vuvod'] = 'Товар успешно добавлен<br/>';
header("location: index.php?id=".$id."");
require_once ('../incfiles/end.php');
exit;                
 }
        else {
            echo "Ошибка при загрузке файла<br/>";
        }
                       
                       /*
mysql_query("INSERT INTO `tovar` SET
                                    `name` = '" .
mysql_real_escape_string($name) . "',             
                                    `opis` = '" .
mysql_real_escape_string($opis) . "',
                `id_user` = '$id_user',
                `name_s` = '$fname',
                `name_h` = '$fname',
                `skreen` = '$newname',
                `refid` = '" . $id . "',
                `real` = '" . $realtime . "',
                `types` = '$ftip',
                `coll` = '$coll',
                `scena` = '$scena',
                `cena` = '$cena'");
                $_SESSION['vuvod'] = 'Товар успешно добавлен<br/>';*/
header("location: index.php?id=".$id."");
require_once ('../incfiles/end.php');
exit;                

}
else
{
echo display_error($handle->error);
}
}
else
{
echo display_error($handle->error);
}
$handle->clean();
}

}
else
{
$_SESSION['vuvod'] = 'Ошибка,файл не существует<br/>';
header("location: index.php");
require_once ('../incfiles/end.php');
exit;
}
require_once ('../incfiles/end.php');
exit;

?>