<?php

include("./include/config.php");
include("./include/function.php");

if(isset($_GET["name"])) {
	$name = $_GET["name"];
} else {
	show_page_not_found();
}

$sql = "SELECT * FROM `pages` WHERE name='$name'";
$page_info = DB::fetch1($sql);

if(! $page_info) {
	show_page_not_found();
} else {
	$name = $page_info['name'];
	$content = $page_info['content'];
	$title = $page_info['title'];
	$description = $page_info['description'];
	$keywords = $page_info['keywords'];
	$members_only = $page_info['members_only'];
}

if($members_only == "1"){
	chk_member_login();
}

function show_page_not_found() {
	header("HTTP/1.0 404 Not Found");
	echo "<html><head><TITLE>Page Not Found</TITLE></head><body>Page Not Found</body></html>";
	exit(0);
}

$smarty->assign('err', $err);
$smarty->assign('html_title', $title);
$smarty->assign('content', $content);
$smarty->assign('html_description', $description);
$smarty->assign('html_keywords', $keywords);
$smarty->display('header.tpl');
$smarty->display('show_page.tpl');
$smarty->display('footer.tpl');
DB::close();
