122 lines
3.4 KiB
PHP
122 lines
3.4 KiB
PHP
<?php
|
|
include("config.php");
|
|
session_start();
|
|
if(!isset($_SESSION["login"])) header("Location: /img/login.php");
|
|
|
|
$paths = array();
|
|
$images = array();
|
|
|
|
$dir = "drw";
|
|
if($_GET["l"] == ".") $_GET["l"] = null;
|
|
if(isset($_GET["l"])) $dir = $_GET["l"];
|
|
if ($handle = opendir($dir)) {
|
|
while (false !== ($entry = readdir($handle))) {
|
|
$x = pathinfo($entry,PATHINFO_EXTENSION);
|
|
if ($x == "" && $entry != "." && $entry != "..") {
|
|
array_push($paths, $entry);
|
|
}
|
|
else if($x == "jpg" || $x == "jpeg" || $x == "png"){
|
|
array_push($images, $entry);
|
|
}
|
|
}
|
|
closedir($handle);
|
|
}
|
|
|
|
if(isset($_GET["t"]) and is_array($_GET["t"])){
|
|
foreach($images as $pic){
|
|
//echo($_GET["t"][$pic] . "\n<br/>");
|
|
$new_tags = $_GET["t"][$pic];
|
|
if($_GET["chk"][$pic] == "on" or !isset($_GET["chk"])){
|
|
$new_tags .= " " . $_GET["mass"];
|
|
}
|
|
|
|
$output = "";
|
|
exec($tmsu . "untag -a $dir/$pic", $output);
|
|
exec($tmsu . "tag --tags=\"" . $new_tags . "\" $dir/$pic", $output);
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Dendy\'s image gallery</title>
|
|
<style>
|
|
.paths{
|
|
margin-bottom: 15px;
|
|
}
|
|
input{
|
|
margin-bottom: 5px;
|
|
}
|
|
.thumb{
|
|
max-height: 100px;
|
|
max-width: 100px;
|
|
}
|
|
textarea{
|
|
background-color: black;
|
|
border: none;
|
|
}
|
|
.mass-box{
|
|
margin-top: 10px;
|
|
margin-bottom: 5px;
|
|
border: solid white 1px;
|
|
width: 100%;
|
|
}
|
|
.tag-box{
|
|
height: 100px;
|
|
width: calc(100% - 100px - 15px - 30px);
|
|
background-color: black;
|
|
border: none;
|
|
}
|
|
.pic-container{
|
|
margin-top: 10px;
|
|
border: solid white 1px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
include("include/header.php");
|
|
|
|
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");
|
|
foreach($paths as $entry){
|
|
echo("<a href='" . $BASE_PATH . "/admin.php?l=$dir/$entry'>$entry</a><br/>\n");
|
|
}
|
|
echo("</div>");
|
|
|
|
/* Images */
|
|
|
|
if($images){
|
|
echo("<form action='admin.php' id='tag-submit'>\n");
|
|
echo("<input type='hidden' name='l' value='" . $_GET["l"] . "'/>\n");
|
|
echo("<input type='submit'/>");
|
|
echo("</form>");
|
|
|
|
echo("<textarea class='mass-box' form='tag-submit' name='mass' placeholder='Tags to assign to all the selected images or all if none are selected.'></textarea>");
|
|
foreach($images as $img){
|
|
$output = "";
|
|
exec($tmsu . "tags -1 '$dir/$img'", $output);
|
|
$num_tags = sizeof($output);
|
|
echo("<div class='pic-container'>\n");
|
|
echo("<img class='thumb' src='" . $BASE_PATH . "/$dir/$img'/>\n");
|
|
|
|
echo("<textarea placeholder='No tags.' class='tag-box' form='tag-submit' name='t[" . $img . "]'>");
|
|
for($i = 1; $i < $num_tags; $i++) echo $output[$i] . " ";
|
|
echo("</textarea>\n");
|
|
echo("<input form='tag-submit' name='chk[" . $img . "]' type='checkbox'/>");
|
|
|
|
echo("</div>\n");
|
|
}
|
|
echo("<br/><input form='tag-submit' type='submit'/>");
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|