File size: 1.83Kb
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Добавление картинки';
include_once '../sys/inc/thead.php';
title();
if($user['level']<2)header("Location: index.php");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `prikol_img` WHERE `act`<'2'"),0)!=0)header("Location: index.php");
if (isset($_GET['act']) && $_GET['act']=='upload')
{
if (!isset($_FILES['file']))$err[]='Ошибка при выгрузке файла';
else
{
$file=esc(stripcslashes(htmlspecialchars($_FILES['file']['name'])));
$file=preg_replace('(\#|\?)', NULL, $file);
$ras=strtolower(preg_replace('#^.*\.#', NULL, $file));
$rasss=explode(';','jpg;png;jpeg;gif');
$ras_ok=false;
for($i=0;$i<count($rasss);$i++)
{
if ($rasss[$i]!=NULL && $ras==$rasss[$i])$ras_ok=true;
}
if (!$ras_ok)$err='Неверное расширение файла';
}
if (!isset($err))
{
mysql_query("INSERT INTO `prikol_img` (`name`) VALUES ('$file')");
copy($_FILES['file']['tmp_name'], H."prikol_img/img/$file");
chmod(H."prikol_img/img/$file", 0666);
header("Location: index.php");
}
}
err();
echo "<form class='foot' enctype=\"multipart/form-data\" action='?act=upload' method=\"post\">
Файл:<br />
<input name='file' type='file' /><br />
<input class=\"submit\" type=\"submit\" value=\"Добавить\" /><br />
*Разрешается выгружать файлы форматов: jpg;gif;jpeg;png<br />
«<a href='index.php'>Отмена</a><br />
</form>";
include_once '../sys/inc/tfoot.php';
?>