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

Размер файла: 4.56Kb
<?php
// by mides, 1da.su

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

if ($u['access'] < 3) {
	header('location: ./');
}

switch ($_GET['act']) {
	default:
		tp('Пользователи');
		if ($_SESSION['info']) echo '<b><u>'.$_SESSION['info'].'</u></b><br />'; unset($_SESSION['info']);
		$count_users = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users`"), 0);
		$pages = ceil($count_users / $config['onpage']);
		$page = intval($_GET['p']) ? abs(intval($_GET['p'])) : 1;
		$from = ($page - 1) * $config['onpage'];
		
		$users_r = mysql_query("SELECT `id`, `karma` FROM `users` ORDER BY `karma` DESC LIMIT $from, $config[onpage]");
		while ($user = mysql_fetch_assoc($users_r)) {
			echo '<a href="../profile.php?id='.$user['id'].'">'.login($user['id']).'</a> (<a href="?act=edit&amp;id='.$user['id'].'">ред</a>/<a href="?act=del&amp;id='.$user['id'].'">уд</a>)<br />';
		}
		navig($page, '?', $pages);
		nav('./');
	break;
	
	case 'edit':
		$id = intval($_REQUEST['id']);
		$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$id'"));
		if ($user['id']) {
			if ($_REQUEST['ok']) {
				$email = check($_POST['email']);
				$access = intval($_REQUEST['access']);
				switch ($access) {
					default: $access = $user['access']; break;
					case '1': $access = 1; break;
					case '2': $access = 2; break;
					case '3': $access = 3; break;
					case '4': $access = 0; break;
				}
				$icq = intval($_POST['icq']);
				$name = check($_POST['name']);
				$sex = intval($_POST['sex']);
				$from = check($_POST['from']);
				$birthday = check($_POST['birthday']);
				$site = check($_POST['site']);
				$about = check($_POST['about']);
				mysql_query("UPDATE `users` SET `email` = '$email', `access` = '$access', `icq` = '$icq', `name` = '$name', `sex` = '$sex', `from` = '$from', `birthday` = '$birthday', `site` = '$site', `about` = '$about' WHERE `id` = '$id'");
				header('location: ?act=edit&id='.$id);
			} else {
				tp('Ред-ть профиль');
				echo '<form action="?act=edit&amp;id='.$id.'&amp;ok=1" method="post">
				<u>'.access($user['id']).' </u>
				<select name="access">
				<option value="0">Не изменять</option>
				<option value="4">Пользователь</option>
				<option value="1">Куратор</option>
				<option value="2">Модератор</option>
				<option value="3">Администратор</option>
				</select><br />
				E-mail(max50):<br /><input name="email" type="text" maxlength="50" value="'.$user['email'].'" /><br />
				ICQ(max9):<br /><input name="icq" type="text" maxlength="9" value="'.$user['icq'].'" /><br />
				Имя(max20):<br /><input name="name" type="text" maxlength="20" value="'.$user['name'].'" /><br />
				Пол: ';
				switch ($user['sex']) {
					case '1': echo 'муж<input name="sex" type="radio" value="1" checked /> <input name="sex" type="radio" value="2" />жен'; break;
					case '2': echo 'муж<input name="sex" type="radio" value="1" /> <input name="sex" type="radio" value="2" checked />жен'; break;
					default: echo 'муж<input name="sex" type="radio" value="1" /> <input name="sex" type="radio" value="2" />жен'; break;
				}
				echo '<br />
				Откуда(max25):<br /><input name="from" type="text" maxlength="25" value="'.$user['from'].'" /><br />
				Дата рождения (дд.мм.гггг):<br /><input name="birthday" type="text" maxlength="25" value="'.$user['birthday'].'" /><br />
				Wap-сайт(<del>http://</del>, max20):<br /><input name="site" type="text" maxlength="20" value="'.$user['site'].'" /><br />
				О себе(max250):<br /><textarea name="about" cols="" rows="3">'.$user['about'].'</textarea><br />
				<input name="submit" type="submit" value="Ok" />
				</form>';
				nav('?');
			}
		} else {
			error('Пользователь не существует.');
			nav('?');
		}
	break;
	
	case 'del':
		$id = intval($_REQUEST['id']);
		if ($_REQUEST['ok']) {
			mysql_query("DELETE FROM `users` WHERE `id` = '$id'");
			$_SESSION['info'] = 'Удален.';
			header('location: ?');
		} else {
			tp('Подтвердите');
			echo 'Вы действительно хотите удалить пользователя '.login($id).'?
			<form action="?act=del&amp;id='.$id.'&amp;ok=1" method="post">
			<input name="submit" type="submit" value="Да" />
			</form>';
			nav('?');
		}
	break;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

require_once '../system/tail_p.php';
?>