Файл: public_html/znachki/admin.php
Строк: 101
<?php
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';
only_reg();
if ($user['level'] < 4)
{
header("Location: /index.php?.SID");
exit;
}
$zn=mysql_fetch_array(mysql_query("select * from `znachki` where `id`='".intval($_GET['znachki'])."';"));
$set['title']="Иконки(Админка)";
include_once '../sys/inc/thead.php';
title();
aut();
if (isset($_GET['add']) && isset($_FILES['file_f']) && ereg('.', $_FILES['file_f']['name']))
{
$file=esc(stripcslashes(htmlspecialchars($_FILES['file_f']['name'])));
$ras=strtolower(eregi_replace('^.*.', NULL, $file));
if (!imagecreatefromstring(file_get_contents($_FILES['file_f']['tmp_name'])))$err='Неверное изображение';
if (!isset($err))
{
$url='';
mysql_query("INSERT INTO `znachki` (`url`) values('$url')");
echo"".mysql_error()."";
$file_id=mysql_insert_id();
copy($_FILES['file_f']['tmp_name'], H.'znachki/images/'.$file_id.'.'.$ras.'');
@chmod(H."znachki/images/$file_id.$ras",0777);
mysql_query("UPDATE `znachki` SET `url` = '/znachki/images/$file_id.$ras' WHERE `id` = '$file_id'");
msg('Иконка Добавлена');
}
}
elseif (isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `znachki` WHERE `id` = '".intval($_GET['delete'])."'"),0))
{
$item = mysql_fetch_array(mysql_query("SELECT * FROM `znachki` WHERE `id` = '".intval($_GET['delete'])."'"));
mysql_query("DELETE FROM `znachki` WHERE `id` = '".intval($_GET['delete'])."' LIMIT 1");
@unlink(H."/znachki/images/$item[id].png");
@unlink(H."/znachki/images/$item[id].jpg");
@unlink(H."/znachki/images/$item[id].gif");
msg('Иконка Удалена');
}
err();
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `znachki` "),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if($k_post==0)
{
echo "<div class='p_t'>n";
echo "Нету иконок";
echo " </div>n";
}
$quer = mysql_query("select * from `znachki` ORDER by `id` DESC LIMIT $start, $set[p_str];");
while ($item = mysql_fetch_array($quer)){
if ($num==1)
{
echo "<div class='rowdown'>n";
$num=0;
}
else
{
echo "<div class='rowup'>";
$num=1;
}
echo "<div class='p_m'><center><img src ='$item[url]' alt='' /></center><br />n";
echo "<a href='?delete=$item[id]&page=$page'>[Удалить]</a></div>";
echo "</div>";
}
echo"</table>";
if ($k_page>1)str("?znachki=$zn[id]&",$k_page,$page);
echo "<form method='post' enctype='multipart/form-data' action='?znachok&add'>n";
echo "- Изображение:<br />n<input name='file_f' type='file' /><br />n";
echo "<input value="Добавить" type="submit" />n";
echo "</form>n";
echo "<div class='foot'>n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
?>