⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feedforall_xmlparser.inc.php

📁 RSS to html
💻 PHP
📖 第 1 页 / 共 5 页
字号:
    }    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["REL"]) && ($attrs["REL"] == "alternate")) || !isset($attrs["REL"]))) || !isset($attrs["TYPE"]))) {          $this->currentItem->link = $attrs["HREF"];        }      } else {        if (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html") && ((isset($attrs["REL"]) && ($attrs["REL"] == "alternate")) || !isset($attrs["REL"]))) || !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);      //      // Find the element that opened this all up.      $endingString = '</'.substr($this->wholeString, $this->currentItem->ItemStartPos+1, 4);      if ($endingString == substr($this->wholeString, $pos, 6)) {        // We are good just where we are      } else {        for (;$pos > 0; $pos--) {          /* Look for a closing angle */          if ($endingString == substr($this->wholeString, $pos, 6)) break;        }      }      $pos++;      $hereToEnd = substr($this->wholeString, $pos);      $closePos = strpos($hereToEnd, '>');      $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) {          if (($this->currentItem->pubDate_t - $this->noon_t) > 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->rssMeshExtra1 = trim($this->currentItem->rssMeshExtra1);        $this->currentItem->rssMeshExtra2 = trim($this->currentItem->rssMeshExtra2);        $this->currentItem->rssMeshExtra3 = trim($this->currentItem->rssMeshExtra3);        $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);        $this->currentItem->rssMeshFeedImageWidth = trim($this->currentItem->rssMeshFeedImageWidth);        if ($this->operateAs == "rss2html") {          //          // Escape any links          $this->currentItem->link = FeedForAll_rss2html_EscapeLink($this->currentItem->link);          $this->currentItem->guid = FeedForAll_rss2html_EscapeLink($this->currentItem->guid);          $this->currentItem->creativeCommons = FeedForAll_rss2html_EscapeLink($this->currentItem->creativeCommons);          $this->currentItem->sourceURL = FeedForAll_rss2html_EscapeLink($this->currentItem->sourceURL);          $this->currentItem->enclosureURL = FeedForAll_rss2html_EscapeLink($this->currentItem->enclosureURL);          $this->currentItem->comments = FeedForAll_rss2html_EscapeLink($this->currentItem->comments);          $this->currentItem->rssMeshFeedImageUrl = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageUrl);          $this->currentItem->rssMeshFeedImageLink = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageLink);        }                //        if ($this->currentItem->contentEncodedUsed) {          $this->contentEncodedUsed = 1;        }        if (FeedForAll_parseExtensions() === TRUE) {          FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);        }        if ($this->UseItem) {          $this->Items[] = $this->currentItem;          if (isset($debugLevel) && ($debugLevel >= 3)) {            echo "DIAG: adding to items, count=".count($this->Items)."<br>\n";          }        }      } else {        unset($this->currentItem);      }      $this->insideItem = FALSE;      $this->level_item = 0;      return;    }    elseif ($this->insideAtomAuthor && ($tagName == "AUTHOR")) {      $this->insideAtomAuthor = FALSE;    }    elseif (($tagName == "IMAGE") && ($this->insideChannelImage)) {      $this->FeedImageTitle = trim($this->FeedImageTitle);      $this->FeedImageURL = trim($this->FeedImageURL);      $this->FeedImageLink = trim($this->FeedImageLink);      $this->FeedImageDescription = trim($this->FeedImageDescription);      $this->FeedImageHeight = trim($this->FeedImageHeight);      $this->FeedImageWidth = trim($this->FeedImageWidth);      if ($this->operateAs == "rss2html") {        //        // Escape any links        $this->FeedImageURL = FeedForAll_rss2html_EscapeLink($this->FeedImageURL);        $this->FeedImageLink = FeedForAll_rss2html_EscapeLink($this->FeedImageLink);      }      if (FeedForAll_parseExtensions() === TRUE) {        FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);      }      $this->insideChannelImage = FALSE;      $this->level_channelImage = 0;      return;    }    elseif ((($tagName == "CHANNEL") && ($this->feedTYPE != "FEE")) || (($tagName == "FEED") && ($this->feedTYPE == "FEE"))) {      $this->FeedPubDate = trim($this->FeedPubDate);      $this->FeedPubDateDC = trim($this->FeedPubDateDC);      $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);      //      // Get the pubDate from pubDate first and then dc:date      if (trim($this->FeedPubDate) != "") {        $this->FeedPubDate_t = strtotime($this->FeedPubDate);      }      elseif (($this->feedTYPE == "FEE") && ($this->FeedAtomUpdated != "")) {        $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);        $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedAtomUpdated);        $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);      }      elseif (trim($this->FeedPubDateDC) != "") {        $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedPubDateDC);        $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);      }      elseif (trim($this->FeedLastBuildDate) != "") {        $this->FeedPubDate_t = strtotime($this->FeedLastBuildDate);        $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);      } else {        $this->FeedPubDate_t = time();        $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);      }      $this->FeedTitle = trim($this->FeedTitle);      if ($this->feedTYPE == "FEE") {        $this->FeedAtomContent = trim($this->FeedAtomContent);        $this->FeedDescription = $this->FeedAtomContent;      } else {        $this->FeedDescription = $this->FeedDescription;      }      if (trim($this->FeedContentEncoded) == "") {        $this->FeedContentEncoded = $this->FeedDescription;      }      $this->FeedLink = trim($this->FeedLink);      if ($this->operateAs == "rss2html") {        //        // Escape any links        $this->FeedLink = FeedForAll_rss2html_EscapeLink($this->FeedLink);        $this->FeedCreativeCommons = FeedForAll_rss2html_EscapeLink($this->FeedCreativeCommons);      }      if (FeedForAll_parseExtensions() === TRUE) {        FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);      }      $this->insideChannel = FALSE;      $this->level_channel = 0;      return;    }    elseif ($this->level == $this->level_channel) {      if ($tagName == "TITLE") {        $this->FeedTitle = trim($this->FeedTitle);      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -