Go to About Wesleyan
Go to Academics
Go to Administration
Go to Admission
Go to Library
Go to Technology
Go to For Students
Go to For Faculty and Staff
Go to For Alumni
Go to For Parents
Go to Virtual Tour
Headlines Header

=> ~~~ItemRssMeshFeedImageTitle~~~ // => ~~~ItemRssMeshFeedImageUrl~~~ // => ~~~ItemRssMeshFeedImageLink~~~ // => ~~~ItemRssMeshFeedImageDescription~~~ // => ~~~ItemRssMeshFeedImageHeight~~~ // => ~~~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 in items. If there are more then one // 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 and in // * Add support for // // 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 // 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 and then // 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 exists if (($useFopenURL == 0) && !function_exists("curl_init")) { $useFopenURL = 1; if (isset($debugLevel) && ($debugLevel >= 3)) { echo "DIAG: setting \$useFopenURL=1 because curl_init() doesn't exist
\n"; } } if ($useFopenURL) { ini_set("allow_url_fopen", "1"); ini_set("user_agent", 'FeedForAll rss2html.php 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 "".$itemString; } } if (!isset($_REQUEST["buildURL"])) { // // Check variables that could be used if URL wrapper are disable or not working if (isset($GLOBALS["XMLFILE"])) { $XMLfilename = $GLOBALS["XMLFILE"]; } if (isset($GLOBALS["TEMPLATE"])) { $TEMPLATEfilename = $GLOBALS["TEMPLATE"]; } if (isset($GLOBALS["FeedTitleLength"])) { $limitFeedTitleLength = abs($GLOBALS["FeedTitleLength"]); } if (isset($GLOBALS["FeedDescriptionLength"])) { $limitFeedDescriptionLength = abs($GLOBALS["FeedDescriptionLength"]); } if (isset($GLOBALS["ItemTitleLength"])) { $limitItemTitleLength = abs($GLOBALS["ItemTitleLength"]); } if (isset($GLOBALS["ItemDescriptionLength"])) { $limitItemDescriptionLength = abs($GLOBALS["ItemDescriptionLength"]); } if (isset($GLOBALS["MAXITEMS"])) { $FeedMaxItems = $GLOBALS["MAXITEMS"]; } if (isset($GLOBALS["NOFUTUREITEMS"])) { $NoFutureItems = TRUE; } if (isset($_REQUEST["XMLFILE"])) { if (stristr($_REQUEST["XMLFILE"], "file"."://")) { // Not allowed ; } elseif (stristr($_REQUEST["XMLFILE"], "://")) { if ($fileAccessLevel == -1) { echo "Configuration setting prohibit using remote files, exiting\n"; exit -1; } else { // URL files are allowed $XMLfilename = $_REQUEST["XMLFILE"]; } } else { if (($fileAccessLevel == 1) || ($fileAccessLevel == -1)) { if (FeedForAll_rss2html_validExtension(basename($_REQUEST["XMLFILE"]), $allowedFeedExtensions) === FALSE) { echo "Configuration setting prohibit using the specified feed file, exiting\n"; exit -1; } $XMLfilename = basename($_REQUEST["XMLFILE"]); } elseif ($fileAccessLevel == 2) { echo "Configuration setting prohibit using local files, exiting\n"; exit -1; } else { // It is local and must be in the same directory $XMLfilename = basename($_REQUEST["XMLFILE"]); } } } if (isset($_REQUEST["TEMPLATE"])) { if (stristr($_REQUEST["TEMPLATE"], "file"."://")) { // Not allowed ; } elseif (stristr($_REQUEST["TEMPLATE"], "://")) { if ($fileAccessLevel == -1) { echo "Configuration setting prohibit using remote files, exiting\n"; exit -1; } else { // URL files are allowed $TEMPLATEfilename = $_REQUEST["TEMPLATE"]; } } else { if (($fileAccessLevel == 1) || ($fileAccessLevel == -1)) { if (FeedForAll_rss2html_validExtension(basename($_REQUEST["TEMPLATE"]), $allowedTemplateExtensions) === FALSE) { echo "Configuration setting prohibit using the specified template file, exiting\n"; exit -1; } $TEMPLATEfilename = basename($_REQUEST["TEMPLATE"]); } elseif ($fileAccessLevel == 2) { echo "Configuration setting prohibit using local files, exiting\n"; exit -1; } else { // It is local and must be in the same directory $TEMPLATEfilename = basename($_REQUEST["TEMPLATE"]); } } } if (isset($_REQUEST["FeedTitleLength"])) { $limitFeedTitleLength = abs($_REQUEST["FeedTitleLength"]); } if (isset($_REQUEST["FeedDescriptionLength"])) { $limitFeedDescriptionLength = abs($_REQUEST["FeedDescriptionLength"]); } if (isset($_REQUEST["ItemTitleLength"])) { $limitItemTitleLength = abs($_REQUEST["ItemTitleLength"]); } if (isset($_REQUEST["ItemDescriptionLength"])) { $limitItemDescriptionLength = abs($_REQUEST["ItemDescriptionLength"]); } // // Maximum number of items to be displayed // if (isset($_REQUEST["MAXITEMS"])) { $FeedMaxItems = $_REQUEST["MAXITEMS"]; } if (isset($_REQUEST["NOFUTUREITEMS"])) { $NoFutureItems = TRUE; } if (isset($outputCacheTTL) && function_exists("FeedForAll_scripts_readOutputCacheFile") && (($cacheContents = FeedForAll_scripts_readOutputCacheFile($XMLfilename, $TEMPLATEfilename)) !== FALSE)) { if (!headers_sent()) { // Send the Content-Type to force $destinationEncoding header("Content-Type: text/html; charset=$destinationEncoding"); } echo $cacheContents; } else { if (($template = FeedForAll_scripts_readFile($TEMPLATEfilename, $useFopenURL)) === FALSE) { if (!isset($hideErrors)) { if ($ReadErrorString == "") { echo "Unable to open template $TEMPLATEfilename, exiting\n"; } else { echo "Unable to open template $TEMPLATEfilename with error $ReadErrorString, exiting\n"; } } exit -1; } if (FeedForAll_rss2html_isTemplate($template) === FALSE) { if (!isset($hideErrors)) { echo "$TEMPLATEfilename is not a valid rss2html.php template file, exiting\n"; } exit -1; } if (strstr($template, "~~~NoFutureItems~~~")) { $NoFutureItems = TRUE; } if (($XML = FeedForAll_scripts_readFile($XMLfilename, $useFopenURL, $allowCachingXMLFiles)) === FALSE) { if (!isset($hideErrors)) { if ($ReadErrorString == "") { echo "Unable to open RSS Feed $XMLfilename, exiting\n"; } else { echo "Unable to open RSS Feed $XMLfilename with error $ReadErrorString, exiting\n"; } } exit -1; } if (strstr(trim($XML), "\n$XML"; } $XML = strstr(trim($XML), "noFutureItems = $NoFutureItems; $rss_parser->wholeString = $convertedXML; xml_set_object($xml_parser, $rss_parser); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING,1); $parseResult = xml_parse($xml_parser, $convertedXML, TRUE); if ($parseResult == 0) { if (!isset($hideErrors)) { $errorCode = xml_get_error_code($xml_parser); echo "\$errorCode = $errorCode
\n"; echo "xml_error_string() = ".xml_error_string($errorCode)."
\n"; echo "xml_get_current_line_number() = ".xml_get_current_line_number($xml_parser)."
\n"; echo "xml_get_current_column_number() = ".xml_get_current_column_number($xml_parser)."
\n"; echo "xml_get_current_byte_index() = ".xml_get_current_byte_index($xml_parser)."
\n"; } } else { xml_parser_free($xml_parser); // make sure the channel contentEncoded is not blank if ($rss_parser->FeedContentEncoded == "") { $rss_parser->FeedContentEncoded = $rss_parser->FeedDescription; } $template = FeedForAll_rss2html_str_replace("~~~FeedXMLFilename~~~", FeedForAll_rss2html_EscapeLink($XMLfilename), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedTitle~~~", FeedForAll_rss2html_limitLength($rss_parser->FeedTitle, $limitFeedTitleLength), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedDescription~~~", FeedForAll_rss2html_limitLength($rss_parser->FeedDescription, $limitFeedDescriptionLength), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedContentEncoded~~~", $rss_parser->FeedContentEncoded, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedLink~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedLink), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedPubDate~~~", $rss_parser->FeedPubDate, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedPubLongDate~~~", date($LongDateFormat, $rss_parser->FeedPubDate_t), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedPubShortDate~~~", date($ShortDateFormat, $rss_parser->FeedPubDate_t), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedPubLongTime~~~", date($LongTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedPubShortTime~~~", date($ShortTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageUrl~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedImageURL), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageTitle~~~", $rss_parser->FeedImageTitle, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageLink~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedImageLink), $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageDescription~~~", $rss_parser->FeedImageDescription, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageHeight~~~", $rss_parser->FeedImageWidth, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedImageWidth~~~", $rss_parser->FeedImageWidth, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedCreativeCommons~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedCreativeCommons), $template); if (FeedForAll_parseExtensions() === TRUE) { $template = FeedForAll_parseExtensions_replaceInChannel($rss_parser, $template); } $match = NULL; $template = str_replace("~~~NoFutureItems~~~", "", $template); // // Sort by PubDate if requested if (strstr($template, "~~~SortByPubDate~~~")) { $template = str_replace("~~~SortByPubDate~~~", "", $template); for ($x = 0; $x < count($rss_parser->Items)-1; $x++) { for ($y = $x+1; $y < count($rss_parser->Items); $y++) { if ($rss_parser->Items[$x]->pubDate_t < $rss_parser->Items[$y]->pubDate_t) { // Swap them $swapTemp = $rss_parser->Items[$x]; $rss_parser->Items[$x] = $rss_parser->Items[$y]; $rss_parser->Items[$y] = $swapTemp; } } } } if (isset($debugLevel) && ($debugLevel >= 3)) { echo "DIAG: adding to items, count=".count($rss_parser->Items)."
\n"; } // The the maximum items requested if (strstr($template, "~~~FeedMaxItems=")) { // Limit the maximun number of items displayed if (preg_match("/~~~FeedMaxItems=([0-9-]*)~~~/", $template, $match) !== FALSE) { if (($match[0] != "") && ($match[1] != "")) { $FeedMaxItems = $match[1]; $template = str_replace("~~~FeedMaxItems=$match[1]~~~", "", $template); if (abs($FeedMaxItems) > count($rss_parser->Items)) { if ($FeedMaxItems > 0) { $FeedMaxItems = count($rss_parser->Items); } else { $FeedMaxItems = -count($rss_parser->Items); } } } } } if (!function_exists("FeedForALL_rss2html_replaceInItem")) { Function FeedForALL_rss2html_replaceInItem($source, $currentItem) { GLOBAL $limitFeedTitleLength; GLOBAL $limitFeedDescriptionLength; GLOBAL $limitItemTitleLength; GLOBAL $limitItemDescriptionLength; GLOBAL $LongDateFormat; GLOBAL $ShortDateFormat; GLOBAL $LongTimeFormat; GLOBAL $ShortTimeFormat; GLOBAL $XMLfilename; $item = FeedForAll_rss2html_str_replace("~~~ItemTitle~~~", FeedForAll_rss2html_limitLength($currentItem->title, $limitItemTitleLength), $source); $item = FeedForAll_rss2html_str_replace("~~~ItemDescription~~~", FeedForAll_rss2html_limitLength($currentItem->description, $limitItemDescriptionLength), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemEnclosureLengthFormatted~~~", FeedForAll_rss2html_sizeToString($currentItem->enclosureLength), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $currentItem->pubDate_t), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $currentItem->pubDate_t), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $currentItem->pubDate_t), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $currentItem->pubDate_t), $item); $knownFields = $currentItem->getArrayOfFields(); foreach ($knownFields as $field) { $item = FeedForAll_rss2html_str_replace($field, $currentItem->getValueOf($field), $item); } $item = FeedForAll_rss2html_CreateUniqueLink($currentItem->title, $currentItem->description, $currentItem->link, $currentItem->guid, $XMLfilename, $item); if (FeedForAll_parseExtensions() === TRUE) { $item = FeedForAll_parseExtensions_replaceInItem($currentItem, $item); } return FeedForAll_rss2html_AddIdentity($item); } } // // Find the string, if it exists, between the ~~~EndItemsRecord~~~ and ~~~BeginItemsRecord~~~ // while ((strstr($template, "~~~BeginItemsRecord~~~")) !== FALSE) { $match = NULL; $allitems = NULL; $loop_limit = min(abs($FeedMaxItems), count($rss_parser->Items)); if (($parts = split("~~~BeginItemsRecord~~~", $template)) !== FALSE) { if (($parts = split("~~~EndItemsRecord~~~", $parts[1])) !== FALSE) { $WholeBlock = $parts[0]; // // Check for ~~~BeginAlternateItemsRecord~~~ // if (strstr($WholeBlock, "~~~BeginAlternateItemsRecord~~~")) { $parts = split("~~~BeginAlternateItemsRecord~~~", $WholeBlock); $block1 = $parts[0]; $block2 = $parts[1]; } else { $block1 = $WholeBlock; $block2 = $WholeBlock; } if ($FeedMaxItems < 0) { for ($x = count($rss_parser->Items)-1; $x >= count($rss_parser->Items) + $FeedMaxItems; $x--) { $allitems .= FeedForALL_rss2html_replaceInItem($block1, $rss_parser->Items[$x]); $x--; if ($x >= count($rss_parser->Items) + $FeedMaxItems) { // // 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
\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
\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 "rss2html.php URL tool\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"; echo "\n"; echo "URL for the XML file: (ie. http://www.myserver.com/file.xml)

