/", $XMLstring, $results) === FALSE) return FALSE; if (count($results) == 0) return FALSE; $initialXMLHeader = $results[0]; $results = str_replace(" ", "", $results); $results = str_replace("'", "\"", $results); if (($location = stristr($results[0], "encoding=")) !== FALSE) { $parts = split("\"", $location); if (strcasecmp($parts[1], $destinationEncoding) == 0) { return $XMLstring; } $inputEncoding = $parts[1]; $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader); } else { $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader); } $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString); if (($newResult = mb_convert_encoding($workString, $destinationEncoding, $inputEncoding)) !== FALSE) { return $newResult; } } if (function_exists("iconv") !== FALSE) { if (preg_match("/<\?xml(.*)\?>/", $XMLstring, $results) === FALSE) return FALSE; if (count($results) == 0) return FALSE; $initialXMLHeader = $results[0]; $results = str_replace(" ", "", $results); $results = str_replace("'", "\"", $results); if (($location = stristr($results[0], "encoding=")) !== FALSE) { $parts = split("\"", $location); if (strcasecmp($parts[1], $destinationEncoding) == 0) { return $XMLstring; } $inputEncoding = $parts[1]; $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader); } else { $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader); } $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString); if (($newResult = iconv($inputEncoding, "$destinationEncoding//TRANSLIT", $workString)) !== FALSE) { return $newResult; } } return 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"; } } 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; } Function FeedForAll_rss2html_str_replace($search, $replace, $subject) { return str_replace($search, $replace, $subject); } Function FeedForAll_rss2html_encodeURL($URLstring) { $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"; }else { $result = $result.$URLstring[$x]; } } return $result; } 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; } Function FeedForAll_rss2html_UseUniqueLink($title, $description, $link, $guid) { if ($title); if ($description); if ($link); if ($guid); return -1; } Function FeedForAll_rss2html_EscapeLink($link) { GLOBAL $escapeAmpInLinks; if ((strstr($link, "://") !== FALSE) && $escapeAmpInLinks) { $link = str_replace("&", "&", $link); } return $link; } // // 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 // // // As much as I hate globals, they are needed due to the // recusive nature of the parser $insidechannel = FALSE; $level_channel = 0; $insidechannelimage = FALSE; $level_channelimage = 0; $insideitem = FALSE; $level_item = 0; if (function_exists("FeedForAll_rss2html_getRFDdate") === FALSE) { Function FeedForAll_rss2html_getRFDdate($datestring) { $year = substr($datestring, 0, 4); $month = substr($datestring, 5, 2); $day = substr($datestring, 8, 2); $hour = substr($datestring, 11, 2); $minute = substr($datestring, 14, 2); $second = substr($datestring, 17, 2); if (substr($datestring, 19, 1) == "Z") { $offset_hour = 0; $offset_minute = 0; } else { if (substr($datestring, 19, 1) == "-") { $offset_hour = substr($datestring, 20, 2); $offset_minute = substr($datestring, 23, 2); } else { $offset_hour = -1*substr($datestring, 20, 2); $offset_minute = -1*substr($datestring, 23, 2); } } return gmmktime($hour+$offset_hour, $minute+$offset_minute, $second, $month, $day, $year); } class FeedForAll_rss2html_RSSParser { var $gotROOT = 0; var $feedTYPE = "RSS"; var $level = 0; var $tag = ""; var $title = ""; var $description = ""; var $contentEncoded = ""; var $link = ""; var $pubdate = ""; var $pubdateDC = ""; var $enclosureURL = ""; var $enclosureLength = ""; var $enclosureType = ""; var $categoryArray = Array(); var $category = ""; var $categoryDomain = ""; var $guid = ""; var $author = ""; var $comments = ""; var $source = ""; var $sourceURL = ""; var $DcCreator = ""; var $creativeCommons = ""; var $rssMeshExtra = ""; var $fimageURL = ""; var $fimageTitle = ""; var $fimageLink = ""; var $FeedTitle = ""; var $FeedDescription = ""; var $FeedContentEncoded = ""; var $FeedLink = ""; var $FeedPubDate = ""; var $FeedPubDateDC = ""; var $FeedPubDate_t = 0; var $FeedLastBuildDate = ""; var $FeedImageURL = ""; var $FeedImageTitle = ""; var $FeedImageLink = ""; var $FeedCreateiveCommons = ""; // // When adding new Item elements, be sure to update the sort below var $ItemTitle = Array(); var $ItemDescription = Array(); var $ItemContentEncoded = Array(); var $ItemLink = Array(); var $ItemPubDate = Array(); var $ItemPubDate_t = Array(); var $ItemEnclosureURL = Array(); var $ItemEnclosureLength = Array(); var $ItemEnclosureType = Array(); var $ItemCategoryArray = Array(); var $ItemGuid = Array(); var $ItemAuthor = Array(); var $ItemComments = Array(); var $ItemSource = Array(); var $ItemSourceURL = Array(); var $ItemCreateiveCommons = Array(); var $ItemRssMeshExtra = Array(); function startElement($parser, $tagName, $attrs) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; GLOBAL $ii; $this->level++; $this->tag = $tagName; if ($this->gotROOT == 0) { $this->gotROOT = 1; if (strstr($tagName, "RSS")) { $this->feedTYPE = "RSS"; } elseif (strstr($tagName, "RDF")) { $this->feedTYPE = "RDF"; } elseif (strstr($tagName, "FEE")) { $this->feedTYPE = "FEE"; $insidechannel = TRUE; $level_channel = 1; } } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $insideitem = TRUE; $level_item = $this->level; } elseif (($insideitem) && ($tagName == "ENCLOSURE")) { if (isset($attrs["URL"])) { $this->enclosureURL = $attrs["URL"]; } if (isset($attrs["TYPE"])) { $this->enclosureType = $attrs["TYPE"]; } if (isset($attrs["LENGTH"])) { $this->enclosureLength = $attrs["LENGTH"]; } } elseif (($insideitem) && ($tagName == "SOURCE")) { if (isset($attrs["URL"])) { $this->sourceURL = $attrs["URL"]; } } elseif (($insideitem) && ($tagName == "CATEGORY")) { if (isset($attrs["DOMAIN"])) { $this->categoryDomain = $attrs["DOMAIN"]; } } elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) { if (isset($attrs["HREF"])) { // ### chai modify //$this->link = $attrs["HREF"]; if((($ii % 3)==0) && ($ii >=3)) { $this->link = $attrs["HREF"]; } $ii++ ; } } elseif ($tagName == "CHANNEL") { $insidechannel = TRUE; $level_channel = $this->level; } elseif (($tagName == "IMAGE") && ($insidechannel = TRUE)) { $insidechannelimage = TRUE; $level_channelimage = $this->level; } if ($parser); } function endElement($parser, $tagName) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; GLOBAL $NoFutureItems; $this->level--; if (($insideitem) && ($tagName == "CATEGORY")) { $this->categoryArray[] = Array("Category" => $this->category, "Domain" => $this->categoryDomain); $this->category = ""; $this->categoryDomain = ""; } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $UseItem = TRUE; if (($useUniq = FeedForAll_rss2html_UseUniqueLink($this->title, $this->description, $this->link, $this->guid)) != -1) { if ($useUniq == 0) { $UseItem = FALSE; } } if ($UseItem) { $this->ItemTitle[] = trim($this->title); $this->ItemDescription[] = trim($this->description); if (trim($this->contentEncoded) == "") { $this->ItemContentEncoded[] = trim($this->description); } else { $this->ItemContentEncoded[] = trim($this->contentEncoded); } $this->ItemLink[] = FeedForAll_rss2html_EscapeLink(trim($this->link)); // // Get the pubDate from pubDate first and then dc:date if (trim($this->pubdate) != "") { $this->ItemPubDate[] = trim($this->pubdate); $this->ItemPubDate_t[] = strtotime($this->pubdate); } else if (trim($this->pubdateDC) != "") { $this->ItemPubDate[] = trim($this->pubdateDC); $this->ItemPubDate_t[] = FeedForAll_rss2html_getRFDdate($this->pubdateDC); } else { //chai // $this->ItemPubDate[] = date("D, d M Y H:i:s +0000"); // $this->ItemPubDate_t[] = time(); $this->ItemPubDate[] = "xxx" ; $this->ItemPubDate_t[] = "yyy" ; } // $this->ItemPubDate[] = trim($this->pubdate); //@@@ $this->ItemPubDate_t[] = strtotime($this->pubdate); //$this->ItemPubDate_t[] = substr($this->pubdate,0,10) ; $this->ItemGuid[] = FeedForAll_rss2html_EscapeLink(trim($this->guid)); if ($this->author == "") { $this->ItemAuthor[] = trim($this->DcCreator); } else { $this->ItemAuthor[] = trim($this->author); } if ($this->creativeCommons == "") { $this->ItemCreateiveCommons[] = FeedForAll_rss2html_EscapeLink(trim($this->FeedCreateiveCommons)); } else { $this->ItemCreateiveCommons[] = FeedForAll_rss2html_EscapeLink(trim($this->creativeCommons)); } $this->ItemSource[] = trim($this->source); $this->ItemSourceURL[] = FeedForAll_rss2html_EscapeLink(trim($this->sourceURL)); $this->ItemEnclosureURL[] = FeedForAll_rss2html_EscapeLink(trim($this->enclosureURL)); $this->ItemEnclosureLength[] = trim($this->enclosureLength); $this->ItemEnclosureType[] = trim($this->enclosureType); $this->ItemCategoryArray[] = $this->categoryArray; $this->ItemCategoryDomain[] = trim($this->categoryDomain); $this->ItemComments[] = FeedForAll_rss2html_EscapeLink(trim($this->comments)); $this->ItemRssMeshExtra[] = trim($this->rssMeshExtra); } $this->title = ""; $this->description = ""; $this->contentEncoded = ""; $this->link = ""; $this->pubdate = ""; $this->pubdateDC = ""; $this->guid = ""; $this->enclosureURL = ""; $this->enclosureLength = ""; $this->enclosureType = ""; $this->categoryArray = Array(); $this->category = ""; $this->categoryDomain = ""; $this->author = ""; $this->comments = ""; $this->source = ""; $this->sourceURL = ""; $this->DcCreator = ""; $this->creativeCommons = ""; $this->rssMeshExtra = ""; $insideitem = FALSE; $level_item = 0; } elseif (($tagName == "IMAGE") && ($insidechannelimage)) { $this->FeedImageURL = trim($this->fimageURL); $this->FeedImageTitle = trim($this->fimageTitle); $this->FeedImageLink = trim($this->fimageLink); $this->fimageURL = ""; $this->fimageTitle = ""; $this->fimageLink = ""; $insidechannelimage = FALSE; $level_channelimage = 0; } elseif ($tagName == "CHANNEL") { // // Get the pubDate from pubDate first and then dc:date if (trim($this->FeedPubDate) != "") { $this->FeedPubDate_t = strtotime($this->FeedPubDate); } else if (trim($this->FeedPubDateDC) != "") { $this->FeedPubDate_t = FeedForAll_rss2html_getRFDdate($this->FeedPubDateDC); } else if (trim($this->FeedLastBuildDate) != "") { $this->FeedPubDate_t = strtotime($this->FeedLastBuildDate); } else { $this->FeedPubDate = date("D, d M Y H:i:s +0000"); $this->FeedPubDate_t = time(); } $insidechannel = FALSE; $level_channel = 0; } elseif ($this->level == $level_channel) { if ($tagName == "TITLE") { $this->FeedTitle = trim($this->title); $this->title = ""; } elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) { $this->FeedDescription = trim($this->description); $this->description = ""; } elseif ($tagName == "DESCRIPTION") { $this->FeedContentEncoded = trim($this->description); $this->contentEncoded = ""; } elseif ($tagName == "LINK") { $this->FeedLink = trim($this->link); $this->link = ""; } } if ($parser); } function characterData($parser, $data) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; if (($data == "") || ($data == NULL)) { } else { if (($insideitem) && ($this->level == $level_item+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT": $this->contentEncoded .= $data; break; case "SUMMARY": $this->description .= $data; break; case "LINK": $this->link .= $data; break; //case "PUBLISHED": //published PUBDATE case "PUBDATE": //published PUBDATE $this->pubdate .= $data; break; case "DC:DATE": $this->pubdateDC .= $data; break; case "MODIFIED": $this->pubdateDC .= $data; break; case "GUID": $this->guid .= $data; break; case "AUTHOR": $this->author .= $data; break; case "COMMENTS": $this->comments .= $data; break; case "SOURCE": $this->source .= $data; break; } } elseif ($insidechannelimage) { switch ($this->tag) { case "TITLE": $this->fimageTitle .= $data; break; case "URL": $this->fimageURL .= $data; break; case "LINK": $this->fimageLink .= $data; break; } } elseif (($insidechannel) && ($this->level == $level_channel+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT": $this->contentEncoded .= $data; break; case "TAGLINE": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBLISHED": $this->FeedPubDate .= $data; break; case "ATOM:UPDATED": $this->FeedPubDateDC .= $data; break; case "MODIFIED": $this->FeedPubDateDC .= $data; break; case "LASTBUILDDATE": $this->FeedLastBuildDate .= $data; break; } } } if ($parser); } } } $template = FeedForAll_rss2html_readFile($TEMPLATEfilename, $useFopenURL) ; if (strstr($template, "~~~NoFutureItems~~~")) { $NoFutureItems = TRUE; } if (($XML = FeedForAll_rss2html_readFile($XMLfilename, $useFopenURL, $allowCachingXMLFiles)) === FALSE) { if ($GLOBALS["ERRORSTRING"] == "") { echo "Unable to open RSS Feed $XMLfilename, exiting\n"; } else { echo "Unable to open RSS Feed $XMLfilename with error $GLOBALS[ERRORSTRING], exiting\n"; } exit -1; } if (strstr(trim($XML), "\n$XML"; } $XML = strstr(trim($XML), "ItemTitle)); // make sure the channel contentEncoded is not blank if ($rss_parser->FeedContentEncoded == "") { $rss_parser->FeedContentEncoded = $rss_parser->FeedDescription; } $template = FeedForAll_rss2html_str_replace("~~~FeedTitle~~~", $rss_parser->FeedTitle, $template); $template = FeedForAll_rss2html_str_replace("~~~FeedDescription~~~", $rss_parser->FeedDescription, $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); $match = NULL; // Sort by PubDate if requested if (strstr($template, "~~~SortByPubDate~~~")) { $template = str_replace("~~~SortByPubDate~~~", "", $template); for ($x = 0; $x < count($rss_parser->ItemTitle)-1; $x++) { for ($y = $x+1; $y < count($rss_parser->ItemTitle); $y++) { if ($rss_parser->ItemPubDate_t[$x] < $rss_parser->ItemPubDate_t[$y]) { // Swap them $swapTemp = $rss_parser->ItemTitle[$x]; $rss_parser->ItemTitle[$x] = $rss_parser->ItemTitle[$y]; $rss_parser->ItemTitle[$y] = $swapTemp; $swapTemp = $rss_parser->ItemDescription[$x]; $rss_parser->ItemDescription[$x] = $rss_parser->ItemDescription[$y]; $rss_parser->ItemDescription[$y] = $swapTemp; $swapTemp = $rss_parser->ItemContentEncoded[$x]; $rss_parser->ItemContentEncoded[$x] = $rss_parser->ItemContentEncoded[$y]; $rss_parser->ItemContentEncoded[$y] = $swapTemp; $swapTemp = $rss_parser->ItemLink[$x]; $rss_parser->ItemLink[$x] = $rss_parser->ItemLink[$y]; $rss_parser->ItemLink[$y] = $swapTemp; $swapTemp = $rss_parser->ItemGuid[$x]; $rss_parser->ItemGuid[$x] = $rss_parser->ItemGuid[$y]; $rss_parser->ItemGuid[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate[$x]; $rss_parser->ItemPubDate[$x] = $rss_parser->ItemPubDate[$y]; $rss_parser->ItemPubDate[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate_t[$x]; $rss_parser->ItemPubDate_t[$x] = $rss_parser->ItemPubDate_t[$y]; $rss_parser->ItemPubDate_t[$y] = $swapTemp; $swapTemp = $rss_parser->ItemEnclosureURL[$x]; $rss_parser->ItemEnclosureURL[$x] = $rss_parser->ItemEnclosureURL[$y]; $rss_parser->ItemEnclosureURL[$y] = $swapTemp; $swapTemp = $rss_parser->ItemEnclosureType[$x]; $rss_parser->ItemEnclosureType[$x] = $rss_parser->ItemEnclosureType[$y]; $rss_parser->ItemEnclosureType[$y] = $swapTemp; $swapTemp = $rss_parser->ItemEnclosureLength[$x]; $rss_parser->ItemEnclosureLength[$x] = $rss_parser->ItemEnclosureLength[$y]; $rss_parser->ItemEnclosureLength[$y] = $swapTemp; $swapTemp = $rss_parser->ItemAuthor[$x]; $rss_parser->ItemAuthor[$x] = $rss_parser->ItemAuthor[$y]; $rss_parser->ItemAuthor[$y] = $swapTemp; $swapTemp = $rss_parser->ItemComments[$x]; $rss_parser->ItemComments[$x] = $rss_parser->ItemComments[$y]; $rss_parser->ItemComments[$y] = $swapTemp; $swapTemp = $rss_parser->ItemCategoryArray[$x]; $rss_parser->ItemCategoryArray[$x] = $rss_parser->ItemCategoryArray[$y]; $rss_parser->ItemCategoryArray[$y] = $swapTemp; $swapTemp = $rss_parser->ItemSource[$x]; $rss_parser->ItemSource[$x] = $rss_parser->ItemSource[$y]; $rss_parser->ItemSource[$y] = $swapTemp; $swapTemp = $rss_parser->ItemSourceURL[$x]; $rss_parser->ItemSourceURL[$x] = $rss_parser->ItemSourceURL[$y]; $rss_parser->ItemSourceURL[$y] = $swapTemp; $swapTemp = $rss_parser->ItemCreativeCommons[$x]; $rss_parser->ItemCreativeCommons[$x] = $rss_parser->ItemCreativeCommons[$y]; $rss_parser->ItemCreativeCommons[$y] = $swapTemp; $swapTemp = $rss_parser->ItemRssMeshExtra[$x]; $rss_parser->ItemRssMeshExtra[$x] = $rss_parser->ItemRssMeshExtra[$y]; $rss_parser->ItemRssMeshExtra[$y] = $swapTemp; } } } } while ((strstr($template, "~~~BeginItemsRecord~~~")) !== FALSE) { $match = NULL; $allitems = NULL; $loop_limit = min(abs($FeedMaxItems), count($rss_parser->ItemTitle)); if (($parts = split("~~~BeginItemsRecord~~~", $template)) !== FALSE) { if (($parts = split("~~~EndItemsRecord~~~", $parts[1])) !== FALSE) { $WholeBlock = $parts[0]; $block1 = $WholeBlock; $block2 = $WholeBlock; for ($x = 0; $x < $loop_limit; $x++) { $item = FeedForAll_rss2html_str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block1); $item = FeedForAll_rss2html_str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemGuid~~~", $rss_parser->ItemGuid[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_CreateUniqueLink($rss_parser->ItemTitle[$x], $rss_parser->ItemDescription[$x], $rss_parser->ItemLink[$x], $rss_parser->ItemGuid[$x], $XMLfilename, $item); $allitems .= $item; $x++; if ($x < $loop_limit) { $item = FeedForAll_rss2html_str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block2); $item = FeedForAll_rss2html_str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemGuid~~~", $rss_parser->ItemGuid[$x], $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = FeedForAll_rss2html_CreateUniqueLink($rss_parser->ItemTitle[$x], $rss_parser->ItemDescription[$x], $rss_parser->ItemLink[$x], $rss_parser->ItemGuid[$x], $XMLfilename, $item); $allitems .= $item; } } $template = str_replace("~~~BeginItemsRecord~~~".$WholeBlock."~~~EndItemsRecord~~~", $allitems, $template); } } } // Since ' is not HTML, but is XML convert. $template = str_replace("'", "'", $template); $template = str_replace("~~~SortByPubDate~~~", "", $template); if (!headers_sent()) { // Send the Content-Type to force $destinationEncoding header("Content-Type: text/html; charset=$destinationEncoding"); } echo FeedForAll_rss2html_pro($template); ?>