<?php namespace Admin; use Parvula\Core\View; use Parvula\Core\Config; use Parvula\Core\Parvula; if (!defined('ROOT')) { exit; } $adminConf = (require DATA . 'admin.conf.php'); if ($adminConf['password'] === "_Your_Password_") { die('You MUST change the default password in `' . DATA . 'admin.conf.php`.'); } $view = new View(ADMIN . 'view'); $view->assign('baseUrl', Parvula::getRelativeURIToRoot()); $view->assign('templateUrl', Parvula::getRelativeURIToRoot() . TMPL . Config::get('template')); // Check password if (isset($_POST, $_POST['password'])) { if ($_POST['password'] === $adminConf['password']) { if (session_id() === '') { session_id(uniqid()); session_start(); } $_SESSION['id'] = uidSession(); $_SESSION['login'] = true; // Post/Redirect/Get pattern header("Location: ./", true, 303); } else { $view->assign('notice', true); }
} // Check if template exists (must have index.html) $baseTemplate = TMPL . Config::get('template'); if (!is_readable($baseTemplate . '/index.html')) { die("Error - Template is not readable"); } Asset::setBasePath(Parvula::getRelativeURIToRoot() . $baseTemplate); $parvula = new Parvula(); $page = $parvula->getPage($pagename); // 404 if (false === $page) { header(' ', true, 404); // Set header to 404 $page = $parvula->getPage(Config::errorPage()); if (false === $page) { // Juste print simple 404 if there is no 404 page die('404 - Page ' . htmlspecialchars($page) . ' not found'); } } try { $view = new View(TMPL . Config::get('template')); // Assign some variables $view->assign(array('baseUrl' => Parvula::getRelativeURIToRoot(), 'templateUrl' => Asset::getBasePath(), 'parvula' => $parvula, 'pages' => function () use($parvula) { return $parvula->getPages(); }, 'site' => $config, 'meta' => $page, 'content' => $page->content)); // Show index template echo $view('index'); } catch (Exception $e) { exceptionHandler($e); } });