\n"; echo "URL for the template file: (ie. http://www.myserver.com/template.html)

\n"; echo "Optional items:
\n"; echo "Maximum items: (Use negative numbers for the last X items)
\n"; echo "No future items:
\n"; if (function_exists("FeedForAll_scripts_contentOfCache")) { echo "
\n"; echo "XML (input) Cache Settings
\n"; echo "Allow Caching of the feed:
\n"; echo "Cache Time: (The number of seconds a file may be cached for before being fetched again)
\n"; echo "
\n"; echo "HTML (output) Cache Settings
\n"; echo "Output Cache Time: (The number of seconds the output may be cached for before being recreated)
\n"; echo "Output Cache Name: (This should be a unique name to prevent conflicts)
\n"; echo "
\n"; } echo "\n"; echo "
\n"; $xmlContents = ""; $templateContents = ""; if (isset($_POST["submit"])) { if ($_SERVER["REQUEST_METHOD"] != "POST") { exit; } 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($_POST["XML"], $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($_POST["TEMPLATE"], $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"; } } } ?>
Quicklinks


Arts at Wesleyan
Sciences at Wesleyan
Writing at Wesleyan
Athletics
Give to Wesleyan
Wesleyan 2020
Red and Black Colorbar
WESLEYAN UNIVERSITY     WESLEYAN STATION      MIDDLETOWN, CT      06459        ©2009 WESLEYAN UNIVERSITY