refactor: move all HTTP-Website code into www subdirectory
Some checks failed
/ phplint (push) Failing after 4s

This commit is contained in:
David Bailey 2023-10-19 21:54:37 +02:00
parent 502ddd1ad9
commit 5bcba0b689
25 changed files with 33 additions and 67 deletions

View file

@ -1,6 +0,0 @@
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/?static/.*
RewriteRule (.*) router.php

1
www/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
vendor/

View file

@ -1 +1,6 @@
Allow from all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/?static/.*
RewriteRule (.*) router.php

View file

View file

@ -1,42 +0,0 @@
body {
color: #B0B0B0;
background: #302A3F;
}
:link {
color: cyan;
font-style: italic;
text-decoration: none;
transition: color 0.2s;
}
:link:hover {
color: lightblue;
}
ul {
display: flex;
flex-direction: row;
justify-content: center;
list-style-type: none;
margin-top: 1em;
padding: 0px;
}
ul li {
padding: 0em 0.3em 0em 0.3em;
}
#big_title {
text-align: center;
font-size: 2.5em;
margin-bottom: 0.2em;
}
#title_separator {
height: 1.5px;
background-color: #ddd;
opacity: 0.5;
margin-left: 2em;
margin-right: 2em;
}

View file

@ -1,11 +0,0 @@
<?php
require_once '../vendor/autoload.php';
$loader = new \Twig\Loader\FilesystemLoader('../templates');
$twig = new \Twig\Environment($loader);
echo $twig->render('index.html',[
"a_variable" => "is very spicy. In a good way."
]);
?>

View file

@ -3,16 +3,30 @@
require_once 'vendor/autoload.php';
$sql = mysqli_connect('mysql', 'root', 'example', 'mysql');
$sql = mysqli_connect('mysql', 'root', 'example', 'dragon_fire');
if (!$sql)
{
echo 'Connection failed<br>';
echo 'Error number: ' . mysqli_connect_errno() . '<br>';
echo 'Error message: ' . mysqli_connect_error() . '<br>';
die();
function get_post_by_path($path) {
global $sql;
$qry = "SELECT * FROM posts WHERE post_path = ?";
$stmt = $sql->prepare($qry);
$stmt->bind_param("s", $path);
$stmt->execute();
// $result = $stmt->get_result();
return $stmt->get_result()->fetch_assoc();
}
//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]);
@ -32,6 +46,11 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
if($_SERVER['REQUEST_URI'] == '/') {
echo $twig->render('root.html');
} elseif(preg_match('/^\/api\/posts(.*)$/', $_SERVER['REQUEST_URI'], $match)) {
header('Content-Type: application/json');
echo json_encode(get_post_by_path($match[1]));
} elseif(preg_match('/^\/about(.html)?$/', $_SERVER['REQUEST_URI'])) {
echo $twig->render('about.html');
} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) {

View file

Before

Width:  |  Height:  |  Size: 527 KiB

After

Width:  |  Height:  |  Size: 527 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After