防止csrf跨站攻击

@param int $type 检测类型   0不检查，1、只检查post，2、post get都检查
259
public static function checkCsrf($type = 1)
    {
        if ($type !== 0 && isset($_SERVER['HTTP_REFERER']) && !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
            if ($type == 1) {
                if (!empty($_POST)) {
                    Response::sendHttpStatus(403);
                    throw new \UnexpectedValueException(Lang::get('_ILLEGAL_REQUEST_'));
                }
            } else {
                Response::sendHttpStatus(403);
                throw new \UnexpectedValueException(Lang::get('_ILLEGAL_REQUEST_'));
            }
        }
    }
1364676
static public function end($type = 'app')
    {
        if (!isset(self::$_timeStore[$type])) {
            throw new Exception(str_cover('没有"{type}"对应的 timer', [
                '{type}' => $type,
            ]));
        }
        $e = self::microTime(false);
        $s = self::$_timeStore[$type];
        unset(self::$_timeStore[$type]);
        return sprintf('%.6f', $e - $s);
    }
435439
public function type($type = null)
    {
        if (is_null($type)) {
            unset($this->filters['post_type']);
        } else {
            $this->filters['post_type'] = $type;
        }
        return $this;
    }
777960
public function actionSubmit( $slug, $type = null ) {

		if( !isset( $type ) ) {

			$type = CoreGlobal::TYPE_FORM;
		}

		$model 		= $this->formService->getBySlugType( $slug, $type );
		$template	= $model->template;
		$formFields	= $model->getFieldsMap();
 		$form		= new GenericForm( [ 'fields' => $formFields, 'ajax' => true ] );

		if( $model->captcha ) {

			$form->setScenario( 'captcha' );
		}

		if( $form->load( Yii::$app->request->post(), 'GenericForm' ) && $form->validate() ) {

			// Save Model
			if( $this->formService->processForm( $model, $form ) ) {

				// Trigger User Mail
				if( $model->userMail ) {

					Yii::$app->formsMailer->sendUserMail( $model, $form );
				}

				// Trigger Admin Mail
				if( $model->adminMail ) {

					Yii::$app->formsMailer->sendAdminMail( $model, $form );
				}

				$data = [];

				// Set success message
				if( isset( $model->success ) ) {

					$data[ 'message' ] = $model->success;
				}

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( $model->success, $data );
			}
		}

		// Generate Errors
		$errors = AjaxUtil::generateErrorMessage( $form );

		// Trigger Ajax Failure
    	return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
    }
328935
public function removeType($type)
    {
        foreach ($this->fields as $fieldname => $field) {
            if ($field->type == $type) {
                unset($this->fields[$fieldname]);
            }
        }
        foreach ($this->button_container as $container => $buttons) {
            foreach ($buttons as $key=>$button) {
                if (strpos($button, 'type="'.$type.'"')!==false) {
                    $this->button_container[$container][$key] = "";
                }
            }
        }

        return $this;
    }
539545
public function removeAllowedType($type)
    {
        if (in_array(strtolower($type), $this->allowedTypes)) {
            unset($this->allowedTypes[array_search(strtolower($type), $this->allowedTypes)]);
        }
        return $this;
    }
1044179
public function flush($type) {
		if (isset($this->cache[$type])) $this->cache[$type]=array();
		return $this;
	}
1041397
public function removeAttribute($type)
    {
        $index = -1;
        if (is_array($this->attributesToSend)) {
            foreach($this->attributesToSend as $i => $attr) {
                if (is_array($attr)) {
                    $tmp = $attr[0];
                } else {
                    $tmp = $attr;
                }
                if ($type == ord(substr($tmp, 0, 1))) {
                    unset($this->attributesToSend[$i]);
                    break;
                }
            }
        }

        return $this;
    }
1146598
public function clear($type = FALSE)
  {
    
	if ($type === FALSE){
		
		$this->_session_unset();
	}
	else {
		
		$messages = $this->_session_get();
		
		if (is_array($messages))
		{		
			foreach($messages as $i=>$message){
			
				if ($message->type == $type){
					
					unset($messages[$i]);
				}
			}
			
			if (!$this->count())
			{
				$this->clear();
			}
			else {
			
				$this->_session_set($messages);
			}
		}
	}
	
    return $this;
  }
1081222
private static function check_type($type=null) {
	if (is_null($type)) {
		return self::TYPE_CONTINUOUS;
	}
	
	if (isset(self::$type_durations[$type]) == false) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('unknown session type');
	}
	
	return $type;
}
809600
public function authenticate($type = '')
    {
        $valt = $this->app->make('token');
        if (!$valt->validate('login_' . $type)) {
            $this->error->add($valt->getErrorMessage());
        } else {
            try {
                $at = AuthenticationType::getByHandle($type);
                $user = $at->controller->authenticate();
                if ($user && $user->isRegistered()) {
                    return $this->finishAuthentication($at, $user);
                }
            } catch (Exception $e) {
                $this->error->add($e->getMessage());
            }
        }

        if (isset($at)) {
            $this->set('lastAuthType', $at);
        }

        $this->view();
    }
27159
public function tmpCleaner($type)
    {
        $this->request->allowMethod(['post', 'delete']);

        $assetsTarget = getConfigOrFail('Assets.target');
        $success = true;

        switch ($type) {
            case 'all':
                @unlink_recursive($assetsTarget, 'empty');
                @unlink_recursive(LOGS, 'empty');
                $success = self::clearCache() && self::clearSitemap() && (new ThumbManager)->clearAll();
                break;
            case 'cache':
                $success = self::clearCache();
                break;
            case 'assets':
                @unlink_recursive($assetsTarget, 'empty');
                break;
            case 'logs':
                @unlink_recursive(LOGS, 'empty');
                break;
            case 'sitemap':
                $success = self::clearSitemap();
                break;
            case 'thumbs':
                $success = (new ThumbManager)->clearAll();
                break;
            default:
                $success = false;
        }

        if ($success) {
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        return $this->redirect($this->referer(['action' => 'tmpViewer']));
    }
1176736
public function wipe($type) {
		$table = $type;
		$table = $this->safeTable($table);
		$sql = "TRUNCATE $table CASCADE";
		$this->adapter->exec($sql);
	}
1033440
public function optionFlush($type = null)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    modules()->flushRegistry();
                    break;

                case 'languages':
                    language()->flushRegistry();
                    break;
            }

        } else {
            modules()->flushRegistry();
            language()->flushRegistry();
        }

        exit(EXIT_SUCCESS);
    }
50903
public function setRedirectType($type) {
        if (!is_int($type)) throw new IllegalTypeException('Illegal type of parameter $type: '.gettype($type));

        $this->redirectType = $type;
        return $this;
    }
1093334
public function closeFilterForm() {
		$type = 'get';
		if ($this->_getFlagUsePost()) {
			$type = 'post';
		}

		$this->ExtBs3Form->requestType = $type;
		$result = $this->ExtBs3Form->end();

		return $result;
	}
73688
public function clear($type, $name)
    {
        if (isset($this->clients[$type][$name])) {
            $this->clients[$type][$name]->shutdown();
            unset($this->clients[$type][$name]);
        }

        return $this;
    }