本文整理匯總了PHP中CHttpRequest::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP CHttpRequest::init方法的具體用法?PHP CHttpRequest::init怎麽用?PHP CHttpRequest::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CHttpRequest
的用法示例。
在下文中一共展示了CHttpRequest::init方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
parent::init();
//Для более надежной защиты от XSS
/*if(isset($_GET))
$_GET=$this->defenderXss($_GET, ["(", ")"]);
if(isset($_COOKIE))
$_COOKIE=$this->defenderXss($_COOKIE, []);
if(isset($_POST))
$_POST=$this->defenderXss($_POST, []);
if(isset($_REQUEST))
$_REQUEST=$this->defenderXss($_REQUEST, []); */
}
示例2: init
/**
* Init
*/
public function init()
{
parent::init();
// Get the path
if (craft()->config->usePathInfo()) {
$pathInfo = $this->getPathInfo();
$path = $pathInfo ? $pathInfo : $this->_getQueryStringPath();
} else {
$queryString = $this->_getQueryStringPath();
$path = $queryString ? $queryString : $this->getPathInfo();
}
// Sanitize
$path = $this->decodePathInfo($path);
// Get the path segments
$this->_segments = array_filter(explode('/', $path));
// Is this a CP request?
$this->_isCpRequest = $this->getSegment(1) == craft()->config->get('cpTrigger');
if ($this->_isCpRequest) {
// Chop the CP trigger segment off of the path & segments array
array_shift($this->_segments);
}
// Is this a paginated request?
if ($this->_segments) {
// Match against the entire path string as opposed to just the last segment
// so that we can support "/page/2"-style pagination URLs
$path = implode('/', $this->_segments);
$pageTrigger = str_replace('/', '\\/', craft()->config->get('pageTrigger'));
if (preg_match("/(.*)\\b{$pageTrigger}(\\d+)\$/", $path, $match)) {
// Capture the page num
$this->_pageNum = (int) $match[2];
// Sanitize
$newPath = $this->decodePathInfo($match[1]);
// Reset the segments without the pagination stuff
$this->_segments = array_filter(explode('/', $newPath));
}
}
// Now that we've chopped off the admin/page segments, set the path
$this->_path = implode('/', $this->_segments);
$this->_checkRequestType();
}
示例3: init
public function init()
{
parent::init();
}
示例4: init
/**
* Initializes the application component.
*
* @return null
*/
public function init()
{
// Is CSRF protection enabled?
if (craft()->config->get('enableCsrfProtection') === true) {
$this->enableCsrfValidation = true;
// Grab the token name.
$this->csrfTokenName = craft()->config->get('csrfTokenName');
}
// Now initialize Yii's CHttpRequest.
parent::init();
// There is no path.
if (craft()->isConsole()) {
$path = '';
} else {
// Get the normalized path.
$path = $this->getNormalizedPath();
}
// Get the path segments
$this->_segments = array_filter(explode('/', $path), function ($value) {
// Explicitly check in case there is a 0 in a segment (i.e. foo/0 or foo/0/bar)
return $value !== '';
});
// Is this a CP request?
$this->_isCpRequest = $this->getSegment(1) == craft()->config->get('cpTrigger');
if ($this->_isCpRequest) {
// Chop the CP trigger segment off of the path & segments array
array_shift($this->_segments);
}
// Is this a paginated request?
$pageTrigger = craft()->config->get('pageTrigger');
if (!is_string($pageTrigger) || !strlen($pageTrigger)) {
$pageTrigger = 'p';
}
// Is this query string-based pagination?
if ($pageTrigger[0] === '?') {
$pageTrigger = trim($pageTrigger, '?=');
if ($pageTrigger === 'p') {
// Avoid conflict with the main 'p' param
$pageTrigger = 'pg';
}
$this->_pageNum = (int) $this->getQuery($pageTrigger, '1');
} else {
if ($this->_segments) {
// Match against the entire path string as opposed to just the last segment so that we can support
// "/page/2"-style pagination URLs
$path = implode('/', $this->_segments);
$pageTrigger = preg_quote(craft()->config->get('pageTrigger'), '/');
if (preg_match("/^(?:(.*)\\/)?{$pageTrigger}(\\d+)\$/", $path, $match)) {
// Capture the page num
$this->_pageNum = (int) $match[2];
// Sanitize
$newPath = $this->decodePathInfo($match[1]);
// Reset the segments without the pagination stuff
$this->_segments = array_filter(explode('/', $newPath));
}
}
}
// Now that we've chopped off the admin/page segments, set the path
$this->_path = implode('/', $this->_segments);
}
示例5: init
/**
* Initializes the application component.
*
* @return null
*/
public function init()
{
// Is CSRF protection enabled?
if (craft()->config->get('enableCsrfProtection') === true) {
$this->enableCsrfValidation = true;
// Grab the token name.
$this->csrfTokenName = craft()->config->get('csrfTokenName');
}
// Now initialize Yii's CHttpRequest.
parent::init();
// There is no path.
if (craft()->isConsole()) {
$path = '';
} else {
// Get the normalized path.
$path = $this->getNormalizedPath();
}
// Get the path segments
$this->_segments = array_filter(explode('/', $path));
// Is this a CP request?
$this->_isCpRequest = $this->getSegment(1) == craft()->config->get('cpTrigger');
if ($this->_isCpRequest) {
// Chop the CP trigger segment off of the path & segments array
array_shift($this->_segments);
}
// Is this a paginated request?
if ($this->_segments) {
// Match against the entire path string as opposed to just the last segment so that we can support
// "/page/2"-style pagination URLs
$path = implode('/', $this->_segments);
$pageTrigger = preg_quote(craft()->config->get('pageTrigger'), '/');
if (preg_match("/^(?:(.*)\\/)?{$pageTrigger}(\\d+)\$/", $path, $match)) {
// Capture the page num
$this->_pageNum = (int) $match[2];
// Sanitize
$newPath = $this->decodePathInfo($match[1]);
// Reset the segments without the pagination stuff
$this->_segments = array_filter(explode('/', $newPath));
}
}
// Now that we've chopped off the admin/page segments, set the path
$this->_path = implode('/', $this->_segments);
}
示例6: init
/**
* Save default language
*/
public function init()
{
$this->_defaultLanguage = Yii::app()->language;
parent::init();
}