<?
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_mysql',null,'index.php?'.SID);
adm_check();
$set['title']='Голова бота';
include_once '../sys/inc/thead.php';
title();


echo "Всего задач в базе: ".mysql_result(mysql_query("SELECT COUNT(*) FROM `bot_tasks`"),0)."<br />\n";

if (isset($_GET['del'])){



mysql_query("DELETE FROM `bot_tasks` WHERE `id` = '$_GET[del]'");


msg('Задача успешно удалена');

}

if (isset($_GET['up_ok'])){

mysql_query("UPDATE `bot_tasks` SET `words` = '$_POST[words]', `answer` = '$_POST[answer]' WHERE `id` = '$_GET[up_ok]' LIMIT 1");

msg('Задача успешно изменена');
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `bot_tasks` "), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `bot_tasks` ORDER BY id DESC LIMIT $start, $set[p_str]");
if ($k_post==0)
{
echo "На данный момент бот ничего не знает\n";
}
while ($mem = mysql_fetch_assoc($q))
{

echo "<b>...$mem[words]...</b><br />";
echo "$mem[answer]";
echo "<a href='?up=$mem[id]&amp;page=$page'><b>[изменить]</b> </a><br />\n";
echo "<a href='?del=$mem[id]&amp;page=$page'><b>[x]</b></a><br />\n";

if (isset($_GET['up']))
{
echo "<form action=\"?up_ok=$mem[id]&amp;page=$page\" method=\"post\">";



echo "Ориентировочные слова:<br />\n";
echo "<input type='text' name='words'
value='$mem[words]' /><br />\n";



echo "Ответ бота:<br />\n";
echo "<input type='text' name='answer'
value='$mem[answer]' /><br />\n";

echo "<input value=\"Переучить бота\" type=\"submit\" />\n";
echo "</form>\n";
} echo "<center>= = = = = = = = =</center>"; }
 if ($k_page>1)str("?",$k_page,$page); // Вывод страниц

if (user_access('adm_panel_show')){
echo "<div class='foot'>\n";
echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";
}
include_once '../sys/inc/tfoot.php';
?>