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


PHP _fetch_remote_file函数代码示例

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


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

示例1: fetch_rss

 /**
  * Build Magpie object based on RSS from URL.
  *
  * @since 1.5.0
  * @package External
  * @subpackage MagpieRSS
  *
  * @param string $url URL to retrieve feed
  * @return bool|MagpieRSS false on failure or MagpieRSS object on success.
  */
 function fetch_rss($url)
 {
     // initialize constants
     init();
     if (!isset($url)) {
         // error("fetch_rss called without a url");
         return false;
     }
     // if cache is disabled
     if (!MAGPIE_CACHE_ON) {
         // fetch file, and parse it
         $resp = _fetch_remote_file($url);
         if (is_success($resp->status)) {
             return _response_to_rss($resp);
         } else {
             // error("Failed to fetch $url and cache is off");
             return false;
         }
     } else {
         // Flow
         // 1. check cache
         // 2. if there is a hit, make sure its fresh
         // 3. if cached obj fails freshness check, fetch remote
         // 4. if remote fails, return stale object, or error
         $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE);
         if (MAGPIE_DEBUG and $cache->ERROR) {
             debug($cache->ERROR, E_USER_WARNING);
         }
         $cache_status = 0;
         // response of check_cache
         $request_headers = array();
         // HTTP headers to send with fetch
         $rss = 0;
         // parsed RSS object
         $errormsg = 0;
         // errors, if any
         if (!$cache->ERROR) {
             // return cache HIT, MISS, or STALE
             $cache_status = $cache->check_cache($url);
         }
         // if object cached, and cache is fresh, return cached obj
         if ($cache_status == 'HIT') {
             $rss = $cache->get($url);
             if (isset($rss) and $rss) {
                 $rss->from_cache = 1;
                 if (MAGPIE_DEBUG > 1) {
                     debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
                 }
                 return $rss;
             }
         }
         // else attempt a conditional get
         // set up headers
         if ($cache_status == 'STALE') {
             $rss = $cache->get($url);
             if (isset($rss->etag) and $rss->last_modified) {
                 $request_headers['If-None-Match'] = $rss->etag;
                 $request_headers['If-Last-Modified'] = $rss->last_modified;
             }
         }
         $resp = _fetch_remote_file($url, $request_headers);
         if (isset($resp) and $resp) {
             if ($resp->status == '304') {
                 // we have the most current copy
                 if (MAGPIE_DEBUG > 1) {
                     debug("Got 304 for {$url}");
                 }
                 // reset cache on 304 (at minutillo insistent prodding)
                 $cache->set($url, $rss);
                 return $rss;
             } elseif (is_success($resp->status)) {
                 $rss = _response_to_rss($resp);
                 if ($rss) {
                     if (MAGPIE_DEBUG > 1) {
                         debug("Fetch successful");
                     }
                     // add object to cache
                     $cache->set($url, $rss);
                     return $rss;
                 }
             } else {
                 $errormsg = "Failed to fetch {$url}. ";
                 if ($resp->error) {
                     # compensate for Snoopy's annoying habbit to tacking
                     # on '\n'
                     $http_error = substr($resp->error, 0, -2);
                     $errormsg .= "(HTTP Error: {$http_error})";
                 } else {
                     $errormsg .= "(HTTP Response: " . $resp->response_code . ')';
                 }
//.........这里部分代码省略.........
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:101,代码来源:rss.php

示例2: filter

   the "comments.php" file within the "Comments Loop" with the following line.
   <br/>
      if(function_exists(ckrating_display_karma)) { ckrating_display_karma(); }
   </p>
   <p>
   <b>Styling the Comment Box:</b>
   The comment styling uses the new
   comment_class filter (introduced in Wordpress 2.7). If your
   theme doesn't use Wordpress 2.7 wp_list_comments(),
   you'll only see the comment text background being styled/highlighted. To
   fix the problem, you need to add comment_class into your existing
   theme. For example code, please see <a
   href="http://brassblogs.com/blog/wordpress-27-and-comment-display">here</a>.
   </p>

<h2>News</h2> <ul style="list-style-type:disc;margin-left: 15px; margin-right:20px;">
<?php 
require_once ABSPATH . WPINC . '/rss.php';
$resp = _fetch_remote_file('http://WealthyNetizen.com/feed/');
if (is_success($resp->status)) {
    $rss = _response_to_rss($resp);
    $blog_posts = array_slice($rss->items, 0, 3);
    $posts_arr = array();
    foreach ($blog_posts as $item) {
        echo '<li><a href="' . $item['link'] . '">' . $item['title'] . '</a><br>' . $item['description'] . '</li>';
    }
}
print '</ul>';
?>
</div>
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:30,代码来源:comment-rating-options.php

示例3: ob_end_flush

</head>

<body>
<h3>Feeds importieren</h3>

<?php 
include './libs/URL.php';
ob_end_flush();
$_ok = TRUE;
if (isset($_FILES['probe']) || !empty($_POST['url'])) {
    require_once 'magpie/rss_fetch.inc';
    require_once 'magpie/rss_parse.inc';
    #require_once('magpie/rss_utils.inc');
    if (!empty($_POST['url'])) {
        if (validateUrlSyntax($_POST['url'], 's+a+')) {
            if (!($snoopy = _fetch_remote_file($_POST['url']))) {
                echo "Ich kann " . $_POST['url'] . " nicht ?en...<br />";
                $_ok = FALSE;
            }
            $simple = $snoopy->results;
            unset($snoopy);
        } else {
            echo "Also, " . $_POST['url'] . " ist aber keine richtige URL...<br />";
            $_ok = FALSE;
        }
    } elseif (isset($_FILES['probe'])) {
        $name = "temp/" . time() . ".opml";
        $_ok = move_uploaded_file($_FILES['probe']['tmp_name'], $name);
        $simple = implode("", file($name));
    }
    if ($_ok) {
开发者ID:BackupTheBerlios,项目名称:erona,代码行数:31,代码来源:import.php

示例4: fof_add_feed

function fof_add_feed($url)
{
    if (!$url) {
        return;
    }
    global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;
    $FOF_FEED_TABLE = FOF_FEED_TABLE;
    $FOF_ITEM_TABLE = FOF_ITEM_TABLE;
    $url = trim($url);
    if (substr($url, 0, 7) != 'http://') {
        $url = 'http://' . $url;
    }
    print "Attempting to subscribe to <a href=\"{$url}\">{$url}</a>...<br>";
    if ($row = fof_is_subscribed($url)) {
        print "You are already subscribed to " . fof_render_feed_link($row) . "<br><br>";
        return true;
    }
    $rss = fetch_rss($url);
    if (!$rss->channel && !$rss->items) {
        echo "&nbsp;&nbsp;<font color=\"darkgoldenrod\">URL is not RSS or is invalid.</font><br>";
        if (!$rss) {
            echo "&nbsp;&nbsp;(error was: <B>" . magpie_error() . "</b>)<br>";
        }
        echo "&nbsp;&nbsp;<a href=\"http://feeds.archive.org/validator/check?url={$url}\">The validator may give more information.</a><br>";
        echo "<br>Attempting autodiscovery...<br><br>";
        $r = _fetch_remote_file($url);
        $c = $r->results;
        if ($c && $r->status >= 200 && $r->status < 300) {
            $l = fof_getRSSLocation($c, $url);
            if ($l) {
                echo "Autodiscovery found <a href=\"{$l}\">{$l}</a>.<br>";
                echo "Attempting to subscribe to <a href=\"{$l}\">{$l}</a>...<br>";
                if ($row = fof_is_subscribed($l)) {
                    print "<br>You are already subscribed to " . fof_render_feed_link($row) . "<br>";
                    return true;
                }
                $rss = fetch_rss($l);
                if (!$rss->channel && !$rss->items) {
                    echo "&nbsp;&nbsp;<font color=\"red\">URL is not RSS, giving up.</font><br>";
                    echo "&nbsp;&nbsp;(error was: <B>" . magpie_error() . "</b>)<br>";
                    echo "&nbsp;&nbsp;<a href=\"http://feeds.archive.org/validator/check?url={$l}\">The validator may give more information.</a><br>";
                } else {
                    fof_actually_add_feed($l, $rss);
                    echo "&nbsp;&nbsp;<font color=\"green\"><b>Subscribed.</b></font><br><br>";
                }
            } else {
                echo "<font color=\"red\"><b>Autodiscovery failed.  Giving up.</b></font><br>";
            }
        } else {
            echo "<font color=\"red\"><b>Can't load URL.  Giving up.</b></font><br>";
        }
    } else {
        fof_actually_add_feed($url, $rss);
        echo "<font color=\"green\"><b>Subscribed.</b></font><br>";
    }
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:56,代码来源:init.php

示例5: noel_theme_display

function noel_theme_display()
{
    ?>
	<div class="wrap">
		<h2><?php 
    _e('Noel Theme Options', 'noel');
    ?>
</h2>
		<?php 
    settings_errors();
    ?>
		<form method="post" action="options.php">
			<?php 
    settings_fields('noel_theme_general_options');
    do_settings_sections('noel_theme_general_options');
    submit_button();
    ?>
		</form>

		<hr/>
		
		<style>
			.mimicpro-feed {
				list-style-type: disc;
				padding-left: 20px;
			}
			.mimicpro-donate {
				float: right;
				width: 250px;
				padding: 15px;
				margin: 0 0 15px 15px;
				border: 1px solid #e5e5e5;
				background-color: #e5e5e5;
				text-align: center;
			}
		</style>
		
		<div class="mimicpro-donate">
			<p>The author spends many hours working to create this theme.</p>
			<p>If you found this theme useful for you, please consider donating a little fortune for the author.</p>
			<p>Thank you.</p>
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
			<input type="hidden" name="cmd" value="_s-xclick">
			<input type="hidden" name="hosted_button_id" value="K6775WC99DFQ6">
			<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
			<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
			</form>
		</div>
		
		<h3><?php 
    _e('News', 'noel');
    ?>
</h3>
		
		<ul class="mimicpro-feed">
		<?php 
    require_once ABSPATH . WPINC . '/rss.php';
    $resp = _fetch_remote_file('http://mimic-project.com/feed/');
    if (is_success($resp->status)) {
        $rss = _response_to_rss($resp);
        $blog_posts = array_slice($rss->items, 0, 4);
        $posts_arr = array();
        foreach ($blog_posts as $item) {
            echo '<li><a href="' . $item['link'] . '" style="font-size:120%;">' . $item['title'] . '</a><br>' . $item['description'] . '</li>';
        }
    }
    print '</ul>';
    ?>
		<div style="clear:both;"></div>
	</div>
<?php 
}
开发者ID:KasaiDot,项目名称:WP-Theme_Mime-DAL,代码行数:72,代码来源:functions.php

示例6: _get

 function _get($uri = NULL)
 {
     if ($uri) {
         $this->uri = $uri;
     }
     // Is the result not yet cached?
     if ($this->_cache_uri !== $this->uri) {
         $headers['Connection'] = 'close';
         $headers['Accept'] = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*';
         $headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress';
         // Use function provided by MagpieRSS package
         $client = _fetch_remote_file($this->uri, $headers);
         if (isset($client->error)) {
             $this->_error = $client->error;
         } else {
             $this->_error = NULL;
         }
         $this->_data = $client->results;
         // Kilroy was here
         $this->_cache_uri = $this->uri;
     }
 }
开发者ID:jcbozonier,项目名称:master,代码行数:22,代码来源:feedwordpress.php


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