1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
* This program 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.
*
* This program 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id: add_comment.php 13409 2006-04-06 11:49:10Z jenst $
*/
?>
<?php
require_once(dirname(__FILE__) . '/init.php');
/* Hack check*/
if (!$gallery->user->canAddComments($gallery->album)) {
echo gTranslate('core', "You are not allowed to perform this action!");
exit;
}
list($save, $id, $commenter_name, $comment_text) = getRequestVar(array('save', 'id', 'commenter_name', 'comment_text'));
$error_text = '';
if ($gallery->user->isLoggedIn() ) {
if (empty($commenter_name) || $gallery->app->comments_anonymous == 'no') {
$commenter_name = $gallery->user->printableName($gallery->app->comments_display_name);
}
} elseif (!isset($commenter_name)) {
$commenter_name = '';
}
if (empty($comment_text)) {
$comment_text = '';
}
if (isset($gallery->app->comments_length)) {
$maxlength = $gallery->app->comments_length;
} else {
$maxlength = 0;
}
if (isset($save)) {
if ( empty($commenter_name) || empty($comment_text)) {
$error_text = gTranslate('core', "Name and comment are both required to save a new comment!");
} elseif ($maxlength >0 && strlen($comment_text) > $maxlength) {
$error_text = sprintf(gTranslate('core', "Your comment is too long, the admin set maximum length to %d chars"), $maxlength);
} elseif (isBlacklistedComment($tmp = array('commenter_name' => $commenter_name, 'comment_text' => $comment_text), false)) {
$error_text = gTranslate('core', "Your Comment contains forbidden words. It will not be added.");
} else {
// Uncomment to forbid html in comments.
// $comment_text = strip_tags($comment_text);
$commenter_name = strip_tags($commenter_name);
$IPNumber = $_SERVER['REMOTE_ADDR'];
$gallery->album->addComment($id, $comment_text, $IPNumber, $commenter_name);
$gallery->album->save();
emailComments($id, $comment_text, $commenter_name);
// Note: In stats.php this causes the browser to show a message about POST data ...
dismissAndReload();
return;
}
}
doctype();
?>
<html>
<head>
<title><?php echo gTranslate('core', "Add Comment") ?></title>
<?php common_header(); ?>
</head>
<body dir="<?php echo $gallery->direction ?>" class="popupbody">
<div class="popuphead"><?php echo gTranslate('core', "Add Comment") ?></div>
<div class="popup" align="center">
<p><?php echo gTranslate('core', "Enter your comment for this picture in the text box below.") ?></p>
<?php
echo $gallery->album->getThumbnailTagById($id);
if (!empty($error_text)) {
echo "\n<br>". gallery_error($error_text);
}
echo "<br><br>";
echo makeFormIntro("add_comment.php", array(), array('type' => 'popup'));
drawCommentAddForm($commenter_name, 35);
?>
<input type="hidden" name="id" value="<?php echo $id ?>">
<br><input type="button" value="<?php echo gTranslate('core', "Cancel") ?>" onclick='parent.close()'>
</form>
</div>
<script language="javascript1.2" type="text/JavaScript">
<!--
// position cursor in top form field
document.g1_form.commenter_name.focus();
//-->
</script>
</div>
<?php print gallery_validation_link("add_comment.php", true, array('id' => $id)); ?>
</body>
</html>
|