46 lines
964 B
PHP
46 lines
964 B
PHP
<?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 " . escape_cmd($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 " . escape_cmd($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 . "/");}
|