/** * Add a comment to the comment data for a post * */ function AddComment($post_index) { global $langmessage; $comments_closed = SimpleBlogCommon::AStrValue('comments_closed', $post_index); if ($comments_closed) { return; } $data = $this->GetCommentData($post_index); //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 (SimpleBlogCommon::strpos($website, '://') === false) { $website = false; } if ($website) { $temp['website'] = $website; } } $data[] = $temp; if (!$this->SaveCommentData($post_index, $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); } return true; }
/** * Regenerate the static content used to display the gadget * */ function GenGadget() { global $langmessage; $posts = array(); $show_posts = $this->WhichPosts(0, SimpleBlogCommon::$data['gadget_entries']); ob_start(); $label = gpOutput::SelectText('Blog'); if (!empty($label)) { echo '<h3>'; echo common::Link('Special_Blog', $label); echo '</h3>'; } foreach ($show_posts as $post_index) { //get $posts if (!isset($posts[$post_index])) { $posts = $this->GetPostFile($post_index, $post_file); } if (!isset($posts[$post_index])) { continue; } $post =& $posts[$post_index]; $header = '<b class="simple_blog_title">'; $label = SimpleBlogCommon::Underscores($post['title']); $header .= SimpleBlogCommon::PostLink($post_index, $label); $header .= '</b>'; $this->BlogHead($header, $post_index, $post, true); $content = strip_tags($post['content']); if (SimpleBlogCommon::$data['gadget_abbrev'] > 6 && SimpleBlogCommon::strlen($content) > SimpleBlogCommon::$data['gadget_abbrev']) { $cut = SimpleBlogCommon::$data['gadget_abbrev']; $pos = SimpleBlogCommon::strpos($content, ' ', $cut - 5); if ($pos > 0 && $cut + 20 > $pos) { $cut = $pos; } $content = SimpleBlogCommon::substr($content, 0, $cut) . ' ... '; $label = gpOutput::SelectText('Read More'); $content .= SimpleBlogCommon::PostLink($post_index, $label); } echo '<p class="simple_blog_abbrev">'; echo $content; echo '</p>'; } if (SimpleBlogCommon::$data['post_count'] > 3) { $label = gpOutput::SelectText('More Blog Entries'); echo common::Link('Special_Blog', $label); } $gadget = ob_get_clean(); $gadgetFile = $this->addonPathData . '/gadget.php'; gpFiles::Save($gadgetFile, $gadget); }