"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
This commit is contained in:
Dendy 2020-12-24 10:26:30 +01:00
parent 88f618b007
commit b9d0790834
Signed by: dendy
GPG Key ID: 0168B35FFD7F608F
2 changed files with 45 additions and 3 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

@ -33,9 +33,6 @@
exec($tmsu . "files -c '" . addcslashes($tag . $exclude_query, '(..)') . "'", $count);
echo("<a href='http://" . $_SERVER['HTTP_HOST'] . "/tag.php?t=" . $tag . "'>(" . $count[0] .") " . $tag ."</a>, ");
}
echo("<br/><br/>");
echo("<");
?>
</body>
</html>