2020-12-24 09:26:30 +00:00
|
|
|
<?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;
|
|
|
|
|
2020-12-24 23:48:04 +00:00
|
|
|
exec($tmsu . "files -c " . escape_cmd($tag) . " 2>&1", $count, $return);
|
2020-12-24 09:26:30 +00:00
|
|
|
|
|
|
|
if($return !== 0){
|
|
|
|
$message = 'Could not execute deletion command: "' . $count[0] . '"';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(intval($count[0]) == 0){
|
|
|
|
$output = "";
|
2020-12-24 23:48:04 +00:00
|
|
|
exec($tmsu . "delete " . escape_cmd($tag), $output);
|
2020-12-24 09:26:30 +00:00
|
|
|
|
|
|
|
$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 . "/");}
|