📄 feedforall_rss2html_pro.php
字号:
<?PHP//// rss2html.php RSS feed to HTML webpage script//// Copyright 2006-2007 NotePage, Inc. all rights reserved// http://www.feedforall.com//// NotePage, Inc. grants registerd users of our FeedForAll and/or// FeedForAll Mac product(s) the right to install and use the// FeedForAll_rss2html_pro.php script free of charge. // Please refer to the EULA included in the download for full license// terms and conditions.//// $Id: FeedForAll_rss2html_pro.php,v 3.0 2007/04/16 14:23:03 housley Exp $//// $Log: FeedForAll_rss2html_pro.php,v $// Revision 3.0 2007/04/16 14:23:03 housley// Release version 3.0 of the scripts//// Revision 1.18 2007/04/09 01:25:50 housley// Fix the commented out code for enabling the extensions//// Revision 1.17 2007/04/06 11:08:58 housley// Add support for the Dublin Core (dc) namespace//// Revision 1.16 2007/03/07 03:01:22 housley// Add the flag to not parse TrackBack//// Revision 1.15 2007/03/05 17:29:45 housley// Add a simple way to block parsing extensions//// Revision 1.14 2007/03/03 21:10:09 housley// * Make the item a full class object// * Support parsing the iTunes(R) extension//// Revision 1.13 2007/02/21 20:24:20 housley// Remove unused function//// Revision 1.12 2007/02/14 01:31:09 housley// Encode the '#' in GUID URLs//// Revision 1.11 2006/11/29 12:04:38 housley// When checking a GUID that is a complex URL, there needs to be some conversions done.//// Revision 1.10 2006/11/05 17:23:00 housley// Work arond a bug in PHP related to large strings an preg_replace_callback()//// Revision 1.9 2006/09/29 19:07:15 housley// Allow rss2html.php not to show an identity when used with any of the// pay scripts.//// Revision 1.8 2006/09/04 12:31:24 housley// If the template is remote, converting the ~~~QUOTE~~~ back to \" still needs to be done.//// Revision 1.7 2006/08/26 11:30:19 housley// Comment the code//// Revision 1.6 2006/08/25 19:15:13 housley// Prevent remote templates with rss2html-pro//// Revision 1.5 2006/08/25 18:00:30 housley// Use a better eval function to allow spanning fo the PHP code//// Revision 1.4 2006/08/25 15:08:57 housley// The ~~~ItemUniqueLink=X~~~ is part for Pro now//// Revision 1.3 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 1.1 2006/08/14 21:25:02 housley// Initial version of a post processing module that would allow PHP to be// used in the template to preform logic.////// ==========================================================================// Configuration options// ==========================================================================//// To prevent parsing of the iTunes(R) XML namespace extension, uncomment the// following line.//$Dont_Parse_iTunes == TRUE;//// To prevent parsing of the TrackBack XML namespace extension, uncomment the// following line.//$Dont_Parse_TrackBack == TRUE;//// To prevent parsing of the DublinCore XML namespace extension, uncomment the// following line.//$Dont_Parse_DublinCore == TRUE;if (function_exists("FeedForAll_rss2html_AddIdentity") === FALSE) { Function FeedForAll_rss2html_AddIdentity($itemString) { return $itemString; }}if (function_exists("FeedForAll_rss2html_pro") === FALSE) { Function FeedForAll_rss2html_pro($string) { // // // IMPORTANT: Since allowing remote templates to use PHP is a HUGE // security violation, on the order of the IE exploits. // Therefore if the template is remote, then no processing // will be done // GLOBAL $TEMPLATEfilename; if (strstr($TEMPLATEfilename, "://") !== FALSE) { // Return our special ~~~QUOTE~~~ back into " return str_replace("~~~QUOTE~~~", "\"", $string); } // Put markers to enter and then exit PHP at the front a back of the // string, this will make it look like PHP has ended before the string $string = "<?php ?>".$string."<?php ?>"; // Convert shortcut echo into a full echo command $string = preg_replace("/<\?=\s+(.*?)\s+\?>/", "<?php echo $1; ?>", $string); // Setup for parsing the string. converting HTML into PHP echo commands $result = ""; while (($startLoc = strpos($string, "?>")) !== FALSE) { $result .= substr($string, 0, $startLoc); $after = substr($string, $startLoc+2); if (($endLoc = strpos($after, "<?")) === FALSE) { $result .= $string; break; } else { $replaceStr = substr($after, 0, $endLoc); $result .= "echo stripslashes(\"".addslashes($replaceStr)."\");"; if ((($startLoc = strpos(strtolower(substr($after, $endLoc)), "<?php")) !== FALSE) && ($startLoc == 0)) { // Fake the advance $endLoc += 3; } $string = substr($after, $endLoc+2); } } $string = str_replace("?>", "", str_replace(array("<?php", "<?"), "", $result)); $result = ""; // // Use output buffering around the eval() ob_start(); eval($string); $result = ob_get_contents(); ob_end_clean(); // Return our special ~~~QUOTE~~~ back into " return str_replace("~~~QUOTE~~~", "\"", $result); } Function FeedForAll_rss2html_str_replace($search, $replace, $subject) { // Convert " to ~~~QUOTE~~~ so we can work with abritarty strings from // the RSS feed $replace = str_replace("\"", "~~~QUOTE~~~", $replace); return str_replace($search, $replace, $subject); } Function FeedForAll_rss2html_CreateUniqueLink($title, $description, $link, $guid, $XMLfilename, $itemTemplate) { $match = Array(); while (preg_match("/~~~ItemUniqueLinkWithTemplate=.*~~~/", $itemTemplate, $match) !== FALSE) { if ((count($match) == 0) || ($match[0] == "")) { // All done return $itemTemplate; } // Get the filename of the template to be used $template = str_replace("ItemUniqueLinkWithTemplate=", "", str_replace("~~~", "", $match[0])); if (($title == "") && ($description == "") && ($guid == "")) { // There is on information that a link can be made of $itemTemplate = str_replace($match[0], "", $itemTemplate); } elseif ($guid != "") { // We have a GUID, good feed creator $replace = "http://$_SERVER[SERVER_NAME]$_SERVER[SCRIPT_NAME]?XMLFILE=".FeedForAll_rss2html_encodeURL($XMLfilename)."&TEMPLATE=".FeedForAll_rss2html_encodeURL($template)."&GUID=".FeedForAll_rss2html_encodeURL($guid, 1)."&MAXITEMS=1"; $itemTemplate = FeedForAll_rss2html_str_replace($match[0], $replace, $itemTemplate); } else { // No GUID, bad feed creator, use a hash of the title and description $replace = "http://$_SERVER[SERVER_NAME]$_SERVER[SCRIPT_NAME]?XMLFILE=".FeedForAll_rss2html_encodeURL($XMLfilename)."&TEMPLATE=".FeedForAll_rss2html_encodeURL($template)."&ITEMHASH=".md5($title.$description)."&MAXITEMS=1"; $itemTemplate = FeedForAll_rss2html_str_replace($match[0], $replace, $itemTemplate); } } if ($link); return $itemTemplate; } Function FeedForAll_rss2html_UseUniqueLink($title, $description, $link, $guid) { // Look for either GUID or ITEMHASH to find the unique items if (isset($_REQUEST["GUID"])) { if (($_REQUEST["GUID"] == $guid) || ($_REQUEST["GUID"] == str_replace("&", "&", $guid))) { return 1; } return 0; } elseif (isset($_REQUEST["ITEMHASH"])) { if ($_REQUEST["ITEMHASH"] == md5(trim($title).trim($description))) { return 1; } return 0; } if ($link); // Neither GUID or ITEMHASH was specified return -1; }}@include("FeedForAll_parse_Extensions.inc.php");?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -