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

📄 feedforall_xmlparser.inc.php

📁 RSS to SQL to store in Database
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        $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);      }      elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) {        $this->FeedDescription = trim($this->FeedDescription);      }      elseif ($tagName == "CONTENT:ENCODED") {        $this->FeedContentEncoded = trim($this->FeedContentEncoded);      }      elseif ($tagName == "LINK") {        $this->FeedLink = trim($this->FeedLink);      }    }    elseif ($tagName == "CONTENT") {      if ($this->insideItem == TRUE) {        // Lets look to see if the content is        if ($this->currentItem->atomContentStartPos) {          //          // The the whole <content ... > string          $pos = xml_get_current_byte_index($parser) - 2;          if ($this->wholeString[$pos] != ">") {            $hereToEnd = substr($this->wholeString, $pos);            $closePos = strpos($hereToEnd, ">");          } else {            $closePos = 0;          }          $fullContentText = substr($this->wholeString, $this->currentItem->atomContentStartPos, $pos + $closePos - $this->currentItem->atomContentStartPos+1);          // Find the end of <content          $start = strpos($fullContentText, ">");          $fullContentText = substr($fullContentText, $start+1);          // Find the end of <div          $start = strpos($fullContentText, ">");          $fullContentText = substr($fullContentText, $start+1);          // Find the start of </content          $start = strrpos($fullContentText, "<");          $fullContentText = substr($fullContentText, 0, $start-1);          // Find the start of </div          $start = strrpos($fullContentText, "<");          $this->currentItem->atomContent = substr($fullContentText, 0, $start-1);          $this->currentItem->atomContentStartPos = 0;        }      } else {        // Lets look to see if the content is        if ($this->FeedAtomContentStartPos) {          //          // The the whole <content ... > string          $pos = xml_get_current_byte_index($parser) - 2;          if ($this->wholeString[$pos] != ">") {            $hereToEnd = substr($this->wholeString, $pos);            $closePos = strpos($hereToEnd, ">");          } else {            $closePos = 0;          }          $fullContentText = substr($this->wholeString, $this->FeedAtomContentStartPos, $pos + $closePos - $this->FeedAtomContentStartPos+1);          // Find the end of <content          $start = strpos($fullContentText, ">");          $fullContentText = substr($fullContentText, $start+1);          // Find the end of <div          $start = strpos($fullContentText, ">");          $fullContentText = substr($fullContentText, $start+1);          // Find the start of </content          $start = strrpos($fullContentText, "<");          $fullContentText = substr($fullContentText, 0, $start-1);          // Find the start of </div          $start = strrpos($fullContentText, "<");          $this->FeedAtomContent = substr($fullContentText, 0, $start-1);          $this->FeedAtomContentStartPos = 0;        }      }    }    if (FeedForAll_parseExtensions() === TRUE) {      FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);    }  }  function characterData($parser, $data) {    if (($data == "") || ($data == NULL)) {    } else {      if (($this->insideItem) && ($this->level == $this->level_item+1)) {        switch ($this->tag) {          case "TITLE":          $this->currentItem->title .= $data;          break;          case "DESCRIPTION":          $this->currentItem->description .= $data;          break;          case "CONTENT:ENCODED":          $this->currentItem->contentEncodedUsed = 1;          $this->currentItem->contentEncoded .= $data;          break;          case "SUMMARY":          $this->currentItem->description .= $data;          break;          case "LINK":          $this->currentItem->link .= $data;          break;          case "PUBDATE":          $this->currentItem->pubDate .= $data;          break;          case "MODIFIED":          $this->currentItem->pubDateDC .= $data;          break;          case "GUID":          $this->currentItem->guid .= $data;          break;                    case "ID":          case "ATOM:ID":          $this->currentItem->atomID .= $data;          break;          case "AUTHOR":          $this->currentItem->author .= $data;          break;          case "COMMENTS":          $this->currentItem->comments .= $data;          break;          case "SOURCE":          $this->currentItem->source .= $data;          break;          case "CATEGORY":          $this->currentItem->category .= $data;          break;          case "CREATIVECOMMONS:LICENSE":          $this->currentItem->creativeCommons .= $data;          break;          case "RSSMESH:EXTRA":          $this->currentItem->rssMeshExtra .= $data;          break;          case "RSSMESH:FEEDIMAGETITLE":          $this->currentItem->rssMeshFeedImageTitle .= $data;          break;          case "RSSMESH:FEEDIMAGEURL":          $this->currentItem->rssMeshFeedImageUrl .= $data;          break;          case "RSSMESH:FEEDIMAGELINK":          $this->currentItem->rssMeshFeedImageLink .= $data;          break;          case "RSSMESH:FEEDIMAGEDESCRIPTION":          $this->currentItem->rssMeshFeedImageDescription .= $data;          break;          case "RSSMESH:FEEDIMAGEHEIGHT":          $this->currentItem->rssMeshFeedImageHeight .= $data;          break;          case "RSSMESH:FEEDIMAGEWIDTH":          $this->currentItem->rssMeshFeedImageWidth .= $data;          break;          case "UPDATED":          case "ATOM:UPDATED":          $this->currentItem->atomUpdated .= $data;          break;                    case "CONTENT":          case "ATOM:CONTENT":          $this->currentItem->atomContent .= $data;          break;                    default:          if ($this->tag == "DC:DATE") {            $this->currentItem->pubDateDC .= $data;          }          if (FeedForAll_parseExtensions() === TRUE) {            FeedForAll_parseExtensions_characterData($parser, $this, $data);          }        }      }      elseif ($this->insideChannelImage) {        switch ($this->tag) {          case "TITLE":          $this->FeedImageTitle .= $data;          break;          case "URL":          $this->FeedImageURL .= $data;          break;          case "LINK":          $this->FeedImageLink .= $data;          break;          case "DESCRIPTION":          $this->FeedImageDescription .= $data;          break;          case "HEIGHT":          $this->FeedImageHeight .= $data;          break;          case "WIDTH":          $this->FeedImageWidth .= $data;          break;          default:          if (FeedForAll_parseExtensions() === TRUE) {            FeedForAll_parseExtensions_characterData($parser, $this, $data);          }        }      }      elseif (($this->insideChannel) && ($this->level == $this->level_channel+1)) {        switch ($this->tag) {          case "TITLE":          $this->FeedTitle .= $data;          break;          case "DESCRIPTION":          $this->FeedDescription .= $data;          break;          case "CONTENT:ENCODED":          $this->FeedContentEncoded .= $data;          break;          case "TAGLINE":          $this->FeedDescription .= $data;          break;          case "LINK":          $this->FeedLink .= $data;          break;          case "PUBDATE":          $this->FeedPubDate .= $data;          break;          case "MODIFIED":          $this->FeedPubDateDC .= $data;          break;          case "LASTBUILDDATE":          $this->FeedLastBuildDate .= $data;          break;          case "CREATIVECOMMONS:LICENSE":          $this->FeedCreativeCommons .= $data;          break;          case "UPDATED":          case "ATOM:UPDATED":          $this->FeedAtomUpdated .= $data;          break;                    case "CONTENT":          case "ATOM:CONTENT":          $this->FeedAtomContent .= $data;          break;                    default:          if ($this->tag == "DC:DATE") {            $this->FeedPubDateDC .= $data;          }          if (FeedForAll_parseExtensions() === TRUE) {            FeedForAll_parseExtensions_characterData($parser, $this, $data);          }        }      }      elseif (($this->insideAtomAuthor) && ($this->insideItem) && ($this->level == $this->level_item+2)) {        switch ($this->tag) {          case "EMAIL":          case "ATOM:EMAIL":          $this->currentItem->atomAuthorEmail .= $data;          break;                    default:          if (FeedForAll_parseExtensions() === TRUE) {            FeedForAll_parseExtensions_characterData($parser, $this, $data);          }        }      }      elseif (($this->insideAtomAuthor) && ($this->insideChannel) && ($this->level == $this->level_channel+2)) {        switch ($this->tag) {          case "EMAIL":          case "ATOM:EMAIL":          $this->FeedAtomAuthorEmail .= $data;          break;                    default:          if (FeedForAll_parseExtensions() === TRUE) {            FeedForAll_parseExtensions_characterData($parser, $this, $data);          }        }      } else {        if (FeedForAll_parseExtensions() === TRUE) {          FeedForAll_parseExtensions_characterData($parser, $this, $data);        }      }    }  }}if (function_exists("FeedForAll_parseExtensions_extendParserClass")) {  $currentBaseClassName = FeedForAll_parseExtensions_extendParserClass("rootRSSParserClass");} else {  $currentBaseClassName = "rootRSSParserClass";}eval('class baseParserClassWithExtensions extends ' . $currentBaseClassName . ' {}');class baseParserClass extends baseParserClassWithExtensions {  Function baseParserClass($operateAs) {    $parentClass = get_parent_class($this);    $this->$parentClass($operateAs);  }}?>

⌨️ 快捷键说明

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