当前位置: 首页>>代码示例>>PHP>>正文


PHP fetch_file_contents函数代码示例

本文整理汇总了PHP中fetch_file_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP fetch_file_contents函数的具体用法?PHP fetch_file_contents怎么用?PHP fetch_file_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fetch_file_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load_page

 protected function load_page($link)
 {
     $doc = new DOMDocument();
     # curl does not follow the 301?
     $url = str_replace("-rss", "", $link);
     $html = fetch_file_contents($url, false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
     $html_enc = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
     $doc->loadHTML($html_enc);
     $basenode = false;
     $add_content = "";
     if ($doc) {
         $xpath = new DOMXPath($doc);
         $nextpage = $xpath->query('//table[@id="table-jtoc"]/tr/td/a[@id="atoc_next"]');
         if ($nextpage && $nextpage->length > 0 && $nextpage->item(0)->hasAttributes()) {
             $add_content = $this->load_page("http://www.golem.de" . $nextpage->item(0)->attributes->getNamedItem("href")->value);
         }
         // first remove advertisement stuff
         $stuff = $xpath->query('(//script)|(//noscript)|(//div[contain(@class, "iqad")])|(//ol[@id="list-jtoc"])|(//table[@id="table-jtoc"])|(//header[@class="cluster-header"]/h1)');
         foreach ($stuff as $removethis) {
             $removethis->parentNode->removeChild($removethis);
         }
         // now get the (cleaned) article
         $entries = $xpath->query('(//article)');
         foreach ($entries as $entry) {
             $basenode = $entry;
             break;
         }
         if ($basenode) {
             return $doc->saveXML($basenode) . $add_content;
         } else {
             return false;
         }
     }
 }
开发者ID:Verisor,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:34,代码来源:init.php

示例2: hook_article_filter

 function hook_article_filter($article)
 {
     if (strpos($article["link"], "raumfahrer.net") !== FALSE) {
         $doc = new DOMDocument();
         @$doc->loadHTML(fetch_file_contents($article["link"]));
         $basenode = false;
         // TODO: Add Express mp3 as attachment/enclosure once plugins are able to do that
         if ($doc) {
             $xpath = new DOMXPath($doc);
             $removestuff = $xpath->query('(//div[@class="druckansicht"])|(//td[@class="head"])');
             foreach ($removestuff as $entry) {
                 $entry->parentNode->removeChild($entry);
             }
             $entries = $xpath->query('(//td[@class="tab_text"])');
             foreach ($entries as $entry) {
                 $basenode = $entry->parentNode->parentNode;
                 break;
             }
             if ($basenode) {
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
     }
     return $article;
 }
开发者ID:EduardBaer,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:25,代码来源:init.php

示例3: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//img[@src])');
                 // we might also check for img[@class='strip'] I guess...
                 $matches = array();
                 foreach ($entries as $entry) {
                     if (preg_match("/(http:\\/\\/.*\\/db\\/files\\/Comics\\/.*)/i", $entry->getAttribute("src"), $matches)) {
                         $basenode = $entry;
                         break;
                     }
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:neynah,项目名称:Tiny-Tiny-RSS,代码行数:33,代码来源:af_comics_explosm.php

示例4: hook_article_filter

 function hook_article_filter($article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["guid"], "buttersafe.com") !== FALSE) {
         if (strpos($article["plugin_data"], "buttersafe,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//img[@src])');
                 $matches = array();
                 foreach ($entries as $entry) {
                     if (preg_match("/(http:\\/\\/buttersafe.com\\/comics\\/\\d{4}.*)/i", $entry->getAttribute("src"), $matches)) {
                         $basenode = $entry;
                         break;
                     }
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
                     $article["plugin_data"] = "buttersafe,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
     }
     return $article;
 }
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:31,代码来源:init.php

示例5: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXpath($doc);
                 $basenode = $xpath->query("//td/center/img")->item(0);
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:neynah,项目名称:Tiny-Tiny-RSS,代码行数:25,代码来源:af_comics_twp.php

示例6: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "erzaehlmirnix.wordpress.com/") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//img[contains(@src, "erzaehlmirnix.files.wordpress.com")])');
                 $found = false;
                 foreach ($entries as $entry) {
                     $basenode = $entry;
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:Verisor,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:29,代码来源:af_comics_erzaehlmirnix.php

示例7: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "userfriendly.org/cartoons") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8"));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//img[@alt])');
                 foreach ($entries as $entry) {
                     if (strpos($entry->getAttribute('alt'), 'Strip for') !== false) {
                         $basenode = $entry;
                         break;
                     }
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:EduardBaer,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:31,代码来源:af_comics_userfriendly.php

示例8: hook_article_filter

 function hook_article_filter($article)
 {
     if (strpos($article["link"], "hltv.org/news/") !== FALSE) {
         $doc = new DOMDocument();
         @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "auto"));
         $basenode = false;
         if ($doc) {
             $xpath = new DOMXPath($doc);
             // first remove advertisement stuff
             $stuff = $xpath->query('(//div[@id="_mcePaste"])');
             foreach ($stuff as $removethis) {
                 $removethis->parentNode->removeChild($removethis);
             }
             $entries = $xpath->query('(//div[@id="newsContent"])');
             foreach ($entries as $entry) {
                 $basenode = $entry;
                 break;
             }
             if ($basenode) {
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
     }
     return $article;
 }
开发者ID:Verisor,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:25,代码来源:init.php

示例9: hook_article_filter

 function hook_article_filter($article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "nationalgeographic.com") !== FALSE) {
         if (strpos($article["plugin_data"], "natgeo,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $basenode = $doc->getElementById("content_mainA");
                 $trash = $xpath->query("//*[@class='aside' or @id='livefyre' or @id='powered_by_livefyre' or @class='social_buttons']");
                 foreach ($trash as $t) {
                     $t->parentNode->removeChild($t);
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "natgeo,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
     }
     return $article;
 }
开发者ID:neynah,项目名称:Tiny-Tiny-RSS,代码行数:28,代码来源:init.php

示例10: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "blog.beetlebum.de") !== FALSE || strpos($article["link"], "fb-kundendienst.de") !== FALSE || strpos($article["link"], "marydeathcomics.com") !== FALSE || strpos($article["link"], "commitstrip.com") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//div[@class="entry-content"]//img[@src])|(//div[@id="content-wrapper"]//img[@src])');
                 foreach ($entries as $entry) {
                     if (preg_match("/(https?:\\/\\/.*\\/wp-content\\/uploads\\/.*)/i", $entry->getAttribute("src"))) {
                         $basenode = $entry;
                         break;
                     }
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:Verisor,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:31,代码来源:af_comics_wordpress.php

示例11: hook_article_filter

 function hook_article_filter($article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["guid"], "dilbert.com") !== FALSE) {
         if (strpos($article["plugin_data"], "dilbert,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $entries = $xpath->query('(//img[@src])');
                 // we might also check for img[@class='strip'] I guess...
                 $matches = array();
                 foreach ($entries as $entry) {
                     if (preg_match("/dyn\\/str_strip\\/.*zoom\\.gif\$/", $entry->getAttribute("src"), $matches)) {
                         $entry->setAttribute("src", rewrite_relative_url("http://dilbert.com/", $matches[0]));
                         $basenode = $entry;
                         break;
                     }
                 }
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "dilbert,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
     }
     return $article;
 }
开发者ID:cs-team,项目名称:tiny_tiny_rss-openshift-quickstart,代码行数:33,代码来源:init.php

示例12: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) {
         if (strpos($article["title"], "News:") === FALSE && strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             $doc = new DOMDocument();
             @$doc->loadHTML(fetch_file_contents($article["link"]));
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0);
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:neynah,项目名称:Tiny-Tiny-RSS,代码行数:25,代码来源:af_comics_cad.php

示例13: process

 function process(&$article)
 {
     $owner_uid = $article["owner_uid"];
     if (strpos($article["guid"], "bunicomic.com") !== FALSE || strpos($article["guid"], "buttersafe.com") !== FALSE || strpos($article["guid"], "whompcomic.com") !== FALSE || strpos($article["guid"], "extrafabulouscomics.com") !== FALSE || strpos($article["guid"], "happyjar.com") !== FALSE || strpos($article["guid"], "csectioncomics.com") !== FALSE) {
         if (strpos($article["plugin_data"], "af_comics,{$owner_uid}:") === FALSE) {
             // lol at people who block clients by user agent
             // oh noes my ad revenue Q_Q
             $res = fetch_file_contents($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
             $doc = new DOMDocument();
             @$doc->loadHTML($res);
             $basenode = false;
             if ($doc) {
                 $xpath = new DOMXPath($doc);
                 $basenode = $xpath->query('//div[@id="comic"]')->item(0);
                 if ($basenode) {
                     $article["content"] = $doc->saveXML($basenode);
                     $article["plugin_data"] = "af_comics,{$owner_uid}:" . $article["plugin_data"];
                 }
             }
         } else {
             if (isset($article["stored"]["content"])) {
                 $article["content"] = $article["stored"]["content"];
             }
         }
         return true;
     }
     return false;
 }
开发者ID:neynah,项目名称:Tiny-Tiny-RSS,代码行数:28,代码来源:af_comics_comicpress.php

示例14: process

 function process(&$article)
 {
     if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
         if ($debug_enabled) {
             _debug("af_pennyarcade: Processing comic");
         }
         $doc = new DOMDocument();
         $doc->loadHTML(fetch_file_contents($article["link"]));
         $basenode = false;
         if ($doc) {
             $xpath = new DOMXPath($doc);
             $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
             if ($basenode) {
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
         return true;
     }
     if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
         if ($debug_enabled) {
             _debug("af_pennyarcade: Processing news post");
         }
         $doc = new DOMDocument();
         $doc->loadHTML(fetch_file_contents($article["link"]));
         if ($doc) {
             $xpath = new DOMXPath($doc);
             $entries = $xpath->query('(//div[@class="post"])');
             $basenode = false;
             foreach ($entries as $entry) {
                 $basenode = $entry;
             }
             $meta = $xpath->query('(//div[@class="meta"])')->item(0);
             if ($meta->parentNode) {
                 $meta->parentNode->removeChild($meta);
             }
             $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0);
             if ($header->parentNode) {
                 $header->parentNode->removeChild($header);
             }
             $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0);
             if ($header->parentNode) {
                 $header->parentNode->removeChild($header);
             }
             $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0);
             if ($basenode) {
                 $basenode->insertBefore($avatar, $basenode->firstChild);
             }
             $uninteresting = $xpath->query('(//div[@class="avatar"])');
             foreach ($uninteresting as $i) {
                 $i->parentNode->removeChild($i);
             }
             if ($basenode) {
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:XelaRellum,项目名称:tt-rss,代码行数:59,代码来源:af_comics_pa.php

示例15: process

 function process(&$article)
 {
     if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
         $doc = new DOMDocument();
         @$doc->loadHTML(fetch_file_contents($article["link"]));
         $basenode = false;
         if ($doc) {
             $xpath = new DOMXpath($doc);
             $basenode = $xpath->query("//td/center/img")->item(0);
             if ($basenode) {
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:XelaRellum,项目名称:tt-rss,代码行数:17,代码来源:af_comics_twp.php


注:本文中的fetch_file_contents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。