Commit after ages. A lot of changes lol

This commit is contained in:
Pòsweg 2020-12-23 08:42:16 +01:00
parent 9956c737cb
commit a2b08e1000
8 changed files with 57 additions and 23 deletions

View File

@ -20,8 +20,8 @@ if(!isset($_SESSION["login"])) header("Location: /img/login.php");
if ($handle = opendir($dir)) { if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
$x = pathinfo($entry,PATHINFO_EXTENSION); $x = pathinfo($entry,PATHINFO_EXTENSION);
if ($x == "" && $entry != ".") { if ($x == "" && $entry != "." && $entry != "..") {
echo("<a href='/img/admin.php?l=$dir/$entry'>$entry</a><br/>\n"); echo("<a href='" . $BASE_PATH . "/admin.php?l=$dir/$entry'>$entry</a><br/>\n");
} }
else if($x == "jpg" || $x == "jpeg" || $x == "png"){ else if($x == "jpg" || $x == "jpeg" || $x == "png"){
array_push($images, $entry); array_push($images, $entry);
@ -35,10 +35,14 @@ if(!isset($_SESSION["login"])) header("Location: /img/login.php");
exec($tmsu . "tags -1 '$dir/$img'", $output); exec($tmsu . "tags -1 '$dir/$img'", $output);
$num_tags = sizeof($output); $num_tags = sizeof($output);
echo("<div style='float:left';>"); echo("<div style='float:left';>");
echo("<img width='100px' src='/img/$dir/$img'/>"); echo("<img width='100px' src='" . $BASE_PATH . "/$dir/$img'/>");
echo("<form><input type='text' value='"); echo("<form action='admin.php'>");
echo("<input type='text' name='tags[" . $img . "]' value='");
for($i = 1; $i < $num_tags; $i++) echo $output[$i] . " "; for($i = 1; $i < $num_tags; $i++) echo $output[$i] . " ";
echo("'/></form>"); echo("'/>");
echo("<input type='hidden' name='l' value='" . $_GET["l"] . "'/>");
echo("</form>");
echo("</div>"); echo("</div>");
} }
?> ?>

View File

@ -2,6 +2,8 @@
$tmsu = "tmsu -D drw/.tmsu/db "; $tmsu = "tmsu -D drw/.tmsu/db ";
$BASE_ROUTE = "";
/* Exclude */ /* Exclude */
$exclude = ""; $exclude = "";

View File

@ -1,4 +1,3 @@
<?php session_start(); ?>
<style> <style>
body{ body{
background-color: black; background-color: black;
@ -22,8 +21,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<div id="header"> <div id="header">
<?php <?php
if($_SESSION["login"] === true) echo "You are logged in - <a href='/img/logout.php'>logout</a>"; //if($_SESSION["login"] === true) echo "You are logged in - <a href='/logout.php'>logout</a>";
else echo "<a href='/img/login.php'>Login</a>"; print("<a href='" . $BASE_PATH . "/'>Home</a> ");
if($_SESSION["login"] === true){
echo "<a href='/logout.php'>logout</a>";
if($_SESSION["username"] == "admin"){
print(" <a href='" . $BASE_PATH . "/admin.php'>Admin</a>");
}
}
else{
echo "<a href='/login.php'>Login</a>";
}
?> ?>
<h1>Pòsweg's Suckless Booru</h1> <h1>Pòsweg's Suckless Booru</h1>
<form method="GET" action="tag.php"> <form method="GET" action="tag.php">

View File

@ -1,3 +1,4 @@
<?php session_start() ?>
<html> <html>
<head> <head>
<title>Pòsweg's image gallery</title> <title>Pòsweg's image gallery</title>
@ -12,12 +13,14 @@
exec($tmsu . "tags", $output); exec($tmsu . "tags", $output);
$tag_num = sizeof($output); $tag_num = sizeof($output);
for($i = 0; $i < $tag_num; $i++){ for($i = 0; $i < $tag_num; $i++){
if($exclude !== ""){
foreach($exclude as $excluded_tag){ foreach($exclude as $excluded_tag){
if($excluded_tag == $output[$i]){ if($excluded_tag == $output[$i]){
unset($output[$i]); unset($output[$i]);
} }
} }
} }
}
$tag_num = sizeof($output); $tag_num = sizeof($output);

View File

@ -1,16 +1,20 @@
<?php <?php
include("include/header.php"); session_start();
$errorMsg = ""; $errorMsg = "";
$validUser = $_SESSION["login"] === true; $validUser = $_SESSION["login"] === true;
$hash = "$2y$10\$AEErDtoqRrizUSS.uIlkDOcX/w3mAxCDo28QnfSNg9FTMC8eQVpeC"; $hash = "$2y$10\$SfW2H/.Sb.MmnBJxs/svAuK7JGk7hL1GADG8tzj7h.AHApZWtuqYW";
if(isset($_POST["sub"])) { if(isset($_POST["sub"])) {
$validUser = $_POST["username"] == "admin" && password_verify($_POST["password"], $hash); $validUser = $_POST["username"] == "admin" && password_verify($_POST["password"], $hash);
if(!$validUser) $errorMsg = "Invalid username or password."; if(!$validUser) $errorMsg = "Invalid username or password.";
else $_SESSION["login"] = true; else{
$_SESSION["login"] = true;
$_SESSION["username"] = $_POST["username"];
}
} }
if($validUser) { if($validUser) {
header("Location: /index.php"); die(); header("Location: /index.php"); die();
} }
include("include/header.php");
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -23,7 +27,7 @@ if($validUser) {
<label for="username">Username:</label><input type="text" value="<?= $_POST["username"] ?>" id="username" name="username" /><br/> <label for="username">Username:</label><input type="text" value="<?= $_POST["username"] ?>" id="username" name="username" /><br/>
<label for="password">Password:</label><input type="password" value="" id="password" name="password" /> <label for="password">Password:</label><input type="password" value="" id="password" name="password" />
<div class="error"><?= $errorMsg ?></div> <div class="error"><?= $errorMsg ?></div>
<input type="submit" value="Home" name="sub" /> <input type="submit" value="Login" name="sub" />
</form> </form>
</body> </body>
</html> </html>

View File

@ -2,5 +2,5 @@
session_start(); session_start();
session_unset(); session_unset();
session_destroy(); session_destroy();
header("Location: /img/index.php"); die(); header("Location: " . $BASE_PATH . "/index.php"); die();
?> ?>

View File

@ -1,3 +1,4 @@
<?php session_start() ?>
<html> <html>
<head> <head>
<?php $thumb_size = 150; ?> <?php $thumb_size = 150; ?>
@ -100,8 +101,8 @@
else if($_GET["p"] + $num_page_selector > $num_pages) $lower_page_num = $num_pages - $num_page_selector*2; else if($_GET["p"] + $num_page_selector > $num_pages) $lower_page_num = $num_pages - $num_page_selector*2;
else $lower_page_num = $_GET["p"] - $num_page_selector; else $lower_page_num = $_GET["p"] - $num_page_selector;
if(!$_GET[p]) $_GET[p] = 1; if(!$_GET["p"]) $_GET["p"] = 1;
$step = ($_GET[p] - 1) * $max; $step = ($_GET["p"] - 1) * $max;
$psb = ""; $psb = "";

View File

@ -13,16 +13,25 @@
include("include/header.php"); include("include/header.php");
include("config.php"); include("config.php");
exec($tmsu . "tags -1 \"" . $_GET["i"] . $excluded_query . "\"", $output);
// if($exclude !== ""){
// foreach($exclude as $excluded_tag){
//
// }
// }
echo "<h1>Tag list</h1>"; echo "<h1>Tag list</h1>";
echo "<img id=\"img\" src=\"/" . $_GET["i"] . "\">"; echo "<img id=\"img\" src=\"/" . $_GET["i"] . "\">";
//Tag list //Tag list
echo "Tags:<br/>";
exec($tmsu . "tags -1 \"" . $_GET["i"] . $excluded_query . "\"", $output);
$num_tags = sizeof($output); $num_tags = sizeof($output);
for($i = 1; $i < $num_tags; $i++){
echo("<a href='http://" . $_SERVER['HTTP_HOST'] . "/tag.php?t=" . $output[$i] . "'>" . $output[$i] ."</a><br/>"); echo "Tags(" . $num_tags . "):<br/>";
unset($output[0]);
foreach($output as $tag){
echo("<a href='http://" . $_SERVER['HTTP_HOST'] . "/tag.php?t=" . $tag . "'>" . $tag ."</a><br/>");
} }
?> ?>
</body> </body>