\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 "RSS2HTML.PHP LINK TOOL
\n";
echo "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.
\n";
echo "\n";
$xmlContents = "";
$templateContents = "";
if (isset($_POST["submit"])) {
if ($_SERVER["REQUEST_METHOD"] != "POST") {
return;
}
echo "
\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"])."\";
";
$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"])."\";
";
$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]\";
\n";
$ssi .= "&MAXITEMS=$_POST[MAXITEMS]";
}
if (isset($_POST["NOFUTUREITEMS"]) && $_POST["NOFUTUREITEMS"] == "on") {
$answer .= "&NOFUTUREITEMS=1";
$answerAlt .= "\$NOFUTUREITEMS = \"1\";
\n";
$ssi .= "&NOFUTUREITEMS=1";
}
if (function_exists("FeedForAll_scripts_contentOfCache")) {
if (isset($_POST["ALLOWXMLCACHE"]) && $_POST["ALLOWXMLCACHE"] == "on") {
$answerAlt .= "\$ALLOWXMLCACHE = \"1\";
\n";
}
if (isset($_POST["XMLCACHETTL"]) && ($_POST["XMLCACHETTL"] != "") && (intval($_POST["XMLCACHETTL"]) != 0)) {
$answerAlt .= "\$XMLCACHETTL = \"$_POST[XMLCACHETTL]\";
\n";
}
if (isset($_POST["OUTCACHETTL"]) && isset($_POST["OUTCACHENAME"])) {
if (($_POST["OUTCACHETTL"] != "") && (intval($_POST["OUTCACHETTL"]) != 0) && ($_POST["OUTCACHENAME"] != "")) {
$answerAlt .= "\$OUTCACHETTL = \"$_POST[OUTCACHETTL]\";
\n";
$answerAlt .= "\$OUTCACHENAME = \"$_POST[OUTCACHENAME]\";
\n";
}
}
}
echo "Results
\n";
if (isset($_POST["XML"]) && $_POST["XML"] != "") {
$XMLfilename = "";
if (stristr($_POST["XML"], "file"."://")) {
// Not allowed
;
}
elseif (stristr($_POST["XML"], "://")) {
if ($fileAccessLevel == -1) {
echo "Configuration setting prohibit using remote files
\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 "Configuration setting prohibit using the specified feed file
\n";
} else {
$XMLfilename = basename($_POST["XML"]);
}
}
elseif ($fileAccessLevel == 2) {
echo "Configuration setting prohibit using local files
\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 "The XML file $_POST[XML] could not be opened.
\n";
} else {
echo "The XML file $_POST[XML] could not be opened with the error $ReadErrorString.
\n";
}
} else {
echo "The XML file $_POST[XML] was SUCCESSFULLY opened
\n";
}
}
}
if (isset($_POST["TEMPLATE"]) && $_POST["TEMPLATE"] != "") {
$TEMPLATEfilename = "";
if (stristr($_POST["TEMPLATE"], "file"."://")) {
// Not allowed
;
}
elseif (stristr($_POST["TEMPLATE"], "://")) {
if ($fileAccessLevel == -1) {
echo "Configuration setting prohibit using remote files
\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 "Configuration setting prohibit using the specified template file
\n";
} else {
$TEMPLATEfilename = basename($_POST["TEMPLATE"]);
}
}
elseif ($fileAccessLevel == 2) {
echo "Configuration setting prohibit using local files
\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 "The template file $_POST[TEMPLATE] could not be opened.
\n";
} else {
echo "The template file $_POST[TEMPLATE] could not be opened with the error $ReadErrorString.
\n";
}
}
elseif (FeedForAll_rss2html_isTemplate($templateContents) === FALSE) {
echo "$_POST[TEMPLATE] is not a valid rss2html.php template file\n";
$templateContents = "";
} else {
echo "The template file $_POST[TEMPLATE] was SUCCESSFULLY opened
\n";
}
}
}
if ($xmlurl != "") {
echo "URL for the XML file properly encoded:
$xmlurl
\n";
}
if ($templateurl != "") {
echo "URL for the template file properly encoded:
$templateurl
\n";
}
echo "Test Link
\n";
echo "Click on link to view results: $answer
\n";
echo "Example Usage
\n";
echo "Server Side Include:
<!--#INCLUDE VIRTUAL="".basename($_SERVER["PHP_SELF"])."?$ssi" -->
\n";
echo "Prefered PHP Include:
<?php
$answerAlt\ninclude("".basename($_SERVER["PHP_SELF"])."");
?>
\n";
echo "PHP Include (Due to security concerns many ISP have configured their servers to prevent this from working):
<?php
include("$answer");
?>
\n";
}
if ($xmlContents != "" || $templateContents != "") {
echo "
\n";
if ($xmlContents != "") {
echo "XML file
\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 "$convertedXML
\n";
}
if ($templateContents != "") {
echo "Template file
\n";
$templateContents = str_replace("&", "&", $templateContents);
$templateContents = str_replace("<", "<", $templateContents);
$templateContents = str_replace(">", ">", $templateContents);
echo "$templateContents
\n";
}
}
}
?>
|