Example #1
0
 function DeleteComment()
 {
     $post_id = $_REQUEST['id'];
     $comment_time = $_REQUEST['comment_time'];
     $data = SimpleBlogCommon::GetCommentData($post_id);
     foreach ($data as $key => $comment) {
         if ($comment['time'] == $comment_time) {
             unset($data[$key]);
         }
     }
     SimpleBlogCommon::SaveCommentData($post_id, $data);
     $this->GetCache();
 }
 /**
  * Remove a comment entry from the comment data
  *
  */
 function DeleteComment()
 {
     global $langmessage;
     $data = SimpleBlogCommon::GetCommentData($this->post_id);
     $comment = $_POST['comment_index'];
     if (!isset($data[$comment])) {
         message($langmessage['OOPS']);
         return;
     }
     unset($data[$comment]);
     if (SimpleBlogCommon::SaveCommentData($this->post_id, $data)) {
         message($langmessage['SAVED']);
         return true;
     } else {
         message($langmessage['OOPS']);
         return false;
     }
 }
Example #3
0
 /**
  * Add a comment to the comment data for a post
  *
  */
 public function AddComment()
 {
     global $langmessage;
     if ($this->comments_closed) {
         return;
     }
     //need a captcha?
     if (SimpleBlogCommon::$data['comment_captcha'] && gp_recaptcha::isActive()) {
         if (!isset($_POST['anti_spam_submitted'])) {
             return false;
         } elseif (!gp_recaptcha::Check()) {
             return false;
         }
     }
     $comment = $this->GetPostedComment();
     if ($comment === false) {
         return false;
     }
     $data = SimpleBlogCommon::GetCommentData($this->post_id);
     $data[] = $comment;
     if (!SimpleBlogCommon::SaveCommentData($this->post_id, $data)) {
         message($langmessage['OOPS']);
         return false;
     }
     message($langmessage['SAVED']);
     $this->EmailComment($comment);
     $this->comment_saved = true;
     return true;
 }
Example #4
0
 /**
  * Add a comment to the comment data for a post
  *
  */
 function AddComment()
 {
     global $langmessage;
     if ($this->comments_closed) {
         return;
     }
     $data = SimpleBlogCommon::GetCommentData($this->post_id);
     //need a captcha?
     if (SimpleBlogCommon::$data['comment_captcha'] && gp_recaptcha::isActive()) {
         if (!isset($_POST['anti_spam_submitted'])) {
             return false;
         } elseif (!gp_recaptcha::Check()) {
             return false;
         }
     }
     if (empty($_POST['name'])) {
         $field = gpOutput::SelectText('Name');
         message($langmessage['OOPS_REQUIRED'], $field);
         return false;
     }
     if (empty($_POST['comment'])) {
         $field = gpOutput::SelectText('Comment');
         message($langmessage['OOPS_REQUIRED'], $field);
         return false;
     }
     $temp = array();
     $temp['name'] = htmlspecialchars($_POST['name']);
     $temp['comment'] = nl2br(strip_tags($_POST['comment']));
     $temp['time'] = time();
     if (!empty($_POST['website']) && $_POST['website'] !== 'http://') {
         $website = $_POST['website'];
         if (mb_strpos($website, '://') === false) {
             $website = false;
         }
         if ($website) {
             $temp['website'] = $website;
         }
     }
     $data[] = $temp;
     if (!SimpleBlogCommon::SaveCommentData($this->post_id, $data)) {
         message($langmessage['OOPS']);
         return false;
     }
     message($langmessage['SAVED']);
     //email new comments
     if (!empty(SimpleBlogCommon::$data['email_comments'])) {
         $subject = 'New Comment';
         $body = '';
         if (!empty($temp['name'])) {
             $body .= '<p>From: ' . $temp['name'] . '</p>';
         }
         if (!empty($temp['website'])) {
             $body .= '<p>Website: ' . $temp['name'] . '</p>';
         }
         $body .= '<p>' . $temp['comment'] . '</p>';
         global $gp_mailer;
         includeFile('tool/email_mailer.php');
         $gp_mailer->SendEmail(SimpleBlogCommon::$data['email_comments'], $subject, $body);
     }
     $this->comment_saved = true;
     return true;
 }