function Check($passed) { $message = gpOutput::SelectText('Sorry, your answer to the verification challenge was incorrect. Please try again.'); if (empty($_POST['asm_1']) || empty($_POST['asm_2']) || empty($_POST['asm_3'])) { message($message . ' (1)'); return false; } $operator_key = $_POST['asm_2']; if (!isset($this->operators[$operator_key])) { message($message . ' (2)'); return false; } switch ($operator_key) { case 1: $result = $_POST['asm_1'] + $_POST['asm_3']; break; case 2: $result = $_POST['asm_1'] - $_POST['asm_3']; break; case 3: $result = $_POST['asm_1'] / $_POST['asm_3']; break; case 4: $result = $_POST['asm_1'] * $_POST['asm_3']; break; } $compare = $_POST['asm_4']; //message('result: '.$result.' vs submitted: '.$compare); if ($compare != $result) { message($message . ' (3)'); return false; } //message('passed'); return $passed; }
function ShowRecent() { global $langmessage; $page->css_admin[] = '/include/css/addons.css'; //for hmargin css pre gpEasy 3.6 echo '<h2 class="hmargin">'; $label = gpOutput::SelectText('Blog'); echo common::Link('Special_Blog', $label); echo ' » '; echo common::Link('Admin_Blog', $langmessage['configuration']); echo ' <span>|</span> '; echo common::Link('Admin_BlogCategories', 'Categories'); echo ' <span>|</span> '; echo gpOutput::SelectText('Comments'); echo '</h2>'; echo '<table style="width:100%" class="bordered">'; echo '<tr><th>'; echo 'Comment'; echo '</th><th>'; echo 'Time / Website'; echo '</th><th>'; echo 'Options'; echo '</th></tr>'; uasort($this->cache, array('SimpleBlogComments', 'Sort')); foreach ($this->cache as $comment) { $this->OutputComment($comment); } echo '</table>'; }
/** * @param string $current */ function Heading($current) { global $langmessage; $options = array('Admin_Blog' => 'Posts', 'Admin_BlogConfig' => $langmessage['configuration'], 'Admin_BlogCategories' => 'Categories', 'Admin_BlogComments' => gpOutput::SelectText('Comments')); $links = array(); foreach ($options as $slug => $label) { if ($slug == $current) { $links[] = $label; } else { $links[] = common::Link($slug, $label); } } echo common::Link('Admin_Blog', 'New Blog Post', 'cmd=new_form', ' class="gpsubmit" style="float:right"'); echo '<h2 class="hmargin">'; $label = gpOutput::SelectText('Blog'); echo common::Link('Special_Blog', $label); echo ' » '; echo implode('<span>|</span>', $links); echo '</h2>'; }
function Show($indexofparent) { global $addonRelativeCode; if ($this->nav_style == 0) { $next = gpOutput::SelectText('Next'); $back = gpOutput::SelectText('Previous'); } elseif ($this->nav_style == 1) { $back = '<img src="' . $addonRelativeCode . '/img/arrow1-back.png' . '" />'; $next = '<img src="' . $addonRelativeCode . '/img/arrow1-next.png ' . '" />'; } elseif ($this->nav_style == 2) { $back = '<img src="' . $addonRelativeCode . '/img/arrow2-back.png' . '" />'; $next = '<img src="' . $addonRelativeCode . '/img/arrow2-next.png ' . '" />'; } elseif ($this->nav_style == 3) { $back = '<img src="' . $addonRelativeCode . '/img/arrow3-back.png' . '" />'; $next = '<img src="' . $addonRelativeCode . '/img/arrow3-next.png ' . '" />'; } if ($this->nav_buttons == 1) { $nav_style = "sides"; } else { $nav_style = ""; } echo '<p class="EC_nav_links' . $nav_style . '">'; if ($this->nav_parent) { $pl = common::GetLabelIndex($indexofparent); $pt = common::IndexToTitle($indexofparent); echo '<a class="EC_home" href="' . common::GetUrl($pt) . '">' . $pl . '</a>'; echo ' '; } if ($this->PrevUrl) { echo '<a class="EC_newer" href="' . $this->PrevUrl . '">' . $back . '</a>'; echo ' '; } if ($this->NextUrl) { echo '<a class="EC_older" href="' . $this->NextUrl . '">' . $next . '</a>'; } echo '</p>'; }
/** * Abbreviate $content if a $limit greater than zero is given * */ public function AbbrevContent($content, $post_index, $limit = 0) { if (!is_numeric($limit) || $limit == 0) { return $content; } $content = strip_tags($content); if (mb_strlen($content) < $limit) { return $content; } $pos = mb_strpos($content, ' ', $limit - 5); if ($pos > 0 && $limit + 20 > $pos) { $limit = $pos; } $content = mb_substr($content, 0, $limit) . ' ... '; $label = gpOutput::SelectText('Read More'); return $content . SimpleBlogCommon::PostLink($post_index, $label); }
/** * Regenerate the static content used to display the gadget * */ static function GenGadget() { global $langmessage; $posts = array(); $show_posts = SimpleBlogCommon::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) { $post = SimpleBlogCommon::GetPostContent($post_index); if (!$post) { continue; } $header = '<b class="simple_blog_title">'; $label = SimpleBlogCommon::Underscores($post['title']); $header .= SimpleBlogCommon::PostLink($post_index, $label); $header .= '</b>'; SimpleBlogCommon::BlogHead($header, $post_index, $post, true); $content = strip_tags($post['content']); if (SimpleBlogCommon::$data['gadget_abbrev'] > 6 && mb_strlen($content) > SimpleBlogCommon::$data['gadget_abbrev']) { $cut = SimpleBlogCommon::$data['gadget_abbrev']; $pos = mb_strpos($content, ' ', $cut - 5); if ($pos > 0 && $cut + 20 > $pos) { $cut = $pos; } $content = mb_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 = SimpleBlogCommon::$data_dir . '/gadget.php'; gpFiles::Save($gadgetFile, $gadget); }
/** * Get Posted Comment * */ protected function GetPostedComment() { global $langmessage; 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; } $comment = array(); $comment['name'] = htmlspecialchars($_POST['name']); $comment['comment'] = nl2br(strip_tags($_POST['comment'])); $comment['time'] = time(); if (!empty($_POST['website']) && $_POST['website'] !== 'http://') { $website = $_POST['website']; if (mb_strpos($website, '://') === false) { $website = false; } if ($website) { $comment['website'] = $website; } } return $comment; }
function __construct() { global $langmessage, $addonRelativeCode, $addonFolderName, $page; $this->Init(); $this->categories = SimpleBlogCommon::AStrToArray('categories'); $cmd = common::GetCommand(); switch ($cmd) { //category commands case 'save_categories': $this->SaveCategories(); break; case 'new_category': $this->NewCategory(); return; case 'save_new_category': $this->SaveNewCategory(); break; case 'delete_category': $this->DeleteCategory(); break; } $page->css_admin[] = '/include/css/addons.css'; //for hmargin css pre gpEasy 3.6 $page->head_js[] = '/data/_addoncode/' . $addonFolderName . '/admin.js'; $label = gpOutput::SelectText('Blog'); echo '<h2 class="hmargin">'; echo common::Link('Special_Blog', $label); echo ' » '; echo common::Link('Admin_Blog', 'Configuration'); echo ' <span>|</span> '; echo ' Categories '; echo ' <span>|</span> '; $comments = gpOutput::SelectText('Comments'); echo common::Link('Admin_BlogComments', $comments); echo '</h2>'; // print all categories and settings echo '<form name="categories" action="' . common::GetUrl('Admin_BlogCategories') . '" method="post">'; echo '<table class="bordered">'; echo '<tr><th> </th><th>Category</th><th>Number of Posts</th><th>Visible</th><th>Options</th></tr>'; echo '<tbody class="sortable_table">'; foreach ($this->categories as $catindex => $catname) { echo '<tr><td style="vertical-align:middle">'; echo '<img src="' . $addonRelativeCode . '/grip.png" height="15" width="15" style="padding:2px;cursor:pointer;"/>'; echo '</td><td>'; echo '<input type="text" name="cattitle[' . $catindex . ']" value="' . $catname . '" class="gpinput" />'; echo '</td><td>'; $astr =& SimpleBlogCommon::$data['category_posts_' . $catindex]; echo substr_count($astr, '>'); echo '</td><td>'; $checked = ''; if (!SimpleBlogCommon::AStrValue('categories_hidden', $catindex)) { $checked = ' checked="checked"'; } echo ' <input type="checkbox" name="catvis[' . $catindex . ']"' . $checked . '/> '; echo '</td><td>'; echo common::Link('Admin_BlogCategories', $langmessage['delete'], 'cmd=delete_category&index=' . $catindex, ' name="postlink" class="gpconfirm" title="Delete this Category?" '); echo '</td></tr>'; } echo '</tbody>'; echo '</table>'; echo '<p>'; echo '<input type="hidden" name="cmd" value="save_categories" />'; echo '<input type="submit" value="' . $langmessage['save_changes'] . '" class="gpsubmit"/>'; echo ' '; echo common::Link('Admin_BlogCategories', 'Add New Category', 'cmd=new_category', ' name="gpabox" '); echo '</p>'; echo '</form>'; // print all posts /* if( count($this->itlist) ){ echo '<h3 onclick="$(this).next(\'form\').toggle()" style="cursor:pointer">All Blog Posts</h3>'; echo '<form name="allposts" action="'.common::GetUrl('Admin_BlogCategories').'" method="post" style="display:none">'; echo '<table style="width:100%">'; foreach( $this->itlist as $postindex => $postdata ){ echo '<tr><td>'.$postdata['title'].' '; echo common::Link('Special_Blog','»','id='.$postindex,'target="_blank"').'</td><td>'; echo '<select id="post'.$postindex.'" name="post'.$postindex.'[]" multiple="multiple" class="gpselect">'; foreach( $this->categories as $catindex => $catdata){ echo '<option value="'.$catindex.'" '.(isset($catdata[$postindex])? 'selected="selected"':'').'>'.$catdata['ct'].'</option>'; } echo '</select>'; echo '</td></tr>'; } echo '</table>'; echo '<input name="save_posts" type="submit" value="'.$langmessage['save'].'" class="gpsubmit" />'; echo '</form>'; } */ }
function ReturnTextWorker($key, $html, $query) { global $langmessage; $result = ''; $wrap = gpOutput::ShowEditLink('Admin_Theme_Content'); if ($wrap) { $title = htmlspecialchars(strip_tags($key)); if (strlen($title) > 20) { $title = substr($title, 0, 20) . '...'; //javscript may shorten it as well } echo gpOutput::EditAreaLink($edit_index, 'Admin_Theme_Content', $langmessage['edit'], $query, ' title="' . $title . '" name="gpabox" '); $result .= '<span class="editable_area" id="ExtraEditArea' . $edit_index . '">'; // class="edit_area" added by javascript } $text = gpOutput::SelectText($key); $result .= str_replace('%s', $text, $html); //in case there's more than one %s if ($wrap) { $result .= '</span>'; } return $result; }
function ShowForm() { global $page, $langmessage, $config; $attr = ''; if ($this->sent) { $attr = ' readonly="readonly" '; } $_GET += array('name' => '', 'email' => '', 'subject' => '', 'message' => ''); $_POST += array('name' => $_GET['name'], 'email' => $_GET['email'], 'subject' => $_GET['subject'], 'message' => $_GET['message']); $require_email =& $config['require_email']; echo '<form class="contactform" action="' . common::GetUrl($page->title) . '" method="post">'; //nonce fields echo '<div style="display:none !important">'; echo '<input type="hidden" name="contact_nonce" value="' . htmlspecialchars(common::new_nonce('contact_post', true)) . '" />'; echo '<input type="text" name="contact_void" value="" />'; echo '</div>'; echo '<label for="contact_name"><span class="title">'; echo gpOutput::ReturnText('your_name'); echo '</span><input id="contact_name" class="input text" type="text" name="name" value="' . htmlspecialchars($_POST['name']) . '" ' . $attr . ' />'; echo '</label>'; echo '<label for="contact_email"><span class="title">'; echo gpOutput::ReturnText('your_email'); if (strpos($require_email, 'email') !== false) { echo '*'; } echo '</span><input id="contact_email" class="input text" type="text" name="email" value="' . htmlspecialchars($_POST['email']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_subject"><span class="title">'; echo gpOutput::ReturnText('subject'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</span><input id="contact_subject" class="input text" type="text" name="subject" value="' . htmlspecialchars($_POST['subject']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_message">'; echo gpOutput::ReturnText('message'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</label>'; echo '<textarea id="contact_message" name="message" ' . $attr . ' rows="10" cols="10">'; echo htmlspecialchars($_POST['message']); echo '</textarea>'; gpPlugin::Action('contact_form_pre_captcha'); if (!$this->sent && gp_recaptcha::isActive()) { echo '<div class="captchaForm">'; echo gpOutput::ReturnText('captcha'); gp_recaptcha::Form(); echo '</div>'; } if ($this->sent) { echo gpOutput::ReturnText('message_sent', '%s', 'message_sent'); } else { echo '<input type="hidden" name="cmd" value="gp_send_message" />'; $key = 'send_message'; $text = gpOutput::SelectText($key); if (gpOutput::ShowEditLink('Admin_Theme_Content')) { $query = 'cmd=edittext&key=' . urlencode($key); echo gpOutput::EditAreaLink($edit_index, 'Admin_Theme_Content', $langmessage['edit'], $query, ' title="' . $key . '" data-cmd="gpabox" '); echo '<input type="submit" class="submit editable_area" id="ExtraEditArea' . $edit_index . '" name="aaa" value="' . $text . '" />'; } else { echo '<input type="submit" class="submit" name="aaa" value="' . $text . '" />'; } } echo '</form>'; }
/** * Show the configuration form * */ function Config() { global $langmessage, $addonFolderName, $gpversion; $defaults = SimpleBlogCommon::Defaults(); $array =& SimpleBlogCommon::$data; $label = gpOutput::SelectText('Blog'); $this->Heading('Admin_BlogConfig'); echo '<form class="renameform" action="' . common::GetUrl('Admin_BlogConfig') . '" method="post">'; echo '<table class="bordered full_width">'; echo '<tr><th>'; echo 'Option'; echo '</th><th>'; echo 'Value'; echo '</th><th>'; echo 'Default'; echo '</th></tr>'; $options = self::Options(); //Pretty Urls echo '<tr><td>Urls</td><td>'; if (version_compare($gpversion, '4.0', '>=')) { self::Radio('urls', $options['urls'], $array['urls']); } else { echo 'Available in gpEasy 4.0+'; } echo '</td><td>'; echo $defaults['urls']; echo '</td></tr>'; //Date Format echo '<tr><td>'; echo 'Date Format'; //echo ' (<a href="http://php.net/manual/en/function.date.php" target="_blank">About</a>)'; echo ' (<a href="http://www.php.net/manual/en/function.strftime.php" target="_blank">About</a>)'; echo '</td><td>'; //echo '<input type="text" name="date_format" size="20" value="'.htmlspecialchars($array['date_format']).'" class="gpinput" />'; echo '<input type="text" name="strftime_format" value="' . htmlspecialchars($array['strftime_format']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['strftime_format']; echo '</td></tr>'; //Subtitle Separator echo '<tr><td>'; echo 'Subtitle Separator'; echo '</td><td>'; echo '<input type="text" name="subtitle_separator" size="20" value="' . htmlspecialchars($array['subtitle_separator']) . '" class="gpinput" />'; echo '</td><td>'; echo htmlspecialchars($defaults['subtitle_separator']); echo '</td></tr>'; //Entries Per Page echo '<tr><td>Entries Per Page</td><td>'; echo '<input type="text" name="per_page" value="' . htmlspecialchars($array['per_page']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['per_page']; echo '</td></tr>'; //Entries Abbreviation Length echo '<tr><td>'; echo 'Entries Abbreviation Length'; echo '</td><td>'; echo '<input type="text" name="post_abbrev" value="' . htmlspecialchars($array['post_abbrev']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['post_abbrev']; echo '</td></tr>'; //Image in Abbrevation echo '<tr><td>'; echo 'Image in Abbrevation'; echo '</td><td>'; if ($array['abbrev_image']) { echo '<input type="checkbox" name="abbrev_image" value="allow" checked="checked" />'; } else { echo '<input type="checkbox" name="abbrev_image" value="allow" />'; } echo '</td><td></td></tr>'; //Categories in Abbreviation echo '<tr><td>'; echo 'Categories in Abbrevation'; echo '</td><td>'; if ($array['abbrev_cat']) { echo '<input type="checkbox" name="abbrev_cat" value="allow" checked="checked" />'; } else { echo '<input type="checkbox" name="abbrev_cat" value="allow" />'; } echo '</td><td></td></tr>'; //Comments echo '<tr><th colspan="3">'; echo 'Gadget'; echo '</th></tr>'; //Entries For Gadget echo '<tr><td>'; echo 'Entries For Gadget'; echo '</td><td>'; echo '<input type="text" name="gadget_entries" value="' . htmlspecialchars($array['gadget_entries']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['gadget_entries']; echo '</td></tr>'; //Gadget Abbreviation Length echo '<tr><td>'; echo 'Gadget Abbreviation Length'; echo '</td><td>'; echo '<input type="text" name="gadget_abbrev" value="' . htmlspecialchars($array['gadget_abbrev']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['gadget_abbrev']; echo '</td></tr>'; //Comments echo '<tr><th colspan="3">'; echo 'Feed'; echo '</th></tr>'; //Entries For Feed echo '<tr><td>'; echo 'Entries For Feed'; echo '</td><td>'; echo '<input type="text" name="feed_entries" value="' . htmlspecialchars($array['feed_entries']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['feed_entries']; echo '</td></tr>'; //Feed Abbreviation Length echo '<tr><td>'; echo 'Feed Abbreviation Length'; echo '</td><td>'; echo '<input type="text" name="feed_abbrev" size="20" value="' . htmlspecialchars($array['feed_abbrev']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['feed_abbrev']; echo '</td></tr>'; //Comments echo '<tr><th colspan="3">'; echo 'Comments'; echo '</th></tr>'; //Allow Comments echo '<tr><td>'; echo 'Allow Comments'; echo '</td><td>'; if ($array['allow_comments']) { echo '<input type="checkbox" name="allow_comments" value="allow" checked="checked" />'; } else { echo '<input type="checkbox" name="allow_comments" value="allow" />'; } echo '</td><td></td></tr>'; //Email New Comment echo '<tr><td>'; echo 'Email New Comments'; echo '</td><td>'; echo '<input type="text" name="email_comments" value="' . htmlspecialchars($array['email_comments']) . '" />'; echo '</td><td></td></tr>'; echo '<tr><td>'; echo 'Commenter Website'; echo '</td><td>'; echo '<select name="commenter_website" class="gpselect">'; if ($array['commenter_website'] == 'nofollow') { echo '<option value="">Hide</option>'; echo '<option value="nofollow" selected="selected">Nofollow Link</option>'; echo '<option value="link">Follow Link</option>'; } elseif ($array['commenter_website'] == 'link') { echo '<option value="">Hide</option>'; echo '<option value="nofollow" selected="selected">Nofollow Link</option>'; echo '<option value="link" selected="selected">Follow Link</option>'; } else { echo '<option value="">Hide</option>'; echo '<option value="nofollow">Nofollow Link</option>'; echo '<option value="link">Follow Link</option>'; } echo '</select>'; echo '</td><td>'; echo 'Hide'; echo '</td></tr>'; echo '<tr><td>'; echo 'reCaptcha'; echo '</td><td>'; if (!gp_recaptcha::isActive()) { $disabled = ' disabled="disabled" '; } else { $disabled = ''; } if ($array['comment_captcha']) { echo '<input type="checkbox" name="comment_captcha" value="allow" checked="checked" ' . $disabled . '/>'; } else { echo '<input type="checkbox" name="comment_captcha" value="allow" ' . $disabled . '/>'; } echo '</td><td>'; echo ''; echo '</td></tr>'; echo '<tr><td></td>'; echo '<td colspan="2">'; echo '<input type="hidden" name="cmd" value="save_config" />'; echo '<input type="submit" name="" value="' . $langmessage['save'] . '" class="gpsubmit" /> '; echo '</td></tr>'; echo '</table>'; echo '<p style="text-align:center">'; echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon=' . urlencode($addonFolderName), ' title="' . urlencode($langmessage['editable_text']) . '" name="gpabox" '); echo ' '; echo common::Link('Admin_BlogConfig', 'Regenerate Gadget', 'cmd=regen', ' name="creq"'); echo '</p>'; echo '</form>'; }
/** * Potential method for allowing users to format the header area of their blog * However, this would make it more difficult for theme developers to design for the blog plugin * */ function BlogHead($header, $post_index, $post, $cacheable = false) { //subtitle $blog_info = '{empty_blog_piece}'; if (!empty($post['subtitle'])) { $blog_info = '<span class="simple_blog_subtitle">'; $blog_info .= $post['subtitle']; $blog_info .= '</span>'; } //blog date $blog_date = '<span class="simple_blog_date">'; $blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'], $post['time']); $blog_date .= '</span>'; //blog comments $blog_comments = '{empty_blog_piece}'; $count = SimpleBlogCommon::AStrValue('comment_counts', $post_index); if ($count > 0) { $blog_comments = '<span class="simple_blog_comments">'; if ($cacheable) { $blog_comments .= gpOutput::SelectText('Comments'); } else { $blog_comments .= gpOutput::GetAddonText('Comments'); } $blog_comments .= ': ' . $count; $blog_comments .= '</span>'; } // format content $format = '{header} <div class="simple_blog_info"> {blog_info} {separator} {blog_date} {separator} {blog_comments} </div>'; $search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}'); $replace = array($header, $blog_info, $blog_date, $blog_comments); $result = str_replace($search, $replace, $format); $reg = '#\\{empty_blog_piece\\}(\\s*)\\{separator\\}#'; $result = preg_replace($reg, '\\1', $result); $reg = '#\\{separator\\}(\\s*){empty_blog_piece\\}#'; $result = preg_replace($reg, '\\1', $result); echo str_replace('{separator}', SimpleBlogCommon::$data['subtitle_separator'], $result); }
/** * Show all blog posts * */ public function ShowPosts() { global $langmessage; $this->Heading('Admin_Blog'); $post_ids = SimpleBlogCommon::AStrToArray('str_index'); $post_titles = SimpleBlogCommon::AStrToArray('titles'); $post_times = SimpleBlogCommon::AStrToArray('post_times'); $post_comments = SimpleBlogCommon::AStrToArray('comment_counts'); $post_drafts = SimpleBlogCommon::AStrToArray('drafts'); $total_posts = count($post_ids); $per_page = 20; $total_pages = ceil($total_posts / $per_page); $offset = 0; //offset if (isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) && $_REQUEST['offset'] > 0) { $offset = $_REQUEST['offset']; } $post_ids = array_slice($post_ids, $offset, $per_page); //pagination links echo '<div style="float:right;margin:20px 0;">'; echo '<span class="page_count">'; echo $offset + 1 . ' to ' . min($total_posts, $offset + $per_page) . ' of ' . $total_posts; echo '</span>'; echo '<ul class="pagination">'; if ($total_posts > $per_page) { for ($i = 0; $i < $total_pages; $i++) { $_offset = $i * $per_page; $class = ''; if ($_offset == $offset) { $class = ' class="active"'; } echo '<li ' . $class . '>' . common::Link('Admin_Blog', $i + 1, 'offset=' . $_offset) . '</li>'; } } echo '</ul>'; echo '</div>'; echo '<table class="bordered full_width striped">'; echo '<thead><tr><th></th><th>Posts (' . number_format($total_posts) . ')'; echo '</th><th>Publish Time</th><th>Comments</th>'; echo '<th>Options</th>'; echo '</tr></thead>'; echo '<tbody>'; foreach ($post_ids as $i => $post_id) { //draft/pending echo '<tr><td width="1%">'; if (isset($post_drafts[$post_id])) { echo 'Draft'; } elseif ($post_times[$post_id] > time()) { echo 'Pending'; } //title echo '</td><td>'; $title = $post_titles[$post_id]; echo SimpleBlogCommon::PostLink($post_id, $title); //post time echo '</td><td>'; if (isset($post_times[$post_id])) { echo strftime(SimpleBlogCommon::$data['strftime_format'], $post_times[$post_id]); } //comments echo '</td><td>'; echo '<span style="display:inline-block;min-width:30px">'; if (isset($post_comments[$post_id])) { echo number_format($post_comments[$post_id]); } else { echo '0'; } echo '</span>'; if (SimpleBlogCommon::$data['allow_comments']) { $comments_closed = SimpleBlogCommon::AStrGet('comments_closed', $post_id); $open = gpOutput::SelectText('Open'); $close = gpOutput::SelectText('Close'); if ($comments_closed) { echo common::Link('Admin_Blog', $open, 'cmd=opencomments&id=' . $post_id, 'name="cnreq"'); echo ' '; echo gpOutput::SelectText('Closed'); } else { echo $open; echo ' '; echo common::Link('Admin_Blog', $close, 'cmd=closecomments&id=' . $post_id, 'name="cnreq"'); } } else { echo common::Link('Admin_BlogConfig', 'Disabled'); } echo '</td><td>'; echo SimpleBlogCommon::PostLink($post_id, 'View Post'); echo ' '; echo common::Link('Admin_Blog/' . $post_id, $langmessage['edit'], 'cmd=edit_post'); echo ' '; echo common::Link('Admin_Blog', $langmessage['delete'], 'cmd=deleteentry&del_id=' . $post_id, array('class' => 'delete gpconfirm', 'data-cmd' => 'cnreq', 'title' => $langmessage['delete_confirm'])); echo '</td></tr>'; } echo '</tbody>'; echo '</table>'; }
/** * Show the configuration form * */ function Config() { global $langmessage, $addonFolderName; $defaults = SimpleBlogCommon::Defaults(); $array =& $this->blogData; $label = gpOutput::SelectText('Blog'); echo '<h2>'; echo common::Link('Special_Blog', $label); echo ' » '; echo $langmessage['configuration']; echo '</h2>'; echo '<form class="renameform" action="' . common::GetUrl('Admin_Blog') . '" method="post">'; echo '<table style="width:100%" class="bordered">'; echo '<tr>'; echo '<th>'; echo 'Option'; echo '</th>'; echo '<th>'; echo 'Value'; echo '</th>'; echo '<th>'; echo 'Default'; echo '</th>'; echo '</tr>'; echo '<tr>'; echo '<td>Entries Per Page</td>'; echo '<td>'; echo '<input type="text" name="per_page" size="20" value="' . htmlspecialchars($array['per_page']) . '" class="gpinput" />'; echo '</td><td>'; echo $defaults['per_page']; echo '</td></tr>'; echo '<tr>'; echo '<td>'; echo 'Entries Abbreviation Length'; echo '</td>'; echo '<td>'; echo '<input type="text" name="post_abbrev" size="20" value="' . htmlspecialchars($array['post_abbrev']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['post_abbrev']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Entries For Gadget'; echo '</td>'; echo '<td>'; echo '<input type="text" name="gadget_entries" size="20" value="' . htmlspecialchars($array['gadget_entries']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['gadget_entries']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Gadget Abbreviation Length'; echo '</td>'; echo '<td>'; echo '<input type="text" name="gadget_abbrev" size="20" value="' . htmlspecialchars($array['gadget_abbrev']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['gadget_abbrev']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Date Format'; //echo ' (<a href="http://php.net/manual/en/function.date.php" target="_blank">About</a>)'; echo ' (<a href="http://www.php.net/manual/en/function.strftime.php" target="_blank">About</a>)'; echo '</td>'; echo '<td>'; //echo '<input type="text" name="date_format" size="20" value="'.htmlspecialchars($array['date_format']).'" class="gpinput" />'; echo '<input type="text" name="strftime_format" size="20" value="' . htmlspecialchars($array['strftime_format']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['strftime_format']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Entries For Feed'; echo '</td>'; echo '<td>'; echo '<input type="text" name="feed_entries" size="20" value="' . htmlspecialchars($array['feed_entries']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['feed_entries']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Feed Abbreviation Length'; echo '</td>'; echo '<td>'; echo '<input type="text" name="feed_abbrev" size="20" value="' . htmlspecialchars($array['feed_abbrev']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo $defaults['feed_abbrev']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Subtitle Separator'; echo '</td>'; echo '<td>'; echo '<input type="text" name="subtitle_separator" size="20" value="' . htmlspecialchars($array['subtitle_separator']) . '" class="gpinput" />'; echo '</td>'; echo '<td>'; echo htmlspecialchars($defaults['subtitle_separator']); echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<th>'; echo 'Comments'; echo '</th>'; echo '<th>'; echo 'Value'; echo '</th>'; echo '<th>'; echo 'Default'; echo '</th>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Allow Comments'; echo '</td>'; echo '<td>'; if ($array['allow_comments']) { echo '<input type="checkbox" name="allow_comments" value="allow" checked="checked" />'; } else { echo '<input type="checkbox" name="allow_comments" value="allow" />'; } echo '</td>'; echo '<td>'; echo ''; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Commenter Website'; echo '</td>'; echo '<td>'; echo '<select name="commenter_website" class="gpselect">'; if ($array['commenter_website'] == 'nofollow') { echo '<option value="">Hide</option>'; echo '<option value="nofollow" selected="selected">Nofollow Link</option>'; echo '<option value="link">Follow Link</option>'; } elseif ($array['commenter_website'] == 'link') { echo '<option value="">Hide</option>'; echo '<option value="nofollow" selected="selected">Nofollow Link</option>'; echo '<option value="link" selected="selected">Follow Link</option>'; } else { echo '<option value="">Hide</option>'; echo '<option value="nofollow">Nofollow Link</option>'; echo '<option value="link">Follow Link</option>'; } echo '</select>'; echo '</td>'; echo '<td>'; echo 'Hide'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'reCaptcha'; echo '</td>'; echo '<td>'; if (!gp_recaptcha::isActive()) { $disabled = ' disabled="disabled" '; } else { $disabled = ''; } if ($array['comment_captcha']) { echo '<input type="checkbox" name="comment_captcha" value="allow" checked="checked" ' . $disabled . '/>'; } else { echo '<input type="checkbox" name="comment_captcha" value="allow" ' . $disabled . '/>'; } echo '</td>'; echo '<td>'; echo ''; echo '</td>'; echo '</tr>'; echo '<tr><td></td>'; echo '<td colspan="2">'; echo '<input type="hidden" name="cmd" value="save_config" />'; echo '<input type="submit" name="" value="' . $langmessage['save'] . '" class="gpsubmit" /> '; echo '</td>'; echo '</tr>'; echo '</table>'; echo '<p style="text-align:center">'; echo ' '; echo common::Link('Special_Blog', 'Back to Your Blog'); echo ' '; echo common::Link('Admin_BlogCategories', 'Categories Admin'); echo ' '; echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon=' . urlencode($addonFolderName), ' title="' . urlencode($langmessage['editable_text']) . '" name="ajax_box" '); echo ' '; echo common::Link('Admin_Blog', 'Regenerate Gadget', 'cmd=regen', ' name="creq"'); echo '</p>'; echo '</form>'; }
/** * Potential method for allowing users to format the header area of their blog * However, this would make it more difficult for theme developers to design for the blog plugin * */ function BlogHead($header, $post_index, $post, $cacheable = false) { $blog_info = '{empty_blog_piece}'; if (!empty($post['subtitle'])) { $blog_info = '<span class="simple_blog_subtitle">'; $blog_info .= $post['subtitle']; $blog_info .= '</span>'; } $blog_date = '<span class="simple_blog_date">'; $blog_date .= strftime($this->blogData['strftime_format'], $post['time']); $blog_date .= '</span>'; $blog_comments = '{empty_blog_piece}'; if ($this->blogData['allow_comments'] && isset($this->blogData['post_info'][$post_index]) && isset($this->blogData['post_info'][$post_index]['comments'])) { $blog_comments = '<span class="simple_blog_comments">'; if ($cacheable) { $blog_comments .= gpOutput::SelectText('Comments'); } else { $blog_comments .= gpOutput::GetAddonText('Comments'); } $blog_comments .= ': ' . $this->blogData['post_info'][$post_index]['comments']; $blog_comments .= '</span>'; } $format = '{header} <div class="simple_blog_info"> {blog_info} {separator} {blog_date} {separator} {blog_comments} </div>'; $search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}'); $replace = array($header, $blog_info, $blog_date, $blog_comments); $result = str_replace($search, $replace, $format); $reg = '#\\{empty_blog_piece\\}(\\s*)\\{separator\\}#'; $result = preg_replace($reg, '\\1', $result); $reg = '#\\{separator\\}(\\s*){empty_blog_piece\\}#'; $result = preg_replace($reg, '\\1', $result); echo str_replace('{separator}', $this->blogData['subtitle_separator'], $result); }
/** * 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; }
/** * Save a user submitted comment * */ function CommentAdd() { global $langmessage; // check the nonce // includes the comment count so resubmissions won't work if (!common::verify_nonce('easy_comments:' . count($this->comment_data), $_POST['nonce'], true)) { $message = gpOutput::GetAddonText('Sorry, your comment was not saved.'); message($message); return false; } //check captcha if ($this->config['comment_captcha'] && gp_recaptcha::isActive()) { if (!gp_recaptcha::Check()) { //recaptcha::check adds message on failure 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 (strpos($website, '://') === false) { $website = false; } if ($website) { $temp['website'] = $website; } } $index = $this->NewIndex(); $this->comment_data[$index] = $temp; //save to index file first if (!$this->UpdateIndex()) { $message = gpOutput::GetAddonText('Sorry, your comment was not saved.'); message($message); return false; } //then save actual comment if ($this->SaveCommentData()) { $message = gpOutput::GetAddonText('Your comment has been saved.'); message($message); return true; } else { $message = gpOutput::GetAddonText('Sorry, your comment was not saved.'); message($message); return false; } }
static function ReturnTextWorker($key, $html, $query, $wrapper_class = '') { global $langmessage; $text = gpOutput::SelectText($key); $result = str_replace('%s', $text, $html); //in case there's more than one %s $editable = gpOutput::ShowEditLink('Admin_Theme_Content'); if ($editable) { $title = htmlspecialchars(strip_tags($key)); if (strlen($title) > 20) { $title = substr($title, 0, 20) . '...'; //javscript may shorten it as well } gpOutput::$editlinks .= gpOutput::EditAreaLink($edit_index, 'Admin_Theme_Content', $langmessage['edit'], $query, ' title="' . $title . '" data-cmd="gpabox" '); return '<span class="editable_area ' . $wrapper_class . '" id="ExtraEditArea' . $edit_index . '">' . $result . '</span>'; } if ($wrapper_class) { return '<span class="' . $wrapper_class . '">' . $result . '</span>'; } return $result; }
function AdminSimpleBlogCategories() { global $langmessage; $this->Init(); $cmd = common::GetCommand(); switch ($cmd) { //category commands case 'save_categories': $this->SaveCategories(); break; case 'new_category': $this->NewCategory(); return; case 'save_new_category': $this->SaveNewCategory(); break; case 'delete_category': $this->DeleteCategory(); break; //archive commands //archive commands case 'fill_archive': $this->FillArchive(); break; case 'clear_archive': $this->ClearArchive(); break; } /* if( isset($_POST['save_posts']) ){ foreach( $this->categories as $catindex => $catdata){ $clean = array( 'ct'=>$catdata['ct'], 'visible'=>$catdata['visible']); $this->categories[$catindex] = $clean; //clean categories } foreach( $this->itlist as $postindex => $postdata){ if( isset($_POST['post'.$postindex]) ){ foreach ($_POST['post'.$postindex] as $catindex){ $this->categories[$catindex][$postindex] = $postdata['title']; } } } gpFiles::SaveArray($this->categories_file,'categories',$this->categories); //save } */ $label = gpOutput::SelectText('Blog'); echo '<h2>'; echo common::Link('Special_Blog', $label); echo ' » '; echo common::Link('Admin_Blog', 'Configuration'); echo ' » '; echo 'Categories</h2>'; // print all categories and settings //echo '<h3>Existing Categories (empty field removes category)</h3>'; echo '<form name="categories" action="' . common::GetUrl('Admin_BlogCategories') . '" method="post">'; echo '<table class="bordered">'; echo '<tr><th>Category</th><th>Number of Posts</th><th>Visible</th><th>Options</th></tr>'; foreach ($this->categories as $catindex => $catdata) { echo '<tr><td>'; echo '<input type="text" name="cattitle' . $catindex . '" value="' . $catdata['ct'] . '" class="gpinput" />'; echo '</td><td>'; echo count($catdata['posts']); echo '</td><td>'; echo ' <input type="checkbox" name="catvis' . $catindex . '"' . ($catdata['visible'] ? ' checked="checked"' : '') . ' /> '; echo '</td><td>'; echo common::Link('Admin_BlogCategories', $langmessage['delete'], 'cmd=delete_category&index=' . $catindex, ' name="postlink" class="gpconfirm" title="Delete this Category?" '); echo '</td></tr>'; } echo '</table>'; echo '<p>'; echo '<input type="hidden" name="cmd" value="save_categories" />'; echo '<input type="submit" value="' . $langmessage['save_changes'] . '" class="gpsubmit"/>'; echo ' '; echo common::Link('Admin_BlogCategories', 'Add New Category', 'cmd=new_category', ' name="admin_box" '); echo '</p>'; echo '</form>'; // print all posts /* if( count($this->itlist) ){ echo '<h3 onclick="$(this).next(\'form\').toggle()" style="cursor:pointer">All Blog Posts</h3>'; echo '<form name="allposts" action="'.common::GetUrl('Admin_BlogCategories').'" method="post" style="display:none">'; echo '<table style="width:100%">'; foreach( $this->itlist as $postindex => $postdata ){ echo '<tr><td>'.$postdata['title'].' '; echo common::Link('Special_Blog','»','id='.$postindex,'target="_blank"').'</td><td>'; echo '<select id="post'.$postindex.'" name="post'.$postindex.'[]" multiple="multiple" class="gpselect">'; foreach( $this->categories as $catindex => $catdata){ echo '<option value="'.$catindex.'" '.(isset($catdata[$postindex])? 'selected="selected"':'').'>'.$catdata['ct'].'</option>'; } echo '</select>'; echo '</td></tr>'; } echo '</table>'; echo '<input name="save_posts" type="submit" value="'.$langmessage['save'].'" class="gpsubmit" />'; echo '</form>'; } */ // archives echo '<br/><h2>Archives</h2>'; echo common::Link('Admin_BlogCategories', 'Fill archive with all posts', 'cmd=fill_archive', ' name="cnreq"') . '<br/>'; echo common::Link('Admin_BlogCategories', 'Clear all posts from archive', 'cmd=clear_archive', ' name="cnreq"'); }