本文整理汇总了PHP中stristr函数的典型用法代码示例。如果您正苦于以下问题:PHP stristr函数的具体用法?PHP stristr怎么用?PHP stristr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stristr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: _isFetchQuery
protected function _isFetchQuery($sql)
{
if (stristr($sql, "DELETE FROM ") || stristr($sql, "UPDATE ") || stristr($sql, "INSERT ")) {
return false;
}
return true;
}
示例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;
}
示例4: loadVariable
private function loadVariable($line)
{
if (stristr($line, '=')) {
$config = explode('=', $line);
$this->variables[trim($config[0])] = trim($config[1]);
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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"));
}
}
}
}
}
示例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;
}
示例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;
}
示例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'))
),
);
}
示例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;
}