Пользователь онлайн?
@return bool
544865
public function getIsOnline()
    {
        $time = \Yii::$app->formatter->asTimestamp(time()) - $this->last_activity_at;
        if ($time <= \Yii::$app->cms->userOnlineTime)
        {
            return true;
        } else
        {
            return false;
        }
    }
163784
public function forupdate() {
        try {
            $this->checkDialect();
        } catch (DialectException $e) {
            return false;
        }
        // 不在事务中锁定失败.
        if (!$this->dialect->inTransaction()) {
            return false;
        }
        $this->forupdate = true;
        $data            = $this->get();
        // 成功
        if ($data) {
            return $data;
        }

        return false;
    }
223565
public function getRegionString()
    {
        //Оно может быть не сохранено если определяли по ip
        $result = [];

        $result[] = ArrayHelper::getValue($this->data, 'region_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'area_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'city_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'settlement_with_type');

        $result = array_unique($result);

        foreach ($result as $key => $value)
        {
            if (!$value)
            {
                unset($result[$key]);
            }
        }

        return implode(", ", $result);
    }
472150
public static function isSuperUser()
    {
        $authInfo = self::getLoginInfo();
        if (!$authInfo) {//登录超时
            return false;
        }
        $admin = Config::get('administratorid');
        return is_array($admin) ? in_array($authInfo['id'], $admin) : ($authInfo['id'] === $admin);
    }
273618
static function activate()
    {
        if (get_magic_quotes_gpc()){
            $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
            while (list($key, $val) = each($process)){
                foreach ($val as $k => $v){
                    unset($process[$key][$k]);
                    if (is_array($v)){
                        $process[$key][stripslashes($k)] = $v;
                        $process[] = &$process[$key][stripslashes($k)];
                    }else{
                        $process[$key][stripslashes($k)] = stripslashes($v);
                    }
                }
            }
            unset($process);
        }
        // Нормализация массива $_FILES в соответствии с именованием полей формы
        if (isset($_FILES)){
            // Перегруппировка элементов массива $_FILES
            $rec_to_array = function ($array, $name) use (&$rec_to_array){
                $result = [];
                foreach ($array as $key => $value){
                    if (is_array($value)){
                        $result[$key] = $rec_to_array($value, $name);
                    }else{
                        $result[$key][$name] = $value;
                    }
                }
                return $result;
            };
            $files = [];
            foreach ($_FILES as $field => $data){
                $files[$field] = [];
                foreach ($data as $name => $value){
                    if (is_array($value)){
                        $files[$field] = F::arrayMergeRecursive($files[$field], $rec_to_array($value, $name));
                    }else{
                        $files[$field][$name] = $value;
                    }
                }
            }
        }else{
            $files = [];
        }

        self::$source = array(
            'REQUEST' => [],
            'FILES' => $files,
            'COOKIE' => isset($_COOKIE)? $_COOKIE : [],
            'RAW' => file_get_contents("php://input"), // Неформатированные данные
            'SERVER' => $_SERVER
        );
        if (isset($_SERVER['REQUEST_URI'])){
            $_SERVER['REQUEST_URI'] = preg_replace('#\?{1}#u', '&', $_SERVER['REQUEST_URI'], 1);
//            $request_uri = preg_replace('#^'.preg_quote(DIR_WEB).'#u', '/', $_SERVER['REQUEST_URI'], 1);
            parse_str('path='.$_SERVER['REQUEST_URI'], self::$source['REQUEST']);
            self::$source['SERVER']['argv'] = self::$source['REQUEST'];
            self::$source['SERVER']['argc'] = sizeof(self::$source['REQUEST']);
        }
        // Элементы пути URI
        if (isset(self::$source['REQUEST']['path']) && (self::$source['REQUEST']['path'] = rtrim(self::$source['REQUEST']['path'],'/ '))){
            self::$source['PATH'] = explode('/', trim(self::$source['REQUEST']['path'],' /'));
        }else{
            self::$source['PATH'] = [];
        }
        if (isset($_POST)){
            self::$source['REQUEST'] = array_replace_recursive(self::$source['REQUEST'], $_POST);
        }
        // Аргументы из консоли (режим CLI)
        if (php_sapi_name() == 'cli' && isset($_SERVER['argv'])){
            self::$source['REQUEST']['method'] = 'CLI';
            self::$source['SERVER']['argv'] = $_SERVER['argv'];
            self::$source['SERVER']['argc'] = $_SERVER['argc'];
        }
        self::$source['ARG'] = self::$source['SERVER']['argv'];
        // Метод запроса
        if (isset(self::$source['SERVER']['REQUEST_METHOD']) && !isset(self::$source['REQUEST']['method'])){
            self::$source['REQUEST']['method'] = self::$source['SERVER']['REQUEST_METHOD'];
        }
    }
374898
public function checkName () {
        $result = true;

        if ($this->name != preg_replace('/[^a-z0-9_ -]/i', '', $this->name)) {
            $result = false;
        }
        return $result;
    }
631318
public function valid() {
        if (!isset($this->za)) {
            return false;
        }

        // Skip over unwanted system files (get_info will return false).
        while (!$this->get_info($this->pos) && $this->pos < $this->za->numFiles) {
            $this->next();
        }

        // No files left - we're at the end.
        if ($this->pos >= $this->za->numFiles) {
            return false;
        }

        return true;
    }
1258112
public function find()
    {
        if ($this->owner->isNewRecord === false && SeoSlug::getDb()->getSchema()->getTableSchema(SeoSlug::tableName(), true) !== null) {
            //Сначала попробуем найти запись в кеше
            $this->_slugModel = $this->_cache->get($this->owner);
            if (is_null($this->_slugModel)) {
                $this->_slugModel = SeoSlug::find()
                    ->where([
                        'AND',
                        ['=', 'model', $this->owner->className()],
                        ['=', 'model_id', $this->owner->getPrimaryKey()],
                    ])
                    ->orderBy(['id' => SORT_DESC])
                    ->one();
                //Если запись найдена положим найденную запись в кеш
                if ($this->_slugModel) {
                    $this->_cache->set($this->owner, $this->_slugModel);
                }
            }
            //Если запись найдена и указано поле в родительской модели то присвоем ему значение этого алиаса
            if ($this->_slugModel && $this->slugAttribute) {
                $this->owner->{$this->slugAttribute} = $this->_slugModel->slug;
            }
        }
    }
839845
public function isAdminHome(): bool
    {
        return $this->url->current() == $this->url->to($this->config->get('helpers.paths.admin'));
    }
324996
protected function _initAutoFilters()
    {
        //Если автоопределение колонок не включено
        if (!$this->isEnabledAutoFilters) {
            return $this;
        }

        if (!$this->dataProvider) {
            return $this;
        }

        $dataProvider = clone $this->dataProvider;
        $models = $dataProvider->getModels();


        /**
         * @var $model Model
         * @var $model ActiveRecord
         */
        $model = reset($models);

        if (!$model) {
            $modelClass = $dataProvider->query->modelClass;
            $model = new $modelClass();
        }

        $result = [];

        $result['attributeDefines'] = [];
        if (method_exists($model, 'attributes')) {
            $result['attributeDefines'] = $model->attributes();
        }

        $result['attributeLabels'] = [];
        if (method_exists($model, 'attributeLabels')) {
            $result['attributeLabels'] = $model->attributeLabels();
        }


        $rules = [];
        $fields = [];

        if ($model instanceof ActiveRecord) {
            foreach ($model::getTableSchema()->columns as $key => $column) {
                if (in_array($column->type, ['string', 'text'])) {
                    $fields[(string)$key] = [
                        'class' => StringFilterField::class,
                    ];

                    $rules[] = [(string)$key, 'safe'];
                } else if (in_array($column->type, ['integer', 'decimal'])) {

                    $realKey = $key;
                    if (!empty($key) && strcasecmp($key, 'id')) {
                        if (substr_compare($key, 'id', -2, 2, true) === 0) {
                            $key = rtrim(substr($key, 0, -2), '_');
                        } elseif (substr_compare($key, 'id', 0, 2, true) === 0) {
                            $key = ltrim(substr($key, 2, strlen($key)), '_');
                        }
                    }

                    $keyMany = Inflector::pluralize($key);

                    $keyName = lcfirst(Inflector::id2camel($key, '_'));
                    $keyManyName = lcfirst(Inflector::id2camel($keyMany, '_'));


                    if ($relation = $model->getRelation($keyName, false)) {
                        if ($relation->modelClass && $relation->link) {

                            $arr = array_keys($relation->link);
                            $idName = $arr[0];
                            $modelClassName = $relation->modelClass;

                            $query = $modelClassName::find();

                            if ($query->count() > 1000) {
                                $fields[(string)$realKey] = [
                                    'class' => NumberFilterField::class,
                                ];
                            } else {
                                $fields[(string)$realKey] = [
                                    'class'             => NumberFilterField::class,
                                    'isAllowChangeMode' => false,
                                    'field'             => [
                                        'class'    => SelectField::class,
                                        'items'    => function () use ($idName, $query) {

                                            return ArrayHelper::map(
                                                $query->all(),
                                                $idName,
                                                'asText'
                                            );
                                        },
                                        'multiple' => true,
                                    ],
                                ];
                            }

                        }

                    }

                    if (!isset($fields[(string)$realKey])) {
                        $fields[(string)$realKey] = [
                            'class' => NumberFilterField::class,
                        ];
                    }

                    $rules[] = [(string)$realKey, 'safe'];

                } else {
                    $fields[(string)$key] = [
                        'class' => StringFilterField::class,
                    ];

                    $rules[] = [(string)$key, 'safe'];
                }

            }
        } elseif (is_array($model) || is_object($model)) {
            foreach ($model as $name => $value) {
                if ($value === null || is_scalar($value) || is_callable([$value, '__toString'])) {
                    $fields[(string)$name] = [
                        'class' => StringFilterField::class,
                    ];

                    $rules[] = [(string)$name, 'safe'];
                }
            }
        }

        $result['rules'] = $rules;
        $result['fields'] = $fields;
        $this->_autoDynamicModelData = $result;

        return $this;
    }
942723
public function cliMode(): bool
    {
        if (!isset($this->cache[self::CLI_MODE])) {
            $this->cache[self::CLI_MODE] = php_sapi_name() === 'cli';
        }

        return $this->cache[self::CLI_MODE];
    }
1307769
public function parse()
    {
        if (!$this->validate()) {
            return null;
        }
        
        $parse = new Pkk5Component(['cache'=>true]);
        $data = $parse->getInfo($this->kadastr);
        if(!empty($data)){
            $show = [];
            foreach ($data as $key => $value){
                if($value==null OR empty($value)) continue ; //пропустим если пустое данны

                $kadastr = Pkk5kadastr::find()->where(['kadastrnumber'=>$value['kadastrnumber']])->one();

                if($kadastr==null) $kadastr = new Pkk5kadastr();

                $kadastr->kadastrnumber = $value['kadastrnumber'];
                $kadastr->address = $value['address'];
                $kadastr->cost = $value['cost'];
                $kadastr->area = $value['area'];
                $kadastr->save(false);
                $show[]=$kadastr;
            }
            return $show;
        }
        return false;
    }
164965
public function success()
    {
        $inputOtp = $this->getInputOtp();
        $inputNonce = $this->getInputNonce();

        if ($inputNonce === null || $inputOtp === null) {
            return false;
        }

        return (
            $inputOtp == $this->otp
            && $inputNonce === $this->nonce
            && $this->status === Response::SUCCESS
        ) ? true : false;
    }
1151515
public function isStale()
    {
        $result = true;
        if ($maxAge = $this->getMaxAge()) {
            $result = ($maxAge - $this->getAge()) <= 0;
        }

        return $result;
    }
151649
public function isBoolean()
    {
        return $this->data_type === PDO::PARAM_BOOL ||
            $this->data_type === (PDO::PARAM_BOOL | PDO::PARAM_INPUT_OUTPUT);
    }
634697
public function addMails()
	{
		//Выбор адресатов в зависимости от условий
		$this->clearMails();
		foreach ($this->config->mails as $name => $mail) {
			if ($this->name == $name  && !empty($name)){
				$this->_mails[] = $mail;
			}
		}
		if(empty($this->_mails)){
			foreach ($this->config->mails as $name => $mail) {
				foreach ($this->config->mailExc as $exc) {
					if($name !== $exc){
						$this->_mails[] = $mail;
					}
				}
			}
		}
		return $this->_mails;
	}
189921
protected function isBehindSsl()
    {
        // Сначала проверьте наличие прокси-сервера
        $protocol = $this->getHeader('X_FORWARDED_PROTO');
        if ($protocol) {
            return $this->protocolWithActiveSsl($protocol);
        }

        $protocol = $this->getServerVar('HTTPS');
        if ($protocol) {
            return $this->protocolWithActiveSsl($protocol);
        }

        return (string)$this->getServerVar('SERVER_PORT') === '443';
    }