本文整理汇总了PHP中stristr函数的典型用法代码示例。如果您正苦于以下问题:PHP stristr函数的具体用法?PHP stristr怎么用?PHP stristr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stristr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: isBackendUser
/**
* Helper-method to determine whether an user is a backend user
*
* @param mixed $user User object or identifier
* @param string $type Either object, email or username
* @return boolean
*/
public static function isBackendUser($user = null, $type = 'object')
{
// Check for empty user
if (empty($user)) {
return false;
}
// Get the right instance
if ($user instanceof JUser == false) {
if ($type == 'email') {
$user = MageBridge::getUser()->loadByEmail($user);
}
if ($type == 'username') {
$user = MageBridge::getUser()->loadByUsername($user);
}
}
// Check the legacy usertype parameter
if (!empty($user->usertype) && (stristr($user->usertype, 'administrator') || stristr($user->usertype, 'manager'))) {
return false;
}
// Check for ACL access
if (method_exists($user, 'authorise') && $user->authorise('core.admin')) {
return true;
}
return false;
}
开发者ID:apiceweb,项目名称:MageBridgeCore,代码行数:32,代码来源:user.php
示例2: _isFetchQuery
protected function _isFetchQuery($sql)
{
if (stristr($sql, "DELETE FROM ") || stristr($sql, "UPDATE ") || stristr($sql, "INSERT ")) {
return false;
}
return true;
}
开发者ID:rockholla,项目名称:zend-framework-ext,代码行数:7,代码来源:DatabaseTable.php
示例3: isMobile
/**
* 判断客户端是否是手机端
* @return bool
*/
public static function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
return true;
}
// 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
if (isset($_SERVER['HTTP_VIA'])) {
// 找不到为flase,否则为true
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
// 脑残法,判断手机发送的客户端标志,兼容性有待提高
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
return true;
}
}
// 协议法,因为有可能不准确,放到最后判断
if (isset($_SERVER['HTTP_ACCEPT'])) {
// 如果只支持wml并且不支持html那一定是移动设备
// 如果支持wml和html但是wml在html之前则是移动设备
if (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))) {
return true;
}
}
return false;
}
开发者ID:minms,项目名称:unitils,代码行数:33,代码来源:Environments.php
示例4: loadVariable
private function loadVariable($line)
{
if (stristr($line, '=')) {
$config = explode('=', $line);
$this->variables[trim($config[0])] = trim($config[1]);
}
}
开发者ID:krzystof,项目名称:wharf,代码行数:7,代码来源:EnvFile.php
示例5: search_doc_files
function search_doc_files($s)
{
$a = get_app();
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
$regexop = db_getfunc('REGEXP');
$r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC));
$r = fetch_post_tags($r, true);
for ($x = 0; $x < count($r); $x++) {
$r[$x]['text'] = $r[$x]['body'];
$r[$x]['rank'] = 0;
if ($r[$x]['term']) {
foreach ($r[$x]['term'] as $t) {
if (stristr($t['term'], $s)) {
$r[$x]['rank']++;
}
}
}
if (stristr($r[$x]['sid'], $s)) {
$r[$x]['rank']++;
}
$r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
// bias the results to the observer's native language
if ($r[$x]['lang'] === App::$language) {
$r[$x]['rank'] = $r[$x]['rank'] + 10;
}
}
usort($r, 'doc_rank_sort');
return $r;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:31,代码来源:help.php
示例6: is_strinclude
function is_strinclude($str, $needle, $type = 0)
{
if (!$needle) {
return false;
}
$flag = true;
if (function_exists('stripos')) {
if ($type == 0) {
if (stripos($str, $needle) === false) {
$flag = false;
}
} else {
if ($type == 1) {
if (strpos($str, $needle) === false) {
$flag = false;
}
}
}
} else {
if ($type == 0) {
if (stristr($str, $needle) === false) {
$flag = false;
}
} else {
if ($type == 1) {
if (strstr($str, $needle) === false) {
$flag = false;
}
}
}
}
return $flag;
}
开发者ID:nanfs,项目名称:lt,代码行数:33,代码来源:old_head.php
示例7: parseAndValidateArguments
function parseAndValidateArguments($args)
{
global $validArgKeys;
$params = array();
foreach ($args as $arg) {
if (stristr($arg, '=')) {
$argKeyValue = explode('=', $arg);
if (count($argKeyValue) === 2) {
// check if it's a valid key-value argument
if (in_array($argKeyValue[0], $validArgKeys)) {
// check the key for validity
$params[$argKeyValue[0]] = $argKeyValue[1];
}
}
}
}
if (count($params) === count($validArgKeys)) {
// @TODO: check the values per key for validity all needs to be numeric but comment a string...
return $params;
} else {
// not enough valid arguments given:
// we simple stop the ongoing process and return none zero.
echo "ERROR 1";
return array();
}
}
开发者ID:Taquma,项目名称:CavAir2,代码行数:26,代码来源:insertSensorData.php
示例8: prepareRequest
/**
* Modify the url and add headers appropriate to authenticate to Acquia Search.
*
* @return
* The nonce used in the request.
*/
protected function prepareRequest(&$url, &$options, $use_data = TRUE)
{
// Add a unique request ID to the URL.
$id = uniqid();
if (!stristr($url, '?')) {
$url .= "?";
} else {
$url .= "&";
}
$url .= 'request_id=' . $id;
// If we're hosted on Acquia, and have an Acquia request ID,
// append it to the request so that we map Solr queries to Acquia search requests.
if (isset($_ENV['HTTP_X_REQUEST_ID'])) {
$xid = empty($_ENV['HTTP_X_REQUEST_ID']) ? '-' : $_ENV['HTTP_X_REQUEST_ID'];
$url .= '&x-request-id=' . rawurlencode($xid);
}
if ($use_data && isset($options['data'])) {
list($cookie, $nonce) = acquia_search_auth_cookie($url, $options['data'], NULL, $this->env_id);
} else {
list($cookie, $nonce) = acquia_search_auth_cookie($url, NULL, NULL, $this->env_id);
}
if (empty($cookie)) {
throw new Exception('Invalid authentication string - subscription keys expired or missing.');
}
$options['headers']['Cookie'] = $cookie;
$options['headers'] += array('User-Agent' => 'acquia_search/' . variable_get('acquia_search_version', '7.x'));
$options['context'] = acquia_agent_stream_context_create($url, 'acquia_search');
if (!$options['context']) {
throw new Exception(t("Could not create stream context"));
}
return $nonce;
}
开发者ID:reveillette,项目名称:CEML,代码行数:38,代码来源:Acquia_Search_Service.php
示例9: getValueFromOptions
public static function getValueFromOptions($field, $value, $config = array())
{
$opts = explode('||', $field->options);
if ($value == '') {
return $value;
}
if (count($opts)) {
$exist = false;
foreach ($opts as $opt) {
$o = explode('=', $opt);
if ($config['doTranslation'] && trim($o[0])) {
$o[0] = JText::_('COM_CCK_' . str_replace(' ', '_', trim($o[0])));
}
// if ( strcasecmp( $o[0], $value ) == 0 ) {
if (stristr($o[0], $value) !== false) {
return isset($o[1]) ? $o[1] : $o[0];
break;
}
}
if ($exist === true) {
$value[] = $val;
}
}
return $value;
}
开发者ID:kolydart,项目名称:SEBLOD,代码行数:25,代码来源:field.php
示例10: isMobile
function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
return true;
}
// 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
if (isset($_SERVER['HTTP_VIA'])) {
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
// 脑残法,判断手机发送的客户端标志,兼容性有待提高
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$clientkeywords = array('iphone', 'android', 'mobile');
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
return true;
}
}
// 协议法,因为有可能不准确,放到最后判断
if (isset($_SERVER['HTTP_ACCEPT'])) {
// 如果只支持wml并且不支持html那一定是移动设备
// 如果支持wml和html但是wml在html之前则是移动设备
if (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))) {
return true;
}
}
return false;
}
开发者ID:zhangpanfei,项目名称:test,代码行数:28,代码来源:判断是否移动端.php
示例11: setTabs
function setTabs($a_show_settings = true)
{
global $lng, $ilHelp;
$ilHelp->setScreenIdComponent("wfld");
$this->ctrl->setParameter($this, "wsp_id", $this->node_id);
$this->tabs_gui->addTab("wsp", $lng->txt("wsp_tab_personal"), $this->ctrl->getLinkTarget($this, ""));
$this->ctrl->setParameterByClass("ilObjWorkspaceRootFolderGUI", "wsp_id", $this->getAccessHandler()->getTree()->getRootId());
$this->tabs_gui->addTab("share", $lng->txt("wsp_tab_shared"), $this->ctrl->getLinkTargetByClass("ilObjWorkspaceRootFolderGUI", "shareFilter"));
$this->tabs_gui->addTab("ownership", $lng->txt("wsp_tab_ownership"), $this->ctrl->getLinkTargetByClass(array("ilObjWorkspaceRootFolderGUI", "ilObjectOwnershipManagementGUI"), "listObjects"));
if (!$this->ctrl->getNextClass($this)) {
if (stristr($this->ctrl->getCmd(), "share")) {
$this->tabs_gui->activateTab("share");
} else {
$this->tabs_gui->activateTab("wsp");
if ($a_show_settings) {
if ($this->checkPermissionBool("read")) {
$this->tabs_gui->addSubTab("content", $lng->txt("content"), $this->ctrl->getLinkTarget($this, ""));
}
if ($this->checkPermissionBool("write")) {
$this->tabs_gui->addSubTab("settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "edit"));
}
}
}
}
}
开发者ID:arlendotcn,项目名称:ilias,代码行数:25,代码来源:class.ilObjWorkspaceFolderGUI.php
示例12: getBrowser
public static function getBrowser()
{
$browsers = "mozilla msie gecko firefox ";
$browsers .= "konqueror safari netscape navigator ";
$browsers .= "opera mosaic lynx amaya omniweb";
$browsers = explode(" ", $browsers);
$nua = strToLower($_SERVER['HTTP_USER_AGENT']);
$res = array();
$l = strlen($nua);
for ($i = 0; $i < count($browsers); $i++) {
$browser = $browsers[$i];
$n = stristr($nua, $browser);
if (strlen($n) > 0) {
$res["version"] = "";
$res["browser"] = $browser;
$j = strpos($nua, $res["browser"]) + $n + strlen($res["browser"]) + 1;
for (; $j <= $l; $j++) {
$s = substr($nua, $j, 1);
if (is_numeric($res["version"] . $s)) {
$res["version"] .= $s;
}
break;
}
}
}
return $res;
}
开发者ID:kotow,项目名称:work,代码行数:27,代码来源:Website.php
示例13: Leech
public function Leech($url)
{
list($url, $pass) = $this->linkpassword($url);
$data = $this->lib->curl($url, $this->lib->cookie, "");
if ($pass) {
$post = $this->parseForm($this->lib->cut_str($data, '<Form name="F1"', '</Form>'));
$post["password"] = $pass;
$data = $this->lib->curl($url, $this->lib->cookie, $post);
if (stristr($data, 'Wrong password')) {
$this->error("wrongpass", true, false);
} elseif (preg_match('@http:\\/\\/(\\w+\\.)?1st-files\\.com\\/d\\/[^"\'><\\r\\n\\t]+@i', $data, $giay)) {
return trim($giay[0]);
}
}
if (stristr($data, '<br><b>Password:</b> <input type="password"')) {
$this->error("reportpass", true, false);
} elseif (stristr($data, '>File Not Found<')) {
$this->error("dead", true, false, 2);
} elseif (!$this->isredirect($data)) {
$post = $this->parseForm($this->lib->cut_str($data, '<Form name="F1"', '</Form>'));
$data = $this->lib->curl($url, $this->lib->cookie, $post);
if (preg_match('@http:\\/\\/(\\w+\\.)?1st-files\\.com\\/d\\/[^"\'><\\r\\n\\t]+@i', $data, $giay)) {
return trim($giay[0]);
}
} else {
return trim($this->redirect);
}
return false;
}
开发者ID:seegras3,项目名称:vinaget-script,代码行数:29,代码来源:1st-files_com.php
示例14: routeProvider
public function routeProvider()
{
// Have to setup error handler here as well, as PHPUnit calls on
// provider methods outside the scope of setUp().
set_error_handler(function ($errno, $errstr) {
return stristr($errstr, 'query route deprecated');
}, E_USER_DEPRECATED);
return array(
'simple-match' => array(
new Query(),
'foo=bar&baz=bat',
null,
array('foo' => 'bar', 'baz' => 'bat')
),
'empty-match' => array(
new Query(),
'',
null,
array()
),
'url-encoded-parameters-are-decoded' => array(
new Query(),
'foo=foo%20bar',
null,
array('foo' => 'foo bar')
),
'nested-params' => array(
new Query(),
'foo%5Bbar%5D=baz&foo%5Bbat%5D=foo%20bar',
null,
array('foo' => array('bar' => 'baz', 'bat' => 'foo bar'))
),
);
}
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:34,代码来源:QueryTest.php
示例15: _save
/**
* Save a template with the current params. Writes file to `Create::$path`.
* Override default save to add timestamp in file name.
*
* @param array $params
* @return string A result string on success of writing the file. If any errors occur along
* the way such as missing information boolean false is returned.
*/
protected function _save(array $params = array())
{
$defaults = array('namespace' => null, 'class' => null);
$params += $defaults;
if (empty($params['class']) || empty($this->_library['path'])) {
return false;
}
$contents = $this->_template();
$result = String::insert($contents, $params);
$namespace = str_replace($this->_library['prefix'], '\\', $params['namespace']);
$date = date('YmdHis');
$path = str_replace('\\', '/', "{$namespace}\\{$date}_{$params['class']}");
$path = $this->_library['path'] . stristr($path, '/');
$file = str_replace('//', '/', "{$path}.php");
$directory = dirname($file);
$relative = str_replace($this->_library['path'] . '/', "", $file);
if (!is_dir($directory) && !mkdir($directory, 0755, true)) {
return false;
}
if (file_exists($file)) {
$prompt = "{$relative} already exists. Overwrite?";
$choices = array('y', 'n');
if ($this->in($prompt, compact('choices')) !== 'y') {
return "{$params['class']} skipped.";
}
}
if (file_put_contents($file, "<?php\n\n{$result}\n\n?>")) {
return "{$params['class']} created in {$relative}.";
}
return false;
}
开发者ID:djordje,项目名称:li3_migrations,代码行数:39,代码来源:Migration.php
示例16: Leech
public function Leech($url)
{
list($url, $pass) = $this->linkpassword($url);
$data = $this->lib->curl($url, $this->lib->cookie, "");
if ($pass) {
$post = $this->parseForm($this->lib->cut_str($data, '<form', '</form>'));
$post["password"] = $pass;
$data = $this->lib->curl($url, $this->lib->cookie, $post);
if (stristr($data, 'Wrong password')) {
$this->error("wrongpass", true, false, 2);
} elseif (preg_match('@https?:\\/\\/www\\d+\\.uptobox.com\\/d\\/[^\'\\"\\s\\t<>\\r\\n]+@i', $data, $link)) {
return trim(str_replace('https', 'http', $link[0]));
}
}
if (stristr($data, 'type="password" name="password')) {
$this->error("reportpass", true, false);
} elseif (stristr($data, 'The file was deleted by its owner') || stristr($data, 'Page not found / La page')) {
$this->error("dead", true, false, 2);
} elseif (!$this->isredirect($data)) {
$post = $this->parseForm($this->lib->cut_str($data, '<form name="F1"', '</form>'));
$data = $this->lib->curl($url, $this->lib->cookie, $post);
if (preg_match('@https?:\\/\\/www\\d+\\.uptobox.com\\/d\\/[^\'\\"\\s\\t<>\\r\\n]+@i', $data, $link)) {
return trim(str_replace('https', 'http', $link[0]));
}
} else {
return trim(str_replace('https', 'http', trim($this->redirect)));
}
return false;
}
开发者ID:seegras3,项目名称:vinaget-script,代码行数:29,代码来源:uptobox_com.php
示例17: openstats
function openstats()
{
$fp = fsockopen($this->host, $this->port, $errno, $errstr, 10);
if (!$fp) {
$this->_error = "{$errstr} ({$errno})";
return 0;
} else {
fputs($fp, "GET /admin.cgi?pass=" . $this->passwd . "&mode=viewxml HTTP/1.0\r\n");
fputs($fp, "User-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$this->_xml .= fgets($fp, 512);
}
fclose($fp);
if (stristr($this->_xml, "HTTP/1.0 200 OK") == true) {
// <-H> Thanks to Blaster for this fix.. trim();
$this->_xml = trim(substr($this->_xml, 42));
} else {
$this->_error = "Bad login";
return 0;
}
$xmlparser = xml_parser_create();
if (!xml_parse_into_struct($xmlparser, $this->_xml, $this->_values, $this->_indexes)) {
$this->_error = "Unparsable XML";
return 0;
}
xml_parser_free($xmlparser);
return 1;
}
}
开发者ID:Karpec,项目名称:gizd,代码行数:29,代码来源:shoutcast.class.php
示例18: get_device_useragent
function get_device_useragent($device)
{
global $astman;
$response = $astman->send_request('Command', array('Command' => "sip show peer {$device}"));
$astout = explode("\n", $response['data']);
$ua = "";
foreach ($astout as $entry) {
if (eregi("useragent", $entry)) {
list(, $value) = split(":", $entry);
$ua = trim($value);
}
}
if ($ua) {
if (stristr($ua, "Aastra")) {
return "aastra";
}
if (stristr($ua, "Grandstream")) {
return "grandstream";
}
if (stristr($ua, "snom")) {
return "snom";
}
if (stristr($ua, "Cisco")) {
return "cisco";
}
if (stristr($ua, "Polycom")) {
return "polycom";
}
}
return null;
}
开发者ID:hardikk,项目名称:HNH,代码行数:31,代码来源:functions.inc.php
示例19: validate_update
/**
* Validates the Input Parameters onBeforeVendorUpdate
*
* @param array $d
* @return boolean
*/
function validate_update(&$d)
{
global $vmLogger;
require_once CLASSPATH . 'imageTools.class.php';
if (!vmImageTools::validate_image($d, "vendor_thumb_image", "vendor")) {
return false;
}
if (!vmImageTools::validate_image($d, "vendor_full_image", "vendor")) {
return false;
}
// convert all "," in prices to decimal points.
if (stristr($d["vendor_min_pov"], ",")) {
$d["vendor_min_pov"] = str_replace(',', '.', $d["vendor_min_pov"]);
}
if (!$d["vendor_name"]) {
$vmLogger->err('You must enter a name for the vendor.');
return False;
}
if (!$d["contact_email"]) {
$vmLogger->err('You must enter an email address for the vendor contact.');
return False;
}
if (!vmValidateEmail($d["contact_email"])) {
$vmLogger->err('Please provide a valide email address for the vendor contact.');
return False;
}
return True;
}
开发者ID:albertobraschi,项目名称:Hab,代码行数:34,代码来源:ps_vendor.php
示例20: associateIpAddress
/**
* Associates IP Address to the server
*
* @param DBServer $dbServer DBServer object
* @param string $ipAddress Public IP address to associate with server.
* @throws \Exception
*/
private static function associateIpAddress(DBServer $dbServer, $ipAddress, $allocationId = null)
{
$aws = $dbServer->GetEnvironmentObject()->aws($dbServer);
$assign_retries = 1;
$retval = false;
while (true) {
try {
// Associate elastic ip address with instance
$request = new AssociateAddressRequestData($dbServer->GetProperty(\EC2_SERVER_PROPERTIES::INSTANCE_ID), $ipAddress);
if ($allocationId) {
$request->allocationId = $allocationId;
$request->publicIp = null;
$request->allowReassociation = true;
}
$aws->ec2->address->associate($request);
$retval = true;
break;
} catch (\Exception $e) {
if (!stristr($e->getMessage(), "does not belong to you") || $assign_retries == 3) {
throw new \Exception($e->getMessage());
} else {
// Waiting...
\Logger::getLogger(__CLASS__)->debug(_("Waiting 2 seconds..."));
sleep(2);
$assign_retries++;
continue;
}
}
break;
}
return $retval;
}
开发者ID:sacredwebsite,项目名称:scalr,代码行数:39,代码来源:EipHelper.php
注:本文中的stristr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论