refactor: move all HTTP-Website code into www subdirectory
Some checks failed
/ phplint (push) Failing after 4s
Some checks failed
/ phplint (push) Failing after 4s
This commit is contained in:
parent
502ddd1ad9
commit
5bcba0b689
25 changed files with 33 additions and 67 deletions
54
router.php
54
router.php
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
|
||||
$sql = mysqli_connect('mysql', 'root', 'example', 'mysql');
|
||||
|
||||
if (!$sql)
|
||||
{
|
||||
echo 'Connection failed<br>';
|
||||
echo 'Error number: ' . mysqli_connect_errno() . '<br>';
|
||||
echo 'Error message: ' . mysqli_connect_error() . '<br>';
|
||||
die();
|
||||
}
|
||||
|
||||
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);
|
||||
|
||||
$twig = new \Twig\Environment($loader,['debug' => true]);
|
||||
$twig->addExtension(new Twig\Extra\Markdown\MarkdownExtension());
|
||||
|
||||
use Twig\Extra\Markdown\DefaultMarkdown;
|
||||
use Twig\Extra\Markdown\MarkdownRuntime;
|
||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||
|
||||
$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
|
||||
public function load($class) {
|
||||
if (MarkdownRuntime::class === $class) {
|
||||
return new MarkdownRuntime(new DefaultMarkdown());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if($_SERVER['REQUEST_URI'] == '/') {
|
||||
echo $twig->render('root.html');
|
||||
} elseif(preg_match('/^\/about(.html)?$/', $_SERVER['REQUEST_URI'])) {
|
||||
echo $twig->render('about.html');
|
||||
} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) {
|
||||
echo $twig->render('/gallery/gallery_entry.html', [
|
||||
'image_url' => '/static/banner/0.png',
|
||||
'image_title' => 'Test!',
|
||||
'image_desc' => 'A soft piece made by a dear friend',
|
||||
'artist_name' => 'Doggonaut',
|
||||
'artist_src_link' => 'https://twitter.com/doggonaut'
|
||||
]);
|
||||
} else {
|
||||
echo $twig->render('rrror.html',[
|
||||
"error_code" => '404 Hoard not found!',
|
||||
"error_description" => "Well, we searched
|
||||
far and wide for `" . $_SERVER['REQUEST_URI'] . "` but
|
||||
somehow it must have gotten lost... Sorry!"
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue