📄 rss2html.php
字号:
//// Revision 2.34 2006/07/21 12:23:36 housley// * If there is no encoding, default to ISO-8859-1// * Modify the XML to show the encoding we used//// Revision 2.33 2006/07/16 10:33:23 housley// Force $useFopenURL if cURL is not installed//// Revision 2.32 2006/07/13 17:05:08 housley// Remove space that causes problems//// Revision 2.31 2006/07/12 12:48:27 housley// Try the iconv() conversion option if mb_string_encode() doesn't exist//// Revision 2.30 2006/05/28 17:52:10 housley// Handle no encoding specified in the feed//// Revision 2.29 2006/05/28 17:51:28 housley// Allow displaying of the Creative Commons License URL//// Revision 2.28 2006/05/28 14:21:47 housley// Add additional capabilities to work with enclosures. The 3 new fields are // ~~~ItemEnclosureType~~~, ~~~ItemEnclosureLength~~~ and ~~~ItemEnclosureLengthFormatted~~~//// Revision 2.27 2006/05/27 19:27:45 housley// * Show a more universal TZ offset example// * Make setting contentEncoded more robust//// Revision 2.26 2006/04/08 23:17:22 housley// A "%" should not be encoded to "%2525", but to "%25"//// Revision 2.25 2006/04/08 23:16:17 housley// Indicate that this is the last parse of XML//// Revision 2.24 2006/03/23 12:10:30 housley// Add a simple way to change the timezone of produced times and dates//// Revision 2.23 2006/03/10 14:21:04 housley// Update the licenses//// Revision 2.22 2006/03/06 15:01:57 housley// Trim white space before and after the XML//// Revision 2.21 2006/03/05 15:15:11 housley// Rename rss2html_CachingExtension.php to FeedForAll_Scripts_CachingExtension.php//// Revision 2.20 2006/03/05 14:43:59 housley// Fix the testing for the character set conversion function//// Revision 2.19 2006/02/28 02:00:04 housley// Add support for ~~~FeedXMLFilename~~~//// Revision 2.18 2006/02/26 15:24:15 housley// Add the capability to limit the length of feed and item titles and descriptions//// Revision 2.17 2006/02/13 18:00:27 housley// Fix the initialization of the item arrays//// Revision 2.16 2006/02/12 14:43:18 housley// If possible convert the feed to UTF-8, for uniformity//// Revision 2.15 2006/02/12 00:21:13 housley// Fix the offsetting of the time//// Revision 2.14 2006/01/26 15:52:37 housley// Fix the error message for opening a feed, it was displaying the template filename.//// Revision 2.13 2006/01/08 23:25:44 housley// Move all user configuration options at the top of the file to make them// easier to find//// Revision 2.12 2005/12/12 16:27:26 housley// Add an interface to allow FeedForAll_scripts_readFile() to be replaced// by one that does caching of the XML files//// Revision 2.11 2005/12/09 19:08:26 housley// Remove the first "banner" since IE barfs//// Revision 2.10 2005/10/22 18:51:47 housley// Improve the formatting//// Revision 2.9 2005/10/22 14:27:57 housley// Fix label in buildURL//// Revision 2.8 2005/10/22 14:20:31 housley// Add buildURL to assist in creating properly encoded links. Show proper// include methods and contents of the files.//// Revision 2.7 2005/10/16 17:54:10 housley// Improvements when using CURL:// - Use the requested file as the REFERER, for sites that might require one// - Allow to follow up to 10 redirects, some sites redirect to real content//// Revision 2.6 2005/10/16 17:32:27 housley// Use lastBuildDate as another possible source if pubDate is empty at the// <channel> level.//// Revision 2.5 2005/09/28 02:08:15 housley// Fix the storage of pubDate at the feed level//// Revision 2.4 2005/09/12 18:56:31 housley// Set a user agent for both fopen and curl transerfers//// Revision 2.3 2005/09/06 22:55:27 housley// GUID doesn't need urlencode()//// Revision 2.2 2005/08/16 19:53:15 housley// Add the ~~~ItemAuthor~~~ subsitution that uses first <author> and then// <dc:creator> for its contents//// Revision 2.1 2005/08/15 14:49:24 housley// Convert ' to ' since ' is not HTML//// Revision 2.0 2005/07/30 14:09:38 housley// Allow "allow_url_fopen" to be sellected, incase CURL is not available.//////// If using cURL, make sure it existsif (($useFopenURL == 0) && !function_exists("curl_init")) { $useFopenURL = -1; if (isset($debugLevel) && ($debugLevel >= 3)) { echo "DIAG: setting \$useFopenURL=-1 because curl_init() doesn't exist<br>\n"; }}if ($useFopenURL == 1) { ini_set("allow_url_fopen", "1"); ini_set("user_agent", "FeedForAll rss2html scripts v3");}$FeedMaxItems = 10000;$NoFutureItems = FALSE;@include("FeedForAll_rss2html_pro.php");if (function_exists("FeedForAll_rss2html_pro") === FALSE) { Function FeedForAll_rss2html_pro($source) { // // This is the place to do any processing that is desired return $source; }}if (function_exists("FeedForAll_parseExtensions") === FALSE) { Function FeedForAll_parseExtensions() { return FALSE; }}@include("FeedForAll_Scripts_CachingExtension.php");@include_once("FeedForAll_XMLParser.inc.php");if (function_exists("FeedForAll_rss2html_limitLength") === FALSE) { Function FeedForAll_rss2html_limitLength($initialValue, $limit = 0) { if (($limit == 0) || (strlen($initialValue) <= $limit )) { // ZERO is for not limited return $initialValue; } // Cut the text at the exact point, ignoring if it is in a word. $result = substr($initialValue, 0, $limit); // Check to see if there are any space we can trim at and if it is not // too far from where we are $lastSpace = strrchr($result,' '); if (($lastSpace !== FALSE) && (strlen($lastSpace) < 20)) { // lose any incomplete word at the end $result = substr($result, 0, -(strlen($lastSpace))); // Append elipses, ... , to show it was truncated $result .= " ..."; } return $result; }}if (function_exists("FeedForAll_rss2html_sizeToString") === FALSE) { Function FeedForAll_rss2html_sizeToString($filesize) { if ($filesize == "") { return ""; } elseif ($filesize >= 1073741824) { return number_format($filesize/1073741824, 1, ".", ",")." GBytes"; } elseif ($filesize >= 1048576) { return number_format($filesize/1048576, 1, ".", ",")." MBytes"; } elseif ($filesize >= 1024) { return number_format($filesize/1024, 1, ".", ",")." KBytes"; } else { return $filesize." Bytes"; } }}if (function_exists("FeedForAll_rss2html_isTemplate") === FALSE) { Function FeedForAll_rss2html_isTemplate($templateData) { if ((strstr($templateData, "~~~Feed") !== FALSE) || (strstr($templateData, "~~~Item") !== FALSE)) { return TRUE; } return FALSE; }}if (function_exists("FeedForAll_rss2html_validExtension") === FALSE) { Function FeedForAll_rss2html_validExtension($filename, $extensions) { $foundValid = FALSE; foreach ($extensions as $value) { if (strtolower($value) == strtolower(substr($filename, -strlen($value)))) { $foundValid = TRUE; break; } } return $foundValid; }}if (function_exists("FeedForAll_rss2html_str_replace") === FALSE) { Function FeedForAll_rss2html_str_replace($search, $replace, $subject) { return str_replace($search, $replace, $subject); }}if (function_exists("FeedForAll_rss2html_encodeURL") === FALSE) { Function FeedForAll_rss2html_encodeURL($URLstring, $includePND = 0) { $result = ""; for ($x = 0; $x < strlen($URLstring); $x++) { if ($URLstring[$x] == '%') { $result = $result."%25"; } elseif ($URLstring[$x] == '?') { $result = $result."%3f"; } elseif ($URLstring[$x] == '&') { $result = $result."%26"; } elseif ($URLstring[$x] == '=') { $result = $result."%3d"; } elseif ($URLstring[$x] == '+') { $result = $result."%2b"; } elseif ($URLstring[$x] == ' ') { $result = $result."%20"; } elseif ($includePND && ($URLstring[$x] == '#')) { $result = $result."%23"; }else { $result = $result.$URLstring[$x]; } } return $result; }}if (function_exists("FeedForAll_rss2html_CreateUniqueLink") === FALSE) { Function FeedForAll_rss2html_CreateUniqueLink($title, $description, $link, $guid, $XMLfilename, $itemTemplate) { GLOBAL $TEMPLATEfilename; $match = Array(); while (preg_match("/~~~ItemUniqueLinkWithTemplate=.*~~~/", $itemTemplate, $match) !== FALSE) { if ((count($match) == 0) || ($match[0] == "")) { // All done return $itemTemplate; } $replace = "http://$_SERVER[SERVER_NAME]$_SERVER[SCRIPT_NAME]?XMLFILE=".FeedForAll_rss2html_encodeURL($XMLfilename)."&TEMPLATE=".FeedForAll_rss2html_encodeURL($TEMPLATEfilename); $itemTemplate = FeedForAll_rss2html_str_replace($match[0], $replace, $itemTemplate); } if ($title); if ($description); if ($link); if ($guid); return $itemTemplate; }}if (function_exists("FeedForAll_rss2html_UseUniqueLink") === FALSE) { Function FeedForAll_rss2html_UseUniqueLink($title, $description, $link, $guid) { if ($title); if ($description); if ($link); if ($guid); return -1; }}if (function_exists("FeedForAll_rss2html_EscapeLink") === FALSE) { Function FeedForAll_rss2html_EscapeLink($link) { GLOBAL $escapeAmpInLinks; if ((strstr($link, "://") !== FALSE) && $escapeAmpInLinks) { // In HTML a link with an & must be converted to & // And for here without :// it is not a link, since relative // URLs are not allowed $link = str_replace("&", "&", $link); } return $link; }}if (function_exists("FeedForAll_rss2html_AddIdentity") === FALSE) { Function FeedForAll_rss2html_AddIdentity($itemString) { return "<!-- HTML generated from an RSS Feed by rss2html.php, http://www.FeedForAll.com/ a NotePage, Inc. product (http://www.notepage.com/) -->".$itemString; }}if (!isset($_REQUEST["buildURL"])) { //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -