From 20407702b92cb93970eaa4a71e659f383d2f92a5 Mon Sep 17 00:00:00 2001 From: jimmacfx Date: Fri, 25 Nov 2005 22:45:21 +0000 Subject: 0.11 git-svn-id: https://forgesvn1.novell.com/svn/original/trunk@8 4fa712ea-3c06-0410-9261-c11b4c06c003 --- www/index.php | 540 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 540 insertions(+) create mode 100644 www/index.php (limited to 'www/index.php') diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..011a614 --- /dev/null +++ b/www/index.php @@ -0,0 +1,540 @@ +

  • '; + $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("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, "
    \n")) { + $page->error( __('Could not write to') . $comment . "!" ); + $page->footer(); + exit; //stop everything + } + fwrite($fh, "
    " . __('Comment from') . "$comment_name
    \n",90); + fwrite($fh, "
    $comment_data
    \n",280); + fwrite($fh, "
    \n"); + + fclose($fh); + } +} + + +//START RENDERING + + +$page->header("Photos"); +require("inc/header.inc.php"); + +// folder > tree +//echo "
    " . $scnamegallery . ""; +echo "
    " . $scnamegallery . ""; + +############################# +# Overall Gallery Index # +############################# +if (!$galerie) { + # finish off navigation bar + echo "
    \n\n\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 + while ($file = $adr->Read()) { + // checking for inc is only really needed when gallery_dir == $root + // hopefully not many galleries will be named inc ;) + if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { + // Use date file for gallery date if avaliable + // info.txt format described in README + readInfo("$root/$gallery_dir/$file/info.txt", $file); + + } + } + + if (!isset($galeriemonth)) $galeriemonth = array(); + if (!isset($galerieday)) $galerieday = array(); + //sort within month depending on $sortinmonth + if ($sortinmonth) { + //alphabetically + ksort($galeriemonth); + reset($galeriemonth); + } else {//by date + arsort($galerieday); + reset($galerieday); + } + + + $thisyear = 0; + for ($i = $yearto; $i >= $yearsince; $i--) { + for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month + // down + foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted) + if ($galeriemonth["$foldername"] == $thismonth && + $galerieyear["$foldername"] == $i) { //such Y/M exists + + $galerieyearordered["$foldername"]=$galerieyear["$foldername"]; + $galeriemonthordered["$foldername"]=$galeriemonth["$foldername"]; + } + } + } + } + + + $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), + __('September'), __('October'), __('November'), __('December')); + $one_out = false; + foreach ($galerieyearordered as $foldername => $year) { + $one_out = true; + if (@$thisyear!=$year) { #if the year is not equal to the current year + #This is the first year + if (@$thisyear) { echo "
    \n\n";}// end last year if this is + // not the first one + #This is a new year + unset($thismonth); + echo "

    $year

    \n"; + echo ""; + } + $month=$galeriemonth["$foldername"]; + # now months + if (@$thismonth!=$month) { + #first one + if (@$thismonth) { echo "
    \n"; } // end of last month if + // this is not the first one + #new month + $monthindex = $month - 1; + $monthname = $months[$monthindex]; + echo "

    $monthname

    \n"; + } + #galleries within month + if ($galerielogin[$foldername]) { + echo "

    "; + echo $galeriename[$foldername]; + echo ""; + } else { + echo " href=\"$ThisScript?galerie=$foldername\">$foldername"; + } + if (@$galeriedesc[$foldername]) { + echo "" . $galeriedesc[$foldername]; + echo "\n"; + } + if (@$galerieauthor[$foldername]) { + echo "by " . $galerieauthor[$foldername]; + echo "\n"; + } + if (@$galerieday[$foldername]) { + echo ""; + echo "$monthname " . $galerieday[$foldername]; + echo "\n"; + } + echo "

    \n"; + $thisyear=$year; + $thismonth=$month; + } + if ($one_out) echo ("
    \n\n\n"); + +############################## +# Individual Gallery Index # +############################## +} elseif (!$snimek) { + + # finish off navigation header + + echo "\n > "; + if ($galeriename[$galerie]) { + echo $galeriename[$galerie]; + } else { + echo $galerie; + } + echo "\n\n"; + + //thumbnails + echo "

    \n"; + $path = "$gallery_dir/$galerie/thumbs"; + $imgfiles = new SortDir($path); + check($galerie); // check for nasty input + while ($file = $imgfiles->read()) { + if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) { + + $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}"; + $imgsize = getimagesize("$root/$thumb"); + //check for portraits + $portrait = "false"; + $class = ""; + if($imgsize[0]<100) { + //portraits need a special class for styling + $class = "portrait"; + } + //check for number of comments per photo + if ($comments) { //there probably won't be user comments if it's off + $NumOfComments = 0; + if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) { + if ($class) $class .= " "; + $class .= "hascomments"; + //now let's count'em + $fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r"); + while (!feof($fh)) { + $line = fgets($fh); + if (eregi("commententry",$line)) $NumOfComments++; + } + fclose($fh); + } + if ($NumOfComments==1) { + $NumOfComments = $NumOfComments . " " . __('Comment'); + } else { + $NumOfComments = $NumOfComments . " " . __('Comments'); + } + } + if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") && + $title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) { + $title = ereg_replace("(\"|\')","",trim(strip_tags($title))); + $title = ereg_replace("(.{77}).*","\\1",$title); + } else + $title = "Photo ${x[1]}"; + + echo " "; + echo ""; + echo "\n"; + } + } + echo "

    \n"; + + //info + echo "
    \n"; + if ($galeriedesc[$galerie]) { + echo "

    "; + echo ""; + echo $galeriedesc[$galerie] . "

    \n"; + } + if ($galerieauthor[$galerie]) { + echo "

    Author: "; + echo ""; + echo $galerieauthor[$galerie] . "

    \n"; + } + echo "
    \n"; + + //and links to archived images: + echo "\n

    \n"; + if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) { + echo "[ " . __('zipped MQ images') . " ] "; + } + if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) { + echo "[ " . __('MQ images tarball') . " ] "; + } + if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { + echo "[ " . __('zipped HQ images') . " ]"; + } + if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { + echo "[ " . __('HQ images tarball') . " ]"; + } + echo "

    "; + +####################### +# Individual Image # +####################### +} else { //low-res image + # finish off header + echo "\n > "; + if ($galeriename[$galerie]) { + echo $galeriename[$galerie]; + } else { + echo $galerie; + } + echo "\n > Photo"; + echo " $snimek"; + $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'); + $page->footer(); + exit; + } + $imgsize = getimagesize("$root/$file"); + /* + navigation($galerie, $snimek, null); + */ + + // mini thumbnail roll + + if ($show_thumbs) { + echo "\n\n
    "; + echo ""; + echo "\n"; + echo " : \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 " "; + echo ""; + echo " \n"; + } + } + if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { + echo ""; + echo "zip"; + } + if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { + echo ""; + echo "zip"; + } + echo "
    \n"; + } else { + // show the popup button + echo "\n\n
    "; + echo ""; + echo "\n"; + echo "
    \n"; + } + + /* main image + thumbnail navigation (prev/next) */ + + $divheight = $imgsize[1] + 10; + echo "
    \n"; // extra kludge + // because of tall + // images + + echo "\"$snimek\"\n"; + navigation($galerie, $snimek, "prev"); + navigation($galerie, $snimek, "next"); + echo "
    \n"; //image + + + 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 "
    "; + include($comment); + echo "
    "; + } + /* 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
    \n"; + echo __('This image has been viewed') . " "; + echo "$counter". " " . __('times') . "."; + //echo date("F dS, Y",filectime($log)); + echo "
    \n\n"; + } else { + echo "\n"; + } + } elseif ($logaccess==2) { + // log time, IP, UA + // TODO - is this really a good thing to do? + } + + + if (file_exists("$gallery_dir/$galerie/mq/img-$snimek.jpg") || file_exists("$gallery_dir/$galerie/hq/img-$snimek.jpg")) { + echo "
    "; + if (file_exists("$gallery_dir/$galerie/mq/img-$snimek.jpg")) { + echo "". __('MQ') . " "; + } + if (file_exists("$gallery_dir/$galerie/hq/img-$snimek.jpg")) { + echo "" . __('HQ') . ""; + } + echo "
    \n"; //mqhq + } + + /* 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 "
    "; + include($user_comment); + echo "
    "; + } + } else { + echo "\n"; + } + } + navigation($galerie, $snimek, null); +} + +require("inc/footer.inc.php"); +$page->footer(); +?> -- cgit v1.2.3