本文整理汇总了PHP中SimplePie_Misc::error方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie_Misc::error方法的具体用法?PHP SimplePie_Misc::error怎么用?PHP SimplePie_Misc::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie_Misc
的用法示例。
在下文中一共展示了SimplePie_Misc::error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
//.........这里部分代码省略.........
if (isset($this->data['headers']['etag'])) {
$headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
}
$file =& new $this->file_class($this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success) {
if ($file->status_code == 304) {
$cache->touch();
return true;
} else {
$headers = $file->headers;
}
} else {
unset($file);
}
}
} else {
return true;
}
} else {
$cache->unlink();
$this->data = array();
}
}
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file)) {
if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url) {
$file =& $this->file;
} else {
$file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
}
}
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success) {
$this->error = $file->error;
if (!empty($this->data)) {
return true;
} else {
return false;
}
}
if (!$this->force_feed) {
// Check if the supplied URL is a feed, if it isn't, look for it.
$locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
if (!$locate->is_feed($file)) {
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
unset($file);
if ($file = $locate->find($this->autodiscovery)) {
if ($cache) {
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
if (!$cache->save($this)) {
trigger_error("{$cache->name} is not writeable", E_USER_WARNING);
}
$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
}
$this->feed_url = $file->url;
} else {
$this->error = "A feed could not be found at {$this->feed_url}";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
}
$locate = null;
}
$headers = $file->headers;
$data = $file->body;
$sniffer = new $this->content_type_sniffer_class($file);
示例2: init
public function init()
{
// Check absolute bare minimum requirements.
if (function_exists('version_compare') && version_compare(PHP_VERSION, '5.0', '<') || !extension_loaded('xml') || !extension_loaded('pcre')) {
return false;
} elseif (!extension_loaded('xmlreader')) {
static $xml_is_sane = null;
if ($xml_is_sane === null) {
$parser_check = xml_parser_create();
xml_parse_into_struct($parser_check, '<foo>&</foo>', $values);
xml_parser_free($parser_check);
$xml_is_sane = isset($values[0]['value']);
}
if (!$xml_is_sane) {
return false;
}
}
// Pass whatever was set with config options over to the sanitizer.
$this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
$this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
if ($this->feed_url !== null || $this->raw_data !== null) {
$this->error = null;
$this->data = array();
$this->multifeed_objects = array();
$cache = false;
if ($this->feed_url !== null) {
$parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
// Decide whether to enable caching
if ($this->cache && $parsed_feed_url['scheme'] !== '') {
$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
}
// If it's enabled and we don't want an XML dump, use the cache
if ($cache && !$this->xml_dump) {
// Load the Cache
$this->data = $cache->load();
if (!empty($this->data)) {
// If the cache is for an outdated build of SimplePie
if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) {
$cache->unlink();
$this->data = array();
} elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) {
$cache = false;
$this->data = array();
} elseif (isset($this->data['feed_url'])) {
// If the autodiscovery cache is still valid use it.
if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) {
// Do not need to do feed autodiscovery yet.
if ($this->data['feed_url'] === $this->data['url']) {
$cache->unlink();
$this->data = array();
} else {
$this->set_feed_url($this->data['feed_url']);
return $this->init();
}
}
} elseif ($cache->mtime() + $this->cache_duration < time()) {
// If we have last-modified and/or etag set
if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
if (isset($this->data['headers']['last-modified'])) {
$headers['if-modified-since'] = $this->data['headers']['last-modified'];
}
if (isset($this->data['headers']['etag'])) {
$headers['if-none-match'] = $this->data['headers']['etag'];
}
$file = new $this->file_class($this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success) {
if ($file->status_code === 304) {
$cache->touch();
return true;
} else {
$headers = $file->headers;
}
} else {
unset($file);
}
}
} else {
return true;
}
} else {
$cache->unlink();
$this->data = array();
}
}
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file)) {
if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) {
$file =& $this->file;
} else {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
$file = new $this->file_class($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen);
}
}
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
$this->error = $file->error;
if (!empty($this->data)) {
return true;
} else {
//.........这里部分代码省略.........
示例3: init
//.........这里部分代码省略.........
$file = new $this->file_class($this->rss_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success) {
$headers = $file->headers();
if ($headers['status']['code'] == 304) {
$cache->touch();
return true;
}
} else {
unset($file);
}
} else {
$cache->unlink();
}
} else {
return true;
}
}
}
} else {
$cache->unlink();
}
}
$this->data = array();
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file)) {
if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->rss_url) {
$file =& $this->file;
} else {
$file = new $this->file_class($this->rss_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
}
}
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success) {
$this->error = $file->error;
return false;
}
// Check if the supplied URL is a feed, if it isn't, look for it.
$locate = new $this->locator_class($file, $this->timeout, $this->useragent);
if (!$locate->is_feed($file)) {
$feed = $locate->find();
if ($feed) {
if ($cache && !$cache->save(array('url' => $this->rss_url, 'feed_url' => $feed))) {
$this->error = "{$cache->name} is not writeable";
SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
}
$this->rss_url = $feed;
return $this->init();
} else {
$this->error = "A feed could not be found at {$this->rss_url}";
SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
return false;
}
}
$headers = $file->headers();
$data = trim($file->body());
$file->close();
unset($file);
} else {
$data = $this->raw_data;
}
// First check to see if input has been overridden.
if (!empty($this->input_encoding)) {
$encoding = $this->input_encoding;
} else {
if (!empty($headers['content-type']) && preg_match('/charset\\s*=\\s*([^;]*)/i', $headers['content-type'], $charset)) {
$encoding = $charset[1];
示例4: init
public function init()
{
if (function_exists('version_compare') && version_compare(PHP_VERSION, '5.0', '<') || !extension_loaded('xml') || !extension_loaded('pcre')) {
return false;
} elseif (!extension_loaded('xmlreader')) {
static $xml_is_sane = null;
if ($xml_is_sane === null) {
$parser_check = xml_parser_create();
xml_parse_into_struct($parser_check, '<foo>&</foo>', $values);
xml_parser_free($parser_check);
$xml_is_sane = isset($values[0]['value']);
}
if (!$xml_is_sane) {
return false;
}
}
$this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
$this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
if ($this->feed_url !== null || $this->raw_data !== null) {
$this->error = null;
$this->data = array();
$this->multifeed_objects = array();
$cache = false;
if ($this->feed_url !== null) {
$parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
if ($this->cache && $parsed_feed_url['scheme'] !== '') {
$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
}
if ($cache && !$this->xml_dump) {
$this->data = $cache->load();
if (!empty($this->data)) {
if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) {
$cache->unlink();
$this->data = array();
} elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) {
$cache = false;
$this->data = array();
} elseif (isset($this->data['feed_url'])) {
if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) {
if ($this->data['feed_url'] === $this->data['url']) {
$cache->unlink();
$this->data = array();
} else {
$this->set_feed_url($this->data['feed_url']);
return $this->init();
}
}
} elseif ($cache->mtime() + $this->cache_duration < time()) {
if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
if (isset($this->data['headers']['last-modified'])) {
$headers['if-modified-since'] = $this->data['headers']['last-modified'];
}
if (isset($this->data['headers']['etag'])) {
$headers['if-none-match'] = $this->data['headers']['etag'];
}
$file = new $this->file_class($this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success) {
if ($file->status_code === 304) {
$cache->touch();
return true;
} else {
$headers = $file->headers;
}
} else {
unset($file);
}
}
} else {
$this->raw_data = false;
return true;
}
} else {
$cache->unlink();
$this->data = array();
}
}
if (!isset($file)) {
if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) {
$file =& $this->file;
} else {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
$file = new $this->file_class($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen);
}
}
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
$this->error = $file->error;
if (!empty($this->data)) {
return true;
} else {
return false;
}
}
if (!$this->force_feed) {
$locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
if (!$locate->is_feed($file)) {
unset($file);
if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) {
if ($cache) {
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
//.........这里部分代码省略.........
示例5: init
//.........这里部分代码省略.........
if (isset($this->data['headers']['etag'])) {
$headers['if-none-match'] = $this->data['headers']['etag'];
}
$file = new $this->file_class($this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success) {
if ($file->status_code == 304) {
$cache->touch();
return true;
} else {
$headers = $file->headers;
}
} else {
unset($file);
}
}
} else {
return true;
}
} else {
$cache->unlink();
$this->data = array();
}
}
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file)) {
if (SimplePie_Misc::is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url) {
$file =& $this->file;
} else {
$file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
}
}
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success) {
$this->error = $file->error;
if (!empty($this->data)) {
return true;
} else {
return false;
}
}
// Check if the supplied URL is a feed, if it isn't, look for it.
$locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds);
if (!$locate->is_feed($file)) {
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
unset($file);
if ($file = $locate->find($this->autodiscovery)) {
if ($cache) {
if (!$cache->save(array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD))) {
trigger_error("{$cache->name} is not writeable", E_USER_WARNING);
}
$cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
}
$this->feed_url = $file->url;
} else {
$this->error = "A feed could not be found at {$this->feed_url}";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
}
$locate = null;
$headers = $file->headers;
$data = trim($file->body);
unset($file);
} else {
$data = $this->raw_data;
}