本文整理汇总了PHP中strstr函数的典型用法代码示例。如果您正苦于以下问题:PHP strstr函数的具体用法?PHP strstr怎么用?PHP strstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _is_auth_success
/**
* [_is_auth_success 验证权限是否成功]
* @param [type] $auths [description]
* @return boolean [description]
*/
private function _is_auth_success($auths)
{
$route = Common::get_route();
//需权限
if (array_key_exists($route, $auths)) {
$user = isset($_SESSION[$this->login_in_session_name]) ? $_SESSION[$this->login_in_session_name] : NULL;
$user_role = isset($user['role']) ? $user['role'] : NULL;
//有权限
if (strstr($auths[$route], "|{$user_role}|")) {
return TRUE;
} else {
//有登录权限
if (strstr($auths[$route], "|1|")) {
//已登录
if (!empty($user)) {
return TRUE;
} else {
$this->error->output('NOTLOGIN_ERROR', array('script' => 'swal({title: "请登录后再进行操作",type: "warning",showCancelButton: true,confirmButtonColor: "#DD6B55",confirmButtonText: "注册/登录",closeOnConfirm: false},function () {showsign();});'));
}
}
//没有权限
$this->error->output('NOAUTH_ERROR', array('script' => 'window.location.href ="' . base_url() . '";'));
}
} else {
return TRUE;
}
}
示例2: generateRoute
/**
* Add all the routes in the router in parameter
* @param $router Router
*/
public function generateRoute(Router $router)
{
foreach ($this->classes as $class) {
$classMethods = get_class_methods($this->namespace . $class . 'Controller');
$rc = new \ReflectionClass($this->namespace . $class . 'Controller');
$parent = $rc->getParentClass();
$parent = get_class_methods($parent->name);
$className = $this->namespace . $class . 'Controller';
foreach ($classMethods as $methodName) {
if (in_array($methodName, $parent) || $methodName == 'index') {
continue;
} else {
foreach (Router::getSupportedHttpMethods() as $httpMethod) {
if (strstr($methodName, $httpMethod)) {
continue 2;
}
if (in_array($methodName . $httpMethod, $classMethods)) {
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
unset($classMethods[$methodName . $httpMethod]);
}
}
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
}
}
$router->add('/' . strtolower($class), new $className(), 'index');
}
}
示例3: init
/**
* Prevent caching on dynamic pages.
*
* @access public
* @return void
*/
public function init()
{
if (false === ($wc_page_uris = get_transient('woocommerce_cache_excluded_uris'))) {
if (woocommerce_get_page_id('cart') < 1 || woocommerce_get_page_id('checkout') < 1 || woocommerce_get_page_id('myaccount') < 1) {
return;
}
$wc_page_uris = array();
$cart_page = get_post(woocommerce_get_page_id('cart'));
$checkout_page = get_post(woocommerce_get_page_id('checkout'));
$account_page = get_post(woocommerce_get_page_id('myaccount'));
$wc_page_uris[] = '/' . $cart_page->post_name;
$wc_page_uris[] = '/' . $checkout_page->post_name;
$wc_page_uris[] = '/' . $account_page->post_name;
$wc_page_uris[] = 'p=' . $cart_page->ID;
$wc_page_uris[] = 'p=' . $checkout_page->ID;
$wc_page_uris[] = 'p=' . $account_page->ID;
set_transient('woocommerce_cache_excluded_uris', $wc_page_uris);
}
if (is_array($wc_page_uris)) {
foreach ($wc_page_uris as $uri) {
if (strstr($_SERVER['REQUEST_URI'], $uri)) {
$this->nocache();
break;
}
}
}
}
示例4: table_column
/**
* Merge a table name and a column name if possible
*
* @param $table
* @param $column
* @return mixed
*/
function table_column($table, $column)
{
if (is_string($column) === false || strstr($column, '.') !== false) {
return $column;
}
return \DB::raw('`' . $table . '`' . '.' . ($column != '*' ? '`' . $column . '`' : $column));
}
示例5: __construct
/**
* Sets GET and POST into local properties
*/
public function __construct(&$conf = false)
{
// parse vars from URI
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) {
$qrystr = str_replace('r=', '', filter_var($_SERVER['QUERY_STRING']));
if (!strstr($qrystr, 'exe/')) {
$this->parseUri($qrystr);
} else {
$key = explode('/', $qrystr);
if (isset($key[1])) {
$this->_exe = $key[1];
}
}
unset($qrystr);
}
// vars from GET
if ($_GET) {
while (list($key, $value) = each($_GET)) {
if ($key != 'r') {
$this->{$key} = $value;
}
}
}
// vars from POST
if ($_POST) {
while (list($key, $value) = each($_POST)) {
$this->{$key} = $value;
}
}
// vars from FILES
if ($_FILES) {
$this->setFiles($conf);
}
}
示例6: expand_ranges
/**
* Assumes that value is not *, and creates an array of valid numbers that
* the string represents. Returns an array.
*/
function expand_ranges($str)
{
if (strstr($str, ",")) {
$arParts = explode(',', $str);
foreach ($arParts as $part) {
if (strstr($part, '-')) {
$arRange = explode('-', $part);
for ($i = $arRange[0]; $i <= $arRange[1]; $i++) {
$ret[] = $i;
}
} else {
$ret[] = $part;
}
}
} elseif (strstr($str, '-')) {
$arRange = explode('-', $str);
for ($i = $arRange[0]; $i <= $arRange[1]; $i++) {
$ret[] = $i;
}
} else {
$ret[] = $str;
}
$ret = array_unique($ret);
sort($ret);
return $ret;
}
示例7: beforeFilter
public function beforeFilter()
{
$this->controller = $this->_registry->getController();
if (!strstr($this->request->contentType(), 'multipart/form-data')) {
$this->request->data = $this->request->input('json_decode', true);
}
}
示例8: from_request
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL)
{
$scheme = !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" ? 'http' : 'https';
@$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded")) {
$post_data = OAuthUtil::parse_parameters(file_get_contents(self::$POST_INPUT));
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header($request_headers['Authorization']);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
示例9: forge
/**
* Forge a new object based on a request.
* @param RequestInterface $request
* @return Response
*/
public static function forge(RequestInterface $request)
{
$headerSize = $request->getInfo(CURLINFO_HEADER_SIZE);
$response = $request->getRawResponse();
$content = strlen($response) === $headerSize ? '' : substr($response, $headerSize);
$rawHeaders = rtrim(substr($response, 0, $headerSize));
$headers = array();
foreach (preg_split('/(\\r?\\n)/', $rawHeaders) as $header) {
if ($header) {
$headers[] = $header;
} else {
$headers = array();
}
}
$headerBag = array();
$info = $request->getInfo();
$status = explode(' ', $headers[0]);
$status = explode('/', $status[0]);
unset($headers[0]);
foreach ($headers as $header) {
list($key, $value) = explode(': ', $header);
$headerBag[trim($key)] = trim($value);
}
$response = new static($content, $info['http_code'], $headerBag);
$response->setProtocolVersion($status[1]);
$response->setCharset(substr(strstr($response->headers->get('Content-Type'), '='), 1));
return $response;
}
示例10: confirm_success
function confirm_success($ALERT)
{
global $PAGE, $this_page, $THEUSER;
$this_page = 'alertconfirmsucceeded';
$criteria = $ALERT->criteria_pretty(true);
$email = $ALERT->email();
$extra = null;
$PAGE->page_start();
$PAGE->stripe_start();
?>
<p>Your alert has been confirmed.</p>
<p>You will now receive email alerts for the following criteria:</p>
<ul><?php
echo $criteria;
?>
</ul>
<p>This is normally the day after, but could conceivably be later due to issues at our or parliament.uk's end.</p>
<?php
$extra = alert_confirmation_advert(array('email' => $email, 'pid' => strstr($ALERT->criteria(), 'speaker:')));
if ($extra) {
$extra = "advert={$extra}";
}
$PAGE->stripe_end();
$PAGE->page_end($extra);
}
示例11: getParams
static function getParams(&$params)
{
$params->def('url', '');
$params->def('scrolling', 'auto');
$params->def('height', '200');
$params->def('height_auto', '0');
$params->def('width', '100%');
$params->def('add', '1');
$params->def('name', 'wrapper');
$url = $params->get('url');
if ($params->get('add')) {
// adds 'http://' if none is set
if (substr($url, 0, 1) == '/') {
// relative url in component. use server http_host.
$url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
} elseif (!strstr($url, 'http') && !strstr($url, 'https')) {
$url = 'http://' . $url;
} else {
$url = $url;
}
}
// auto height control
if ($params->def('height_auto')) {
$load = 'onload="iFrameHeight()"';
} else {
$load = '';
}
$params->set('load', $load);
$params->set('url', $url);
return $params;
}
示例12: testReports
public function testReports()
{
$reports = FannieAPI::listModules('FannieReportPage', true);
$config = FannieConfig::factory();
$logger = new FannieLogger();
$op_db = $config->get('OP_DB');
$dbc = FannieDB::get($op_db);
$dbc->throwOnFailure(true);
foreach ($reports as $report_class) {
$obj = new $report_class();
$obj->setConfig($config);
$obj->setLogger($logger);
$dbc->selectDB($op_db);
$obj->setConnection($dbc);
$pre = $obj->preprocess();
$this->assertInternalType('boolean', $pre);
$auth = $obj->checkAuth();
$this->assertInternalType('boolean', $pre);
$html_form = $obj->form_content();
$this->assertNotEquals(0, strlen($html_form), 'Report form is empty for ' . $report_class);
$form = new \COREPOS\common\mvc\ValueContainer();
foreach ($obj->requiredFields() as $field) {
if (strstr($field, 'date')) {
$form->{$field} = date('Y-m-d');
} else {
$form->{$field} = 1;
}
}
$obj->setForm($form);
$preamble = $obj->report_description_content();
$this->assertInternalType('array', $preamble, 'Report did not return description content ' . $report_class);
$results = $obj->fetch_report_data();
$this->assertInternalType('array', $results, 'Report did not return results ' . $report_class);
}
}
示例13: getRemoteInfo
function getRemoteInfo()
{
$proxy = "";
$IP = "";
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
$proxy = $_SERVER["REMOTE_ADDR"];
} elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
$IP = $_SERVER["HTTP_CLIENT_IP"];
} else {
$IP = $_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$IP = getenv('HTTP_X_FORWARDED_FOR');
$proxy = getenv('REMOTE_ADDR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$IP = getenv('HTTP_CLIENT_IP');
} else {
$IP = getenv('REMOTE_ADDR');
}
}
if (strstr($IP, ',')) {
$ips = explode(',', $IP);
$IP = $ips[0];
}
$RemoteInfo[0] = $IP;
$RemoteInfo[1] = @GetHostByAddr($IP);
$RemoteInfo[2] = $proxy;
return $RemoteInfo;
}
示例14: _login
protected function _login($user)
{
$this->session->set_userdata((array) $user);
//update login time
$this->db->where('id', $user->ID);
$this->db->update('user', array('last_login' => time()));
// send them back to where they came from, either the referer if they
// have one, or the flashdata
$referer = $this->input->server('HTTP_REFERER');
// Only allow the referrer to be on this site - this prevents a loop
// to Twitter after login, and other possible phishing attacks
$base = $this->config->item('base_url');
if (substr($referer, 0, strlen($base)) != $base) {
$referer = $base;
}
$to = $this->session->flashdata('url_after_login') ? $this->session->flashdata('url_after_login') : $referer;
// List different routes we don't want to reroute to
$bad_routes = $this->non_forward_urls;
foreach ($bad_routes as $route) {
if (strstr($to, $route)) {
redirect('user/main');
}
}
// our $to is good, so redirect
redirect($to);
}
示例15: theme_user
function theme_user($data)
{
include_once "theme.inc.php";
$content = '';
foreach ($data as $r) {
if (strstr($r['source'], '<')) {
$source = str_replace("<a ", '<a class="left microblog-item-position"', $r['source']);
} else {
$source = '<a class="left microblog-item-position">' . $r['source'] . '</a>';
}
$content .= '<div class="item" id="' . $r['tweet_id'] . '">
<div class="item-delete">
<a class="right"></a>
</div>
<div class="left item-pic">
<img alt="" width="50" height="50" src="' . $r['profile_image_url'] . '">
</div>
<div class="left item-content">
<div class="item-blog">
<a class="item-blog-name" target="_blank" href="' . BASE_URL . 'profile/' . $r['post_screenname'] . '">' . $r['post_screenname'] . '</a>:' . $r['content'] . '
</div>
<div class="item-other">
<span class="left item-time">' . time_tran($r['post_datetime']) . '</span>' . $source . '
<a class="right item-control last delete">
删除</a>
</div>
</div>
<div class="clear">
</div>
</div>';
}
echo $content;
}