📄 feedforall_xmlparser.inc.php
字号:
} elseif ($elementName == "~~~ItemRssMeshFeedImageDescription~~~") { return $this->rssMeshFeedImageDescription; } elseif ($elementName == "~~~ItemRssMeshFeedImageHeight~~~") { return $this->rssMeshFeedImageHeight; } elseif ($elementName == "~~~ItemRssMeshFeedImageWidth~~~") { return $this->rssMeshFeedImageWidth; } return NULL; } Function getArrayOfFields() { $result = Array(); $result[] = "~~~ItemTitle~~~"; $result[] = "~~~ItemDescription~~~"; $result[] = "~~~ItemContentEncoded~~~"; $result[] = "~~~ItemLink~~~"; $result[] = "~~~ItemPubDate~~~"; $result[] = "~~~ItemPubDateAsNumber~~~"; $result[] = "~~~ItemEnclosureUrl~~~"; $result[] = "~~~ItemEnclosureType~~~"; $result[] = "~~~ItemEnclosureLength~~~"; $result[] = "~~~ItemGuid~~~"; $result[] = "~~~ItemAuthor~~~"; $result[] = "~~~ItemComments~~~"; $result[] = "~~~ItemSource~~~"; $result[] = "~~~ItemSourceUrl~~~"; $result[] = "~~~ItemCategory~~~"; $result[] = "~~~ItemCategoryDomain~~~"; $result[] = "~~~ItemCreativeCommons~~~"; $result[] = "~~~ItemRssMeshExtra~~~"; $result[] = "~~~ItemRssMeshFeedImageTitle~~~"; $result[] = "~~~ItemRssMeshFeedImageUrl~~~"; $result[] = "~~~ItemRssMeshFeedImageLink~~~"; $result[] = "~~~ItemRssMeshFeedImageDescription~~~"; $result[] = "~~~ItemRssMeshFeedImageHeight~~~"; $result[] = "~~~ItemRssMeshFeedImageWidth~~~"; return $result; } }$startingClassName = "rootItemClass";if (function_exists("rssFilter_extendClass")) { $startingClassName = rssFilter_extendClass($startingClassName);}if (function_exists("FeedForAll_parseExtensions_extendClass")) { $currentBaseClassName = FeedForAll_parseExtensions_extendClass($startingClassName);} else { $currentBaseClassName = $startingClassName;}eval('class baseItemClassWithExtensions extends ' . $currentBaseClassName . ' {}');class baseItemClass extends baseItemClassWithExtensions { Function baseItemClass($operateAs) { $parentClass = get_parent_class($this); $this->$parentClass($operateAs); }}class rootRSSParserClass { var $operateAs; var $gotROOT; var $feedTYPE; var $wholeString; var $level; var $tag; var $noFutureItems; var $currentItem; var $FeedTitle; var $FeedDescription; var $FeedContentEncoded; var $FeedLink; var $FeedPubDate; var $FeedPubDateDC; var $FeedPubDate_t; var $FeedLastBuildDate; var $FeedImageURL; var $FeedImageTitle; var $FeedImageLink; var $FeedImageDescription; var $FeedImageHeight; var $FeedImageWidth; var $FeedCreativeCommons; var $FeedAtomUpdated; var $FeedAtomContent; var $FeedAtomContentStartPos; var $FeedAtomAuthorEmail; var $contentEncodedUsed; var $Items; // var $insideChannel = FALSE; var $level_channel; var $insideChannelImage = FALSE; var $level_channelImage; var $insideItem = FALSE; var $level_item; var $insideAtomAuthor = FALSE; Function rootRSSParserClass($operateAs) { $this->operateAs = $operateAs; $this->gotROOT = 0; $this->feedTYPE = "RSS"; $this->wholeString = ""; $this->level = 0; $this->tag = ""; $this->noFutureItems = 0;; $this->FeedImageURL = ""; $this->FeedImageTitle = ""; $this->FeedImageLink = ""; $this->FeedImageDescription = ""; $this->FeedImageHeight = ""; $this->FeedImageWidth = ""; $this->currentItem; $this->FeedTitle = ""; $this->FeedDescription = ""; $this->FeedContentEncoded = ""; $this->FeedLink = ""; $this->FeedPubDate = ""; $this->FeedPubDateDC = ""; $this->FeedPubDate_t = 0; $this->FeedLastBuildDate = ""; $this->FeedImageURL = ""; $this->FeedImageTitle = ""; $this->FeedImageLink = ""; $this->FeedImageDescription = ""; $this->FeedImageHeight = ""; $this->FeedImageWidth = ""; $this->FeedCreativeCommons = ""; $this->FeedAtomUpdated = ""; $this->FeedAtomContent = ""; $this->FeedAtomContentStartPos = 0; $this->FeedAtomAuthorEmail = ""; $this->contentEncodedUsed = 0; $this->Items = Array(); // $this->insideChannel = FALSE; $this->level_channel = 0; $this->insideChannelImage = FALSE; $this->level_channelImage = 0; $this->insideItem = FALSE; $this->level_item = 0; } function startElement($parser, $tagName, $attrs) { GLOBAL $debugLevel; $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"; $this->insideChannel = TRUE; $this->level_channel = 1; } } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: startElement(\$parser, $tagName, \$attrs)<br>\n"; } $this->insideItem = TRUE; $this->level_item = $this->level; $this->currentItem = new baseItemClass($this->operateAs); // // Find the start of the <item> or <entry> $this->currentItem->ItemStartPos = xml_get_current_byte_index($parser); if ($this->wholeString[$this->currentItem->ItemStartPos] != "<") { $startToHere = substr($this->wholeString, 0, $this->currentItem->ItemStartPos); $this->currentItem->ItemStartPos = strrpos($startToHere, "<"); } } elseif ($this->insideChannel && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) { $this->insideAtomAuthor = TRUE; } elseif ($this->insideItem && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) { $this->insideAtomAuthor = TRUE; } elseif (($this->insideItem) && ($tagName == "ENCLOSURE")) { if (isset($attrs["URL"])) { $this->currentItem->enclosureURL = $attrs["URL"]; } if (isset($attrs["TYPE"])) { $this->currentItem->enclosureType = $attrs["TYPE"]; } if (isset($attrs["LENGTH"])) { $this->currentItem->enclosureLength = $attrs["LENGTH"]; } } elseif (($this->insideItem) && ($tagName == "SOURCE")) { if (isset($attrs["URL"])) { $this->currentItem->sourceURL = $attrs["URL"]; } } elseif (($this->insideItem) && ($tagName == "CATEGORY")) { if (isset($attrs["DOMAIN"])) { $this->currentItem->categoryDomain = $attrs["DOMAIN"]; } } elseif (($this->insideItem) && ($tagName == "GUID")) { if (isset($attrs["ISPERMALINK"])) { $this->currentItem->guidIsPermaLink = $attrs["ISPERMALINK"]; } } elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) { if ($this->insideItem) { if (isset($attrs["REL"]) && ($attrs["REL"] == "enclosure")) { $this->currentItem->enclosureURL = $attrs["HREF"]; $this->currentItem->enclosureType = $attrs["TYPE"]; $this->currentItem->enclosureLength = $attrs["LENGTH"]; } elseif (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html")) || !isset($attrs["TYPE"]))) { $this->currentItem->link = $attrs["HREF"]; } } else { if (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html")) || !isset($attrs["TYPE"]))) { $this->FeedLink = $attrs["HREF"]; } } } elseif ($tagName == "CHANNEL") { $this->insideChannel = TRUE; $this->level_channel = $this->level; } elseif (($tagName == "IMAGE") && ($this->insideChannel == TRUE)) { $this->insideChannelImage = TRUE; $this->level_channelImage = $this->level; } elseif ($tagName == "CONTENT") { if ($this->insideItem == TRUE) { if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) { // // Find the start of the <content ... > $this->currentItem->atomContentStartPos = xml_get_current_byte_index($parser); if ($this->wholeString[$this->currentItem->atomContentStartPos] != "<") { $startToHere = substr($this->wholeString, 0, $this->currentItem->atomContentStartPos); $this->currentItem->atomContentStartPos = strrpos($startToHere, "<"); } } } else { if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) { // // Find the start of the <content ... > $this->FeedAtomContentStartPos = xml_get_current_byte_index($parser); if ($this->wholeString[$this->FeedAtomContentStartPos] != "<") { $startToHere = substr($this->wholeString, 0, $this->FeedAtomContentStartPos); $this->FeedAtomContentStartPos = strrpos($startToHere, "<"); } } } } if (FeedForAll_parseExtensions() === TRUE) { FeedForAll_parseExtensions_startElemend($parser, $this, $tagName, $attrs); } } function endElement($parser, $tagName) { GLOBAL $debugLevel; $this->tag = ""; $this->level--; if (($this->insideItem) && ($tagName == "CATEGORY")) { $this->currentItem->categoryArray[] = Array("Category" => $this->currentItem->category, "Domain" => $this->currentItem->categoryDomain); $this->currentItem->category = ""; $this->currentItem->categoryDomain = ""; } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: endElement(\$parser, $tagName)<br>\n"; } $this->UseItem = TRUE; // // Do any special processing to convert ATOM to RSS 2.0 if ($this->feedTYPE == "FEE") { if ($this->currentItem->guid == "") { // There was no GUID, use ID $this->currentItem->guid = $this->currentItem->atomID; $this->currentItem->guidIsPermaLink = "false"; } } // // The the whole item string $pos = xml_get_current_byte_index($parser) - 2; if ($this->wholeString[$pos] != ">") { $hereToEnd = substr($this->wholeString, $pos); $closePos = strpos($hereToEnd, ">"); } else { $closePos = 0; } $this->currentItem->itemFullText = substr($this->wholeString, $this->currentItem->ItemStartPos, $pos + $closePos - $this->currentItem->ItemStartPos+1); // // Get the pubDate from pubDate first and then dc:date if (trim($this->currentItem->pubDate) != "") { $this->currentItem->pubDate = trim($this->currentItem->pubDate); $this->currentItem->pubDate_t = strtotime($this->currentItem->pubDate); } elseif (($this->feedTYPE == "FEE") && (trim($this->currentItem->atomUpdated) != "")) { $this->currentItem->atomUpdated = trim($this->currentItem->atomUpdated); $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->atomUpdated); $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t); } elseif (trim($this->currentItem->pubDateDC) != "") { $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->pubDateDC); $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t); } else { $this->currentItem->pubDate_t = time(); $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t); } if (($this->operateAs == "rssFilter") && function_exists("rssFilter_useItem")) { GLOBAL $_REQUEST; $this->UseItem = rssFilter_useItem($this->currentItem); if (isset($_REQUEST["testScript"])) { if ($this->UseItem) { echo "USING Item: ".htmlentities($this->currentItem->title)."<br>\n"; } else { echo "NOT Using: ".htmlentities($this->currentItem->title)."<br>\n"; } } } if ($this->operateAs == "rssMesh") { if (($this->itemLimit >= 0) && (count($this->Items) > $this->itemLimit)) { $this->UseItem = FALSE; } } elseif ($this->operateAs == "rss2html") { if (($useUniq = FeedForAll_rss2html_UseUniqueLink($this->currentItem->title, $this->currentItem->description, $this->currentItem->link, $this->currentItem->guid)) != -1) { if ($useUniq == 0) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: FeedForAll_rss2html_UseUniqueLink() => 0, Not using<br>\n"; } $this->UseItem = FALSE; } } if ($this->noFutureItems) { $noon = strtotime("today at 12:00"); if (($this->currentItem->pubDate_t - $noon) > 43200) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: future pubdate, Not using<br>\n"; } $this->UseItem = FALSE; } } } if ($this->UseItem) { if (isset($debugLevel) && ($debugLevel >= 2)) { echo "DIAG: Using item \"".$this->currentItem->title."\"<br>\n"; } // // Clean up some of the values $this->currentItem->title = trim($this->currentItem->title); $this->currentItem->description = trim($this->currentItem->description); if ($this->feedTYPE == "FEE") { $this->currentItem->atomContent = trim($this->currentItem->atomContent); $this->currentItem->description = $this->currentItem->atomContent; } else { $this->currentItem->description = $this->currentItem->description; } if (trim($this->currentItem->contentEncoded) == "") { if ($this->operateAs != "rssMesh") { $this->currentItem->contentEncoded = $this->currentItem->description; } } else { $this->currentItem->contentEncoded = trim($this->currentItem->contentEncoded); } if (trim($this->currentItem->description) == "") { $this->currentItem->description = trim($this->currentItem->contentEncoded); } $this->currentItem->link = trim($this->currentItem->link); $this->currentItem->guid = trim($this->currentItem->guid); $this->currentItem->guidIsPermaLink = trim($this->currentItem->guidIsPermaLink); if ($this->feedTYPE == "FEE") { $this->currentItem->atomAuthorEmail = trim($this->currentItem->atomAuthorEmail); $this->currentItem->author = trim($this->currentItem->atomAuthorEmail); } $this->currentItem->author = trim($this->currentItem->author); if ($this->currentItem->creativeCommons == "") { $this->currentItem->creativeCommons = trim($this->FeedCreativeCommons); } else { $this->currentItem->creativeCommons = trim($this->currentItem->creativeCommons); } if ($this->operateAs == "rss2sql") { if (($this->currentItem->source == "") && ($this->sourceFeedURL != "")) { $this->currentItem->source = $this->FeedTitle; $this->currentItem->sourceURL = $this->sourceFeedURL; } } $this->currentItem->source = trim($this->currentItem->source); $this->currentItem->sourceURL = trim($this->currentItem->sourceURL); $this->currentItem->enclosureURL = trim($this->currentItem->enclosureURL); $this->currentItem->enclosureLength = trim($this->currentItem->enclosureLength); $this->currentItem->enclosureType = trim($this->currentItem->enclosureType); $this->currentItem->comments = trim($this->currentItem->comments); $this->currentItem->rssMeshExtra = trim($this->currentItem->rssMeshExtra); $this->currentItem->rssMeshFeedImageTitle = trim($this->currentItem->rssMeshFeedImageTitle); $this->currentItem->rssMeshFeedImageUrl = trim($this->currentItem->rssMeshFeedImageUrl); $this->currentItem->rssMeshFeedImageLink = trim($this->currentItem->rssMeshFeedImageLink); $this->currentItem->rssMeshFeedImageDescription = trim($this->currentItem->rssMeshFeedImageDescription); $this->currentItem->rssMeshFeedImageHeight = trim($this->currentItem->rssMeshFeedImageHeight);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -