Просмотр файла admin/settings.php

Размер файла: 3Kb
<?php
include('../inc/funct.php');
include('../inc/core.php');
if (empty($_SESSION['access'])){ redirect('index.php?act=auto'); die(); }
if ($_SESSION['access']!=1){ redirect('index.php?act=auto'); die(); }
if (empty($_GET['act'])) $act = 'index';
	else $act = htmlspecialchars($_GET['act']);

if ($act=='index') {
	$pagetitle = 'Настройки';
	include('../inc/header.php');
	echo '<div id="title_a">'.$pagetitle.'</div>';
	echo '<div align="center">
	<form action="settings.php?act=getset" method="post">
	URL каталога:<br>
	<input type="text" name="url" value="'.URL.'"><br>
	Показывать прямые ссылки на сайты с рейтингом более:<br> (0 - прямые ссылки на все сайты)<br>
	<input type="text" name="minreit" value="'.minreit.'">
	<hr><b>Настройки базы данных</b><br>
	Адрес сервера: (обычно это localhost)<br>
	<input type="text" name="host" value="'.db_host.'"><br>
	Имя пользователя:<br>
	<input type="text" name="user" value="'.db_user.'"><br>
	Пароль:<br>
	<input type="password" name="password" value="'.db_password.'"><br>
	Название базы данных:<br>
	<input type="text" name="database" value="'.db_database.'"><br>
	<input type="submit" value="Изменить">
	</form></div>
	<div id="aut"><a href="index.php">Назад в админку</a></div>';
}

if ($act=='getset') {
	if (empty($_POST['url'])) { $_SESSION['error'] = 'URL не может быть пустым'; redirect('settings.php'); die(); }
	if (empty($_POST['minreit'])) { $_SESSION['error'] = 'Минимальный рейтинг не может быть пустым'; redirect('settings.php'); die(); }
	if (empty($_POST['host'])) { $_SESSION['error'] = 'Адрес сервера не может быть пустым'; redirect('settings.php'); die(); }
	if (empty($_POST['user'])) { $_SESSION['error'] = 'Имя пользователя не может быть пустым'; redirect('settings.php'); die(); }
	if (empty($_POST['database'])) { $_SESSION['error'] = 'Название базы данных не может быть пустым'; redirect('settings.php'); die(); }
	if (file_put_contents('../inc/const.php', '<?php define("URL","'.htmlspecialchars($_POST['url']).'"); define("db_host","'.htmlspecialchars($_POST['host']).'"); 
  define("db_user","'.htmlspecialchars($_POST['user']).'"); define("db_password","'.htmlspecialchars($_POST['password']).'"); 
  define("db_database","'.htmlspecialchars($_POST['database']).'"); define("minreit","'.htmlspecialchars($_POST['minreit']).'"); define("foot","<div id=\"foot\"><a href=\"localhost\">Powered by fLipE</a></div><div align=\"right\">Design by VaiZerD</div>") ?>')) {
		$_SESSION['info'] = 'Настройки успешно сохранены';
		redirect('settings.php');
		die();
	} else {
		$_SESSION['error'] = 'Ошибка при сохранении настроек';
		redirect('settings.php');
		die();
	}
}

include('../inc/footer.php');
?>