undid the autoappend/prepend

This commit is contained in:
Zdenek Borovec 2024-05-10 17:20:25 +02:00
parent 5ddabf9c0f
commit 1fc2dcdd6f
19 changed files with 170 additions and 23 deletions

View file

@ -29,8 +29,6 @@ Anyways, let's get to the *how*.
- SQL_PASSWORD
- SQL_DATABASE
- Changes to php.ini should include:
- adding the /docs/common/header.hp and /docs/common/footer.php as
the auto_prepend_file and auto_append_file
- Enabling the pdo_mysql extension
- Setting the file_uploads on and setting max upload (and post) size,
if you are going to make use of that function. Please note that it is
@ -46,6 +44,10 @@ Anyways, let's get to the *how*.
- The basic skeleton for any document should be:
```php
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
// Display the header with desired title.
display_header(<PAGETITLE>);
?>
@ -53,6 +55,10 @@ display_header(<PAGETITLE>);
<!--
Your main content here, try to wrap it in <article> tags for nice padding
-->
<?php
include_once($COMMONS."/header.php");
?>
```
- Do check out the already existing css rules before adding your own, the rule
for what you are trying to create might already exist. I might add a more

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = "./../../docs/common";
include_once($COMMONS."/header.php");
display_header("403: Forbidden");
?>
@ -8,3 +12,7 @@ display_header("403: Forbidden");
<img src="https://assets.zdenekborovec.cz/upload/3e0cef92-8dad-4085-9db4-e9c8e1437e0a/c7ec620b-1666-4ab9-ad35-ad3daf1b53b2.png" alt="Internet meme image of a confused-looking cat with a text reading &quot;Hey you... What are you doing here??&quot;">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = "./../../docs/common";
include_once($COMMONS."/header.php");
display_header("404: Not Found");
?>
@ -8,3 +12,7 @@ display_header("404: Not Found");
<img src="https://assets.zdenekborovec.cz/upload/7316caee796b4cb280cc769ea5f852fa/32a6269147ce4c6c813d4f0449ae1da9/9f532c593d134c6dad5bc63684fe22c2" alt="GIF of a cat hiding in a cupboard">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = "./../../docs/common";
include_once($COMMONS."/header.php");
display_header("500: Internal Server Error");
?>
@ -8,3 +12,7 @@ display_header("500: Internal Server Error");
<img src="https://assets.zdenekborovec.cz/upload/bddac3669dd44acc8a41e2f935c94a3a/0c5f9e325ba34c02a24f53e50a1cc68d/62aa400be23d4c5ab3f6e2abe666d070" alt="GIF of a very confused cat.">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = "./../../docs/common";
include_once($COMMONS."/header.php");
display_header("503: Service Unavailable");
?>
@ -8,3 +12,7 @@ display_header("503: Service Unavailable");
<img src="https://assets.zdenekborovec.cz/upload/db3181344f0249a09fbc2ba1096b35c4/4b974e9c1e214ea4ad57174a33aa1c4f/bb9d675f430f4fd8990fd3a993a7ee96" alt="GIF of a cat going to work in a cardboard box.">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
class BlogpostComment
{
public $comment_id;
@ -367,8 +371,9 @@ function load_blog($conn, $blogId){
// Check DB connection
if($conn == null){
include($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 503 Not Foud", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/504.php");
include_once($COMMONS."/footer.php");
die();
}
@ -396,9 +401,9 @@ $blogId = sanitize_input($_GET["guid"]);
// If no ID was entered, display warning and die.
if(!$blogId) {
display_header("No article requested.");
include($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Foud", true, 404);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
include_once($COMMONS."/footer.php");
die();
}
@ -406,9 +411,9 @@ $blogPost = load_blog($conn, $blogId);
// If no ID was entered, display warning and die.
if(!$blogPost) {
display_header("Article not found");
include($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Foud", true, 404);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
include_once($COMMONS."/footer.php");
die();
}
@ -439,4 +444,6 @@ printf("
// Display the blog comments
$blogPost->display_comments();
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
/**
* Display a blog-preview div
*/
@ -40,8 +44,9 @@ function display_blog_preview($blogpost_id, $title, $abstract,
function display_blog_previews($conn){
// Check DB connection
if($conn == null){
include($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include_once($COMMONS."/footer.php");
die();
}
@ -95,4 +100,6 @@ display_header("Blogs");
<?php
display_blog_previews($conn);
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
// Error string for the content deletion confirmation
$confStringErr = "";
@ -9,10 +13,12 @@ $confStringErr = "";
function delete_user($conn, $confirmString) {
global $confStringErr;
$conn = null;
// Check DB connection
if($conn == null){
include($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include_once($COMMONS."/footer.php");
die();
}
@ -155,4 +161,6 @@ else{
Please sign in to delete your account.
</article>");
}
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("403: Forbidden");
?>
@ -8,3 +12,7 @@ display_header("403: Forbidden");
<img src="https://assets.zdenekborovec.cz/upload/3e0cef92-8dad-4085-9db4-e9c8e1437e0a/c7ec620b-1666-4ab9-ad35-ad3daf1b53b2.png" alt="Internet meme image of a confused-looking cat with a text reading &quot;Hey you... What are you doing here??&quot;">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,5 +1,9 @@
<?php
display_header("404: Not Found");
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("403: Forbidden");
?>
<article>
@ -8,3 +12,7 @@ display_header("404: Not Found");
<img src="https://assets.zdenekborovec.cz/upload/7316caee796b4cb280cc769ea5f852fa/32a6269147ce4c6c813d4f0449ae1da9/9f532c593d134c6dad5bc63684fe22c2" alt="GIF of a cat hiding in a cupboard">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,5 +1,9 @@
<?php
display_header("500: Internal Server Error");
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("403: Forbidden");
?>
<article>
@ -8,3 +12,7 @@ display_header("500: Internal Server Error");
<img src="https://assets.zdenekborovec.cz/upload/bddac3669dd44acc8a41e2f935c94a3a/0c5f9e325ba34c02a24f53e50a1cc68d/62aa400be23d4c5ab3f6e2abe666d070" alt="GIF of a very confused cat.">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,5 +1,10 @@
<?php
display_header("503: Service Unavailable");
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("403: Forbidden");
?>
<article>
@ -8,3 +13,7 @@ display_header("503: Service Unavailable");
<img src="https://assets.zdenekborovec.cz/upload/db3181344f0249a09fbc2ba1096b35c4/4b974e9c1e214ea4ad57174a33aa1c4f/bb9d675f430f4fd8990fd3a993a7ee96" alt="GIF of a cat going to work in a cardboard box.">
</div>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,10 +1,14 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
// If the user does not have the 1000 0000 permission,
// throw a 403: Forbidden error.
if(!(bool)($_SESSION["current_user"]->permissions & 128)) {
header($_SERVER["SERVER_PROTOCOL"]." 403 Forbidden", true, 403);
include($_SERVER["DOCUMENT_ROOT"]."/errors/403.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/403.php");
include_once($COMMONS."/footer.php");
die();
}
@ -41,3 +45,7 @@ if(isset($_POST["submit"])) {
<input name="userfile" type="file">
<input name="submit" type="submit" value="Send File">
</form>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("About");
?>
@ -74,3 +78,7 @@ display_header("About");
Beauty is in the eye of the beholder and while I can appreciate this look is unusual, I really dig it. You are always free to make your own custom css for my site, of course. Hmm, now I am thinking about adding built-in customisation support, but that would require user settings, and having users makes no sense until theres some kind of user interaction like a forum, or article comments, or something like that. I will save that one for later.
</p>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
// Define previous attempt and error variables and set to empty values.
$usernameOld = $passwordOld = "";
$usernameErr = $passwordErr = "";
@ -15,8 +19,9 @@ function attempt_login($conn, $username, $password) {
// Check DB connection
if($conn == null){
include($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include_once($COMMONS."/footer.php");
die();
}
@ -122,3 +127,7 @@ display_header("Login");
<input name="submit" type="submit" tabindex="3" value="Send">
</form>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("Privacy policy");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("Unit conversions");
?>
@ -185,3 +189,7 @@ display_header("Unit conversions");
</tr>
</table>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
display_header("Random tools");
?>
@ -12,3 +16,7 @@ display_header("Random tools");
</li>
</ul>
</article>
<?php
include_once($COMMONS."/footer.php");
?>

View file

@ -1,4 +1,8 @@
<?php
$COMMONS = $_SERVER['DOCUMENT_ROOT'] . "/../common";
include_once($COMMONS."/header.php");
// Define previous attempt and error variables and set to empty values.
$usernameOld = $passwordOld = $passwordConfOld = "";
$usernameErr = $passwordErr = "";
@ -17,8 +21,9 @@ function attempt_register($conn, $username, $password, $passwordConf) {
// Check DB connection
if($conn == null){
include($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include($_SERVER["DOCUMENT_ROOT"]."/../common/footer.php");
header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include_once($COMMONS."/footer.php");
die();
}
@ -221,3 +226,7 @@ if (isset($_POST["submit"])) {
you minimize this risk.
</p>
</article>
<?php
include_once($COMMONS."/footer.php");
?>