2020-05-09 18:53:47 +00:00
< ? php
2020-12-23 23:56:25 +00:00
include ( " config.php " );
2020-05-09 18:53:47 +00:00
session_start ();
if ( ! isset ( $_SESSION [ " login " ])) header ( " Location: /img/login.php " );
2020-12-23 22:22:28 +00:00
$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 );
}
2020-12-23 23:56:25 +00:00
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 " ])){
2020-12-24 13:21:56 +00:00
$new_tags .= " " . $_GET [ " mass " ];
2020-12-23 23:56:25 +00:00
}
$output = " " ;
exec ( $tmsu . " untag -a $dir / $pic " , $output );
exec ( $tmsu . " tag --tags= \" " . $new_tags . " \" $dir / $pic " , $output );
}
}
2020-05-09 18:53:47 +00:00
?>
2020-12-23 22:22:28 +00:00
<! DOCTYPE html >
2020-05-09 18:53:47 +00:00
< html >
< head >
2020-12-23 23:56:25 +00:00
< title > Dendy\ ' s image gallery </ title >
2020-12-23 22:22:28 +00:00
< style >
. paths {
margin - bottom : 15 px ;
}
input {
margin - bottom : 5 px ;
}
. thumb {
max - height : 100 px ;
max - width : 100 px ;
}
2020-12-23 23:56:25 +00:00
textarea {
background - color : black ;
border : none ;
}
. mass - box {
margin - top : 10 px ;
margin - bottom : 5 px ;
border : solid white 1 px ;
width : 100 % ;
}
. tag - box {
2020-12-23 22:22:28 +00:00
height : 100 px ;
2020-12-23 23:56:25 +00:00
width : calc ( 100 % - 100 px - 15 px - 30 px );
2020-12-23 22:22:28 +00:00
background - color : black ;
border : none ;
}
. pic - container {
margin - top : 10 px ;
border : solid white 1 px ;
}
</ style >
2020-05-09 18:53:47 +00:00
</ head >
< body >
< ? php
include ( " include/header.php " );
2020-12-24 00:57:52 +00:00
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> " );
2020-05-09 18:53:47 +00:00
2020-12-23 22:22:28 +00:00
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> " );
2020-12-23 23:56:25 +00:00
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> " );
2020-12-23 22:22:28 +00:00
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 " );
2020-12-23 23:56:25 +00:00
echo ( " <textarea placeholder='No tags.' class='tag-box' form='tag-submit' name='t[ " . $img . " ]'> " );
2020-12-23 22:22:28 +00:00
for ( $i = 1 ; $i < $num_tags ; $i ++ ) echo $output [ $i ] . " " ;
echo ( " </textarea> \n " );
2020-12-23 23:56:25 +00:00
echo ( " <input form='tag-submit' name='chk[ " . $img . " ]' type='checkbox'/> " );
2020-12-23 22:22:28 +00:00
echo ( " </div> \n " );
}
2020-12-23 23:56:25 +00:00
echo ( " <br/><input form='tag-submit' type='submit'/> " );
2020-12-23 22:22:28 +00:00
}
2020-05-09 18:53:47 +00:00
?>
</ body >
</ html >