📄 rss2html.php
字号:
// This is at least one more item so use the Alternate definition // $allitems .= FeedForALL_rss2html_replaceInItem($block2, $rss_parser->Items[$x]); } } } else { for ($x = 0; $x < $loop_limit; $x++) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: Doing item fillin, \$x = $x; \$loop_limit = $loop_limit<br>\n"; } $allitems .= FeedForALL_rss2html_replaceInItem($block1, $rss_parser->Items[$x]); $x++; if ($x < $loop_limit) { // // This is at least one more item so use the Alternate definition // if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: Doing item fillin, \$x = $x; \$loop_limit = $loop_limit<br>\n"; } $allitems .= FeedForALL_rss2html_replaceInItem($block2, $rss_parser->Items[$x]); } } } $template = str_replace("~~~BeginItemsRecord~~~".$WholeBlock."~~~EndItemsRecord~~~", $allitems, $template); } } } // Since ' is not HTML, but is XML convert. $template = str_replace("'", "'", $template); if (!headers_sent()) { // Send the Content-Type to force $destinationEncoding header("Content-Type: text/html; charset=$destinationEncoding"); } $resultHTML = FeedForAll_rss2html_pro($template); echo $resultHTML; if (isset($outputCacheTTL) && function_exists("FeedForAll_scripts_writeOutputCacheFile")) { FeedForAll_scripts_writeOutputCacheFile($XMLfilename, $TEMPLATEfilename, $resultHTML); } } }} else { if (!headers_sent()) { // Send the Content-Type to force $destinationEncoding header("Content-Type: text/html; charset=$destinationEncoding"); } echo "<html><head><title>rss2html.php URL tool</title><meta http-equiv=\"content-type\" content=\"text/html;charset=$destinationEncoding\"></head><body bgcolor=\"#EEEEFF\">\n"; // // We are in "buildURL" mode to help create properly encoded URLs to pass to rss2html.php $_xml = ""; if (isset($_POST["XML"])) { $_xml = $_POST["XML"]; } $_template = ""; if (isset($_POST["TEMPLATE"])) { $_template = $_POST["TEMPLATE"]; } $_maxitems = ""; if (isset($_POST["MAXITEMS"])) { $_maxitems = $_POST["MAXITEMS"]; } $_nofutureitems = ""; if (isset($_POST["NOFUTUREITEMS"])) { $_nofutureitems = $_POST["NOFUTUREITEMS"]; } if (function_exists("FeedForAll_scripts_contentOfCache")) { $_cacheTTL = ""; if (isset($_POST["XMLCACHETTL"])) { $_cacheTTL = $_POST["XMLCACHETTL"]; } $_allowCachingXMLFiles = ""; if (isset($_POST["ALLOWXMLCACHE"])) { $_allowCachingXMLFiles = $_POST["ALLOWXMLCACHE"]; } $_outputCacheTTL = ""; if (isset($_POST["OUTCACHETTL"])) { $_outputCacheTTL = $_POST["OUTCACHETTL"]; } $_outputCacheFileName = ""; if (isset($_POST["OUTCACHENAME"])) { $_outputCacheFileName = $_POST["OUTCACHENAME"]; } } // Display the entry form echo "<center><h1>RSS2HTML.PHP LINK TOOL</h1></center>\n"; echo "<p>To assist with the with the creation of properly encoded URLs for use with rss2html.php this tool has been created. Fill in the URLs or file paths for both the XML file and your template file in the boxes below and then click "Submit". The program will then return the URLs properly encoded in a string that calls rss2html.php. You can click on this link to test the results. The program will also indicate if it was unable to open either of the URLs it was given.</p>\n"; echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"buildURL\" value=\"1\">\n"; echo "URL for the XML file: (ie. http://www.myserver.com/file.xml)<br><input type=\"text\" name=\"XML\" size=\"100\" value=\"$_xml\"><br>\n"; echo "URL for the template file: (ie. http://www.myserver.com/template.html)<br><input type=\"text\" name=\"TEMPLATE\" size=\"100\" value=\"$_template\"><br>\n"; echo "<b>Optional items:</b><br>\n"; echo "Maximum items: <input type=\"text\" name=\"MAXITEMS\" size=\"5\" value=\"$_maxitems\"> (Use negative numbers for the last X items)<br>\n"; echo "No future items: <input type=\"checkbox\" name=\"NOFUTUREITEMS\" "; if ($_nofutureitems == "on") { echo "CHECKED"; } echo "><br>\n"; if (function_exists("FeedForAll_scripts_contentOfCache")) { echo "<table cellpadding=\"2\" cellspacing=\"2\" width=\"100%\" border=\"1\"><tr><td>\n"; echo "<strong>XML (input) Cache Settings</strong><br>\n"; echo "Allow Caching of the feed: <input type=\"checkbox\" name=\"ALLOWXMLCACHE\" "; if ($_allowCachingXMLFiles == "on") { echo "CHECKED"; } echo "><br>\n"; echo "Cache Time: <input type=\"text\" name=\"XMLCACHETTL\" size=\"5\" value=\"$_cacheTTL\"> (The number of seconds a file may be cached for before being fetched again)<br>\n"; echo "<hr>\n"; echo "<strong>HTML (output) Cache Settings</strong><br>\n"; echo "Output Cache Time: <input type=\"text\" name=\"OUTCACHETTL\" size=\"5\" value=\"$_outputCacheTTL\"> (The number of seconds the output may be cached for before being recreated)<br>\n"; echo "Output Cache Name: <input type=\"text\" name=\"OUTCACHENAME\" size=\"40\" value=\"$_outputCacheFileName\"> (This should be a unique name to prevent conflicts)<br>\n"; echo "</td></tr></table>\n"; } echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">\n"; echo "</form>\n"; $xmlContents = ""; $templateContents = ""; if (isset($_POST["submit"])) { if ($_SERVER["REQUEST_METHOD"] != "POST") { return; } echo "<hr>\n"; $answer = ""; $answerAlt = ""; $ssi = ""; $xmlurl = ""; $templateurl = ""; if ((isset($_POST["XML"]) && $_POST["XML"] != "") || (isset($_POST["TEMPLATE"]) && $_POST["TEMPLATE"] != "")) { $answer .= "http://$_SERVER[SERVER_NAME]$_SERVER[PHP_SELF]?"; } if (isset($_POST["XML"]) && $_POST["XML"] != "") { $answer .= "XMLFILE=".FeedForAll_rss2html_encodeURL($_POST["XML"]); $answerAlt .= "\$XMLFILE = \"".str_replace("&", "&", $_POST["XML"])."\";<br>"; $ssi .= "XMLFILE=".FeedForAll_rss2html_encodeURL($_POST["XML"]); $xmlurl = FeedForAll_rss2html_encodeURL($_POST["XML"]); } if ((isset($_POST["XML"]) && $_POST["XML"] != "") && (isset($_POST["TEMPLATE"]) && $_POST["TEMPLATE"] != "")) { $answer .= "&"; $ssi .= "&"; } if (isset($_POST["TEMPLATE"]) && $_POST["TEMPLATE"] != "") { $answer .= "TEMPLATE=".FeedForAll_rss2html_encodeURL($_POST["TEMPLATE"]); $answerAlt .= "\$TEMPLATE = \"".str_replace("&", "&", $_POST["TEMPLATE"])."\";<br>"; $ssi .= "TEMPLATE=".FeedForAll_rss2html_encodeURL($_POST["TEMPLATE"]); $templateurl = FeedForAll_rss2html_encodeURL($_POST["TEMPLATE"]); } if (isset($_POST["MAXITEMS"]) && $_POST["MAXITEMS"] != "" && intval($_POST["MAXITEMS"] != 0)) { $answer .= "&MAXITEMS=$_POST[MAXITEMS]"; $answerAlt .= "\$MAXITEMS = \"$_POST[MAXITEMS]\";<br>\n"; $ssi .= "&MAXITEMS=$_POST[MAXITEMS]"; } if (isset($_POST["NOFUTUREITEMS"]) && $_POST["NOFUTUREITEMS"] == "on") { $answer .= "&NOFUTUREITEMS=1"; $answerAlt .= "\$NOFUTUREITEMS = \"1\";<br>\n"; $ssi .= "&NOFUTUREITEMS=1"; } if (function_exists("FeedForAll_scripts_contentOfCache")) { if (isset($_POST["ALLOWXMLCACHE"]) && $_POST["ALLOWXMLCACHE"] == "on") { $answerAlt .= "\$ALLOWXMLCACHE = \"1\";<br>\n"; } if (isset($_POST["XMLCACHETTL"]) && ($_POST["XMLCACHETTL"] != "") && (intval($_POST["XMLCACHETTL"]) != 0)) { $answerAlt .= "\$XMLCACHETTL = \"$_POST[XMLCACHETTL]\";<br>\n"; } if (isset($_POST["OUTCACHETTL"]) && isset($_POST["OUTCACHENAME"])) { if (($_POST["OUTCACHETTL"] != "") && (intval($_POST["OUTCACHETTL"]) != 0) && ($_POST["OUTCACHENAME"] != "")) { $answerAlt .= "\$OUTCACHETTL = \"$_POST[OUTCACHETTL]\";<br>\n"; $answerAlt .= "\$OUTCACHENAME = \"$_POST[OUTCACHENAME]\";<br>\n"; } } } echo "<h1>Results</h1>\n"; if (isset($_POST["XML"]) && $_POST["XML"] != "") { $XMLfilename = ""; if (stristr($_POST["XML"], "file"."://")) { // Not allowed ; } elseif (stristr($_POST["XML"], "://")) { if ($fileAccessLevel == -1) { echo "<p style=\"color: red;\">Configuration setting prohibit using remote files</p>\n"; } else { // URL files are allowed $XMLfilename = $_POST["XML"]; } } else { if (($fileAccessLevel == 1) || ($fileAccessLevel == -1)) { if (FeedForAll_rss2html_validExtension(basename($_POST["XML"]), $allowedFeedExtensions) === FALSE) { echo "<p style=\"color: red;\">Configuration setting prohibit using the specified feed file</p>\n"; } else { $XMLfilename = basename($_POST["XML"]); } } elseif ($fileAccessLevel == 2) { echo "<p style=\"color: red;\">Configuration setting prohibit using local files</p>\n"; } else { // It is local and must be in the same directory $XMLfilename = basename($_POST["XML"]); } } if ($XMLfilename != "") { if (($xmlContents = FeedForAll_scripts_readFile($XMLfilename, $useFopenURL)) === FALSE) { if ($ReadErrorString == "") { echo "<p>The XML file <b>$_POST[XML]</b> could not be opened.</p>\n"; } else { echo "<p>The XML file <b>$_POST[XML]</b> could not be opened with the error <b>$ReadErrorString</b>.</p>\n"; } } else { echo "<p>The XML file <b>$_POST[XML]</b> was SUCCESSFULLY opened</p>\n"; } } } if (isset($_POST["TEMPLATE"]) && $_POST["TEMPLATE"] != "") { $TEMPLATEfilename = ""; if (stristr($_POST["TEMPLATE"], "file"."://")) { // Not allowed ; } elseif (stristr($_POST["TEMPLATE"], "://")) { if ($fileAccessLevel == -1) { echo "<p style=\"color: red;\">Configuration setting prohibit using remote files</p>\n"; } else { // URL files are allowed $TEMPLATEfilename = $_POST["TEMPLATE"]; } } else { if (($fileAccessLevel == 1) || ($fileAccessLevel == -1)) { if (FeedForAll_rss2html_validExtension(basename($_POST["TEMPLATE"]), $allowedTemplateExtensions) === FALSE) { echo "<p style=\"color: red;\">Configuration setting prohibit using the specified template file</p>\n"; } else { $TEMPLATEfilename = basename($_POST["TEMPLATE"]); } } elseif ($fileAccessLevel == 2) { echo "<p style=\"color: red;\">Configuration setting prohibit using local files</p>\n"; } else { // It is local and must be in the same directory $TEMPLATEfilename = basename($_POST["TEMPLATE"]); } } if ($TEMPLATEfilename != "") { if (($templateContents = FeedForAll_scripts_readFile($TEMPLATEfilename, $useFopenURL)) === FALSE) { if ($ReadErrorString == "") { echo "<p>The template file <b>$_POST[TEMPLATE]</b> could not be opened.</p>\n"; } else { echo "<p>The template file <b>$_POST[TEMPLATE]</b> could not be opened with the error <b>$ReadErrorString</b>.</p>\n"; } } elseif (FeedForAll_rss2html_isTemplate($templateContents) === FALSE) { echo "$_POST[TEMPLATE] is not a valid rss2html.php template file\n"; $templateContents = ""; } else { echo "<p>The template file <b>$_POST[TEMPLATE]</b> was SUCCESSFULLY opened</p>\n"; } } } if ($xmlurl != "") { echo "<p>URL for the XML file properly encoded:<br><pre>$xmlurl</pre></p>\n"; } if ($templateurl != "") { echo "<p>URL for the template file properly encoded:<br><pre>$templateurl</pre></p>\n"; } echo "<h2>Test Link</h2>\n"; echo "<p>Click on link to view results: <a href=\"$answer\" target=\"_blank\">$answer</a></p>\n"; echo "<h2>Example Usage</h2>\n"; echo "<p>Server Side Include:<br><nobr style=\"font-weight: bolder; color: red;\"><!--#INCLUDE VIRTUAL="".basename($_SERVER["PHP_SELF"])."?$ssi" --></nobr></p>\n"; echo "<p>Prefered PHP Include:<br><nobr style=\"font-weight: bolder; color: red;\"><?php<br>$answerAlt\ninclude("".basename($_SERVER["PHP_SELF"])."");<br>?></nobr></p>\n"; echo "<p>PHP Include (Due to security concerns many ISP have configured their servers to prevent this from working):<br><nobr style=\"font-weight: bolder; color: red;\"><?php<br>include("$answer");<br>?></nobr></p>\n"; } if ($xmlContents != "" || $templateContents != "") { echo "<br><hr><br>\n"; if ($xmlContents != "") { echo "<h1>XML file</h1>\n"; if (($convertedXML = FeedForAll_scripts_convertEncoding($xmlContents, $missingEncodingDefault, $destinationEncoding)) === FALSE) { // Conversions failed, probably becasue it was wrong or the routines were missing $convertedXML = $xmlContents; } $convertedXML = str_replace("&", "&", $convertedXML); $convertedXML = str_replace("<", "<", $convertedXML); $convertedXML = str_replace(">", ">", $convertedXML); echo "<pre>$convertedXML</pre><br>\n"; } if ($templateContents != "") { echo "<h1>Template file</h1>\n"; $templateContents = str_replace("&", "&", $templateContents); $templateContents = str_replace("<", "<", $templateContents); $templateContents = str_replace(">", ">", $templateContents); echo "<pre>$templateContents</pre><br>\n"; } }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -