/** * Get the comment data for a single post * */ function GetCommentData($post_id) { // pre 1.7.4 $commentDataFile = $this->addonPathData . '/comments_data_' . $post_id . '.txt'; $data = SimpleBlogCommon::FileData($commentDataFile); if ($data) { return $data; } // 1.7.4+ $commentDataFile = $this->addonPathData . '/comments/' . $post_id . '.txt'; $data = SimpleBlogCommon::FileData($commentDataFile); if ($data) { return $data; } return array(); }
function GetRecent() { if (!file_exists($this->dir)) { return false; } $new_entries = false; $files = scandir($this->dir); foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; } list($post_id, $ext) = explode('.', $file, 2); if (!is_numeric($post_id)) { continue; } //should already be part of the cache $full_path = $this->dir . '/' . $file; $mod_time = filemtime($full_path); if ($mod_time < $this->cache_mod) { continue; } $data = SimpleBlogCommon::FileData($full_path); foreach ($data as $comment) { if ($comment['time'] < $this->cache_mod) { continue; } $unique = $post_id . '.' . $comment['time']; $comment['post_id'] = $post_id; $this->cache[$unique] = $comment; $new_entries = true; } } if ($new_entries) { uasort($this->cache, array('SimpleBlogComments', 'Sort')); $dataTxt = serialize($this->cache); gpFiles::Save($this->cache_file, $dataTxt); } }
/** * Get the comment data for a single post * */ public static function GetCommentData($post_id) { // pre 1.7.4 $file = self::$data_dir . '/comments_data_' . $post_id . '.txt'; $data = SimpleBlogCommon::FileData($file); if (is_array($data)) { return $data; } // 1.7.4+ $file = self::$data_dir . '/comments/' . $post_id . '.txt'; $data = SimpleBlogCommon::FileData($file); if (is_array($data)) { return $data; } return array(); }