$gallerytitle = "THE TARAPORE & LOGANATHAN HIGHER SECONDARY SCHOOL FOR GIRLS";
$gallerydir = ".";
$owneremail = "postmaster@localhost";
$activestyle = "rounded";
$sendmail = "0";
$showexif = "0";
$showcomments = "0";
$thumbcaptions = "0";
$resizelargeimg = "1024";
$dateformat = "j.m.Y, H:i";
$images_side = "4";
$pagerows = "5";
$upload_height = "250";
$upload_width = "250";
$upload_quality = "85";
$gallerycopyright = "Copyright © 2021";
$adminpass = "7cdae8728193469654d2b837317f4b96";
$version = "B13";
?>
//////////////////////////////////////////////////////////////////////////////////////
// //
// MiniGal //
// //
// Copyright © 2004 Thomas Rybak //
// http://www.thomasrybak.com/minigal //
// minigal@thomasrybak.com //
// //
// MiniGal is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// MiniGal is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, you can find it here: //
// http://www.gnu.org/copyleft/gpl.html //
// //
//////////////////////////////////////////////////////////////////////////////////////
class Minigal
{
var $activestyle;
var $list;
var $gallerydir;
var $page;
var $image;
var $images_side;
var $pagerows;
var $gallerytitle;
var $dateformat;
var $gallerycopyright;
var $upload_height;
var $upload_width;
//////////////////////////////
// DEBUG MODE //
//////////////////////////////
function debug() {
if (isset($_REQUEST["debug"]) && $_REQUEST["debug"] == "yes") {
?>
SERVER_NAME | if ($_SERVER["SERVER_NAME"]) echo $_SERVER["SERVER_NAME"]; ?>
|
PHP_SELF | if ($_SERVER["PHP_SELF"]) echo $_SERVER["PHP_SELF"]; ?>
|
PATH_TRANSLATED | if ($_SERVER["PATH_TRANSLATED"]) echo $_SERVER["PATH_TRANSLATED"]; ?>
|
SERVER_SOFTWARE | if ($_SERVER["SERVER_SOFTWARE"]) echo $_SERVER["SERVER_SOFTWARE"]; ?>
|
Operating system | if ($_ENV["OS"]) echo $_ENV["OS"]; ?>
|
Gallery dir | if ($this->gallerydir) echo $this->gallerydir; ?>
|
Admin email | if ($this->owneremail) echo $this->owneremail; ?>
|
safe_mode | if (ini_get("safe_mode")) echo ini_get("safe_mode") ?> |
open_basedir | if (ini_get("open_basedir")) echo ini_get("open_basedir") ?> |
file_uploads | if (ini_get("file_uploads")) echo ini_get("file_uploads") ?> |
}
}
//////////////////////////////
// GET FILES & FOLDERS //
//////////////////////////////
function dirlist()
{
$allowed_files = array(".jpg",".jpeg",".gif",".png",".mov",".avi",".mpg",".mpeg",".wmv",".asf");
$disallowed_dirs = array(".","..","thumbs","styles","counter","minigal");
$dirarray = array();
$filearray = array();
$this->list = str_replace("..", "", $this->list);
if (is_dir("$this->gallerydir/$this->list")) {
$workdir = opendir("$this->gallerydir/$this->list");
while ($pointer = readdir($workdir)) {
if (is_dir("$this->gallerydir/$this->list/$pointer") && !in_array(strtolower($pointer),$disallowed_dirs)) { $this->dirarray[] = $pointer; }
elseif (is_file("$this->gallerydir/$this->list/$pointer") && in_array(strtolower(strrchr($pointer, ".")), $allowed_files)) { $this->filearray[] = $pointer; }
}
closedir($workdir);
}
if (@$this->dirarray > 0) { sort($this->dirarray); }
if (@$this->filearray > 0) { sort($this->filearray); }
}
//////////////////////////////
// IS DIR EMPTY //
//////////////////////////////
function is_dir_empty($dir)
{
$allowed_files = array(".jpg",".jpeg",".gif",".png",".mov",".avi",".mpg",".mpeg",".wmv",".asf");
if (is_dir($dir)) {
$dl = opendir($dir);
if ($dl) {
while($name = readdir($dl)) {
if (!is_dir($name) && in_array(strtolower(strrchr($name, ".")), $allowed_files)) {
return false;
break;
}
}
closedir($dl);
}
return true;
} else {
return true;
}
}
//////////////////////////////
// FIND THUMBNAIL //
//////////////////////////////
function setthumb($dirarray)
{
unset($thumb);
$allowed_files = array(".jpg",".jpeg",".gif",".png");
if (strlen($this->list) > 0) { $this->list .= "/"; } //Set list variable ending slash
$thumbdir = opendir("$this->gallerydir/$this->list$dirarray");
if (is_dir("$this->gallerydir/$this->list$dirarray/thumbs")) {
while (false !== ($thumbtemp = readdir($thumbdir))) {
// Standard thumb
if (is_file("$this->gallerydir/$this->list$dirarray/thumbs/tn_thumb.jpg")) {
return "$this->list$dirarray/thumbs/tn_thumb.jpg";
} else
// Locked folder
if (is_file("$this->gallerydir/$this->list$dirarray/locked.dir")) {
return "styles/$this->activestyle/images/locked.gif";
}
//"Random thumb"
if (is_file("$this->gallerydir/$this->list$dirarray/$thumbtemp") && in_array(strtolower(strrchr($thumbtemp, ".")), $allowed_files)) {
return "$this->list$dirarray/thumbs/tn_$thumbtemp";
} else
// Empty dir
if ($this->is_dir_empty("$this->gallerydir/$this->list$dirarray")===true) {
return "styles/$this->activestyle/images/emptythumb.gif";
}
}
} else {
return "styles/$this->activestyle/images/emptythumb.gif";
}
closedir($thumbdir);
if (strlen($this->list) > 0) { rtrim($this->list, "/"); } //Un-Set list variable ending slash
}
//////////////////////////////
// FOLDER NAME/CAPTION //
//////////////////////////////
function getfoldername($i)
{
if (strlen($this->list) > 0) { $this->list .= "/"; } //Set list variable ending slash
if (is_file("$this->gallerydir/" . $this->list . "/" . $this->dirarray[$i] . "/caption.dir")) {
$fd = fopen ("$this->gallerydir/" . $this->list . "/" . $this->dirarray[$i] . "/caption.dir", "rt");
$currentvalue = "";
while (!feof($fd)) {
$currentvalue .= fgets($fd, 4096);
}
fclose ($fd);
echo $currentvalue;
} else {
echo $this->dirarray[$i];
}
if (strlen($this->list) > 0) { rtrim($this->list, "/"); } //Un-Set list variable ending slash
}
//////////////////////////////
// GETCURRENTFOLDER //
//////////////////////////////
function getcurrentfolder()
{
if (is_file($this->list . "/caption.dir")) {
$fd = fopen ($this->list . "/caption.dir", "rt");
while(!feof($fd)) {
echo fgets($fd, 4096); }
fclose ($fd);
} else {
echo (strlen($this->list) > 0) ? $this->list : $this->gallerytitle ;
}
}
//////////////////////////////
// GALLERY NAVIGATION //
//////////////////////////////
function navigation($delimiter = ">")
{
$imagecomp = 0;
if ($this->image) { $imagecomp = 1; }
$pos = strpos($this->list, "/");
$updirs = explode("/", $this->list);
$dircount = count($updirs);
$dirstring = "";
$updirstring = "";
if ($dircount > 0) {
if (strlen($this->list) > 0 || isset($_GET["image"])) {
echo "" . $this->lang["gallery"] . "";
for ($i = 0; $i < ($dircount + $imagecomp - 1); $i++) {
if (is_file($updirstring . $updirs[$i] . "/caption.dir")) {
$fd = fopen($updirstring . $updirs[$i] . "/caption.dir", "rt");
while (!feof($fd)) {
$currentdir = fgets($fd, 4096);
}
fclose ($fd);
} else {
$currentdir = $updirs[$i];
}
$updirstring .= $updirs[$i]. "/";
if (strlen($updirs[$i]) > 0) {
$dirstring .= " $delimiter " . $currentdir . "";
}
}
}
}
echo $dirstring;
}
//////////////////////////////
// IMAGE NAVIGATION(S) //
//////////////////////////////
function imagenav($style)
{
$subpage = "1";
$number_this = (array_search($this->image, $this->filearray)+1);
$number_total = count($this->filearray);
// Select style:
if ($style == "1") {
$nav_first_on = '
';
$nav_first_off = '
';
$nav_prev_on = '
';
$nav_prev_off = '
';
$nav_next_on = '
';
$nav_next_off = '
';
$nav_last_on = '
';
$nav_last_off = '
';
} else {
if ($style == "2") {
$nav_first_on = $this->lang["first"]; $nav_first_off = $this->lang["first"];
$nav_prev_on = $this->lang["prev"]; $nav_prev_off = $this->lang["prev"];
$nav_next_on = $this->lang["next"]; $nav_next_off = $this->lang["next"];
$nav_last_on = $this->lang["last"]; $nav_last_off = $this->lang["last"];
} else {
$nav_first_on = "<<<<"; $nav_first_off = "<<<<";
$nav_prev_on = "<<"; $nav_prev_off = "<<";
$nav_next_on = ">>"; $nav_next_off = ">>";
$nav_last_on = ">>>>"; $nav_last_off = ">>>>";
}
}
if ($_GET["page"] == "all") { $subpage = "all"; }
if (array_search($this->image, $this->filearray) > 0) {
$nav_first = "filearray[0] . "&list=$this->list&page=$subpage\">$nav_first_on";
} else $nav_first = $nav_first_off;
$subpage = ceil((array_search($this->image, $this->filearray)) / ($this->images_side * $this->pagerows));
if ($_GET["page"] == "all") { $subpage = "all"; }
if (array_search($this->image, $this->filearray) > 0) {
$nav_previous = "filearray[array_search($this->image, $this->filearray)-1]) . "&list=$this->list&page=$subpage\">$nav_prev_on";
} else $nav_previous = $nav_prev_off;
$subpage = ceil((array_search($this->image, $this->filearray) + 2) / ($this->images_side * $this->pagerows));
if ($_GET["page"] == "all") { $subpage = "all"; }
if (array_search($this->image, $this->filearray) + 1 < count($this->filearray)) {
$nav_next = "filearray[array_search($this->image, $this->filearray) + 1]) . "&list=$this->list&page=$subpage\">$nav_next_on";
} else $nav_next = $nav_next_off;
$subpage = ceil((count($this->filearray))/($this->images_side*$this->pagerows));
if ($_GET["page"] == "all") { $subpage = "all"; }
if (array_search($this->image, $this->filearray) + 1 != count($this->filearray)) {
$nav_last = "filearray[(count($this->filearray) - 1)]) . "&list=$this->list&page=$subpage\">$nav_last_on";
} else $nav_last = $nav_last_off;
include("styles/$this->activestyle/templates/template_imagenav.php");
}
//////////////////////////////
// PAGE NAVIGATION //
//////////////////////////////
function pagecounter()
{
if ($this->page == "") { $this->page = 1; }
if (($this->images_side * $this->pagerows) < count($this->filearray)) {
echo "\n
\n";
}
}
//////////////////////////////
// SHOW CAPTION //
//////////////////////////////
function showcaption()
{
$openfile = "$this->gallerydir/$this->list/thumbs/" . $this->image . ".cmt";
if (is_file($openfile)) {
$fd = fopen($openfile, "rb");
echo fgets($fd, 4096);
fclose ($fd);
}
}
//////////////////////////////
// GALLERY COPYRIGHT //
//////////////////////////////
function gallerycopyright()
{
echo $this->gallerycopyright;
}
//////////////////////////////
// SHOW EXIF //
//////////////////////////////
function showexif($showexif)
{
if ($showexif == "1") {
include("exif.php");
$exif = read_exif_data_raw("$this->gallerydir/$this->list/$this->image","no");
if ($exif["IFD0"]["Model"] != "") {
include("styles/$this->activestyle/templates/template_exif.php");
}
}
}
//////////////////////////////
// SHOW INTRO TEXT //
//////////////////////////////
function showfolderintro()
{
if(is_file("$this->gallerydir/$this->list/description.dir")) {
$fd = fopen ("$this->gallerydir/$this->list/description.dir", "rt");
$currentvalue = "";
while (!feof ($fd)) {
$currentvalue .= fgets($fd, 4096);
}
fclose ($fd);
echo '' . nl2br($currentvalue) . '
';
}
}
//////////////////////////////
// FOLDER PASSWORD //
//////////////////////////////
function folderpwdcheck()
{
if (is_file("$this->list/locked.dir")) { // is folder locked?
$currentpass = "";
$fd = fopen("$this->list/locked.dir", "rt");
$currentpass = trim(fgets($fd, 4096));
fclose ($fd);
if (md5($_POST["folderpass"]) == $currentpass) { // if password is correct:
$_SESSION["folderpass"] = $_POST["folderpass"];
$_SESSION["logintime"] = time();
}
if (md5($_SESSION["folderpass"]) != $currentpass) {
echo "\n";
if (isset($_POST["folderpass"])) {
echo "
" . $this->lang["wrong pwd"] . "
\n";
}
?>
include("styles/$this->activestyle/templates/template_footer.php");
exit();
} elseif ((time() - $_SESSION["logintime"]) < 900) { // Renew timestamp if not too old
$_SESSION["logintime"] = time();
} else { // Do security logoff
session_destroy();
?>
include("styles/$this->activestyle/templates/template_footer.php");
exit();
}
}
}
//////////////////////////////
// IMAGE COMMENTS //
//////////////////////////////
function imagecomments($showcomments)
{
if (isset($_REQUEST["input"])) { // Input comments
$chatfile = "$this->gallerydir/$this->list/thumbs/$this->image.txt";
if (strlen($_REQUEST["input"]) > 0 && strlen($_REQUEST["name"]) > 0 && strlen($_REQUEST["email"]) > 0) {
if (!is_file($chatfile)) {
$fd = fopen($chatfile,"a+");
} else
$fd = fopen($chatfile,"r+");
while (!feof ($fd)) {
$bufferprewrite[] = fgets($fd, 4096);
}
fclose($fd);
array_pop($bufferprewrite);
$bufferprewrite = array_reverse($bufferprewrite);
$array = explode("¤", $bufferprewrite[0]);
if (rtrim($array[1]) <> ucfirst(rtrim($_REQUEST["input"]))) {
$buffer = date($this->dateformat) . "¤" . ucfirst($_REQUEST["input"]) . "¤" . ucfirst($_REQUEST["name"]) . "¤" . $_REQUEST["email"] . "\r\n";
$fd = fopen($chatfile,"a+");
fwrite($fd,$buffer);
fclose($fd);
// Send comment mail
if ($this->sendmail == "1") {
if (isset($_SERVER["SCRIPT_URI"])) {
$preset1 = dirname($_SERVER["SCRIPT_URI"]);
} else {
$preset1 = $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]);
}
mail($this->owneremail, "$this->gallerytitle: " . $this->lang["mailsubj"], date($this->dateformat,time()) . "\n\n" . $_REQUEST["name"] . "(" . $_REQUEST["email"] . ") " . $this->lang["mailcontent1"] . ":\n\n" . $_REQUEST["input"] . "\n\n" . $this->lang["mailcontent2"] . "\n\n$preset1/index.php?image=" . rawurlencode("$this->image") . "&list=" . rawurlencode("$this->list"), "From: " . $_REQUEST["email"] . "\nReply-to: " . $_REQUEST["email"]);
}
}
} else {
echo '' . $this->lang["error comment"] . '
';
}
}
//Show user COMMENTS
if ($showcomments == 1) {
?>
}
}
//////////////////////////////
// GET CAPTION //
//////////////////////////////
function getcaption($thumbcaptions, $i)
{
if ($thumbcaptions == "1") {
$this->caption = "";
if (strlen($this->list) > 0) { $this->list .= "/"; } //Set list variable ending slash
$openfile = "$this->gallerydir/" . $this->list . "thumbs/" . $this->filearray[$i] . ".cmt";
if (is_file($openfile)) {
$fd = fopen ($openfile, "rb");
echo fgets($fd, 4096);
fclose ($fd);
}
}
if (strlen($this->list) > 0) { rtrim($this->list, "/"); } //Un-Set list variable ending slash
}
}
?>