Example #1
0
<?php

namespace tour;

/********************************
*   This is the gateway script 
*********************************/
require_once 'Cache/Lite.php';
require_once __DIR__ . "/../vendor/autoload.php";
$db = new \mysqli('localhost', Config::$DBUSER, Config::$DBPASS, Config::$DATABASE);
if ($db->connect_error) {
    $_SESSION['errmsg'] = 'Database connection problem';
    header("Location: " . Config::$WEB_ADDRESS . Config::$ERROR_PAGE);
}
$params = $_GET;
// the Page class will parse this later
if (key_exists('path', $params)) {
    $path = $params['path'];
    unset($params['path']);
} else {
    $path = '';
}
try {
    $db = new PageModel();
    $page = new Page($db, $path, $params);
    $html = $page->get_html();
} catch (\Exception $e) {
    $_SESSION['errmsg'] = $e->getMessage();
    header("Location: " . Config::$WEB_ADDRESS . Config::$PAGE404);
}
echo $html;