Add image page.
This commit is contained in:
parent
805bebcf65
commit
16cfecafbf
3 changed files with 75 additions and 26 deletions
17
image.php
Normal file
17
image.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
include 'include/db.php';
|
||||||
|
include 'include/templates.php';
|
||||||
|
|
||||||
|
showHeader();
|
||||||
|
$imgs = getImage(1);
|
||||||
|
$imgs[0]["uploader"] = uuidToUsername($imgs[0]["uploader"]);
|
||||||
|
$tags = explode(",", $imgs[0]["tags"]);
|
||||||
|
|
||||||
|
echo '<center><img src="' . $imgs[0]["location"] . '" /></center>';
|
||||||
|
echo '<strong>Uploader:</strong> ' . $imgs[0]["uploader"];
|
||||||
|
echo '<br/><strong>Tags:</strong>';
|
||||||
|
for($x = 0; $x < count($tags); $x++) {
|
||||||
|
printTag($tags[$x], true);
|
||||||
|
}
|
||||||
|
echo $footer;
|
||||||
|
?>
|
|
@ -184,6 +184,21 @@ function getImages($page = 0) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getImage($id) {
|
||||||
|
global $db;
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
$getStatement = $db->prepare("SELECT location, uploader, tags FROM images where id = ?");
|
||||||
|
$getStatement->bindParam(1, $id, SQLITE3_INTEGER);
|
||||||
|
$result = $getStatement->execute();
|
||||||
|
while ($res = $result->fetchArray(1))
|
||||||
|
{
|
||||||
|
array_push($data, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
function usernameToUuid($username) {
|
function usernameToUuid($username) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
@ -193,4 +208,14 @@ function usernameToUuid($username) {
|
||||||
|
|
||||||
return $result->fetchArray()[0];
|
return $result->fetchArray()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uuidToUsername($uuid) {
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$getStatement = $db->prepare("SELECT username FROM users WHERE uuid = ?");
|
||||||
|
$getStatement->bindParam(1, $uuid, SQLITE3_TEXT);
|
||||||
|
$result = $getStatement->execute();
|
||||||
|
|
||||||
|
return $result->fetchArray()[0];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -6,36 +6,43 @@ $headerNoButtons = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' .
|
||||||
$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>';
|
$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="/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>';
|
$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>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>';
|
$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 printTag($tag, $largerFontSize = false) {
|
||||||
|
if($largerFontSize == false) {
|
||||||
|
echo '<tag color="black">' . $tag . '</tag>';
|
||||||
|
} else {
|
||||||
|
echo '<tag color="black" style="font-size: 1em;">' . $tag . '</tag>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 . '" style="max-width: 200px; max-height: 200px;"/><br/><div class="details" style="font-size:20px;">';
|
||||||
$imgend = '</div></div>';
|
$imgend = '</div></div>';
|
||||||
echo "$imgstart";
|
echo "$imgstart";
|
||||||
for($x = 0; $x < count($tags); $x++) {
|
for($x = 0; $x < count($tags); $x++) {
|
||||||
$tagblock = '<tag color="black">' . $tags[$x] . '</tag>';
|
printTag($tags[$x]);
|
||||||
echo "$tagblock";
|
}
|
||||||
}
|
echo "$imgend";
|
||||||
echo "$imgend";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHeader($hideButtons = 0) {
|
function showHeader($hideButtons = 0) {
|
||||||
// PHP is so quirky!!! I love scoping :sparkling-heart:
|
// PHP is so quirky!!! I love scoping :sparkling-heart:
|
||||||
global $headerNoButtons;
|
global $headerNoButtons;
|
||||||
global $headerLoggedIn;
|
global $headerLoggedIn;
|
||||||
global $headerGuest;
|
global $headerGuest;
|
||||||
global $headerAdmin;
|
global $headerAdmin;
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if ($hideButtons == 1) { echo $headerNoButtons; return; }
|
if ($hideButtons == 1) { echo $headerNoButtons; return; }
|
||||||
if (!empty($db) && isset($_COOKIE["meowboardSession"])) {
|
if (!empty($db) && isset($_COOKIE["meowboardSession"])) {
|
||||||
if (isAdmin(tokenToUuid($_COOKIE["meowboardSession"])) == 1) {
|
if (isAdmin(tokenToUuid($_COOKIE["meowboardSession"])) == 1) {
|
||||||
echo $headerAdmin;
|
echo $headerAdmin;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
echo $headerLoggedIn;
|
echo $headerLoggedIn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($_COOKIE["meowboardSession"])) { echo $headerLoggedIn; return; }
|
if (isset($_COOKIE["meowboardSession"])) { echo $headerLoggedIn; return; }
|
||||||
echo $headerGuest;
|
echo $headerGuest;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue