-<?php
-
- ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . LOCAL_ROOT . '/lib/');
-
- require_once 'data.php';
- require_once 'output.php';
-
- define_constants();
-
+<?php
+
+ define('PLOG_ROOT', $_SERVER['DOCUMENT_ROOT'] . '/plog');
+ define('WEBROOT', 'http://' . $_SERVER['SERVER_NAME']);
+ define('TEMPLATE_DIR', dirname(realpath(__FILE__)) . '/../templates');
+ define('CONTENT_ROOT', $_SERVER['DOCUMENT_ROOT'] . '/content');
+ define('CONTENT_BASEDIR', $_SERVER['DOCUMENT_ROOT'] . '/content' . $_SERVER['SCRIPT_URL']);
+ define('CONTENT_WEBROOT', 'http://' . $_SERVER['SERVER_NAME'] . '/content' . $_SERVER['SCRIPT_URL']);
+ define('CONTENT_SRC', CONTENT_BASEDIR . 'content.php');
+
+ define('CONFIG', 'config');
+
+ ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realpath(__FILE__)));
+ require_once 'output.php';
+ require_once 'template.php';
+
+ # response format
+ list($response_format, $response_mime_type) = parse_format($_GET['format'], 'html');
+
+ # template
+ $template = new Template();
+
+ # parse content dir
+ if (is_dir(CONTENT_BASEDIR)) {
+
+ # config
+ if (is_file(CONTENT_BASEDIR . CONFIG))
+ $config = parse_ini_file(CONTENT_BASEDIR . CONFIG);
+
+ # template
+ if ($config['template'])
+ $template->set_src(TEMPLATE_DIR . '/' . $config['template'] . '.' . $response_format . '.tpl');
+ else if (file_exists(CONTENT_SRC))
+ $template->set_src(CONTENT_SRC);
+
+// echo $template->src;
+
+ # content
+ # images
+ $images = array();
+ foreach(glob(CONTENT_BASEDIR . "{*.jpg,*.gif,*.png}", GLOB_BRACE) as $img) {
+ $i = array();
+ $i['name'] = basename($img);
+ $i['url'] = str_replace(CONTENT_BASEDIR, CONTENT_WEBROOT, $img);
+ $images[] = $i;
+ }
+ }
+
+ # header
+// header("Content-Type: {$response_mime_type}; charset=UTF-8");
+// $template->render();
+
+
+
+// print_r($_SERVER);
+
+// $images = glob("images/{*.jpg,*.gif,*.png}", GLOB_BRACE);
+// print_r($images);
+
+
+
+
+// require_once 'data.php';
+// require_once 'output.php';
+
+// define_constants();
+
?>
\ No newline at end of file