Просмотр файла gb/index.php

Размер файла: 1.43Kb
<?

	require_once ('config.php');
	require_once ('kernel/GuestBook.php');
	require_once ('kernel/HtmlPage.php');

	define('UP_PATH', '');

	session_start();

	$guestBook = new GuestBook;
	$auth = new Authorisation;

	if (isset($_GET['exit'])) {
		$auth->ExitUser();
	}

	if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['post']))
	{
		$err_num = $guestBook->AddPost();
		if ($err_num)
		{
			$error_message = new ErrorMessage($err_num);
		} else {
			header('Location: '.$_SERVER['PHP_SELF']);
			exit();
		}
	}

	if (isset($_GET['edit']) && $_GET['edit']=='del' && isset($_GET['id']) && is_numeric($_GET['id']) && $auth->IsAuth())
	{
		$err_num = $guestBook->DelPost();
		if ($err_num)
		{
			$error_message = new ErrorMessage($err_num);
		} else {
			header('Location: '.$_SERVER['PHP_SELF']);
			exit();
		}
	}

	$page = new HtmlPage;
	$page->ShowTitle();
	if (isset($error_message)) $error_message->ShowMessage();
	$page->ShowAddForm();
	$page->ShowNavLine($guestBook->GetCurPageNum(), $guestBook->GetMaxPageNum());
	if ($auth->IsAuth())
	{
		$page->ShowRecords($guestBook->GetRecords(), true);
	} else {
		$page->ShowRecords($guestBook->GetRecords());
	}
	$page->ShowNavLine($guestBook->GetCurPageNum(), $guestBook->GetMaxPageNum());

	//$page->ShowAddForm();

	if ($auth->IsAuth()) {
		$page->ShowAdminBottom();
	} else {
		$page->ShowAuthoriseForm();
	}
	$page->ShowFooter();

?>