code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function setPageState($name,$value,$defaultValue=null)
{
if($this->_pageStates===null)
$this->_pageStates=$this->loadPageStates();
if($value===$defaultValue)
unset($this->_pageStates[$name]);
else
$this->_pageStates[$name]=$value;
$params=func_get_args();
$this->recordCachingAction('','setPageState',$params);
} | Saves a persistent page state value.
A page state is a variable that is persistent across POST requests of the same page.
In order to use persistent page states, the form(s) must be stateful
which are generated using {@link CHtml::statefulForm}.
@param string $name the state name
@param mixed $value the page state value
@param mixed $defaultValue the default page state value. If this is the same as
the given value, the state will be removed from persistent storage.
@see getPageState
@see CHtml::statefulForm | setPageState | php | yiisoft/yii | framework/web/CController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CController.php | BSD-3-Clause |
protected function loadPageStates()
{
if(!empty($_POST[self::STATE_INPUT_NAME]))
{
if(($data=base64_decode($_POST[self::STATE_INPUT_NAME]))!==false)
{
if(extension_loaded('zlib'))
$data=@gzuncompress($data);
if(($data=Yii::app()->getSecurityManager()->validateData($data))!==false)
return unserialize($data);
}
}
return array();
} | Loads page states from a hidden input.
@return array the loaded page states | loadPageStates | php | yiisoft/yii | framework/web/CController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CController.php | BSD-3-Clause |
protected function savePageStates($states,&$output)
{
$data=Yii::app()->getSecurityManager()->hashData(serialize($states));
if(extension_loaded('zlib'))
$data=gzcompress($data);
$value=base64_encode($data);
$output=str_replace(CHtml::pageStateField(''),CHtml::pageStateField($value),$output);
} | Saves page states as a base64 string.
@param array $states the states to be saved.
@param string $output the output to be modified. Note, this is passed by reference. | savePageStates | php | yiisoft/yii | framework/web/CController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CController.php | BSD-3-Clause |
public function init()
{
parent::init();
$this->normalizeRequest();
} | Initializes the application component.
This method overrides the parent implementation by preprocessing
the user request data. | init | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
protected function normalizeRequest()
{
// normalize request
if(version_compare(PHP_VERSION,'7.4.0','<'))
{
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
if(isset($_GET))
$_GET=$this->stripSlashes($_GET);
if(isset($_POST))
$_POST=$this->stripSlashes($_POST);
if(isset($_REQUEST))
$_REQUEST=$this->stripSlashes($_REQUEST);
if(isset($_COOKIE))
$_COOKIE=$this->stripSlashes($_COOKIE);
}
}
if($this->enableCsrfValidation)
Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken'));
} | Normalizes the request data.
This method strips off slashes in request data if get_magic_quotes_gpc() returns true.
It also performs CSRF validation if {@link enableCsrfValidation} is true. | normalizeRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function stripSlashes(&$data)
{
if(is_array($data))
{
if(count($data) == 0)
return $data;
$keys=array_map('stripslashes',array_keys($data));
$data=array_combine($keys,array_values($data));
return array_map(array($this,'stripSlashes'),$data);
}
else
return stripslashes($data);
} | Strips slashes from input data.
This method is applied when magic quotes is enabled.
@param mixed $data input data to be processed
@return mixed processed data | stripSlashes | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getParam($name,$defaultValue=null)
{
return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue);
} | Returns the named GET or POST parameter value.
If the GET or POST parameter does not exist, the second parameter to this method will be returned.
If both GET and POST contains such a named parameter, the GET parameter takes precedence.
@param string $name the GET parameter name
@param mixed $defaultValue the default parameter value if the GET parameter does not exist.
@return mixed the GET parameter value
@see getQuery
@see getPost | getParam | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getQuery($name,$defaultValue=null)
{
return isset($_GET[$name]) ? $_GET[$name] : $defaultValue;
} | Returns the named GET parameter value.
If the GET parameter does not exist, the second parameter to this method will be returned.
@param string $name the GET parameter name
@param mixed $defaultValue the default parameter value if the GET parameter does not exist.
@return mixed the GET parameter value
@see getPost
@see getParam | getQuery | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPost($name,$defaultValue=null)
{
return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
} | Returns the named POST parameter value.
If the POST parameter does not exist, the second parameter to this method will be returned.
@param string $name the POST parameter name
@param mixed $defaultValue the default parameter value if the POST parameter does not exist.
@return mixed the POST parameter value
@see getParam
@see getQuery | getPost | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getDelete($name,$defaultValue=null)
{
if($this->getIsDeleteViaPostRequest())
return $this->getPost($name, $defaultValue);
if($this->getIsDeleteRequest())
{
$restParams=$this->getRestParams();
return isset($restParams[$name]) ? $restParams[$name] : $defaultValue;
}
else
return $defaultValue;
} | Returns the named DELETE parameter value.
If the DELETE parameter does not exist or if the current request is not a DELETE request,
the second parameter to this method will be returned.
If the DELETE request was tunneled through POST via _method parameter, the POST parameter
will be returned instead (available since version 1.1.11).
@param string $name the DELETE parameter name
@param mixed $defaultValue the default parameter value if the DELETE parameter does not exist.
@return mixed the DELETE parameter value
@since 1.1.7 | getDelete | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPut($name,$defaultValue=null)
{
if($this->getIsPutViaPostRequest())
return $this->getPost($name, $defaultValue);
if($this->getIsPutRequest())
{
$restParams=$this->getRestParams();
return isset($restParams[$name]) ? $restParams[$name] : $defaultValue;
}
else
return $defaultValue;
} | Returns the named PUT parameter value.
If the PUT parameter does not exist or if the current request is not a PUT request,
the second parameter to this method will be returned.
If the PUT request was tunneled through POST via _method parameter, the POST parameter
will be returned instead (available since version 1.1.11).
@param string $name the PUT parameter name
@param mixed $defaultValue the default parameter value if the PUT parameter does not exist.
@return mixed the PUT parameter value
@since 1.1.7 | getPut | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPatch($name,$defaultValue=null)
{
if($this->getIsPatchViaPostRequest())
return $this->getPost($name, $defaultValue);
if($this->getIsPatchRequest())
{
$restParams=$this->getRestParams();
return isset($restParams[$name]) ? $restParams[$name] : $defaultValue;
}
else
return $defaultValue;
} | Returns the named PATCH parameter value.
If the PATCH parameter does not exist or if the current request is not a PATCH request,
the second parameter to this method will be returned.
If the PATCH request was tunneled through POST via _method parameter, the POST parameter
will be returned instead.
@param string $name the PATCH parameter name
@param mixed $defaultValue the default parameter value if the PATCH parameter does not exist.
@return mixed the PATCH parameter value
@since 1.1.16 | getPatch | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getRestParams()
{
if($this->_restParams===null)
{
$result=array();
if (strncmp((string)$this->getContentType(), 'application/json', 16) === 0)
$result = CJSON::decode($this->getRawBody(), $this->jsonAsArray);
elseif(function_exists('mb_parse_str'))
mb_parse_str($this->getRawBody(), $result);
else
parse_str($this->getRawBody(), $result);
$this->_restParams=$result;
}
return $this->_restParams;
} | Returns request parameters. Typically PUT, PATCH or DELETE.
@return array the request parameters
@since 1.1.7
@since 1.1.13 method became public | getRestParams | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getRawBody()
{
static $rawBody;
if($rawBody===null)
$rawBody=file_get_contents('php://input');
return $rawBody;
} | Returns the raw HTTP request body.
@return string the request body
@since 1.1.13 | getRawBody | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getUrl()
{
return $this->getRequestUri();
} | Returns the currently requested URL.
This is the same as {@link getRequestUri}.
@return string part of the request URL after the host info. | getUrl | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getHostInfo($schema='')
{
if($this->_hostInfo===null)
{
if($secure=$this->getIsSecureConnection())
$http='https';
else
$http='http';
if(isset($_SERVER['HTTP_HOST']))
$this->_hostInfo=$http.'://'.$_SERVER['HTTP_HOST'];
else
{
$this->_hostInfo=$http.'://'.$_SERVER['SERVER_NAME'];
$port=$secure ? $this->getSecurePort() : $this->getPort();
if(($port!==80 && !$secure) || ($port!==443 && $secure))
$this->_hostInfo.=':'.$port;
}
}
if($schema!=='')
{
$secure=$this->getIsSecureConnection();
if($secure && $schema==='https' || !$secure && $schema==='http')
return $this->_hostInfo;
$port=$schema==='https' ? $this->getSecurePort() : $this->getPort();
if($port!==80 && $schema==='http' || $port!==443 && $schema==='https')
$port=':'.$port;
else
$port='';
$pos=strpos($this->_hostInfo,':');
return $schema.substr($this->_hostInfo,$pos,strcspn($this->_hostInfo,':',$pos+1)+1).$port;
}
else
return $this->_hostInfo;
} | Returns the schema and host part of the application URL.
The returned URL does not have an ending slash.
By default this is determined based on the user request information.
You may explicitly specify it by setting the {@link setHostInfo hostInfo} property.
@param string $schema schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
@return string schema and hostname part (with port number if needed) of the request URL (e.g. https://www.yiiframework.com)
@see setHostInfo | getHostInfo | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setHostInfo($value)
{
$this->_hostInfo=rtrim($value,'/');
} | Sets the schema and host part of the application URL.
This setter is provided in case the schema and hostname cannot be determined
on certain Web servers.
@param string $value the schema and host part of the application URL. | setHostInfo | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getBaseUrl($absolute=false)
{
if($this->_baseUrl===null)
$this->_baseUrl=rtrim(dirname($this->getScriptUrl()),'\\/');
return $absolute ? $this->getHostInfo() . $this->_baseUrl : $this->_baseUrl;
} | Returns the relative URL for the application.
This is similar to {@link getScriptUrl scriptUrl} except that
it does not have the script file name, and the ending slashes are stripped off.
@param boolean $absolute whether to return an absolute URL. Defaults to false, meaning returning a relative one.
@return string the relative URL for the application
@see setScriptUrl | getBaseUrl | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setBaseUrl($value)
{
$this->_baseUrl=$value;
} | Sets the relative URL for the application.
By default the URL is determined based on the entry script URL.
This setter is provided in case you want to change this behavior.
@param string $value the relative URL for the application | setBaseUrl | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getScriptUrl()
{
if($this->_scriptUrl===null)
{
$scriptName=basename($_SERVER['SCRIPT_FILENAME']);
if(basename($_SERVER['SCRIPT_NAME'])===$scriptName)
$this->_scriptUrl=$_SERVER['SCRIPT_NAME'];
elseif(basename($_SERVER['PHP_SELF'])===$scriptName)
$this->_scriptUrl=$_SERVER['PHP_SELF'];
elseif(isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME'])===$scriptName)
$this->_scriptUrl=$_SERVER['ORIG_SCRIPT_NAME'];
elseif(($pos=strpos($_SERVER['PHP_SELF'],'/'.$scriptName))!==false)
$this->_scriptUrl=substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$scriptName;
elseif(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===0)
$this->_scriptUrl=str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME']));
else
throw new CException(Yii::t('yii','CHttpRequest is unable to determine the entry script URL.'));
}
return $this->_scriptUrl;
} | Returns the relative URL of the entry script.
The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework.
@throws CException when it is unable to determine the entry script URL.
@return string the relative URL of the entry script. | getScriptUrl | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setScriptUrl($value)
{
$this->_scriptUrl='/'.trim($value,'/');
} | Sets the relative URL for the application entry script.
This setter is provided in case the entry script URL cannot be determined
on certain Web servers.
@param string $value the relative URL for the application entry script. | setScriptUrl | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPathInfo()
{
if($this->_pathInfo===null)
{
$pathInfo=$this->getRequestUri();
if(($pos=strpos($pathInfo,'?'))!==false)
$pathInfo=substr($pathInfo,0,$pos);
$pathInfo=$this->decodePathInfo($pathInfo);
$scriptUrl=$this->getScriptUrl();
$baseUrl=$this->getBaseUrl();
if(strpos($pathInfo,$scriptUrl)===0)
$pathInfo=substr($pathInfo,strlen($scriptUrl));
elseif($baseUrl==='' || strpos($pathInfo,$baseUrl)===0)
$pathInfo=substr($pathInfo,strlen($baseUrl));
elseif(strpos($_SERVER['PHP_SELF'],$scriptUrl)===0)
$pathInfo=substr($_SERVER['PHP_SELF'],strlen($scriptUrl));
else
throw new CException(Yii::t('yii','CHttpRequest is unable to determine the path info of the request.'));
if($pathInfo==='/' || $pathInfo===false)
$pathInfo='';
elseif($pathInfo!=='' && $pathInfo[0]==='/')
$pathInfo=substr($pathInfo,1);
if(($posEnd=strlen($pathInfo)-1)>0 && $pathInfo[$posEnd]==='/')
$pathInfo=substr($pathInfo,0,$posEnd);
$this->_pathInfo=$pathInfo;
}
return $this->_pathInfo;
} | Returns the path info of the currently requested URL.
This refers to the part that is after the entry script and before the question mark.
The starting and ending slashes are stripped off.
@return string part of the request URL that is after the entry script and before the question mark.
Note, the returned pathinfo is decoded starting from 1.1.4.
Prior to 1.1.4, whether it is decoded or not depends on the server configuration
(in most cases it is not decoded).
@throws CException if the request URI cannot be determined due to improper server configuration | getPathInfo | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
protected function decodePathInfo($pathInfo)
{
$pathInfo = urldecode($pathInfo);
// is it UTF-8?
// https://w3.org/International/questions/qa-forms-utf-8.html
if(preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $pathInfo))
{
return $pathInfo;
}
else
{
return $this->utf8Encode($pathInfo);
}
} | Decodes the path info.
This method is an improved variant of the native urldecode() function and used in {@link getPathInfo getPathInfo()} to
decode the path part of the request URI. You may override this method to change the way the path info is being decoded.
@param string $pathInfo encoded path info
@return string decoded path info
@since 1.1.10 | decodePathInfo | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
private function utf8Encode($s)
{
$s.=$s;
$len=strlen($s);
for ($i=$len>>1,$j=0; $i<$len; ++$i,++$j) {
switch (true) {
case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
default: $s[$j] = "\xC3"; $s[++$j] = chr(ord($s[$i]) - 64); break;
}
}
return substr($s, 0, $j);
} | Encodes an ISO-8859-1 string to UTF-8
@param string $s
@return string the UTF-8 translation of `s`.
@see https://github.com/yiisoft/yii/issues/4505
@see https://github.com/symfony/polyfill-php72/blob/master/Php72.php#L24 | utf8Encode | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getRequestUri()
{
if($this->_requestUri===null)
{
if(isset($_SERVER['REQUEST_URI']))
{
$this->_requestUri=$_SERVER['REQUEST_URI'];
if(!empty($_SERVER['HTTP_HOST']))
{
if(strpos($this->_requestUri,$_SERVER['HTTP_HOST'])!==false)
$this->_requestUri=preg_replace('/^\w+:\/\/[^\/]+/','',$this->_requestUri);
}
else
$this->_requestUri=preg_replace('/^(http|https):\/\/[^\/]+/i','',$this->_requestUri);
}
elseif(isset($_SERVER['ORIG_PATH_INFO'])) // IIS 5.0 CGI
{
$this->_requestUri=$_SERVER['ORIG_PATH_INFO'];
if(!empty($_SERVER['QUERY_STRING']))
$this->_requestUri.='?'.$_SERVER['QUERY_STRING'];
}
else
throw new CException(Yii::t('yii','CHttpRequest is unable to determine the request URI.'));
}
return $this->_requestUri;
} | Returns the request URI portion for the currently requested URL.
This refers to the portion that is after the {@link hostInfo host info} part.
It includes the {@link queryString query string} part if any.
The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework.
@return string the request URI portion for the currently requested URL.
@throws CException if the request URI cannot be determined due to improper server configuration | getRequestUri | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getQueryString()
{
return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'';
} | Returns part of the request URL that is after the question mark.
@return string part of the request URL that is after the question mark | getQueryString | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsSecureConnection()
{
return isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'],'on')===0 || $_SERVER['HTTPS']==1)
|| isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'],'https')===0;
} | Return if the request is sent via secure channel (https).
@return boolean if the request is sent via secure channel (https) | getIsSecureConnection | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getRequestType()
{
if(isset($_POST['_method']))
return strtoupper($_POST['_method']);
elseif(isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']))
return strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
return strtoupper(isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'GET');
} | Returns the request type, such as GET, POST, HEAD, PUT, PATCH, DELETE.
Request type can be manually set in POST requests with a parameter named _method. Useful
for RESTful request from older browsers which do not support PUT, PATCH or DELETE
natively (available since version 1.1.11).
@return string request type, such as GET, POST, HEAD, PUT, PATCH, DELETE. | getRequestType | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsPostRequest()
{
return isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'POST');
} | Returns whether this is a POST request.
@return boolean whether this is a POST request. | getIsPostRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsDeleteRequest()
{
return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'DELETE')) || $this->getIsDeleteViaPostRequest();
} | Returns whether this is a DELETE request.
@return boolean whether this is a DELETE request.
@since 1.1.7 | getIsDeleteRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
protected function getIsDeleteViaPostRequest()
{
return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'DELETE');
} | Returns whether this is a DELETE request which was tunneled through POST.
@return boolean whether this is a DELETE request tunneled through POST.
@since 1.1.11 | getIsDeleteViaPostRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsPutRequest()
{
return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'PUT')) || $this->getIsPutViaPostRequest();
} | Returns whether this is a PUT request.
@return boolean whether this is a PUT request.
@since 1.1.7 | getIsPutRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
protected function getIsPutViaPostRequest()
{
return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'PUT');
} | Returns whether this is a PUT request which was tunneled through POST.
@return boolean whether this is a PUT request tunneled through POST.
@since 1.1.11 | getIsPutViaPostRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsPatchRequest()
{
return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'PATCH')) || $this->getIsPatchViaPostRequest();
} | Returns whether this is a PATCH request.
@return boolean whether this is a PATCH request.
@since 1.1.16 | getIsPatchRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
protected function getIsPatchViaPostRequest()
{
return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'PATCH');
} | Returns whether this is a PATCH request which was tunneled through POST.
@return boolean whether this is a PATCH request tunneled through POST.
@since 1.1.16 | getIsPatchViaPostRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsAjaxRequest()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';
} | Returns whether this is an AJAX (XMLHttpRequest) request.
@return boolean whether this is an AJAX (XMLHttpRequest) request. | getIsAjaxRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getIsFlashRequest()
{
return isset($_SERVER['HTTP_USER_AGENT']) && (stripos($_SERVER['HTTP_USER_AGENT'],'Shockwave')!==false || stripos($_SERVER['HTTP_USER_AGENT'],'Flash')!==false);
} | Returns whether this is an Adobe Flash or Adobe Flex request.
@return boolean whether this is an Adobe Flash or Adobe Flex request.
@since 1.1.11 | getIsFlashRequest | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getServerPort()
{
return $_SERVER['SERVER_PORT'];
} | Returns the server port number.
@return integer server port number | getServerPort | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getUrlReferrer()
{
return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null;
} | Returns the URL referrer, null if not present
@return string URL referrer, null if not present | getUrlReferrer | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getUserAgent()
{
return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null;
} | Returns the user agent, null if not present.
@return string user agent, null if not present | getUserAgent | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getUserHost()
{
return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null;
} | Returns the user host name, null if it cannot be determined.
@return string user host name, null if cannot be determined | getUserHost | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getScriptFile()
{
if($this->_scriptFile!==null)
return $this->_scriptFile;
else
return $this->_scriptFile=realpath($_SERVER['SCRIPT_FILENAME']);
} | Returns entry script file path.
@return string entry script file path (processed w/ realpath()) | getScriptFile | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getBrowser($userAgent=null)
{
return get_browser($userAgent,true);
} | Returns information about the capabilities of user browser.
@param string $userAgent the user agent to be analyzed. Defaults to null, meaning using the
current User-Agent HTTP header information.
@return array user browser capabilities.
@see https://www.php.net/manual/en/function.get-browser.php | getBrowser | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getAcceptTypes()
{
return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null;
} | Returns user browser accept types, null if not present.
@return string user browser accept types, null if not present | getAcceptTypes | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getContentType()
{
if (isset($_SERVER["CONTENT_TYPE"])) {
return $_SERVER["CONTENT_TYPE"];
} elseif (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
//fix bug https://bugs.php.net/bug.php?id=66606
return $_SERVER["HTTP_CONTENT_TYPE"];
}
return null;
} | Returns request content-type
The Content-Type header field indicates the MIME type of the data
contained in {@link getRawBody()} or, in the case of the HEAD method, the
media type that would have been sent had the request been a GET.
@return string request content-type. Null is returned if this information is not available.
@link https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
HTTP 1.1 header field definitions
@since 1.1.17 | getContentType | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPort()
{
if($this->_port===null)
$this->_port=!$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 80;
return $this->_port;
} | Returns the port to use for insecure requests.
Defaults to 80, or the port specified by the server if the current
request is insecure.
You may explicitly specify it by setting the {@link setPort port} property.
@return integer port number for insecure requests.
@see setPort
@since 1.1.3 | getPort | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setPort($value)
{
$this->_port=(int)$value;
$this->_hostInfo=null;
} | Sets the port to use for insecure requests.
This setter is provided in case a custom port is necessary for certain
server configurations.
@param integer $value port number.
@since 1.1.3 | setPort | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getSecurePort()
{
if($this->_securePort===null)
$this->_securePort=$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 443;
return $this->_securePort;
} | Returns the port to use for secure requests.
Defaults to 443, or the port specified by the server if the current
request is secure.
You may explicitly specify it by setting the {@link setSecurePort securePort} property.
@return integer port number for secure requests.
@see setSecurePort
@since 1.1.3 | getSecurePort | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setSecurePort($value)
{
$this->_securePort=(int)$value;
$this->_hostInfo=null;
} | Sets the port to use for secure requests.
This setter is provided in case a custom port is necessary for certain
server configurations.
@param integer $value port number.
@since 1.1.3 | setSecurePort | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getCookies()
{
if($this->_cookies!==null)
return $this->_cookies;
else
return $this->_cookies=new CCookieCollection($this);
} | Returns the cookie collection.
The result can be used like an associative array. Adding {@link CHttpCookie} objects
to the collection will send the cookies to the client; and removing the objects
from the collection will delete those cookies on the client.
@return CCookieCollection the cookie collection. | getCookies | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public static function parseAcceptHeader($header)
{
$matches=array();
$accepts=array();
// get individual entries with their type, subtype, basetype and params
if($header!==null)
preg_match_all('/(?:\G\s?,\s?|^)(\w+|\*)\/(\w+|\*)(?:\+(\w+))?|(?<!^)\G(?:\s?;\s?(\w+)=([\w\.]+))/',$header,$matches);
// the regexp should (in theory) always return an array of 6 arrays
if(count($matches)===6)
{
$i=0;
$itemLen=count($matches[1]);
while($i<$itemLen)
{
// fill out a content type
$accept=array(
'type'=>$matches[1][$i],
'subType'=>$matches[2][$i],
'baseType'=>null,
'params'=>array(),
);
// fill in the base type if it exists
if($matches[3][$i]!==null && $matches[3][$i]!=='')
$accept['baseType']=$matches[3][$i];
// continue looping while there is no new content type, to fill in all accompanying params
for($i++;$i<$itemLen;$i++)
{
// if the next content type is null, then the item is a param for the current content type
if($matches[1][$i]===null || $matches[1][$i]==='')
{
// if this is the quality param, convert it to a double
if($matches[4][$i]==='q')
{
// sanity check on q value
$q=(double)$matches[5][$i];
if($q>1)
$q=(double)1;
elseif($q<0)
$q=(double)0;
$accept['params'][$matches[4][$i]]=$q;
}
else
$accept['params'][$matches[4][$i]]=$matches[5][$i];
}
else
break;
}
// q defaults to 1 if not explicitly given
if(!isset($accept['params']['q']))
$accept['params']['q']=(double)1;
$accepts[] = $accept;
}
}
return $accepts;
} | Parses an HTTP Accept header, returning an array map with all parts of each entry.
Each array entry consists of a map with the type, subType, baseType and params, an array map of key-value parameters,
obligatorily including a `q` value (i.e. preference ranking) as a double.
For example, an Accept header value of <code>'application/xhtml+xml;q=0.9;level=1'</code> would give an array entry of
<pre>
array(
'type' => 'application',
'subType' => 'xhtml',
'baseType' => 'xml',
'params' => array(
'q' => 0.9,
'level' => '1',
),
)
</pre>
<b>Please note:</b>
To avoid great complexity, there are no steps taken to ensure that quoted strings are treated properly.
If the header text includes quoted strings containing space or the , or ; characters then the results may not be correct!
See also {@link https://tools.ietf.org/html/rfc2616#section-14.1} for details on Accept header.
@param string $header the accept header value to parse
@return array the user accepted MIME types. | parseAcceptHeader | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public static function compareAcceptTypes($a,$b)
{
// check for equal quality first
if($a['params']['q']===$b['params']['q'])
if(!($a['type']==='*' xor $b['type']==='*'))
if (!($a['subType']==='*' xor $b['subType']==='*'))
// finally, higher number of parameters counts as greater precedence
if(count($a['params'])===count($b['params']))
return 0;
else
return count($a['params'])<count($b['params']) ? 1 : -1;
// more specific takes precedence - whichever one doesn't have a * subType
else
return $a['subType']==='*' ? 1 : -1;
// more specific takes precedence - whichever one doesn't have a * type
else
return $a['type']==='*' ? 1 : -1;
else
return ($a['params']['q']<$b['params']['q']) ? 1 : -1;
} | Compare function for determining the preference of accepted MIME type array maps
See {@link parseAcceptHeader()} for the format of $a and $b
@param array $a user accepted MIME type as an array map
@param array $b user accepted MIME type as an array map
@return integer -1, 0 or 1 if $a has respectively greater preference, equal preference or less preference than $b (higher preference comes first). | compareAcceptTypes | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPreferredAcceptTypes()
{
if($this->_preferredAcceptTypes===null)
{
$accepts=self::parseAcceptHeader($this->getAcceptTypes());
usort($accepts,array(get_class($this),'compareAcceptTypes'));
$this->_preferredAcceptTypes=$accepts;
}
return $this->_preferredAcceptTypes;
} | Returns an array of user accepted MIME types in order of preference.
Each array entry consists of a map with the type, subType, baseType and params, an array map of key-value parameters.
See {@link parseAcceptHeader()} for a description of the array map.
@return array the user accepted MIME types, as array maps, in the order of preference. | getPreferredAcceptTypes | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function getPreferredAcceptType()
{
$preferredAcceptTypes=$this->getPreferredAcceptTypes();
return empty($preferredAcceptTypes) ? false : $preferredAcceptTypes[0];
} | Returns the user preferred accept MIME type.
The MIME type is returned as an array map (see {@link parseAcceptHeader()}).
@return array the user preferred accept MIME type or false if the user does not have any. | getPreferredAcceptType | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
private function stringCompare($a, $b)
{
if ($a[0] == $b[0]) {
return 0;
}
return ($a[0] < $b[0]) ? 1 : -1;
} | String compare function used by usort.
Included to circumvent the use of closures (not supported by PHP 5.2) and create_function (deprecated since PHP 7.2.0)
@param array $a
@param array $b
@return int -1 (a>b), 0 (a==b), 1 (a<b) | stringCompare | php | yiisoft/yii | framework/web/CHttpRequest.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php | BSD-3-Clause |
public function setBasePath($value)
{
if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
$this->_basePath=$basePath;
else
throw new CException(Yii::t('yii','CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
array('{path}'=>$value)));
} | Sets the root directory storing published asset files.
@param string $value the root directory storing published asset files
@throws CException if the base path is invalid | setBasePath | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
public function getPublishedPath($path,$hashByName=false)
{
if(is_string($path) && ($path=realpath($path))!==false)
{
$base=$this->getBasePath().DIRECTORY_SEPARATOR.$this->generatePath($path,$hashByName);
return is_file($path) ? $base.DIRECTORY_SEPARATOR.basename($path) : $base ;
}
else
return false;
} | Returns the published path of a file path.
This method does not perform any publishing. It merely tells you
if the file or directory is published, where it will go.
@param string $path directory or file path being published
@param boolean $hashByName whether the published directory should be named as the hashed basename.
If false, the name will be the hash taken from dirname of the path being published and path mtime.
Defaults to false. Set true if the path being published is shared among
different extensions.
@return string the published file path. False if the file or directory does not exist | getPublishedPath | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
public function getPublishedUrl($path,$hashByName=false)
{
if(isset($this->_published[$path]))
return $this->_published[$path];
if(is_string($path) && ($path=realpath($path))!==false)
{
$base=$this->getBaseUrl().'/'.$this->generatePath($path,$hashByName);
return is_file($path) ? $base.'/'.basename($path) : $base;
}
else
return false;
} | Returns the URL of a published file path.
This method does not perform any publishing. It merely tells you
if the file path is published, what the URL will be to access it.
@param string $path directory or file path being published
@param boolean $hashByName whether the published directory should be named as the hashed basename.
If false, the name will be the hash taken from dirname of the path being published and path mtime.
Defaults to false. Set true if the path being published is shared among
different extensions.
@return string the published URL for the file or directory. False if the file or directory does not exist. | getPublishedUrl | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
protected function hash($path)
{
return sprintf('%x',crc32($path.Yii::getVersion()));
} | Generate a CRC32 hash for the directory path. Collisions are higher
than MD5 but generates a much smaller hash string.
@param string $path string to be hashed.
@return string hashed string. | hash | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
protected function generatePath($file,$hashByName=false)
{
if (is_file($file))
$pathForHashing=$hashByName ? dirname($file) : dirname($file).filemtime($file);
else
$pathForHashing=$hashByName ? $file : $file.filemtime($file);
return $this->hash($pathForHashing);
} | Generates path segments relative to basePath.
@param string $file for which public path will be created.
@param bool $hashByName whether the published directory should be named as the hashed basename.
@return string path segments without basePath.
@since 1.1.13 | generatePath | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
public function rewind()
{
$this->_key=reset($this->_keys);
} | Rewinds internal array pointer.
This method is required by the interface Iterator. | rewind | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function key()
{
return $this->_key;
} | Returns the key of the current array element.
This method is required by the interface Iterator.
@return mixed the key of the current array element | key | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function current()
{
return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
} | Returns the current array element.
This method is required by the interface Iterator.
@return mixed the current array element | current | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function next()
{
do
{
$this->_key=next($this->_keys);
}
while(!isset($_SESSION[$this->_key]) && $this->_key!==false);
} | Moves the internal pointer to the next array element.
This method is required by the interface Iterator. | next | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function valid()
{
return $this->_key!==false;
} | Returns whether there is an element at current position.
This method is required by the interface Iterator.
@return boolean | valid | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function init()
{
parent::init();
if($this->autoStart)
$this->open();
register_shutdown_function(array($this,'close'));
} | Initializes the application component.
This method is required by IApplicationComponent and is invoked by application. | init | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getUseCustomStorage()
{
return false;
} | Returns a value indicating whether to use custom session storage.
This method should be overridden to return true if custom session storage handler should be used.
If returning true, make sure the methods {@link openSession}, {@link closeSession}, {@link readSession},
{@link writeSession}, {@link destroySession}, and {@link gcSession} are overridden in child
class, because they will be used as the callback handlers.
The default implementation always return false.
@return boolean whether to use custom storage. | getUseCustomStorage | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function open()
{
if($this->getUseCustomStorage())
@session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession'));
@session_start();
if(YII_DEBUG && session_id()=='')
{
$message=Yii::t('yii','Failed to start session.');
if(function_exists('error_get_last'))
{
$error=error_get_last();
if(isset($error['message']))
$message=$error['message'];
}
Yii::log($message, CLogger::LEVEL_WARNING, 'system.web.CHttpSession');
}
} | Starts the session if it has not started yet. | open | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function close()
{
if(session_id()!=='')
@session_write_close();
} | Ends the current session and store session data. | close | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function destroy()
{
if(session_id()!=='')
{
@session_unset();
@session_destroy();
}
} | Frees all session variables and destroys all data registered to a session. | destroy | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function regenerateID($deleteOldSession=false)
{
if($this->getIsStarted())
session_regenerate_id($deleteOldSession);
} | Updates the current session id with a newly generated one .
Please refer to {@link https://php.net/session_regenerate_id} for more details.
@param boolean $deleteOldSession Whether to delete the old associated session file or not.
@since 1.1.8 | regenerateID | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function openSession($savePath,$sessionName)
{
return true;
} | Session open handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $savePath session save path
@param string $sessionName session name
@return boolean whether session is opened successfully | openSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function closeSession()
{
return true;
} | Session close handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@return boolean whether session is closed successfully | closeSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function readSession($id)
{
return '';
} | Session read handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@return string the session data | readSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function writeSession($id,$data)
{
return true;
} | Session write handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@param string $data session data
@return boolean whether session write is successful | writeSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function destroySession($id)
{
return true;
} | Session destroy handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@return boolean whether session is destroyed successfully | destroySession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function gcSession($maxLifetime)
{
return true;
} | Session GC (garbage collection) handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param integer $maxLifetime the number of seconds after which data will be seen as 'garbage' and cleaned up.
@return boolean whether session is GCed successfully | gcSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getIterator()
{
return new CHttpSessionIterator;
} | Returns an iterator for traversing the session variables.
This method is required by the interface IteratorAggregate.
@return CHttpSessionIterator an iterator for traversing the session variables. | getIterator | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getCount()
{
return count($_SESSION);
} | Returns the number of items in the session.
@return integer the number of session variables | getCount | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function count()
{
return $this->getCount();
} | Returns the number of items in the session.
This method is required by Countable interface.
@return integer number of items in the session. | count | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function get($key,$defaultValue=null)
{
return isset($_SESSION[$key]) ? $_SESSION[$key] : $defaultValue;
} | Returns the session variable value with the session variable name.
This method is very similar to {@link itemAt} and {@link offsetGet},
except that it will return $defaultValue if the session variable does not exist.
@param mixed $key the session variable name
@param mixed $defaultValue the default value to be returned when the session variable does not exist.
@return mixed the session variable value, or $defaultValue if the session variable does not exist.
@since 1.1.2 | get | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function itemAt($key)
{
return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
} | Returns the session variable value with the session variable name.
This method is exactly the same as {@link offsetGet}.
@param mixed $key the session variable name
@return mixed the session variable value, null if no such variable exists | itemAt | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function add($key,$value)
{
$_SESSION[$key]=$value;
} | Adds a session variable.
Note, if the specified name already exists, the old value will be removed first.
@param mixed $key session variable name
@param mixed $value session variable value | add | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetExists($offset)
{
return isset($_SESSION[$offset]);
} | This method is required by the interface ArrayAccess.
@param mixed $offset the offset to check on
@return boolean | offsetExists | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetGet($offset)
{
return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null;
} | This method is required by the interface ArrayAccess.
@param mixed $offset the offset to retrieve element.
@return mixed the element at the offset, null if no element is found at the offset | offsetGet | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetSet($offset,$item)
{
$_SESSION[$offset]=$item;
} | This method is required by the interface ArrayAccess.
@param mixed $offset the offset to set element
@param mixed $item the element value | offsetSet | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetUnset($offset)
{
unset($_SESSION[$offset]);
} | This method is required by the interface ArrayAccess.
@param mixed $offset the offset to unset element | offsetUnset | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function __construct($scenario='')
{
$this->setScenario($scenario);
$this->init();
$this->attachBehaviors($this->behaviors());
$this->afterConstruct();
} | Constructor.
@param string $scenario name of the scenario that this model is used in.
See {@link CModel::scenario} on how scenario is used by models.
@see getScenario | __construct | php | yiisoft/yii | framework/web/CFormModel.php | https://github.com/yiisoft/yii/blob/master/framework/web/CFormModel.php | BSD-3-Clause |
public function getDataProvider()
{
return $this->_dataProvider;
} | Returns the data provider to iterate over
@return CDataProvider the data provider to iterate over | getDataProvider | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function getTotalItemCount()
{
return $this->_totalItemCount;
} | Gets the total number of items to iterate over
@return integer the total number of items to iterate over | getTotalItemCount | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function current()
{
return $this->_items[$this->_currentIndex];
} | Gets the current item in the list.
This method is required by the Iterator interface.
@return mixed the current item in the list | current | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function key()
{
$pageSize=$this->_dataProvider->getPagination()->getPageSize();
return $this->_currentPage*$pageSize+$this->_currentIndex;
} | Gets the key of the current item.
This method is required by the Iterator interface.
@return integer the key of the current item | key | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function next()
{
$pageSize=$this->_dataProvider->getPagination()->getPageSize();
$this->_currentIndex++;
if($this->_currentIndex >= $pageSize)
{
$this->_currentPage++;
$this->_currentIndex=0;
$this->loadPage();
}
} | Moves the pointer to the next item in the list.
This method is required by the Iterator interface. | next | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function rewind()
{
$this->_currentIndex=0;
$this->_currentPage=0;
$this->loadPage();
} | Rewinds the iterator to the start of the list.
This method is required by the Iterator interface. | rewind | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function valid()
{
return $this->key() < $this->_totalItemCount;
} | Checks if the current position is valid or not.
This method is required by the Iterator interface.
@return boolean true if this index is valid | valid | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function count()
{
return $this->_totalItemCount;
} | Gets the total number of items in the dataProvider.
This method is required by the Countable interface.
@return integer the total number of items | count | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public static function getInstance($model, $attribute)
{
return self::getInstanceByName(CHtml::resolveName($model, $attribute));
} | Returns an instance of the specified uploaded file.
The file should be uploaded using {@link CHtml::activeFileField}.
@param CModel $model the model instance
@param string $attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.
@return CUploadedFile the instance of the uploaded file.
Null is returned if no file is uploaded for the specified model attribute.
@see getInstanceByName | getInstance | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstances($model, $attribute)
{
return self::getInstancesByName(CHtml::resolveName($model, $attribute));
} | Returns all uploaded files for the given model attribute.
@param CModel $model the model instance
@param string $attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.
@return CUploadedFile[] array of CUploadedFile objects.
Empty array is returned if no available file was found for the given attribute. | getInstances | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstanceByName($name)
{
if(null===self::$_files)
self::prefetchFiles();
return isset(self::$_files[$name]) && self::$_files[$name]->getError()!=UPLOAD_ERR_NO_FILE ? self::$_files[$name] : null;
} | Returns an instance of the specified uploaded file.
The name can be a plain string or a string like an array element (e.g. 'Post[imageFile]', or 'Post[0][imageFile]').
@param string $name the name of the file input field.
@return CUploadedFile the instance of the uploaded file.
Null is returned if no file is uploaded for the specified name. | getInstanceByName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstancesByName($name)
{
if(null===self::$_files)
self::prefetchFiles();
$len=strlen($name);
$results=array();
foreach(array_keys(self::$_files) as $key)
if(0===strncmp($key, $name.'[', $len+1) && self::$_files[$key]->getError()!=UPLOAD_ERR_NO_FILE)
$results[] = self::$_files[$key];
return $results;
} | Returns an array of instances starting with specified array name.
If multiple files were uploaded and saved as 'Files[0]', 'Files[1]',
'Files[n]'..., you can have them all by passing 'Files' as array name.
@param string $name the name of the array of files
@return CUploadedFile[] the array of CUploadedFile objects. Empty array is returned
if no adequate upload was found. Please note that this array will contain
all files from all subarrays regardless how deeply nested they are. | getInstancesByName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.