stripos() public method

Returns the numeric position of the first occurrence of needle in the haystack string.
public stripos ( object $haystack, string $needle, integer $offset ) : boolean
$haystack object
$needle string Note that the needle may be a string of one or more characters. If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
$offset integer The optional offset parameter allows you to specify which character in haystack to start searching. The position returned is still relative to the beginning of haystack.
return boolean If needle is not found, stripos() will return boolean false.
Beispiel #1
0
 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;
         }
     }
 }
Beispiel #2
0
    function init()
    {
        if (function_exists('version_compare') && version_compare(PHP_VERSION, '4.1.0', '<') || !extension_loaded('xml') || !extension_loaded('pcre')) {
            return false;
        }
        if (isset($_GET[$this->javascript])) {
            if (function_exists('ob_gzhandler')) {
                ob_start('ob_gzhandler');
            }
            header('Content-type: text/javascript; charset: UTF-8');
            header('Cache-Control: must-revalidate');
            header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT');
            // 7 days
            ?>
function embed_odeo(link) {
	document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
}

function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
	if (placeholder != '') {
		document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
	}
	else {
		document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
	}
}

function embed_flash(bgcolor, width, height, link, loop, type) {
	document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
}

function embed_flv(width, height, link, placeholder, loop, player) {
	document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
}

function embed_wmedia(width, height, link) {
	document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
}
			<?php 
            exit;
        }
        // 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->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 = new $this->cache_class($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();
                                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 (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;
            }
            // 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;
        }
    }