Размер файла: 3.3Kb
<?php
require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
include_once ('../themes/header.php');
if (isset($_GET['act'])) {
$act = check($_GET['act']);
} else {
$act = 'index';
}
if (isset($_GET['start'])) {
$start = abs(intval($_GET['start']));
} else {
$start = 0;
}
show_title('site.png', 'Выбрать x-статус');
$config['newtitle'] = 'Выбрать x-статус';
if (!is_user) redirect(BASEDIR);
switch ($act):
case 'index':
$total = DB::run() -> querySingle("SELECT count(*) FROM `x-status`;");
if ($total > 0) {
if ($start >= $total) {
$start = 0;
}
echo '<a href="#down"><img src="../images/img/downs.gif" alt="image" /></a> ';
$kolvo = 10;
$querystatus = DB::run() -> query("SELECT * FROM `x-status` ORDER BY id DESC LIMIT ".$start.", ".$kolvo.";");
while ($data = $querystatus -> fetch()) {
echo '<div class="b">';
echo '<div class="img"><img src="../images/xstatus/'.$data['image'].'" alt="x-status"></div>';
echo $data['title'];
echo '<span class="imgright"><a href="xstatus.php?act=set&id='.$data['id'].'">Выбрать</a></span>';
echo '</div>';
}
$count = DB::run() -> querySingle('SELECT count(*) FROM `user_status` WHERE login="'.$_SESSION['log'].'";');
if ($count!=0) {
echo '<form action="xstatus.php?act=del" method="post">
<span class="imgright"><input type="submit" value="Удалить статус" /></span></form>';
}
page_strnavigation('xstatus.php?', $kolvo, $start, $total);
} else {
echo '<img src="../images/img/error.gif" alt="Ошибка" />Статусы еще не добавлены. <a href="xstatus.php?act=add">Добавьте первый статус</a><br/>';
}
break;
case 'set':
if (isset($_GET['id'])) $id = abs(intval($_GET['id']));
else redirect('index.php?act=menu&'.SID);
echo '
<div class="form">
<form action="xstatus.php?act=getset" method="post" >
Подпись:<br/>
<input type="text" name="status">
<input type="hidden" name="status_id" value="'.$id.'">
<input type="submit" value="Выбрать">
</form>
</div><br/>
';
break;
case 'getset':
if (isset($_POST['status_id'])) $id = abs(intval($_POST['status_id']));
else
show_error('Ошибка!!');
if (strlen($_POST['status']) > 3 && strlen($_POST['status']) <= 100) {
$text = check($_POST['status']);
DB::run() -> query('DELETE FROM `user_status` WHERE `login`="'.$_SESSION['log'].'";');
$status = DB::run() -> query("SELECT * FROM `x-status` WHERE id=$id;");
$status = $status->fetch();
DB::run() -> query("INSERT INTO `user_status` (`login`,`img`,`text`) VALUES (?,?,?);", array($_SESSION['log'],$status['image'],$text));
$_SESSION['note'] = 'Статус успешно изменен';
redirect('index.php?act=menu&'.SID);
} else show_error('Слишком короткий или слишком длинный текст статуса');
break;
case 'del':
DB::run() -> query('DELETE FROM `user_status` WHERE `login`="'.$_SESSION['log'].'";');
$_SESSION['note'] = 'Статус успешно удален';
redirect('index.php?act=menu&'.SID);
break;
default:
redirect('index.php?act=menu&'.SID);
endswitch;
include_once ('../themes/footer.php');
?>