本文整理汇总了PHP中Str::inString方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::inString方法的具体用法?PHP Str::inString怎么用?PHP Str::inString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::inString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url
/**
* Generates a full readable url.
*
* @param string $url The url parameters
* @param boolean $appendSession Append session id to url
*
* @return string
*/
public static function url($url, $appendSession = false)
{
$session = Core::getRequest()->getGET("sid");
if (!COOKIE_SESSION && $appendSession && $session) {
if (Str::inString("?", $url)) {
$url .= "?sid=" . $session;
} else {
$url .= "&sid=" . $session;
}
}
$lang = Core::getRequest()->getPOST("lang") ? Core::getRequest()->getPOST("lang") : Core::getRequest()->getGET("lang");
if (self::APPEND_LANG_TO_URL && $lang) {
if (Str::inString("?", $url)) {
$url = $url . "?lang=" . $lang;
} else {
$url = $url . "&lang=" . $lang;
}
} else {
if (!Link::isExternal($url) && !preg_match("~^" . BASE_URL . "~si", $url) && self::APPEND_HOST_PATH) {
$url = BASE_URL . $url;
}
}
return $url;
}
示例2: startSession
/**
* Start a new session and destroy old sessions.
*
* @return Login
*/
public function startSession()
{
if (!$this->dataChecked) {
$this->checkData();
}
// Disables old sessions.
if ($this->cacheActive) {
Core::getCache()->cleanUserCache($this->userid);
}
Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
// Start new session.
$sessionSeed = Str::encode((string) microtime(1));
$this->sid = Str::substring($sessionSeed, 0, $this->getSessionLength());
unset($sessionSeed);
$spec = array("sessionid" => $this->sid, "userid" => $this->userid, "ipaddress" => IPADDRESS, "useragent" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "time" => TIME, "logged" => 1);
Core::getQuery()->insert("sessions", $spec);
if ($this->canLogin) {
if (COOKIE_SESSION) {
Core::getRequest()->setCookie("sid", $this->sid, $this->getCookieExpire());
$this->sessionUrl = $this->redirection;
} else {
if (Str::inString("?", $this->redirection)) {
$this->sessionUrl = $this->redirection . "&sid=" . $this->sid . "&login=true";
} else {
$this->sessionUrl = $this->redirection . "?sid=" . $this->sid . "&login=true";
}
}
if ($this->cacheActive) {
Core::getCache()->buildUserCache($this->sid);
}
Hook::event("StartSession", array($this, $this->sessionUrl));
if ($this->redirectOnSuccess) {
doHeaderRedirection($this->sessionUrl, true);
}
} else {
$this->loginFailed("CANNOT_LOGIN");
}
return $this;
}
示例3: redirect
/**
* Sets Location header and response code. Forces replacement of any prior
* redirects.
*
* @param string $url URL to redirect
* @param boolean $appendSession Append the session string
*
* @return void
*/
public static function redirect($url, $appendSession = true)
{
if (Link::isExternal($url) || Str::inString("http://", $url)) {
$path = $url;
} else {
if ($appendSession && !Str::inString("sid=", $url) && URL_SESSION) {
!Str::inString("?", $url) ? $url .= "?sid=" . SID : ($url .= "&sid=" . SID);
} else {
$path = HTTP_HOST . REQUEST_DIR . $url;
}
}
self::set("Location", $path);
self::statusCode(302);
self::send();
return exit;
}
示例4: checkEmail
/**
* Checks a string for valid email address.
*
* @param string
*
* @return boolean
*/
function checkEmail($mail)
{
if (!preg_match("#^[a-zA-Z0-9-]+([._a-zA-Z0-9.-]+)*@[a-zA-Z0-9.-]+\\.([a-zA-Z]{2,4})\$#is", $mail)) {
return false;
}
$banned = Core::getConfig()->get("BANNED_EMAILS");
if (!empty($banned)) {
$banned = Arr::trim(explode(",", $banned));
foreach ($banned as $expr) {
if (Str::inString($expr, $mail)) {
return false;
}
}
}
return true;
}
示例5: serialize
/**
* @param array $options
* @return string
*/
protected function serialize($options)
{
if (!empty($options)) {
$hasKeys = Str::inString("=>", $options);
$options = Arr::trim(explode(",", $options));
$opts = $options;
if ($hasKeys) {
$opts = array();
$size = count($options);
for ($i = 0; $i < $size; $i++) {
$cell = Arr::trim(explode("=>", $options[$i]));
$opts[$cell[0]] = $cell[1];
}
}
return serialize($opts);
}
return "";
}