📄 rss2html.php
字号:
<?PHP//// rss2html.php RSS feed to HTML webpage script//// Copyright 2004-2007 NotePage, Inc.// http://www.feedforall.com//// This script may be used and modified freely for business or personal use// This script may not be resold in any form// This script may only be redistributed in its original form////// $Id: rss2html.php,v 3.10 2007/07/16 16:48:48 housley Exp $////// ==========================================================================// Configuration options// ==========================================================================//// Set the following variable useFopenURL to one if you want/need to use// fopen() instead of CURL or FeedForAll_fopen()$useFopenURL = 0;//// If XLMFILE is passed as part of the URL, XMLFILE=, then it will be used// otherwise the the file below is used.//$XMLfilename = "http://examlple.com/sample.xml";$XMLfilename = "sample.xml";//// If TEMPLATE is passed as part of the URL. TEMPLATE=, then it will be used// otherwise the the file below is used.//$TEMPLATEfilename = "http://examlple.com/sample-template.html";$TEMPLATEfilename = "sample-template.html";//// Since some feeds may have titles or descriptins in the feed or items that// are longer then want fits in your HTML page it is possible to trim them// with the following 4 variables. A values of 0 (ZERO) displays the full// length.// CAUTION: Do not limit a title or description that has HTML in it, the// will not produce a valid HTML page.$limitFeedTitleLength = 0; // Not limited, in the URL as FeedTitleLength=$limitFeedDescriptionLength = 0; // Not limited, in the URL as FeedDescriptionLength=$limitItemTitleLength = 0; // Not limited, in the URL as ItemTitleLength=$limitItemDescriptionLength = 0; // Not limited, in the URL as ItemDescriptionLength=//// date() function documented http://www.php.net/manual/en/function.date.php$LongDateFormat = "F jS, Y"; // ie, "Jan 21st, 2004"$ShortDateFormat = "m/d/Y"; // ie, "1/21/2004"//$ShortDateFormat = "d/m/Y"; // ie, "21/1/2004"$LongTimeFormat = "H:i:s T O"; // ie, "13:24:30 EDT -0400"$ShortTimeFormat = "h:i A"; // ie, "1:24 PM"//// Timezone - If your server is not in the same timezone as you are the timezone// of the times and dates produced in the above from can be controlled with the// below code. Just uncomment the following line and change to the correct// zonename. A full list is available here, http://www.php.net/manual/en/timezones.php// You town.city probably isn't listed, so look for a neighboring major city// putenv("TZ=America/New_York");//// Registered user of FeedForAll and FeedForAll Mac product(s) have access// to a caching module. This enables it's use if it is installed.$allowCachingXMLFiles = 0;//// File access level: The variable $fileAccessLevel can be used limit what files// and type of files (local or remote) can be used with rss2html.php// -1 = Remote files are NOT allowed, only local files allowed for template// and feed which have filenames ending in extensions in the// $allowedTemplateExtensions and $allowedFeedExtensions lists below// 0 = Remote files and any local files allowed for template and feed// 1 = Remote files and only local files allowed for template and feed// which have filenames ending in extensions in the// $allowedTemplateExtensions and $allowedFeedExtensions lists below// 2 = No local files allowed, remote files only.$fileAccessLevel = 1;//// Allowed file extensions is a list of the allowable extensions for local for// the template and the feed. New entries can be added by following the example// below.$allowedTemplateExtensions = Array(".html", ".htm", ".shtml");$allowedFeedExtensions = Array(".xml", ".rss");//// Destination Encoding: By default rss2html.php converts all feeds to UTF-8// and then produces webpages in UTF-8 because UTF-8 is capable of displaying// all possible characters.$destinationEncoding = "UTF-8";//// Missing Encoding Default: Some feeds do not specify the character set // they are encoded in. The XML specification states that if there is no// encoding specified the XML file, all RSS feeds are XML, must be encoded// in UTF-8, but experience has show differently. This specifies the // encoding that will be used for feeds that don't specify the encoding.//$missingEncodingDefault = "UTF-8";$missingEncodingDefault = "ISO-8859-1";//// Escape Ampersand In Links: Proper HTML requires that a link with an// apersand in while inside of an HTML page have that '&' converted to// '&'.$escapeAmpInLinks = 1;//// $connectTimeoutLimit allows the limiting the amount of time cURL will// wait to successfully connect to a remote server. Use with caution,// a value too small will cause all connections to fail.//$connectTimeoutLimit = 30;//// $hideErrors: This will prevent all error messages from being displayed.// CAUTION enabling this will cause rss2html.php to fail silently with// no indication to why there was no output// $hideErrors = 1;// ==========================================================================// Below this point of the file there are no user editable options. Your// are welcome to make any modifications that you wish to any of the code// below, but that is not necessary for normal use.// ==========================================================================// $Log: rss2html.php,v $// Revision 3.10 2007/07/16 16:48:48 housley// On some systems the exit statements in here was terminating all PHP// processing.//// Revision 3.9 2007/07/16 13:06:37 housley// Add ~~~NumberOfFeedItems~~~ to allow access to the number of items that// will be processed for display.//// Revision 3.8 2007/07/08 13:42:39 housley// Create my own version of fopen() to try and get files when cURL is not// available. FeedForAll_fopen() is based on just connecting to the server// and reading the results.//// Revision 3.7 2007/06/25 13:55:10 housley// Fix mistake where ?buildURL would falsely say a file could be opened,// when in reality it could not be opened//// Revision 3.6 2007/06/05 13:39:38 housley// Enable access to output caching in rss2html.php//// Revision 3.5 2007/05/27 14:32:05 housley// Add a debug message when switching to fopen() because curl_init() does// not exist//// Revision 3.4 2007/05/04 11:54:19 housley// When checking for caching, check a function only in the caching module//// Revision 3.3 2007/05/03 18:52:16 housley// Fix typo in debug statement//// Revision 3.2 2007/05/03 16:14:07 housley// * It seems the XML parser doesn't like most of the HTML entities, process them by hand// * The check to display errors was backwards//// Revision 3.1 2007/04/24 11:36:09 housley// Fix an error that prevented using PHP includes to display more then one// feed on a page//// Revision 3.0 2007/04/16 14:23:03 housley// Release version 3.0 of the scripts//// Revision 2.76 2007/04/13 18:30:10 housley// * Atom:content might need whole string so always make it available// * atom:content of type xhtml is in a div that needs to be stripped and// then used as is.//// Revision 2.75 2007/04/11 19:59:43 housley// Add an option to hide error messages//// Revision 2.74 2007/04/11 18:38:08 housley// Update the user agent to be 3.0//// Revision 2.73 2007/04/11 12:13:12 housley// * Fix the code to limit the number of items// * Add some debug messages//// Revision 2.72 2007/04/11 10:40:38 housley// Add some debug messages//// Revision 2.71 2007/04/10 17:16:45 housley// Allow the input caching to be set during buildURL, only for one PHP include// type//// Revision 2.70 2007/04/10 15:19:28 housley// Allow for the caching for the HTML output of rss2html.php//// Revision 2.69 2007/04/04 20:55:46 housley// Add the ability to set CURLOPT_CONNECTTIMEOUT//// Revision 2.68 2007/03/30 13:18:33 housley// Use getArrayOfFields() and getValueOf() to simplfy tag replacement, except// where special processing needs to be done//// Revision 2.67 2007/03/05 18:23:58 housley// Don't abort processing on XML parse error, just don't do anything else//// Revision 2.66 2007/03/05 01:33:44 housley// Use a command convert and readFile routines//// Revision 2.65 2007/03/05 01:19:45 housley// Rename FeedForAll_rss2html_readFile() to FeedForAll_scripts_readFile()//// Revision 2.64 2007/03/04 13:41:53 housley// * Pass the parsing mode to the item class// * Cleanup the feed level processing// * rss2html uses the separate parser too//// Revision 2.63 2007/03/03 21:10:09 housley// * Make the item a full class object// * Support parsing the iTunes(R) extension//// Revision 2.62 2007/02/26 00:33:53 housley// Fix assignment in comparison//// Revision 2.61 2007/02/14 01:05:52 housley// Add the option of encoding the '#' in URLs in some conditions//// Revision 2.60 2007/01/26 14:08:46 housley// Show a better method to change timezone//// Revision 2.59 2007/01/04 19:01:51 housley// Parse the new rssMesh.php fields://// <rssMesh:feedImageTitle> => ~~~ItemRssMeshFeedImageTitle~~~// <rssMesh:feedImageUrl> => ~~~ItemRssMeshFeedImageUrl~~~// <rssMesh:feedImageLink> => ~~~ItemRssMeshFeedImageLink~~~// <rssMesh:feedImageDescription> => ~~~ItemRssMeshFeedImageDescription~~~// <rssMesh:feedImageHeight> => ~~~ItemRssMeshFeedImageHeight~~~// <rssMesh:feedImageWidth> => ~~~ItemRssMeshFeedImageWidth~~~//// Revision 2.58 2006/12/22 16:30:21 housley// Add a check to see if cURL is allowed to follow redirects//// Revision 2.57 2006/11/06 14:59:22 housley// Minor text changes in buildURL//// Revision 2.56 2006/11/06 14:39:24 housley// Create a new method of including rss2html.php that will work on servers// with remote URL restrictions (allow_url_fopen) that many ISPs are currently// using.//// Revision 2.55 2006/10/17 16:05:05 housley// Since some of the newer versions of the XML parser look at the encoding// in the feed and ignore the one passed in on the call, change the encoding// in the feed before parsing.//// Revision 2.54 2006/09/29 19:50:33 housley// Add a function to convert & in a certian RSS fields to &, so it will be proper HTML//// Revision 2.53 2006/09/22 20:21:55 housley// Fix the problem of displaying an invalid date with an odd number of items//// Revision 2.51 2006/09/04 12:33:17 housley// Exit after a parser error. The parser stopped, so should we.//// Revision 2.50 2006/08/29 18:58:38 housley// Changes to handle when there are not string conversion modules//// Revision 2.49 2006/08/25 15:09:22 housley// Add hooks for a new feature in rss2html-pro//// Revision 2.48 2006/08/25 11:36:37 housley// * Add the capability to change the character set that feeds are converted to// * Allow specifying the encoding to use for feeds that don't specify the encoding//// Revision 2.46 2006/08/24 20:23:56 housley// Over come a well meaning, but very misguided ISP removing file:// from// all scripts. Not only did the remove it in a place that was doing good,// it was extremely simple to bypass.//// Revision 2.45 2006/08/21 20:19:32 housley// Use special routines so that rss2html-pro will work with RSS fields that// have quotes in them.//// Revision 2.43 2006/08/18 23:42:16 housley// Add hooks for rss2html-pro post processing//// Revision 2.42 2006/08/11 17:15:45 housley// Add the ability to restrict the use of the rss2html.php script.//// Revision 2.41 2006/08/09 23:57:35 housley// If <?xml ... is missing add it//// Revision 2.40 2006/08/09 15:32:58 housley// If mb_string_convert fails, try iconv//// Revision 2.39 2006/08/04 19:59:02 housley// Assuming 0xa9 is (c) was bad//// Revision 2.38 2006/08/03 11:06:45 housley// * Don't change the encoding string in the header// * Give access to the first category in a feed//// Revision 2.37 2006/07/29 14:29:40 housley// Add support for <category> in items. If there are more then one <category>// element, only the first is accessable. The 2 new tags are// ~~~ItemCategory~~~ and ~~~ItemCategoryDomain~~~//// Revision 2.36 2006/07/29 13:19:23 housley// Trim any leading BOM because some PHP5 installations have problems if it// is there.//// Revision 2.35 2006/07/27 00:27:03 housley// * Add support for <source> and <comments> in <item>// * Add support for <rssMesh:extra>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -