/** * Regenerate the atom.feed file * */ static function GenFeed() { global $config, $addonFolderName, $dirPrefix; ob_start(); $atomFormat = 'Y-m-d\\TH:i:s\\Z'; $show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['feed_entries']); if (isset($_SERVER['HTTP_HOST'])) { $server = 'http://' . $_SERVER['HTTP_HOST']; } else { $server = 'http://' . $_SERVER['SERVER_NAME']; } $serverWithDir = $server . $dirPrefix; echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; echo '<feed xmlns="http://www.w3.org/2005/Atom">' . "\n"; echo '<title>' . $config['title'] . '</title>' . "\n"; echo '<link href="' . $serverWithDir . '/data/_addondata/' . str_replace(' ', '%20', $addonFolderName) . '/feed.atom" rel="self" />' . "\n"; echo '<link href="' . $server . common::GetUrl('Special_Blog') . '" />' . "\n"; echo '<id>urn:uuid:' . self::uuid($serverWithDir) . '</id>' . "\n"; echo '<updated>' . date($atomFormat, time()) . '</updated>' . "\n"; echo '<author><name>' . $config['title'] . '</name></author>' . "\n"; foreach ($show_posts as $post_index) { $post = SimpleBlogCommon::GetPostContent($post_index); if (!$post) { continue; } echo '<entry>' . "\n"; echo '<title>' . SimpleBlogCommon::Underscores($post['title']) . '</title>' . "\n"; echo '<link href="' . $server . SimpleBlogCommon::PostUrl($post_index) . '"></link>' . "\n"; echo '<id>urn:uuid:' . self::uuid($post_index) . '</id>' . "\n"; echo '<updated>' . date($atomFormat, $post['time']) . '</updated>' . "\n"; $content =& $post['content']; if (SimpleBlogCommon::$data['feed_abbrev'] > 0 && mb_strlen($content) > SimpleBlogCommon::$data['feed_abbrev']) { $content = mb_substr($content, 0, SimpleBlogCommon::$data['feed_abbrev']) . ' ... '; $label = gpOutput::SelectText('Read More'); $content .= '<a href="' . $server . SimpleBlogCommon::PostUrl($post_index, $label) . '">' . $label . '</a>'; } //old images $replacement = $server . '/'; $content = str_replace('src="/', 'src="' . $replacement, $content); //new images $content = str_replace('src="../', 'src="' . $serverWithDir, $content); //images without /index.php/ $content = str_replace('src="./', 'src="' . $serverWithDir, $content); //href self::FixLinks($content, $server, 0); echo '<summary type="html"><![CDATA[' . $content . ']]></summary>' . "\n"; echo '</entry>' . "\n"; } echo '</feed>' . "\n"; $feed = ob_get_clean(); $feedFile = SimpleBlogCommon::$data_dir . '/feed.atom'; gpFiles::Save($feedFile, $feed); }
/** * Display the visitor form for adding comments * */ public function CommentForm() { if ($this->comments_closed) { echo '<div class="comments_closed">'; echo gpOutput::GetAddonText('Comments have been closed.'); echo '</div>'; return; } if ($this->comment_saved) { return; } $_POST += array('name' => '', 'website' => 'http://', 'comment' => ''); echo '<h3>'; echo gpOutput::GetAddonText('Leave Comment'); echo '</h3>'; echo '<form method="post" action="' . SimpleBlogCommon::PostUrl($this->post_id) . '">'; echo '<ul>'; //name echo '<li>'; echo '<label>'; echo gpOutput::GetAddonText('Name'); echo '</label><br/>'; echo '<input type="text" name="name" class="text" value="' . htmlspecialchars($_POST['name']) . '" />'; echo '</li>'; //website if (!empty(SimpleBlogCommon::$data['commenter_website'])) { echo '<li>'; echo '<label>'; echo gpOutput::GetAddonText('Website'); echo '</label><br/>'; echo '<input type="text" name="website" class="text" value="' . htmlspecialchars($_POST['website']) . '" />'; echo '</li>'; } //comment echo '<li>'; echo '<label>'; echo gpOutput::ReturnText('Comment'); echo '</label><br/>'; echo '<textarea name="comment" cols="30" rows="7" >'; echo htmlspecialchars($_POST['comment']); echo '</textarea>'; echo '</li>'; //recaptcha if (SimpleBlogCommon::$data['comment_captcha'] && gp_recaptcha::isActive()) { echo '<input type="hidden" name="anti_spam_submitted" value="anti_spam_submitted" />'; echo '<li>'; echo '<label>'; echo gpOutput::ReturnText('captcha'); echo '</label><br/>'; gp_recaptcha::Form(); echo '</li>'; } //submit button echo '<li>'; echo '<input type="hidden" name="cmd" value="Add Comment" />'; $html = '<input type="submit" name="" class="submit" value="%s" />'; echo gpOutput::GetAddonText('Add Comment', $html); echo '</li>'; echo '</ul>'; echo '</form>'; }
static function PostLink($post, $label, $query = '', $attr = '') { return '<a href="' . SimpleBlogCommon::PostUrl($post, $query, true) . '" ' . $attr . '>' . common::Ampersands($label) . '</a>'; }