Файл: auction/admin/index.php
Строк: 176
<?
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/adm_check.php';
include_once '../../sys/inc/user.php';
user_access('adm_menu',null,'/adm_panel/index.php?'.SID);
adm_check();
$set['title']='Админка'; // заголовок страницы
include_once '../../sys/inc/thead.php';
title();
if (isset($_POST['edit'])) {
$id = intval($_GET['id']);
$name = my_esc($_POST['edit']);
$balls = intval($_POST['balls']);
$type = trim($_POST['stype']);
$time_st = intval($_POST['time'])*3600;
$time_us = intval($_POST['time_st'])*3600;
mysql_query("UPDATE `auction` SET `name` = '$name' WHERE `id` = '$id' ");
mysql_query("UPDATE `auction_st` SET `balls` = '$balls', `type` = '$type', `time` = '$time_st', `time_st` = '$time_us' WHERE `id_auction` = '$id' ");
msg("Измененно");
}
if (isset($_POST['name']) && isset($user))
{
$name = trim($_POST['name']);
$balls = intval($_POST['balls']);
$type = trim($_POST['stype']);
$time_st = intval($_POST['time'])*3600;
if (strlen2($name)<1){
$err[]='Слишком короткое название';
}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `auction` WHERE `name` = '".my_esc($name)."' LIMIT 1"),0)!=0){
$err='Такоe название уже существует';
}
elseif(!isset($err)){
mysql_query("INSERT INTO `auction` (name, time) values('".my_esc($name)."', '$time')");
mysql_query("INSERT INTO `auction_st` (id_auction, balls, type, time) values('".mysql_insert_id()."', '$balls', '$type', '$time_st')");
msg('Аукцион успешно добавлено');
}
}
err();
aut(); // форма авторизации
if (isset($_GET['ed'])) {
$id_ed = intval($_GET['ed']);
$txt = mysql_fetch_assoc(mysql_query("SELECT * FROM `auction` WHERE `id` = '".$id_ed."' "));
$txt2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `auction_st` WHERE `id_auction` = '".$id_ed."' "));
echo '<form action = "?id='.$id_ed.'" method=post>';
echo "<br />Название: <br /> <input name="edit" value = "$txt[name] "><br />n";
echo "<br />Аукцион для модуля:<br />n";
if ($txt2['type'] == 'gift')
echo '<input type = "radio" value = "gift" name = "stype" checked>Подарки<br />';
else
echo '<input type = "radio" value = "gift" name = "stype">Подарки<br />';
if ($txt2['type'] == 'ocenka')
echo '<input type = "radio" value = "ocenka" name = "stype" checked>Оценка 5+<br />';
else
echo '<input type = "radio" value = "ocenka" name = "stype">Оценка 5+<br />';
if ($txt2['type'] == 'liders')
echo '<input type = "radio" value = "liders" name = "stype" checked>Лидеры<br />';
else
echo '<input type = "radio" value = "liders" name = "stype">Лидеры<br />';
if ($txt2['type'] == 'nevidimka')
echo '<input type = "radio" value = "nevidimka" name = "stype" checked>Невидимка<br />';
else
echo '<input type = "radio" value = "nevidimka" name = "stype">Невидимка<br />';
echo "<br />Стартовая цена (в баллах) :<br /> <input name="balls" value = "$txt2[balls]"><br />n";
echo "<br />Время действия услуги (в часах) :<br /> <input name="time_st" value = "$txt2[time_st]"> час.<br />n";
echo "<br />Время на аукцион (в часах) :<br /> <input name="time" value = "$txt2[time]"> час.<br />n";
echo '<input type = "submit" value = "Изменить"><br />';
echo "</form>n";
include_once '../../sys/inc/tfoot.php';
exit;
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `auction`"),0);
echo '<br /> Всего аукционов '.$k_post.'<br />';
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>n";
if ($k_post==0)
{
echo " <tr>n";
echo " <td class='p_t'>n";
echo "Нет добавленных аукционовn";
echo " </td>n";
echo " </tr>n";
}
echo '<form action = "?" method="POST">';
echo "<br />Название:<br /> <input name="name"><br />n";
echo "<br />Аукцион для модуля:<br />n";
?>
<input type = "radio" value = "gift" name = "stype" checked = "checked">Подарки<br />
<input type = "radio" value = "ocenka" name = "stype">Оценка 5+<br />
<input type = "radio" value = "liders" name = "stype">Лидеры<br />
<input type = "radio" value = "nevidimka" name = "stype">Невидимка<br />
<?
echo "<br />Стартовая цена (в баллах) :<br /> <input name="balls" value = "10"><br />n";
echo "<br />Время действия услуги (в часах) :<br /> <input name="time_st" value = "1"> час.<br />n";
echo "<br />Время на аукцион (в часах) :<br /> <input name="time" value = "1"> час.<br />n";
echo "<input value="Отправить" type="submit" />n";
echo "</form>n";
$txt_show=mysql_query("SELECT * FROM `auction` ORDER BY id DESC LIMIT $start, 30");
while ($txt = mysql_fetch_assoc($txt_show)) {
$auct=mysql_fetch_assoc(mysql_query("SELECT * FROM `auction_st` WHERE `id_auction` = '".$txt['id']."' "));
/*-----------зебра-----------*/
if ($num==0){
echo '<div class="nav1">';
$num=1;
}
elseif ($num==1){
echo '<div class="nav2">';
$num=0;
}
/*---------------------------*/
echo '<b>Название:</b> '.$txt['name'].' <br />';
echo '<b>Начальная цена <span style = "color:gray;">(в баллах)</span>:</b> '.$auct['balls'].' <br />';
if ($auct['type'] == 'gift')
$type = 'Подарки';
if ($auct['type'] == 'ocenka')
$type = 'Оценка 5+';
if ($auct['type'] == 'liders')
$type = 'Лидеры';
if ($auct['type'] == 'nevidimka')
$type = 'Невидимка';
echo '<b>Для модуля:</b> '.$type.' <br />';
echo '<b>Время на аукцион:</b> '.($auct['time']/3600).' час.<br />';
echo '<b>Время действия услуги:</b> '.($auct['time_st']/3600).' час.<br />';
echo "<a href='?ed=$txt[id]'><img src='img/set.png' height = 16 align = 'right'></a> <a href='delete.php?id=$txt[id]'><img src='img/delete.png' align = 'right'></a><br />";
echo " </div>n";
echo " </tr>n";
}
echo "</div></table>n";
echo '<div class = "foot"><a href="/auction/">Аукционы</a></div>';
if ($k_page>1)str('index.php?',$k_page,$page); // Вывод страниц
echo "</div>n";
include_once '../../sys/inc/tfoot.php';
?>