/**
  * Open/Close the comments for a blog post
  *
  * @param boolean $closed
  */
 function ToggleComments($closed, $post_id)
 {
     global $langmessage;
     if ($closed) {
         SimpleBlogCommon::AStrSet('comments_closed', $post_id, 1);
     } else {
         SimpleBlogCommon::AStrRm('comments_closed', $post_id);
     }
     if (SimpleBlogCommon::SaveIndex()) {
         $this->comments_closed = $closed;
         message($langmessage['SAVED']);
     } else {
         message($langmessage['OOPS']);
     }
 }
Example #2
0
 /**
  * Check and Save the user submitted configuration
  * @return bool
  *
  */
 function SaveConfig()
 {
     global $langmessage;
     $options = self::Options();
     if (isset($_POST['urls']) && isset($options['urls'][$_POST['urls']])) {
         SimpleBlogCommon::$data['urls'] = $_POST['urls'];
     }
     SimpleBlogCommon::$data['per_page'] = (int) $_POST['per_page'];
     if (is_numeric($_POST['post_abbrev'])) {
         SimpleBlogCommon::$data['post_abbrev'] = (int) $_POST['post_abbrev'];
     } elseif (empty($_POST['post_abbrev'])) {
         SimpleBlogCommon::$data['post_abbrev'] = '';
     }
     SimpleBlogCommon::$data['gadget_entries'] = (int) $_POST['gadget_entries'];
     SimpleBlogCommon::$data['gadget_abbrev'] = (int) $_POST['gadget_abbrev'];
     $format = htmlspecialchars($_POST['strftime_format']);
     if (@strftime($format)) {
         SimpleBlogCommon::$data['strftime_format'] = $format;
     }
     SimpleBlogCommon::$data['feed_entries'] = (int) $_POST['feed_entries'];
     SimpleBlogCommon::$data['feed_abbrev'] = (int) $_POST['feed_abbrev'];
     SimpleBlogCommon::$data['abbrev_image'] = isset($_POST['abbrev_image']);
     SimpleBlogCommon::$data['abbrev_cat'] = isset($_POST['abbrev_cat']);
     //comments
     SimpleBlogCommon::$data['allow_comments'] = isset($_POST['allow_comments']);
     SimpleBlogCommon::$data['commenter_website'] = (string) $_POST['commenter_website'];
     SimpleBlogCommon::$data['comment_captcha'] = isset($_POST['comment_captcha']);
     SimpleBlogCommon::$data['subtitle_separator'] = (string) $_POST['subtitle_separator'];
     SimpleBlogCommon::$data['email_comments'] = $_POST['email_comments'];
     if (!SimpleBlogCommon::SaveIndex()) {
         message($langmessage['OOPS']);
         return false;
     }
     message($langmessage['SAVED']);
     return true;
 }
Example #3
0
 /**
  * Save the comment data for a blog post
  *
  */
 public static function SaveCommentData($post_index, $data)
 {
     global $langmessage;
     // check directory
     $dir = self::$data_dir . '/comments';
     if (!gpFiles::CheckDir($dir)) {
         return false;
     }
     $commentDataFile = $dir . '/' . $post_index . '.txt';
     $dataTxt = serialize($data);
     if (!gpFiles::Save($commentDataFile, $dataTxt)) {
         return false;
     }
     // clean pre 1.7.4 files
     $commentDataFile = self::$data_dir . '/comments_data_' . $post_index . '.txt';
     if (file_exists($commentDataFile)) {
         unlink($commentDataFile);
     }
     SimpleBlogCommon::AStrSet('comment_counts', $post_index, count($data));
     SimpleBlogCommon::SaveIndex();
     SimpleBlogCommon::ClearCommentCache();
     return true;
 }
Example #4
0
 /**
  * Save the post
  *
  */
 public static function SavePost($post_id, $post)
 {
     global $langmessage;
     $_POST += array('title' => '', 'content' => '', 'subtitle' => '', 'isDraft' => '', 'category' => array());
     $title = htmlspecialchars($_POST['title']);
     $title = trim($title);
     if (empty($title)) {
         message($langmessage['TITLE_REQUIRED']);
         return false;
     }
     self::GetPostedTime();
     //different time
     //organize posts based on publish time
     SimpleBlogCommon::AStrSet('post_times', $post_id, $_POST['time']);
     $post_times = SimpleBlogCommon::AStrToArray('post_times');
     arsort($post_times);
     $str_index = array_keys($post_times);
     SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($str_index);
     //get next static gen time
     SimpleBlogCommon::NextGenTime();
     //create post array
     $post['title'] = $title;
     $post['content'] = $_POST['content'];
     $post['subtitle'] = htmlspecialchars($_POST['subtitle']);
     $post['categories'] = $_POST['category'];
     $post['time'] = $_POST['time'];
     unset($post['isDraft']);
     //save to data file
     if (!parent::SavePost($post_id, $post)) {
         return false;
     }
     //draft
     if ($_POST['isDraft'] === 'on') {
         SimpleBlogCommon::AStrSet('drafts', $post_id, 1);
     } else {
         SimpleBlogCommon::AStrRm('drafts', $post_id);
     }
     SimpleBlogCommon::AStrSet('titles', $post_id, $title);
     self::UpdatePostCategories($post_id);
     //find and update the edited post in categories and archives
     if (!SimpleBlogCommon::SaveIndex()) {
         message($langmessage['OOPS'] . ' (Index not saved)');
         return false;
     }
     SimpleBlogCommon::GenStaticContent();
     message($langmessage['SAVED']);
     return true;
 }
Example #5
0
 /**
  * Remove a category
  *
  */
 function DeleteCategory()
 {
     global $langmessage;
     if (!isset($_POST['index'])) {
         message($langmessage['OOPS'] . ' (Invalid Index)');
         return false;
     }
     $index = $_POST['index'];
     if (!isset($this->categories[$index])) {
         message($langmessage['OOPS'] . ' (Invalid Index)');
         return false;
     }
     unset($this->categories[$index]);
     unset(SimpleBlogCommon::$data['category_posts_' . $index]);
     SimpleBlogCommon::AStrRm('categories_hidden', $index);
     SimpleBlogCommon::$data['categories'] = SimpleBlogCommon::AStrFromArray($this->categories);
     if (!SimpleBlogCommon::SaveIndex()) {
         message($langmessage['OOPS']);
         return false;
     }
     SimpleBlogCommon::GenStaticContent();
     message($langmessage['SAVED']);
 }