View file panel/config.php

File size: 2.25Kb
<?php
// by mides, 1da.su

require_once '../system/sys.php';
require_once '../system/auth_a.php';
require_once '../system/header.php';
session_start();

if ($u['access'] < 3) {
	error('Нет доступа.');
	nav('./');
}

switch ($_GET['act']) {
	default:
		tp('Настройки сайта');
		if ($_SESSION['info']) echo '<b><u>'.$_SESSION['info'].'</u></b><br />';
		unset($_SESSION['info']);
		$conf_r = mysql_query("SELECT * FROM `config` WHERE `id` = 1");
		$conf = mysql_fetch_assoc($conf_r);
		echo '<form action="?act=do" method="post">
		Стиль по умочанию:<br /><select name="style">';
		$styles = glob('../inc/styles/*', GLOB_ONLYDIR);
		foreach ($styles as $style) {
			$selected = ($conf['style'] == basename($style)) ? ' selected="selected"' : '';
			echo '<option value="'.basename($style).'"'.$selected.'>'.basename($style).'</option>';
		} 
		echo '</select><br />
		Элементов на страницу(1-99):<br /><input name="onpage" type="text" value="'.$conf['onpage'].'" maxlength="2" /><br />
		Антиспам(1-999сек):<br /><input name="antispam" type="text" value="'.$conf['antispam'].'" maxlength="3" /><br />
		Время, в течении которого можно ре-ть сообщение(0-9999сек):<br /><input name="edit_time" type="text" value="'.$conf['edit_time'].'" maxlength="4" /><br />
		Время пинка(1-999сек):<br /><input name="kick" type="text" value="'.$conf['kick'].'" maxlength="3" /><br />
		<input name="submit" type="submit" value="Ok" />
		</form>';
		nav('./');
	break;
	
	case 'do':
		if ($_POST['onpage'] and $_POST['antispam'] and $_POST['kick']) {
			$style = check($_POST['style']);
			$onpage = abs(intval($_POST['onpage']));
			$antispam = abs(intval($_POST['antispam']));
			$edit_time = abs(intval($_POST['edit_time']));
			$kick = abs(intval($_POST['kick']));
			mysql_query("UPDATE `config` SET `style` = '$style', `onpage` = '$onpage', `antispam` = '$antispam', `edit_time` = '$edit_time', `kick` = '$kick' WHERE `id` = 1");
			$_SESSION['info'] = 'Сохранено.';
			header('location: ?');
			exit;
		} else {
			error('Вы не заполнили поля.');
			nav('?');
		}
	break;
}

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