Файл: games/anagrama/angrm/index.php
Строк: 96
<?
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/start.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/compress.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/sess.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/home.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/settings.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/db_connect.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/ipua.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/fnc.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/adm_check.php';
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/user.php';
user_access('adm_menu',null,'/adm_panel/index.php?'.SID);
adm_check();
$set['title']='Админка'; // заголовок страницы
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/thead.php';
title();
if (isset($_POST['edit']) && isset($user)) {
$id = intval($_GET['id']);
$name = my_esc($_POST['edit']);
$name = mb_strtolower($_POST['edit'], "UTF-8");
$balls = count(preg_split("//u", $name, -1, PREG_SPLIT_NO_EMPTY));
mysql_query("UPDATE `anagramma` SET `original_text` = '$name', `balls` = '$balls' WHERE `id` = '$id' ");
msg("Измененно");
}
if (isset($_POST['name']) && isset($user))
{
$name =trim($_POST['name']);
$name = mb_strtolower($_POST['name'], "UTF-8");
$balls = count(preg_split("//u", $name, -1, PREG_SPLIT_NO_EMPTY));
if (strlen2($name)<1){$err[]='Слишком маленькое слово';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `anagramma` WHERE `original_text` = '".my_esc($name)."' LIMIT 1"),0)!=0){$err='Такоe слово уже существует';}
elseif(!isset($err)){
mysql_query("INSERT INTO `anagramma` (original_text, balls) values('".my_esc($name)."', '$balls')");
msg('Слово успешно добавлено');
}
}
err();
aut(); // форма авторизации
if (isset($_GET['ed'])) {
$id_ed = intval($_GET['ed']);
$txt=mysql_fetch_assoc(mysql_query("SELECT * FROM `anagramma` WHERE `id` = '".$id_ed."' "));
echo '<form action = "?id='.$id_ed.'" method=post>
<input name = edit type = text value = "'.$txt['original_text'].'"><br />
<input type = submit value = Изменить><br />';
include_once '../../sys/inc/tfoot.php';
exit;
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `anagramma`"),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 method="post" name='message' action="?$passgen">n";
echo "<br />Слово:<br /> <input name="name"><br />n";
echo "<input value="Отправить" type="submit" />n";
echo "</form>n";
$txt_show=mysql_query("SELECT * FROM `anagramma` ORDER BY original_text DESC LIMIT $start, 30");
while ($txt = mysql_fetch_assoc($txt_show)) {
echo "<div class = 'p_m'>";
echo $txt['original_text'].' ('.$txt['balls'].')';
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 "</table>n";
if ($k_page>1)str('index.php?',$k_page,$page); // Вывод страниц
echo "</div>n";
require_once$_SERVER['DOCUMENT_ROOT'].'/sys/inc/tfoot.php';
?>