Просмотр файла panel/status.php

Размер файла: 2.8Kb
<?php
// by Mike O. (mides), coolcms.org

require_once '../includes/sys.php';
require_once '../includes/auth_a.php';
require_once '../includes/header.php';

if (!access(3)) {
    redirect(HTTPHOME);
}

switch ($act) {
	default:
		echo '<div class="title"><a href="./">АДМ</a>&raquo; Статусы</div><div class="body">';
		note();
				
		$status_r = mysql_query("SELECT * FROM `status` ORDER BY `min_karma` DESC");
		while ($status = mysql_fetch_assoc($status_r)) {
			echo '<a href="?act=edit&amp;id='.$status['id'].'"><b>'.$status['name'].'</b> (min: '.$status['min_karma'].', max: '.$status['max_karma'].'</a>)<br />';
		}
		echo '<br />
		<form action="?act=add" method="post" name="form">
		Название:<br /><input name="name" type="text" maxlength="50" /><br />
		Статус, если карма от:<br /><input name="min_karma" type="text" size="5" /> и до <input name="max_karma" type="text" size="5" /><br />
		<input name="submit" type="submit" value="Ok" />
		</form>
		<br />
		<a href="./">В админку</a></div>';
	break;
	
	case 'add':
		if (!empty($_POST['name'])) {
			$name = check($_POST['name']);
			$min_karma = intval($_POST['min_karma']);
			$max_karma = intval($_POST['max_karma']);
			mysql_query("INSERT INTO `status` SET `name` = '$name', `min_karma` = '$min_karma', `max_karma` = '$max_karma'");
			$_SESSION['note'] = 'Добавлено';
		}
		redirect('?');
	break;
	
	case 'edit':
		$status = mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id` = '$id'"));
		if ($status['id']) {
			if ($ok) {
				if (!empty($_POST['del'])) {
					mysql_query("DELETE FROM `status` WHERE `id` = '$id'");
				} else {
					$name = check($_POST['name']);
					$min_karma = intval($_POST['min_karma']);
					$max_karma = intval($_POST['max_karma']);
					mysql_query("UPDATE `status` SET `name` = '$name', `min_karma` = '$min_karma', `max_karma` = '$max_karma' WHERE `id` = '$status[id]'");
				}
				redirect('?');
			} else {
				tp('Ред-ть');
				echo '<div class="body">';
				note();
				echo '<form name="form" action="?act=edit&amp;id='.$id.'&amp;ok=1" method="post" name="form">
				Название(max50):<br /><input name="name" type="text" value="'.$status['name'].'" maxlength="50" /><br />
				Статус, если карма от:<br /><input name="min_karma" type="text" value="'.$status['min_karma'].'" size="5" /> и до <input name="max_karma" type="text" value="'.$status['max_karma'].'" size="5" /><br />
				<input name="del" type="checkbox" value="1" /> удалить<br />
				<input name="submit" type="submit" value="Ok" />
				</form>';
				nav('?');
			}
		} else {
			redirect('?');
		}
	break;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

require_once '../includes/tail.php';
?>