<?php 
define('DMPATH', dirname(__DIR__) . '/');
define('ROOTPATH', dirname(__FILE__) . '/');

require_once(ROOTPATH . "lib/_config.php");

$WIT = new WIT();

include(ROOTPATH . "inc/ajax_index.php");

$basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
$uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));

if (_Q("DEBUG") == "1") define('_DEBUG', true);
else define('_DEBUG', false);

if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?'));
$base_uri = '/' . trim($uri, '/');

$routes = array();
$routes = explode('/', $base_uri);
foreach($routes as $route)
{
	if(trim($route) != '')
		array_push($routes, $route);
}

$PAGEID = $routes[1];

if ($PAGEID == "") $PAGEID = "home";


$path = ROOTPATH . "page/" . $PAGEID . ".php";
if(!file_exists($path)) {
	$PAGEID = "404";
}

$path = ROOTPATH . "page/" . $PAGEID . ".php";

?>
<!DOCTYPE html>
<html lang="ko">
	<head>
<?php
include(ROOTPATH . "inc/head.inc.php");
?>
	</head>
	<body>	
<?php     
include($path);
?>

</body>
</html>	