aboutsummaryrefslogtreecommitdiff
path: root/www/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/index.php')
-rw-r--r--www/index.php356
1 files changed, 110 insertions, 246 deletions
diff --git a/www/index.php b/www/index.php
index 011a614..1483b84 100644
--- a/www/index.php
+++ b/www/index.php
@@ -2,14 +2,6 @@
# uncomment this to check for uninitialized variables etc.:
# error_reporting (E_ALL);
-# get variables from the _SERVER array in order to not
-# rely on register_globals = On
-# (this will not work with standalone PHP)
-$ThisScript=preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
-$ScriptFileName=$_SERVER['SCRIPT_FILENAME'];
-$HostName=$_SERVER['SERVER_NAME'];
-$ThisUrl = $_SERVER['REQUEST_URI'];
-
#language support
require_once ("lib/lib.l10n.php");
require_once("inc/config.inc.php");
@@ -68,78 +60,7 @@ if ($galerie) {
}
}
-// processing of the user comment data
-if($comments && @$_POST["commentdata"]) {
- $username = @$_COOKIE["username"];
- $comment_name = @$_POST["commentname"];
- $save_comment_name = @$_POST["savecommentname"];
- $comment_data = @$_POST["commentdata"];
- $comment_kolacek = @$_POST["commentkolacek"];
- $comment_spamcheck = @$_POST["commentspamcheck"];
-
- #check for HTML tags
-
- $comment_name = stripslashes(strip_tags($comment_name));
- $allowedTags = '<a><b><i><ul><li><blockquote><br>';
- $comment_data = stripslashes(strip_tags($comment_data,$allowedTags));
- // thanks google:
- // http://www.google.com/googleblog/2005/01/preventing-comment-spam.html
- $comment_data = eregi_replace("<a ","<a rel=\"nofollow\" ",$comment_data);
-
- #further comment spam
- $comment_blacklist = array("pharmacy", "poker", "Viagra");
-
- foreach($comment_blacklist as $blackword) {
- $check = addslashes($blackword);
- if (eregi($check,$comment_data)) {
- #write error message
- $page->error( __('No comment spam'), __('Your comment includes blacklisted word') . __('No comment spam') );
- $page->footer();
- exit; //stop everything
- }
- }
-
- if ($comment_kolacek!=md5($comment_spamcheck)) {
- $page->error( __('No comment spam'), __('You ve written the check number wrong' ) );
- $page->footer();
- exit; //stop everything
- }
-
- if (!$comment_name) {
- $comment_name = $_COOKIE["username"];
- }
-
- // ok so we got a comment
- if ($comment_name && $save_comment_name) {
- // save out name in a cookie
- if (!setcookie("username","$comment_name",
- mktime(0, 0, 0, 12, 30, 2030))) {
- print __('Could not set name cookie!');
- exit;
- }
- }
-
- // create a user_comment file if not existant or append to it
- if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
- $comment = "$root/$gallery_dir/$galerie/comments/user_$snimek.txt";
- $fh = fopen("$comment", "a");
-
- if (!$comment_name) {
- $comment_name = __('Anonymous');
- }
- if (!fwrite($fh, "<div class=\"commententry\">\n")) {
- $page->error( __('Could not write to') . $comment . "!" );
- $page->footer();
- exit; //stop everything
- }
- fwrite($fh, " <div class=\"name\">" . __('Comment from') . "<em>$comment_name</em></div>\n",90);
- fwrite($fh, " <div class=\"commentdata\">$comment_data</div>\n",280);
- fwrite($fh, "</div>\n");
-
- fclose($fh);
- }
-}
-
+$page->process_comment_form();
//START RENDERING
@@ -148,15 +69,15 @@ $page->header("Photos");
require("inc/header.inc.php");
// folder > tree
-//echo "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
-echo "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>";
+//print "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
+print "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>";
#############################
# Overall Gallery Index #
#############################
if (!$galerie) {
# finish off navigation bar
- echo "</div>\n\n<!-- listing galleries-->\n\n";
+ print "</div>\n\n<!-- listing galleries-->\n\n";
# I've nuked date.txt to replace it with a more generic info.txt
# It optionally supplies i18n name, camera model, author and date
# TODO: imgconv script support
@@ -207,55 +128,55 @@ if (!$galerie) {
$one_out = true;
if (@$thisyear!=$year) { #if the year is not equal to the current year
#This is the first year
- if (@$thisyear) { echo " </div>\n</div>\n";}// end last year if this is
+ if (@$thisyear) { print " </div>\n</div>\n";}// end last year if this is
// not the first one
#This is a new year
unset($thismonth);
- echo "<div class=\"year\"><h3>$year</h3>\n";
- echo "";
+ print "<div class=\"year\"><h3>$year</h3>\n";
+ print "";
}
$month=$galeriemonth["$foldername"];
# now months
if (@$thismonth!=$month) {
#first one
- if (@$thismonth) { echo " </div>\n"; } // end of last month if
+ if (@$thismonth) { print " </div>\n"; } // end of last month if
// this is not the first one
#new month
$monthindex = $month - 1;
$monthname = $months[$monthindex];
- echo " <div class=\"month\"><h4>$monthname</h4>\n";
+ print " <div class=\"month\"><h4>$monthname</h4>\n";
}
#galleries within month
if ($galerielogin[$foldername]) {
- echo " <p class=\"restricted\"><a ";
+ print " <p class=\"restricted\"><a ";
} else {
- echo " <p><a ";
+ print " <p><a ";
}
if (@$galeriename[$foldername]) {
- echo " href=\"$ThisScript?galerie=$foldername\">";
- echo $galeriename[$foldername];
- echo "</a>";
+ print " href=\"$ThisScript?galerie=$foldername\">";
+ print $galeriename[$foldername];
+ print "</a>";
} else {
- echo " href=\"$ThisScript?galerie=$foldername\">$foldername</a>";
+ print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>";
}
if (@$galeriedesc[$foldername]) {
- echo "<span class=\"desc\">" . $galeriedesc[$foldername];
- echo "</span>\n";
+ print "<span class=\"desc\">" . $galeriedesc[$foldername];
+ print "</span>\n";
}
if (@$galerieauthor[$foldername]) {
- echo "<span class=\"author\">by&nbsp;" . $galerieauthor[$foldername];
- echo "</span>\n";
+ print "<span class=\"author\">by&nbsp;" . $galerieauthor[$foldername];
+ print "</span>\n";
}
if (@$galerieday[$foldername]) {
- echo "<span class=\"date\">";
- echo "$monthname&nbsp;" . $galerieday[$foldername];
- echo "</span>\n";
+ print "<span class=\"date\">";
+ print "$monthname&nbsp;" . $galerieday[$foldername];
+ print "</span>\n";
}
- echo "</p>\n";
+ print "</p>\n";
$thisyear=$year;
$thismonth=$month;
}
- if ($one_out) echo (" </div>\n</div>\n\n");
+ if ($one_out) print (" </div>\n</div>\n\n");
##############################
# Individual Gallery Index #
@@ -264,16 +185,16 @@ if (!$galerie) {
# finish off navigation header
- echo "\n &gt; ";
+ print "\n &gt; ";
if ($galeriename[$galerie]) {
- echo $galeriename[$galerie];
+ print $galeriename[$galerie];
} else {
- echo $galerie;
+ print $galerie;
}
- echo "</div>\n\n";
+ print "</div>\n\n";
//thumbnails
- echo "<p class=\"bigthumbnails\">\n";
+ print "<p class=\"bigthumbnails\">\n";
$path = "$gallery_dir/$galerie/thumbs";
$imgfiles = new SortDir($path);
check($galerie); // check for nasty input
@@ -316,223 +237,166 @@ if (!$galerie) {
} else
$title = "Photo ${x[1]}";
- echo " <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
- echo " title=\"$title, $NumOfComments\"";
- if ($class) echo " class=\"$class\"";
- echo ">";
- echo "<img ";
+ print " <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
+ print " title=\"$title, $NumOfComments\"";
+ if ($class) print " class=\"$class\"";
+ print ">";
+ print "<img ";
if ($thumbsize) {
- echo "width=\"120\" height=\"80\" ";
+ print "width=\"120\" height=\"80\" ";
} else {
// scale portraits to 80 height
if ($portrait) {
//portrait
- echo "width=\"";
+ print "width=\"";
$scaled = round($imgsize[0] / 1.5);
- echo $scaled;
- echo "\" height=\"${imgsize[0]}\"";
+ print $scaled;
+ print "\" height=\"${imgsize[0]}\"";
} else {
//landscape
- echo $imgsize[3];
+ print $imgsize[3];
}
}
- echo " src=\"$thumb\" ";
- echo "alt=\"photo No. ${x[1]}\" />";
- echo "</a>\n";
+ print " src=\"$thumb\" ";
+ print "alt=\"photo No. ${x[1]}\" />";
+ print "</a>\n";
}
}
- echo "</p>\n";
+ print "</p>\n";
//info
- echo "<div id=\"info\">\n";
+ print "<div id=\"info\">\n";
if ($galeriedesc[$galerie]) {
- echo "<p>";
- echo "<span class=\"value\">";
- echo $galeriedesc[$galerie] . "</span></p>\n";
+ print "<p>";
+ print "<span class=\"value\">";
+ print $galeriedesc[$galerie] . "</span></p>\n";
}
if ($galerieauthor[$galerie]) {
- echo "<p><span class=\"key\">Author: </span>";
- echo "<span class=\"value\">";
- echo $galerieauthor[$galerie] . "</span></p>\n";
+ print "<p><span class=\"key\">Author: </span>";
+ print "<span class=\"value\">";
+ print $galerieauthor[$galerie] . "</span></p>\n";
}
- echo "</div>\n";
+ print "</div>\n";
//and links to archived images:
- echo "\n<p class=\"archives\">\n";
+ print "\n<p class=\"archives\">\n";
if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
- echo "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
+ print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
}
if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
- echo "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
+ print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
- echo "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
+ print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
- echo "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
+ print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
}
- echo "</p>";
+ print "</p>";
#######################
# Individual Image #
#######################
} else { //low-res image
# finish off header
- echo "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
+ print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
if ($galeriename[$galerie]) {
- echo $galeriename[$galerie];
+ print $galeriename[$galerie];
} else {
- echo $galerie;
+ print $galerie;
}
- echo "</a>\n &gt; Photo";
- echo " $snimek</div>";
+ print "</a>\n &gt; Photo";
+ print " $snimek</div>";
$path = "$gallery_dir/$galerie/thumbs";
$imgfiles = new SortDir("$path");
check($galerie);
$path = "$gallery_dir/$galerie/lq";
$file = "$path/img-$snimek.jpg";
if (!file_exists($file)) {
- echo __('No such image');
+ print __('No such image');
$page->footer();
exit;
}
- $imgsize = getimagesize("$root/$file");
- /*
- navigation($galerie, $snimek, null);
- */
+
+ if (!$picture) { //picture may have been created if commentform submitted
+ require_once("$root/inc/photo.class.inc.php");
+ $picture = new C_photo($file, $snimek);
+ }
// mini thumbnail roll
if ($show_thumbs) {
- echo "\n<!--mini thumbnail roll-->\n<div class=\"thumbroll\">";
- echo "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
- echo "&amp;exif_style=$exif_style\">";
- echo "</a>\n";
- echo " : \n";
+ print "\n<!--mini thumbnail roll-->\n<div class=\"thumbroll\">";
+ print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
+ print "&amp;exif_style=$exif_style\">";
+ print "</a>\n";
+ print " : \n";
while ($thumbfile = $imgfiles->read()) {
if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
$thumbfile, $x)) {
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
- echo " <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}";
- echo "&amp;show_thumbs=$show_thumbs\"";
- echo " title=" . get_photo_title($galerie, $x[1]) . ">";
- echo "<img class=\"thumb\" ";
+ print " <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}";
+ print "&amp;show_thumbs=$show_thumbs\"";
+ print " title=" . get_photo_title($galerie, $x[1]) . ">";
+ print "<img class=\"thumb\" ";
// hadess' hack (TM) ;)
if ($thumbsize) {
- echo " width=\"24\" height=\"16\"";
+ print " width=\"24\" height=\"16\"";
} else {
$minithumb=getimagesize("$root/$thumb");
$w=$minithumb[0]/6;
$h=$minithumb[1]/6;
- echo " width=\"$w\" height=\"$h\"";
+ print " width=\"$w\" height=\"$h\"";
}
- echo " src=\"$thumb\" ";
- echo "alt=\"photo No. ${x[1]}\" />";
- echo "</a> \n";
+ print " src=\"$thumb\" ";
+ print "alt=\"photo No. ${x[1]}\" />";
+ print "</a> \n";
}
}
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
- echo "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
- echo "zip<span /></a>";
+ print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
+ print "zip<span /></a>";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
- echo "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
- echo "zip<span /></a>";
+ print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
+ print "zip<span /></a>";
}
- echo "</div>\n";
+ print "</div>\n";
} else {
// show the popup button
- echo "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
- echo "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
- echo "&amp;exif_style=$exif_style&amp;show_thumbs=yes\"";
- echo " title=\"" . __('Show Thumbnail Navigation') . "\">";
- echo "</a>\n";
- echo "</div>\n";
+ print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
+ print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
+ print "&amp;exif_style=$exif_style&amp;show_thumbs=yes\"";
+ print " title=\"" . __('Show Thumbnail Navigation') . "\">";
+ print "</a>\n";
+ print "</div>\n";
}
/* main image + thumbnail navigation (prev/next) */
-
- $divheight = $imgsize[1] + 10;
- echo "<div id=\"image\" style=\"height: ${divheight}px\">\n"; // extra kludge
- // because of tall
- // images
- echo "<img id=\"preview\" ${imgsize[3]} src=\"$file\" alt=\"$snimek\" />\n";
- navigation($galerie, $snimek, "prev");
- navigation($galerie, $snimek, "next");
- echo "</div>\n"; //image
+ $picture->renderPreview();
+ $page->navigation($galerie, $snimek, "prev");
+ $page->navigation($galerie, $snimek, "next");
+ print "</div>\n"; //end image div
+
if ($exif_prog) require("$root/inc/exif.inc.php");
- /* Image comment (caption really) */
- $comment = "$root/$gallery_dir/$galerie/comments/$snimek.txt";
- if (file_exists($comment)) {
- echo "<div class=\"comment\">";
- include($comment);
- echo "</div>";
- }
- /* Counter/Access Log - also requires comments dir world writable */
- if ($log_access==1) {
- //simple counter
- if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
- $log = "$root/$gallery_dir/$galerie/comments/log_$snimek.txt";
- if (file_exists($log)){
- $fh = fopen($log, "r");
- $counter = rtrim(fgets($fh));
- fclose($fh);
- } else {
- $counter = 0;
- }
- $counter++;
- $fh = fopen($log,"w");
- if (!fwrite($fh, "$counter\n")) {
- $page->error( __('Could not write to') . $log . "!");
- $page->footer();
- exit; //stop everything
- }
- fclose($fh);
- //Now display something
- echo "\n<div id=\"log\">\n";
- echo __('This image has been viewed') . " ";
- echo "<strong>$counter</strong>". " " . __('times') . ".";
- //echo date("F dS, Y",filectime($log));
- echo "</div>\n\n";
- } else {
- echo "<!-- ". __('WARNING: comment dir not writable') . "-->\n";
- }
- } elseif ($logaccess==2) {
- // log time, IP, UA
- // TODO - is this really a good thing to do?
+ /* Image comment
+ really poor naming here, it is caption.
+ */
+ $picture->renderCaption();
+
+
+ //show page counter
+ if ($log_access) {
+ $picture->renderCounter();
}
-
- if (file_exists("$gallery_dir/$galerie/mq/img-$snimek.jpg") || file_exists("$gallery_dir/$galerie/hq/img-$snimek.jpg")) {
- echo "<div id=\"mqhq\">";
- if (file_exists("$gallery_dir/$galerie/mq/img-$snimek.jpg")) {
- echo "<a href=\"$gallery_dir/$galerie/mq/img-$snimek.jpg\">". __('MQ') . "</a> ";
- }
- if (file_exists("$gallery_dir/$galerie/hq/img-$snimek.jpg")) {
- echo "<a href=\"$gallery_dir/$galerie/hq/img-$snimek.jpg\">" . __('HQ') . "</a>";
- }
- echo "</div>\n"; //mqhq
- }
+ $picture->renderBigSize();
- /* User comments */
- if ($comments) {
- if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
- require("inc/comment.inc.php");
- $user_comment = "$root/$gallery_dir/$galerie/comments/user_$snimek.txt";
-
- if (file_exists($user_comment)) {
- echo "<div class=\"user_comment\">";
- include($user_comment);
- echo "</div>";
- }
- } else {
- echo "<!-- WARNING: comment dir not writable -->\n";
- }
- }
- navigation($galerie, $snimek, null);
+ $page->user_comments($picture->number);
+ $page->navigation($galerie, $snimek, null);
}
require("inc/footer.inc.php");