Initial routing

develop
Sven Slootweg 11 years ago
parent eeba3a5ef3
commit 22622d6b3c

@ -16,3 +16,6 @@ if(!isset($_APP)) { die("Unauthorized."); }
$_CPHP = true;
$_CPHP_CONFIG = "../config.json";
require("cphp/base.php");
require("lib/Markdown.php");
require("lib/MarkdownExtra.php");

@ -0,0 +1,18 @@
<?php
/*
* Cryto is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
/* TODO: Have a dynamic homepage rather than a static one. */
$sPageContents = NewTemplater::Render("homepage", $locale->strings, array());

@ -0,0 +1,25 @@
<?php
/*
* Cryto is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
try
{
$sPage = Page::CreateFromQuery("SELECT * FROM pages WHERE `Slug` = :Slug", array(":Slug" => $router->uParameters[1]), 60, true);
}
catch (NotFoundException $e)
{
throw new RouterException("Page does not exist.");
}
$sPageContents = Michelf\MarkdownExtra::defaultTransform($sPage->uBody);

@ -14,3 +14,29 @@
$_APP = true;
require("includes/base.php");
$sPageTitle = "";
$sPageContents = "";
$router = new CPHPRouter();
$router->allow_slash = true;
$router->ignore_query = true;
$router->routes = array(
0 => array(
"^/$" => "modules/homepage.php",
"^/(.*)$" => "modules/page.php"
)
);
try
{
$router->RouteRequest();
}
catch (RouterException $e)
{
http_status_code(404);
die("404 Not Found");
}
echo($sPageContents);

Loading…
Cancel
Save