<?php
include 'env.php';
require_once(LIB.'common.inc.php');
$url = $_SERVER['REQUEST_URI'];
$params = explode('/', $url);
$base = explode('/', BASE_URL);
//TODO: delete http://HOST
array_splice($params, 0, count($base)-1);
$page = '';
if (empty($params) || empty($params[0])) {
	$page = 'index';
} else {
	$page = $params[0];
}
$page = str_replace('/', '', str_replace('.', '', $page));
$params = array_slice($params, 1);
foreach ($params as $k => $v) {
	$params[$k] = rawurldecode($v);
}

if (! file_exists(PAGES.$page.'.php')) {
	header('HTTP/1.0 404 File Not Found');
	$sub_title = 'ページが見つかりません。';
	$message = $sub_title;
	include PAGES.'error.php';
	die;
}

$_BULLET = array(
	'page' => $page,
	'params' => $params,
	'url' => $url
);

include PAGES.$page.'.php';
?>