function build_rss_feed($site, $rss_dir, $lang, $news_items) { global $path_to_root; $rss_items = array(); // RSS feed items $pub_date = 0; // RSS feed publication date foreach ($news_items as $news_item) { $english_news_filename = $path_to_root . $news_item['filename']; $translated_news_filename = $path_to_root . "lang/{$lang}/" . $news_item['filename']; // Read the translated news file if (file_exists($translated_news_filename)) { $fp = @fopen($translated_news_filename, "r"); $news_full = @fread($fp, filesize($translated_news_filename)) or die("File {$translated_news_filename} not readable"); @fclose($fp); } else { // Fallback to english if translation is not available if (file_exists($english_news_filename)) { $fp = @fopen($english_news_filename, "r"); $news_full = @fread($fp, filesize($english_news_filename)) or die("File {$english_news_filename} not readable"); @fclose($fp); } else { die("File " . $news_item['filename'] . " does not exist"); } } $n = strpos($news_full, '</b><br>'); if ($n === false) { // note: three equal signs echo 'Error, on file ' . $news_item['filename'] . "from {$lang} "; die('News title separator not found'); // not found... } // transform the relative paths into absolute //$description = ereg_replace('href="(?!http)', "href=\"$site", substr($news_full, $n+9)); $description = preg_replace('/href="(?!http)/i', "href=\"{$site}", substr($news_full, $n + 9)); $rss_items[] = array("pub_date" => date("r", $news_item['unix_timestamp']), "url" => $site, "guid" => $site . 'index.html?filename=main.html#' . date('Y_m_d', $news_item['unix_timestamp']), "isPermaLink" => false, "headline" => str_replace('&', '&', substr($news_full, 3, $n - 3)), "description" => str_replace('&', '&', $description), "author" => "KDevelop webmaster", "category" => "KDevelop news"); $pub_date = max($news_item['unix_timestamp'], $pub_date); } // to avoid a warning in the include("... translations.inc") $filename = ''; // for $languages include $path_to_root . "translations.inc"; // always include english as a fallback if ($lang != 'en') { include $path_to_root . "lang/{$lang}/translations.inc"; } // the other languages $channel = array('encoding' => $l_charset_encoding, 'name' => 'KDevelop news', 'url' => $site, 'self_url' => $site . $rss_dir . "kdevelop_news_{$lang}.rss", 'description' => "KDevelop development news ({$languages[$lang]})", 'language' => $lang, 'pub_date' => date("r", $pub_date)); $fp = @fopen($path_to_root . $rss_dir . "kdevelop_news_{$lang}.rss", "w"); @fwrite($fp, create_rss_feed($channel, $rss_items)) or die("File {$news_filename} not writeable"); @fclose($fp); }
$url = phorum_get_url(PHORUM_INDEX_URL); $name = $PHORUM["title"]; $description = ""; } $channel = array( "name" => $name, "url" => $url, "description" => $description, "pub_date" => date("r",$pub_date), "language" => $PHORUM['locale'] ); $data = create_rss_feed($channel, $items); } $charset = ''; if (! empty($GLOBALS["PHORUM"]["DATA"]["CHARSET"])) { $charset = '; charset=' . htmlspecialchars($GLOBALS["PHORUM"]["DATA"]['CHARSET']); } header("Content-Type: text/xml$charset"); echo $data; phorum_cache_put("rss", $cache_key, $data, 300); /*******************************************************/