Add displaying images, adjust upload parameters.

Also add copyright information to the footer in the template.
This commit is contained in:
abbie 2024-07-28 21:23:46 +01:00
parent d0ce926f3b
commit 0a2925c5f5
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
4 changed files with 48 additions and 8 deletions

View file

@ -74,9 +74,10 @@ function addImage($location, $uploader, $tags) {
function flushSessionTokens() { function flushSessionTokens() {
global $db; global $db;
$timestamp = time();
$flushStatement = $db->prepare("DELETE FROM tokens WHERE expiry < ?"); $flushStatement = $db->prepare("DELETE FROM tokens WHERE expiry < ?");
$flushStatement->bindParam(1, time(), SQLITE3_INTEGER); $flushStatement->bindParam(1, $timestamp, SQLITE3_INTEGER);
$flushStatement->execute(); $flushStatement->execute();
} }
@ -142,4 +143,40 @@ function loggedInCheck() {
} }
} }
} }
function getImageAmount() {
global $db;
$statement = $db->prepare("SELECT id FROM images ORDER BY id DESC LIMIT 1");
$result = $statement->execute();
return $result->fetchArray()[0];
}
function getAmountOfPages() {
$maxId = getImageAmount();
return ceil($maxId/10);
}
function getImages($page = 0) {
global $db;
$data = array();
$maxId = getImageAmount();
$upperBound = ((int)$maxId-((int)$page*10));
$lowerBound = $upperBound-10;
$t2 = $upperBound-0; // I genuinely have no idea why this works but don't touch it.
$getStatement = $db->prepare("SELECT location, tags FROM images WHERE id > ? AND id <= ? ORDER BY id DESC LIMIT 10");
$getStatement->bindParam(1, $lowerBound, SQLITE3_INTEGER);
$getStatement->bindParam(2, $t2, SQLITE3_INTEGER);
$result = $getStatement->execute();
while ($res = $result->fetchArray(1))
{
array_push($data, $res);
}
return $data;
}
?> ?>

View file

@ -1,11 +1,11 @@
<?php <?php
if(!isset($sitename)) { $sitename = "meowboard"; } if(!isset($sitename)) { $sitename = "meowboard"; }
$headerGuest = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="css/zimit.min.css"><link rel="stylesheet" type="text/css" href="css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="login.php" id="menu">login</a></li></ul></nav></header><br/><main>'; $headerGuest = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="/css/zimit.min.css"><link rel="stylesheet" type="text/css" href="/css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="/index.php" id="menu">home</a></li><li><a href="/login.php" id="menu">login</a></li></ul></nav></header><br/><main>';
$headerNoButtons = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="css/zimit.min.css"><link rel="stylesheet" type="text/css" href="css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a></nav></header><br/><main>'; $headerNoButtons = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="/css/zimit.min.css"><link rel="stylesheet" type="text/css" href="/css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a></nav></header><br/><main>';
$headerLoggedIn = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="css/zimit.min.css"><link rel="stylesheet" type="text/css" href="css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="upload.php" id="menu">upload</a></li><li><a href="settings.php" id="menu">settings</a></li><li><a href="logout.php" id="menu">logout</a></li></ul></nav></header><br/><main>'; $headerLoggedIn = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="/css/zimit.min.css"><link rel="stylesheet" type="text/css" href="/css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="/index.php" id="menu">home</a></li><li><a href="/upload.php" id="menu">upload</a></li><li><a href="/settings.php" id="menu">settings</a></li><li><a href="/logout.php" id="menu">logout</a></li></ul></nav></header><br/><main>';
$headerAdmin = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="css/zimit.min.css"><link rel="stylesheet" type="text/css" href="css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="upload.php" id="menu">upload</a></li><li><a href="settings.php" id="menu">settings</a></li><li><a href="admin.php" id="menu">admin</a></li><li><a href="logout.php" id="menu">logout</a></li></ul></nav></header><br/><main>'; $headerAdmin = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' . $sitename . '</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="/css/zimit.min.css"><link rel="stylesheet" type="text/css" href="/css/custom.css"></head><body><header><nav><a class="site">' . $sitename . '</a><ul id="menu"><li><a href="/index.php" id="menu">home</a></li><li><a href="/upload.php" id="menu">upload</a></li><li><a href="/settings.php" id="menu">settings</a></li><li><a href="/admin.php" id="menu">admin</a></li><li><a href="/logout.php" id="menu">logout</a></li></ul></nav></header><br/><main>';
$footer = '</main><footer>bla bla copyright content and like uh meow</footer></body></html>'; $footer = '</main><footer>This website is powered by <form style="display:inline;"><button type="submit" formaction="https://git.colean.cc/threeoh6000/meowboard">meowboard</button></form>, licenced under the EUPL 1.2. This theme uses the <form style="display:inline;"><button type="submit" formaction="https://firezenk.github.io/zimit/">Zimit framework</button></form>, licenced under the MIT licence.</footer></body></html>';
function dispImage($imgurl, $tags) { function dispImage($imgurl, $tags) {
$imgstart = '<div class="thumbnail" style="padding:10px;"><img src="' . $imgurl . '"/><br/><div class="details" style="font-size:20px;">'; $imgstart = '<div class="thumbnail" style="padding:10px;"><img src="' . $imgurl . '"/><br/><div class="details" style="font-size:20px;">';
$imgend = '</div></div>'; $imgend = '</div></div>';

View file

@ -9,6 +9,9 @@ if (isset($_COOKIE["meowboardSession"])) {
} }
showHeader(); showHeader();
dispImage("https://media.discordapp.net/attachments/823599010166210610/963104145164886077/image0-4.gif", array("meow","witch")); $imgs = getImages();
for ($i = 0; $i < sizeof($imgs); $i++){
dispImage($imgs[$i]["location"], explode(",", $imgs[$i]["tags"]));
}
echo $footer; echo $footer;
?> ?>

View file

@ -16,7 +16,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$uploadValid = 0; $uploadValid = 0;
} }
if(ctype_alnum(str_replace(",","",$_POST["tags"])) == false){ if(ctype_alnum(str_replace("_", "",str_replace(",","",$_POST["tags"]))) == false){
$uploadValid = 0; $uploadValid = 0;
} }