Compare commits

...

6 Commits

Author SHA1 Message Date
Dendy 44d7e6f8a4
Add go to admin from view 2020-12-24 14:32:40 +01:00
Dendy 4fd150c79d
Fix setting mass tags space 2020-12-24 14:21:56 +01:00
Dendy b9d0790834
"I don't really know"
I don't really know but i forgot to add the new file int the
previous commit anyway, oops.

Just making this to have a stable ground to make another
commit tbh
2020-12-24 10:26:30 +01:00
Dendy 88f618b007
Add message notification thingie 2020-12-24 10:04:19 +01:00
Dendy e6c41fa25a
Add action to remove unused tags 2020-12-24 01:57:52 +01:00
Dendy d3c559a23a
Fix image view scaling 2020-12-24 01:17:19 +01:00
6 changed files with 92 additions and 10 deletions

45
actions/delete-unused.php Normal file
View File

@ -0,0 +1,45 @@
<?php
session_start();
include("../config.php");
if(!$_IS_ADMIN){
die("Not authorized.");
}
$deleted_tags = "";
$message = "No unused tags found.";
$output = "";
$return = 0;
exec($tmsu . "tags", $output, $return);
foreach($output as $tag){
$count = "";
$return = 0;
exec($tmsu . "files -c '" . addcslashes($tag, '(..)') . "' 2>&1", $count, $return);
if($return !== 0){
$message = 'Could not execute deletion command: "' . $count[0] . '"';
break;
}
if(intval($count[0]) == 0){
$output = "";
exec($tmsu . "delete " . $tag, $output);
$deleted_tags .= $tag . " ";
}
}
if($deleted_tags !== "") $message = "Deleted unused tags: (" . $deleted_tags . ")";
array_push($_SESSION["msg"], $message);
if(isset($_GET["_back"])){
header("Location: " . $_GET["_back"]);
}
else{
//header("Location: " . $BASE_PATH . "/?msg[0]=" , $message);
header("Location: " . $BASE_PATH . "/");}

View File

@ -27,7 +27,7 @@ if(isset($_GET["t"]) and is_array($_GET["t"])){
//echo($_GET["t"][$pic] . "\n<br/>");
$new_tags = $_GET["t"][$pic];
if($_GET["chk"][$pic] == "on" or !isset($_GET["chk"])){
$new_tags .= $_GET["mass"];
$new_tags .= " " . $_GET["mass"];
}
$output = "";
@ -78,7 +78,11 @@ if(isset($_GET["t"]) and is_array($_GET["t"])){
<?php
include("include/header.php");
echo "<h2>Woah</h2>";
echo("<h2>Utilities</h2>");
echo("<a href='actions/delete-unused.php?_back=" . $BASE_PATH . $_SERVER['PHP_SELF'] . "'>Delete unused tags</a>");
echo("<h2>Tag files</h2>");
echo("<div class='paths'>");
echo("<a href='" . $BASE_PATH . "/admin.php?l=" . dirname($dir) . "'><-</a><br/>\n");

View File

@ -1,6 +1,6 @@
<?php
$tmsu = "tmsu -D drw/.tmsu/db ";
$tmsu = "tmsu -D /strg/drw/.tmsu/db ";
$BASE_ROUTE = "";
@ -22,4 +22,12 @@ if(!isset($_SESSION["login"])){
$exclude_query = $exclude_query . $alone_exclude_query;
$alone_exclude_query = "'" . $alone_exclude_query . "'";
}
$_IS_LOGGED = $_SESSION["login"] === "true";
$_IS_ADMIN = $_SESSION["username"] === "admin";
if(!is_array($_SESSION["msg"])){
$_SESSION["msg"] = array();
}
?>

View File

@ -17,6 +17,14 @@
#header{
text-align: center;
}
.alert{
margin: 20px;
padding: 5px;
color: orange;
border: solid orange 1px;
margin: auto;
width: 60vw;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div id="header">
@ -41,4 +49,13 @@
<input type="text" name="t" value="<?php if($_GET["t"]) echo $_GET["t"]; ?>">
<input type="submit">
</form>
<?php
if(isset($_SESSION["msg"]) and is_array($_SESSION["msg"])){
foreach($_SESSION["msg"] as $message){
echo("<div class='alert'>" . $message . "</div>");
$_SESSION["msg"] = array();
}
}
?>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<?php $thumb_size = 150; ?>
<title>Pòsweg\'s image gallery</title>
<title>Dendy\'s image gallery</title>
<style>
.title{
text-align: left;

View File

@ -1,17 +1,19 @@
<?php session_start() ?>
<html>
<head>
<title>Pòsweg's image gallery</title>
<title>Dendy\'s image gallery</title>
<style>
#img{
height: 70vh;
max-height: 70vh;
float: right;
max-width: 100%;
}
</style>
</head>
<body>
<?php
include("config.php");
include("include/header.php");
include("config.php");
exec($tmsu . "tags -1 \"" . $_GET["i"] . $excluded_query . "\"", $output);
@ -21,18 +23,24 @@
// }
// }
echo "<h1>Tag list</h1>";
echo "<img id=\"img\" src=\"/" . $_GET["i"] . "\">";
//Tag list
$num_tags = sizeof($output);
echo "Tags(" . $num_tags . "):<br/>";
echo "<h2>Tag list (" . $num_tags . ")</h2>";
//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/>");
}
if($_IS_ADMIN){
echo("<h2>Admin</h2>");
echo("<a href='" . $BASE_PATH . "/admin.php?l=" . dirname($_GET["i"]) . "'>View folder</a>");
}
?>
</body>
</html>