From 9956c737cb1cf4fb37cb03b28cb62420cce21bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=B2sweg?= Date: Sat, 9 May 2020 20:53:47 +0200 Subject: [PATCH] initial commit --- .gitignore | 3 + admin.php | 46 ++++++++++++++ config.php | 23 +++++++ include/header.php | 33 ++++++++++ index.php | 35 +++++++++++ login.php | 29 +++++++++ logout.php | 6 ++ tag.php | 153 +++++++++++++++++++++++++++++++++++++++++++++ view.php | 29 +++++++++ 9 files changed, 357 insertions(+) create mode 100644 .gitignore create mode 100644 admin.php create mode 100644 config.php create mode 100644 include/header.php create mode 100644 index.php create mode 100644 login.php create mode 100644 logout.php create mode 100644 tag.php create mode 100644 view.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6cd7a3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +drw + +.thumb/ diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..f407306 --- /dev/null +++ b/admin.php @@ -0,0 +1,46 @@ + + + + Pòsweg's image gallery + + +Woah"; + + $images = array(); + + $dir = "drw"; + if(isset($_GET["l"])) $dir = $_GET["l"]; + if ($handle = opendir($dir)) { + while (false !== ($entry = readdir($handle))) { + $x = pathinfo($entry,PATHINFO_EXTENSION); + if ($x == "" && $entry != ".") { + echo("$entry
\n"); + } + else if($x == "jpg" || $x == "jpeg" || $x == "png"){ + array_push($images, $entry); + } + } + closedir($handle); + } + + foreach($images as $img){ + $output = ""; + exec($tmsu . "tags -1 '$dir/$img'", $output); + $num_tags = sizeof($output); + echo("
"); + echo(""); + echo("
"); + echo("
"); + } +?> + + diff --git a/config.php b/config.php new file mode 100644 index 0000000..2be7d0c --- /dev/null +++ b/config.php @@ -0,0 +1,23 @@ + diff --git a/include/header.php b/include/header.php new file mode 100644 index 0000000..f5b9e01 --- /dev/null +++ b/include/header.php @@ -0,0 +1,33 @@ + + + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..33b5777 --- /dev/null +++ b/index.php @@ -0,0 +1,35 @@ + + + Pòsweg's image gallery + + +Tag list"; + + exec($tmsu . "tags", $output); + $tag_num = sizeof($output); + for($i = 0; $i < $tag_num; $i++){ + foreach($exclude as $excluded_tag){ + if($excluded_tag == $output[$i]){ + unset($output[$i]); + } + } + } + + $tag_num = sizeof($output); + + // Echo total tag count + echo "

There is a total of " . $tag_num . " tags

"; + + //Tag list + foreach($output as $tag){ + $count = ""; + exec($tmsu . "files -c " . $tag . $exclude_query, $count); + echo("(" . $count[0] .") " . $tag .", "); + } +?> + + diff --git a/login.php b/login.php new file mode 100644 index 0000000..50cb52e --- /dev/null +++ b/login.php @@ -0,0 +1,29 @@ + + + + + + Login + + +
+ " id="username" name="username" />
+ +
+ +
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..4c2373f --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + diff --git a/tag.php b/tag.php new file mode 100644 index 0000000..3333798 --- /dev/null +++ b/tag.php @@ -0,0 +1,153 @@ + + + + Pòsweg's image gallery + + + +setImageFormat($x); + $image->thumbnailImage($thumb_size, $thumb_size, TRUE); + $image->writeImage($thumb_path); + echo "creating thumb"; + } + + return ""; + } + + echo "return"; + + echo("

" . $_GET ["t"] . "

"); + + /* Get image paths */ + + /* Queries */ + + // Handle * and void to show everything + if(!$_GET["t"] || $_GET["t"] == "*") + exec($tmsu . "files " . $alone_exclude_query, $output); + // regular query + else exec($tmsu . "files '" . $_GET["t"] . $exclude_query . "'", $output); + + /* Purge things that aren't images */ + + $total = sizeof($output); + for($i = 0; $i < $total; $i++){ + $x = pathinfo($output[$i],PATHINFO_EXTENSION); + if($x != "jpg" && $x != "jpeg" && $x != "png") unset($output[$i]); + } + $output = array_values($output); + $total = sizeof($output); + + // Set base directory + $basedir = "/tag.php?"; + if($_GET["t"]) $basedir = $basedir . "t=".$_GET["t"] . "&"; + $basedir = $basedir . "p="; + + $max = 25; + + /* PAGE SELECTION BAR */ + + $num_pages = ceil($total/$max); + $num_page_selector = 3; //number of pages selectable before and after + if($_GET["p"] - $num_page_selector < 1) $lower_page_num = 1; + else if($_GET["p"] + $num_page_selector > $num_pages) $lower_page_num = $num_pages - $num_page_selector*2; + else $lower_page_num = $_GET["p"] - $num_page_selector; + + if(!$_GET[p]) $_GET[p] = 1; + $step = ($_GET[p] - 1) * $max; + + $psb = ""; + + $psb = $psb . "
\n"; + if($_GET["p"] > 2){ + $psb = $psb . "\n"; + } + if($_GET["p"] != 1){ + $psb = $psb . "\n"; + } + for($i = $lower_page_num; $i < $lower_page_num + $num_page_selector*2 + 1 && $i < $num_pages + 1; $i++){ + $psb = $psb . "
\n"; + if($i != $_GET["p"]) $psb = $psb . "".$i." \n"; + else $psb = $psb . $i . " \n"; + $psb = $psb . "
\n"; + } + if($_GET["p"] != $num_pages){ + $psb = $psb . "\n"; + } + if($_GET["p"] < $num_pages - 1){ + $psb = $psb . "\n"; + } + $psb = $psb . "
\n"; + + /* END OF PAGE SELECTION BAR */ + + // Title + if($total != 0) echo "

There are a total of " . $total . " images under the tag(s) " . $_GET["t"] . ".

\n"; + else echo "There aren't any images with that tag query"; + + echo $psb; + + /* ACTUAL IMAGES */ + + echo "
"; + for($i = 0 + $step; $i < $max + $step && $i < $total; $i++){ + echo ""; + echo "\n\t
\n"; + //echo "\t\t" . basename($output[$i]) . "
\n"; + echo "
" . thumbmake($output[$i]) . "
"; + echo "\t
\n"; + echo "
\n\n"; + } + echo "
"; + + echo $psb; +?> + + diff --git a/view.php b/view.php new file mode 100644 index 0000000..84cabe1 --- /dev/null +++ b/view.php @@ -0,0 +1,29 @@ + + + Pòsweg's image gallery + + + +Tag list"; + + echo ""; + + //Tag list + echo "Tags:
"; + exec($tmsu . "tags -1 \"" . $_GET["i"] . $excluded_query . "\"", $output); + $num_tags = sizeof($output); + for($i = 1; $i < $num_tags; $i++){ + echo("" . $output[$i] ."
"); + } +?> + +