aboutsummaryrefslogtreecommitdiff
path: root/www/inc
diff options
context:
space:
mode:
Diffstat (limited to 'www/inc')
-rw-r--r--www/inc/comment_form.inc.php33
-rw-r--r--www/inc/config.inc.php17
-rw-r--r--www/inc/db.class.inc.php63
-rw-r--r--www/inc/exif.inc.php4
-rw-r--r--www/inc/funkce.inc.php62
-rw-r--r--www/inc/global.js13
-rw-r--r--www/inc/header.inc.php24
-rw-r--r--www/inc/photo.class.inc.php279
-rw-r--r--www/inc/www.class.inc.php145
9 files changed, 552 insertions, 88 deletions
diff --git a/www/inc/comment_form.inc.php b/www/inc/comment_form.inc.php
new file mode 100644
index 0000000..5ac8348
--- /dev/null
+++ b/www/inc/comment_form.inc.php
@@ -0,0 +1,33 @@
+<?php
+/*
+ * The HTML contained in this file is valid XHTML 1.0 Strict
+ */
+
+echo "<div id=\"comment_block\">\n";
+
+?>
+ <?php echo"<div id=\"showhideform\"><strong> " . __('Post a Comment') . "</strong>:"; ?>
+ <span class="comment_toggle">
+ [&nbsp;
+ <?php echo"<a href=\"javascript:toggle_comment()\"><span id=\"showlink\">" . __('Show Form') . "</span><span id=\"hidelink\" style=\"display:none;\">" . __('Hide Form') . "</span></a>"; ?>
+ &nbsp;]
+ </span>
+ </div>
+
+ <div id="comment_form" style="display: none;">
+<?php
+$this->form_start($ThisUrl, "post", NULL);
+$this->input("text", "commentname", $username, __('Name:'), NULL, _('Enter your name.') );
+$this->input("checkbox", "savecommentname", "1", __('Remember Name:'), "yes",
+ __('Should the browser remember your name?'));
+$magic_number = random_digits(4);
+//temporary. should generate an image instead
+echo "<div class=\"row\"><div class=\"control\">$magic_number</div></div>\n";
+$this->input("hidden", "commentkolacek", md5($magic_number), NULL, NULL, NULL);
+$this->input("text", "commentspamcheck", "", __('Retype PIN Above:'), NULL, __('Enter the number shown above.'));
+$this->input("textarea", "commentdata", "", __('Comment') . " :" , NULL, __('Allowed HTML tags: a,b,i,ul,li,blockquote,br.') );
+$this->input("submit", "", __('Send') , NULL, NULL, NULL);
+$this->form_end();
+?>
+ </div>
+</div>
diff --git a/www/inc/config.inc.php b/www/inc/config.inc.php
index 1f0bbd3..c800fac 100644
--- a/www/inc/config.inc.php
+++ b/www/inc/config.inc.php
@@ -1,8 +1,12 @@
<?php
#base dirname
//dirname("__FILE__/..")
- eregi("^(.*)/[^/]*$", $ScriptFileName, $x);
- $root = $x[1];
+ $ThisScript=preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
+ $ScriptFileName=$_SERVER['SCRIPT_FILENAME'];
+ $HostName=$_SERVER['SERVER_NAME'];
+ $ThisUrl = $_SERVER['REQUEST_URI'];
+ eregi("^(.*)/[^/]*$", $ScriptFileName, $x);
+ $root = $x[1];
# ===========================================================================
# dir index
$sortinmonth = 0;// 1 - alphabetically
@@ -46,7 +50,7 @@ $scnamegallery = "Photo Gallery Index";
$app["name"] = "Original"; // opensource remote image gallery,
// initialy not as lovely
$app["url"] = "http://jimmac.musichall.cz/original.php3";
- $app["version"] = "0.11";
+ $app["version"] = "0.12pre";
# ===========================================================================
# EXIF metadata app path (helper app for php3 and older php4)
# uncomment the method you want to use if you want EXIF data reported
@@ -95,15 +99,16 @@ $scnamegallery = "Photo Gallery Index";
# eg. it can be "../galleries" to use a galleries dir above the original dir.
$gallery_dir="../galleries";
+#Enable this to access extended tracking functionality
+#depends on sqlite
+$have_sqlite = 1;
+
# This controls wheather web visitors will be able to post
# comments to images
$comments = 1;
# Access Log/Counter
# $log_access = 0; // no access logging
-# $log_access = 1; // simple counter
-# $log_access = 2; // detailed log FIXME: TODO (not sure about doing this, as
- // it duplicates server's access log and tends to grow large
$log_access = 1;
#css styles
diff --git a/www/inc/db.class.inc.php b/www/inc/db.class.inc.php
new file mode 100644
index 0000000..00804a7
--- /dev/null
+++ b/www/inc/db.class.inc.php
@@ -0,0 +1,63 @@
+<?php
+/* SQLite DB class for storing
+ - image views,
+ - user comments
+*/
+
+$dbfile = "$root/$gallery_dir/photos.db";
+
+//unfortunately in php4, the SQLiteDatabse class isn't created so we have to
+
+class SQLiteDatabase {
+ var $dbfile;
+
+ function SQLiteDatabase ($dbfile) {
+
+ $this->dbfile = $dbfile;
+ //if db file doesn't exist, fill with skeleton
+ if (file_exists($this->dbfile)) {
+ $this->dbres = sqlite_open($this->dbfile, 0666, $sqliteerror);
+ } else {
+ //fill with skeleton
+ $folder = dirname($this->dbfile);
+ if (!is_writable($folder)) { //we need write permission to create database
+ die("<p style=\"color:red;\">cannot create dabase. check permissions.</p>\n");
+ } else {
+ $this->dbres = sqlite_open($this->dbfile, 0666, $sqliteerror);
+ //photo table
+ $sql = "create table photo (id INTEGER PRIMARY KEY, caption TEXT, ";
+ $sql .= "counter INTEGER, number INTEGER, album TEXT, name TEXT)";
+ $this->query($sql);
+ //comment table
+ $sql = "create table comment (id INTEGER PRIMARY KEY, user TEXT, ";
+ $sql .= "comment_body TEXT, photo_id INT, date DATETIME)";
+ $this->query($sql);
+ }
+ }
+ }
+
+ function query($sql) {
+ global $page;
+
+ if (!$this->result = sqlite_query($this->dbres, $sql)) {
+ print "Query failed, <span style=\"color: blue;\"><pre>$sql</pre></style>\n";
+ print sqlite_error_string (sqlite_last_error($this->dbres));
+ $page->footer();
+ exit;
+ }
+ }
+
+ function count() {
+ return sqlite_num_rows($this->result);
+ }
+
+ function rewind() { //just to abstract from sqlite
+ sqlite_rewind($this->result);
+ }
+
+}
+
+
+$db = new SQLiteDatabase("$dbfile");
+
+?>
diff --git a/www/inc/exif.inc.php b/www/inc/exif.inc.php
index f78741e..7b8262d 100644
--- a/www/inc/exif.inc.php
+++ b/www/inc/exif.inc.php
@@ -99,7 +99,7 @@ if ($exif_prog=="php4") {
}
echo "<tr>\n";
echo "<td></td>";
- echo "<td><a href=\"javascript:toggle_exif()\">" . __("Less info");
+ echo "<td><a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("Less info");
echo "</a></td>";
echo "</tr>\n";
echo "</table>\n";
@@ -136,7 +136,7 @@ if ($exif_prog=="php4") {
}
}
- echo "<a href=\"javascript:toggle_exif()\">" . __("More info");
+ echo "<a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("More info");
echo "</a></p>\n";
echo "</div>\n";
}
diff --git a/www/inc/funkce.inc.php b/www/inc/funkce.inc.php
index be897f7..e45d725 100644
--- a/www/inc/funkce.inc.php
+++ b/www/inc/funkce.inc.php
@@ -1,66 +1,4 @@
<?php
-function navigation ($gallery, $snapshot, $image) {
- global $gallery_dir, $root, $ThisScript, $textnav, $img,
- $show_thumbs, $exif_style, $PNthumbScale;
-
- $next = $snapshot + 1;
- $prev = $snapshot - 1;
-
- if (!$image) { // this will render a navigation bar - max 3 buttons
- echo "\n<div class=\"navbuttons\">\n";
- echo "<div class=\"navbuttonsshell\">\n";
- if ($snapshot > 1) { //previous
- echo "<a id=\"previcon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
- echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
- echo " accesskey=\"p\">";
- echo "&lt; <span class=\"accesskey\">P</span>revious</a>\n";
- }
- echo "&nbsp;";
- if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) { //next
- echo "<a id=\"nexticon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
- echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
- echo " accesskey=\"n\">";
- echo "<span class=\"accesskey\">N</span>ext &gt;</a>\n";
- }
- echo "</div>\n</div>\n";
- } elseif ($image=="prev") { //previous thumbnail
- if ($snapshot > 1) { //previous
- echo "<div class=\"prevthumb\">";
- echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
- echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
- if (file_exists("$gallery_dir/$gallery/thumbs/img-$prev.png")) {
- $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.png";
- } else {
- $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.jpg";
- }
- $v = getimagesize("$root/$Pthumb");
- echo "<img alt=\"Previous\" src=\"";
- echo $Pthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
- echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
- echo "<br />" . __('Previous');
- echo "</a></div>\n";
- }
- } else { //next thumbnail
- if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) {
- echo "<div class=\"nextthumb\">";
- echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
- echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
- if (file_exists("$gallery_dir/$gallery/thumbs/img-$next.png")) {
- $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.png";
- } else {
- $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.jpg";
- }
- $v = getimagesize("$root/$Nthumb");
- echo "<img alt=\"Next\" src=\"";
- echo $Nthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
- echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
- //echo "<br /><span class=\"accesskey\">N</span>ext";
- echo "<br />" . __('Next') ;
- echo "</a></div>\n";
- }
- }
-
-}
function check($file) {
global $gallery_dir, $page;
diff --git a/www/inc/global.js b/www/inc/global.js
index ff8ec21..048af85 100644
--- a/www/inc/global.js
+++ b/www/inc/global.js
@@ -65,15 +65,12 @@ function toggle_comment() {
}
}
-function toggle_exif() {
- var exif_table = document.getElementById('exif_table');
- var exif_line = document.getElementById('exif_line');
- if(exif_table.style.display == 'none') {
- exif_table.style.display = 'block';
- exif_line.style.display = 'none';
+function toggle_div(classname) {
+ var div = document.getElementById(classname);
+ if(div.style.display == 'none') {
+ div.style.display = 'block';
} else {
- exif_table.style.display = 'none';
- exif_line.style.display = 'block';
+ div.style.display = 'none';
}
}
diff --git a/www/inc/header.inc.php b/www/inc/header.inc.php
index 483b6ef..970c651 100644
--- a/www/inc/header.inc.php
+++ b/www/inc/header.inc.php
@@ -1,14 +1,20 @@
<div class="stylenavbar">
-[ style:
-<?php
-foreach ($themes as $skin => $url) {
- echo "<a href=\"#\" title=\"$skin\"";
- echo " onclick=\"setActiveStyleSheet('$skin')\">";
- echo "$skin</a> \n";
-}
-?>
-]
+ <div id="styleshiden" style="display: block;">
+ <p><a href="javascript:toggle_div('styleshiden');toggle_div('stylesshown');">show styles</a></p>
+ </div>
+ <div id="stylesshown" style="display: none;">
+ <ul>
+ <?php
+ foreach ($themes as $skin => $url) {
+ echo "<li><a href=\"javascript:setActiveStyleSheet('$skin')\" title=\"$skin\">";
+ echo "$skin</a></li> \n";
+ }
+ ?>
+ </ul>
+ <p><a href="javascript:toggle_div('styleshiden');toggle_div('stylesshown');">hide styles</a></p>
+ </div>
</div>
+
<?php
echo "<h1 class=\"title\"><a href=\"http://$HostName$ThisScript\">Photo Gallery<span /></a></h1>\n\n";
?>
diff --git a/www/inc/photo.class.inc.php b/www/inc/photo.class.inc.php
new file mode 100644
index 0000000..10b507d
--- /dev/null
+++ b/www/inc/photo.class.inc.php
@@ -0,0 +1,279 @@
+<?php
+/* Photo class for dealing with individual images
+
+*/
+
+class C_photo {
+ var $id;
+ var $preview;
+ var $previewsize;
+ var $mq;
+ var $hq;
+ var $name;
+ var $caption;
+ var $file;
+ var $number;
+ var $counter;
+ var $album;
+ var $comments; //rendered string
+
+ function C_photo($file, $number) {
+ global $root, $gallery_dir, $galerie, $db;
+
+ $this->file = $file;
+ $this->number = $number;
+ $this->album = $galerie;
+ //init from filesystem
+ //preview
+ $this->preview = "$gallery_dir/$galerie/lq/img-" . $this->number . ".jpg";
+ $this->previewsize = getimagesize($this->preview);
+ //MQ
+ if (file_exists("$root/$gallery_dir/$galerie/mq/img-" . $this->number . ".jpg")) {
+ $this->mq = "$gallery_dir/$galerie/mq/img-" . $this->number . ".jpg";
+ }
+ //HQ
+ if (file_exists("$root/$gallery_dir/$galerie/hq/img-" . $this->number . ".jpg")) {
+ $this->hq = "$gallery_dir/$galerie/hq/img-" . $this->number . ".jpg";
+ }
+ if ($GLOBALS['have_sqlite']) { //query just once
+ require_once("$root/inc/db.class.inc.php");
+ $sql = "select * from photo where ";
+ $sql .= "number=" . $this->number . " and ";
+ $sql .= "album='" . $this->album . "'";
+ $db->query($sql);
+ }
+ $this->readCaption();
+ $this->readCounter(); //reads access log number
+ if ($GLOBALS['have_sqlite']) { //need to get photo id first
+ if (!$db->count()) {//no record for this photo, let's update the record
+ //FIXME - if no photo data in db, create a unique index for it
+ //and add number, album, caption and views.
+ $sql = "insert into photo (name, caption, counter, number, album)";
+ $sql .= " values (";
+ $sql .= "\"" . $this->name . "\", ";
+ $sql .= "\"" . $this->caption . "\", ";
+ $sql .= $this->counter . ", ";
+ $sql .= $this->number . ", ";
+ $sql .= "\"" . $this->album . "\"";
+ $sql .= ")";
+ $db->query($sql);
+ print "\n\n<!-- We've moved the data to the database.-->";
+ //now we still need to query for the id
+ $sql = "select id from photo where ";
+ $sql .= "number=" . $this->number . " and ";
+ $sql .= "album='" . $this->album . "'";
+ $db->query($sql);
+ }
+ $db->rewind();
+ $resultarray = sqlite_fetch_array($db->result);
+ $this->id = $resultarray["id"];
+ print "\n\n<!-- image id: " . $this->id . " -->\n";
+ }
+ $this->readComments();
+ }
+
+ function readCaption() {
+ global $have_sqlite, $root, $gallery_dir, $galerie, $db;
+
+ /* reads name and caption of a photo
+ - either from sqlite database or filesystem
+ */
+ if ($have_sqlite) {
+ //try reading from sqlite
+ if ($db->count()) {
+ $result = sqlite_fetch_array($db->result);
+ $this->name = $result["name"];
+ $this->caption = $result["caption"];
+ return; //no need to fallback anymore
+ }
+ }
+
+ //we falback to filesystem
+ $buffer = "";
+ $captionfile = "$root/$gallery_dir/$galerie/comments/" . $this->number . ".txt";
+ $fh = @fopen($captionfile, "r");
+ if ($fh) {
+ while (!feof($fh)) {
+ $buffer .= fgets($fh, 4096);
+ }
+ fclose($fh);
+ } else { // no caption file
+ $this->name = __("Photo ") . $this->number;
+ return;
+ }
+ //parse buffer
+ if(eregi("^<span>(.*)</span>( - )?(.*)", $buffer, $x)) {
+ $this->name = $x[1]; //mostly "Photo"
+ $this->caption = chop($x[3]);
+ } else {
+ $this->caption = $buffer;
+ }
+ }
+
+ function readCounter() {
+ global $log_access, $root, $gallery_dir, $galerie, $db;
+
+ if ($GLOBALS['have_sqlite']) {
+ //try reading from sqlite
+ if ($db->count()) {
+ $db->rewind();
+ $result = sqlite_fetch_array($db->result);
+ $this->counter = $result["counter"];
+ return; //no need to fallback anymore
+ }
+ }
+ //we fallback to filesystem :/
+ if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
+ $log = "$root/$gallery_dir/$galerie/comments/log_" . $this->number . ".txt";
+ if (file_exists($log)){
+ $fh = @fopen($log, "r");
+ $this->counter = rtrim(fgets($fh));
+ fclose($fh);
+ } else {
+ $this->counter = 0;
+ }
+ } else {
+ //doesn't do anything if no perms
+ print "<!-- ". __('WARNING: comment dir not writable') . "-->\n";
+ return 0; //failure
+ }
+ return 1; //success
+ }
+
+ function readComments() {
+ global $root, $gallery_dir, $galerie, $db;
+
+ if ($GLOBALS['have_sqlite']) {
+ //we have and will use SQLite
+ //FIXME
+ print "\n<!--SQLITE comments FIXME-->\n\n";
+ return 1;
+ } else {
+ //filesystem
+ $comments = "$root/$gallery_dir/$galerie/comments/user_" . $this->number . ".txt";
+ if (file_exists($comments)){
+ $buffer = "";
+ $fh = @fopen($comments, "r");
+ if ($fh) {
+ while (!feof($fh)) {
+ $buffer .= fgets($fh, 4096);
+ }
+ $this->comments = $buffer;
+ fclose($fh);
+ }
+ }
+ }
+ }
+
+ function renderCounter() {
+
+ print "\n<div id=\"log\">\n";
+ print __('This image has been viewed') . " ";
+ print "<strong>" . $this->counter . "</strong>". " " . __('times') . ".";
+ print "</div>\n\n";
+ $this->writeCounter(); //save state
+
+ }
+
+ function writeCounter() {
+ global $log_access, $root, $gallery_dir, $galerie, $page, $db;
+
+ $this->counter++; //we add to counter
+ if ($GLOBALS['have_sqlite']) {
+ //we have SQLite
+ $sql = "update photo set counter=" . $this->counter;
+ $sql .= " where id=" . $this->id;
+ $db->query($sql);
+ return; //no need to fallback anymore
+ }
+ //fallback to filesystem
+ if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
+ $log = "$root/$gallery_dir/$galerie/comments/log_". $this->number .".txt";
+ if (!is_writable($log)) {
+ print "\n\n\n<!-- cannot open $log. Check permissions.";
+ print "\nAborting counter write -->\n";
+ return 0;
+ }
+ $fh = fopen($log,"w");
+ if (!fwrite($fh, $this->counter . "\n")) {
+ $page->error( __('Could not write to') . $log . "!");
+ $page->footer();
+ exit; //stop everything
+ }
+ fclose($fh);
+ }
+ }
+
+ function renderBigSize() {
+
+ if ($this->mq || $this->hq) {
+ print "<div id=\"mqhq\">";
+ if ($this->mq) {
+ print "<a href=\"" . $this->mq . "\">". __('MQ') . "</a> ";
+ }
+ if ($this->hq) {
+ print "<a href=\"" . $this->hq . "\">" . __('HQ') . "</a>";
+ }
+ print "</div>\n";
+ }
+ }
+
+ function renderPreview() {
+
+ $divheight = $this->previewsize[1] + 10;
+ print "<div id=\"image\" style=\"height: ${divheight}px\">\n"; // extra kludge
+ // because of tall
+ // images
+
+ print "<img id=\"preview\" " . $this->previewsize[3] . " src=\"". $this->file;
+ print "\" alt=\"$snimek\" />\n";
+ }
+
+ function renderCaption() {
+
+ print "<div class=\"comment\">";
+ print "<span>" . $this->name . "</span>";
+ if ($this->caption) {
+ print " &ndash; ";
+ print $this->caption;
+ print "</div>";
+ }
+ }
+
+ function addComment($comment_name, $comment_data) { //adds comment to file or database
+ global $log_access, $root, $gallery_dir, $galerie, $page;
+
+ if ($GLOBALS['have_sqlite']) {
+ //sqlite
+ print "\n<!--SQLITE comments addition FIXME-->\n\n";
+ } else {
+ //filesystem
+ if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
+ $comment = "$root/$gallery_dir/$galerie/comments/user_";
+ $comment .= $this->number . ".txt";
+ if (file_exists($comment) && !is_writable($comment)) {
+ $page->error("Permission Denied", __('Could not write to') . $comment .
+ "!\n Check permissions.\n");
+ $page->footer();
+ exit; //stop everything
+ }
+
+ $fh = fopen("$comment", "a");
+ if (!$comment_name) {
+ $comment_name = __('Anonymous');
+ }
+ if (!fwrite($fh, "<div class=\"commententry\">\n")) {
+ $page->error("Write Failed", __('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);
+ }
+ }
+ }
+}
+?>
diff --git a/www/inc/www.class.inc.php b/www/inc/www.class.inc.php
index 2206382..27683cc 100644
--- a/www/inc/www.class.inc.php
+++ b/www/inc/www.class.inc.php
@@ -188,7 +188,150 @@ class C_www {
echo "</div>\n";
}
-
+
+ function navigation ($gallery, $snapshot, $image) {
+ global $gallery_dir, $root, $ThisScript, $textnav, $img,
+ $show_thumbs, $exif_style, $PNthumbScale;
+
+ $next = $snapshot + 1;
+ $prev = $snapshot - 1;
+
+ if (!$image) { // this will render a navigation bar - max 3 buttons
+ echo "\n<div class=\"navbuttons\">\n";
+ echo "<div class=\"navbuttonsshell\">\n";
+ if ($snapshot > 1) { //previous
+ echo "<a id=\"previcon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
+ echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
+ echo " accesskey=\"p\">";
+ echo "&lt; <span class=\"accesskey\">P</span>revious</a>\n";
+ }
+ echo "&nbsp;";
+ if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) { //next
+ echo "<a id=\"nexticon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
+ echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
+ echo " accesskey=\"n\">";
+ echo "<span class=\"accesskey\">N</span>ext &gt;</a>\n";
+ }
+ echo "</div>\n</div>\n";
+ } elseif ($image=="prev") { //previous thumbnail
+ if ($snapshot > 1) { //previous
+ echo "<div class=\"prevthumb\">";
+ echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
+ echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
+ if (file_exists("$gallery_dir/$gallery/thumbs/img-$prev.png")) {
+ $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.png";
+ } else {
+ $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.jpg";
+ }
+ $v = getimagesize("$root/$Pthumb");
+ echo "<img alt=\"Previous\" src=\"";
+ echo $Pthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
+ echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
+ echo "<br />" . __('Previous');
+ echo "</a></div>\n";
+ }
+ } else { //next thumbnail
+ if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) {
+ echo "<div class=\"nextthumb\">";
+ echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
+ echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
+ if (file_exists("$gallery_dir/$gallery/thumbs/img-$next.png")) {
+ $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.png";
+ } else {
+ $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.jpg";
+ }
+ $v = getimagesize("$root/$Nthumb");
+ echo "<img alt=\"Next\" src=\"";
+ echo $Nthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
+ echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
+ //echo "<br /><span class=\"accesskey\">N</span>ext";
+ echo "<br />" . __('Next') ;
+ echo "</a></div>\n";
+ }
+ }
+ }
+
+ function user_comments($photo) {
+ global $root, $gallery_dir, $galerie, $comments, $picture;
+
+ if ($comments) {
+ if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
+ require("inc/comment_form.inc.php");
+
+ if ($picture->comments) {
+ print "<div class=\"user_comment\">";
+ print $picture->comments;
+ print "</div>";
+ }
+ } else {
+ print "<!-- WARNING: comment dir not writable -->\n";
+ }
+ }
+ }
+
+ function process_comment_form() { // processing of the user comment data
+ global $comments, $root, $gallery_dir, $galerie, $snimek;
+
+ 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
+ $this->error( __('No comment spam'), __('Your comment includes blacklisted word') . __('No comment spam') );
+ $this->footer();
+ exit; //stop everything
+ }
+ }
+
+ if ($comment_kolacek!=md5($comment_spamcheck)) {
+ $this->error( __('No comment spam'), __('You ve written the check number wrong' ) );
+ $this->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 (!$picture) {
+ require_once("$root/inc/photo.class.inc.php");
+ $path = "$gallery_dir/$galerie/lq";
+ $file = "$path/img-$snimek.jpg";
+ $picture = new C_photo($file, $snimek);
+ }
+ $picture->addcomment($comment_name, $comment_data);
+ }
+ }
}
# return dirs sorted