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


PHP SimplePie_Misc::stripos方法代码示例

本文整理汇总了PHP中SimplePie_Misc::stripos方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie_Misc::stripos方法的具体用法?PHP SimplePie_Misc::stripos怎么用?PHP SimplePie_Misc::stripos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie_Misc的用法示例。


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

示例1: __construct

 public function __construct($mysql_location, $name, $extension)
 {
     $host = $mysql_location->get_host();
     if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') {
         $server = ':' . substr($host, 5, -1);
     } else {
         $server = $host;
         if ($mysql_location->get_port() !== null) {
             $server .= ':' . $mysql_location->get_port();
         }
     }
     if (strpos($mysql_location->get_userinfo(), ':') !== false) {
         list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
     } else {
         $username = $mysql_location->get_userinfo();
         $password = null;
     }
     if ($this->mysql = mysql_connect($server, $username, $password)) {
         $this->id = $name . $extension;
         $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
         if (!isset($this->options['prefix'][0])) {
             $this->options['prefix'][0] = '';
         }
         if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) && mysql_query('SET NAMES utf8') && ($query = mysql_unbuffered_query('SHOW TABLES'))) {
             $db = array();
             while ($row = mysql_fetch_row($query)) {
                 $db[] = $row[0];
             }
             if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) {
                 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))')) {
                     $this->mysql = null;
                 }
             }
             if (!in_array($this->options['prefix'][0] . 'items', $db)) {
                 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) {
                     $this->mysql = null;
                 }
             }
         } else {
             $this->mysql = null;
         }
     }
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:43,代码来源:simplepie.inc.php

示例2: init


//.........这里部分代码省略.........
                        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;
            }
            // First check to see if input has been overridden.
            if ($this->input_encoding !== false) {
                $encoding = $this->input_encoding;
            } elseif (isset($headers['content-type']) && preg_match('/;[\\x09\\x20]*charset=([^;]*)/i', $headers['content-type'], $charset)) {
                $encoding = $charset[1];
            } elseif (preg_match("/^<\\?xml[ \t\r\n]+version([ \t\r\n]+)?=([ \t\r\n]+)?(\"1.0\"|'1.0'|\"1.1\"|'1.1')[ \t\r\n]+encoding([ \t\r\n]+)?=([ \t\r\n]+)?(\"[A-Za-z][A-Za-z0-9._\\-]*\"|'[A-Za-z][A-Za-z0-9._\\-]*')([ \t\r\n]+standalone([ \t\r\n]+)?=([ \t\r\n]+)?(\"(yes|no)\"|'(yes|no)'))?([ \t\r\n]+)?\\?>/", $data, $prolog)) {
                $encoding = substr($prolog[6], 1, -1);
            } elseif (strpos($data, "��") === 0) {
                $encoding = 'UTF-32be';
            } elseif (strpos($data, "��") === 0) {
                $encoding = 'UTF-32';
            } elseif (strpos($data, "��") === 0) {
                $encoding = 'UTF-16be';
            } elseif (strpos($data, "��") === 0) {
                $encoding = 'UTF-16le';
            } elseif (strpos($data, "") === 0) {
                $encoding = 'UTF-8';
            } elseif (isset($headers['content-type']) && strtolower(SimplePie_Misc::parse_mime($headers['content-type'])) == 'text/xml') {
                $encoding = 'US-ASCII';
            } elseif (isset($headers['content-type']) && SimplePie_Misc::stripos(SimplePie_Misc::parse_mime($headers['content-type']), 'text/') === 0) {
                $encoding = 'ISO-8859-1';
            } else {
                $encoding = 'UTF-8';
            }
            // Change the encoding to UTF-8 (as we always use UTF-8 internally)
            if ($encoding != 'UTF-8') {
                $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8');
            }
            // Strip illegal characters
            $data = SimplePie_Misc::utf8_bad_replace($data);
            $parser = new $this->parser_class();
            $parser->pre_process($data, 'UTF-8');
            // If we want the XML, just output that and quit
            if ($this->xml_dump) {
                header('Content-type: text/xml; charset=UTF-8');
                echo $data;
                exit;
            } elseif ($parser->parse($data)) {
                unset($data);
                $this->data = $parser->get_data();
                if (isset($this->data['child'])) {
                    if (isset($headers)) {
                        $this->data['headers'] = $headers;
                    }
                    $this->data['build'] = SIMPLEPIE_BUILD;
                    // Cache the file if caching is enabled
                    if ($cache && !$cache->save($this->data)) {
                        trigger_error("{$cache->name} is not writeable", E_USER_WARNING);
                    }
                    return true;
                } 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;
                }
            } else {
                $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
                SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
                return false;
            }
        } elseif (!empty($this->multifeed_url)) {
            $i = 0;
            $success = 0;
            $this->multifeed_objects = array();
            foreach ($this->multifeed_url as $url) {
                if (SIMPLEPIE_PHP5) {
                    // This keyword needs to defy coding standards for PHP4 compatibility
                    $this->multifeed_objects[$i] = clone $this;
                } else {
                    $this->multifeed_objects[$i] = $this;
                }
                $this->multifeed_objects[$i]->set_feed_url($url);
                $success |= $this->multifeed_objects[$i]->init();
                $i++;
            }
            return (bool) $success;
        } else {
            return false;
        }
    }
开发者ID:pyfun,项目名称:dokuwiki,代码行数:101,代码来源:SimplePie.php


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