析构函数

@access public
557577
public function end() {
		if ($this->is_end) {
			return;
		}
		$this->is_end = true;
		if ($this->sw_response) {
			if (($this->tpl_auto === null && self::$tpl_auto_config) || $this->tpl_auto) {
				$this->display();
			}
			$this->sw_response->end();
			$this->sw_response = null;
		}
		$this->tpl_engine_obj = null;
	}
495520
public function run()
    {

        $id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;

        $config = Json::encode($this->config);

        //ready部分代码，是为了缩略图管理。UEditor本身就很大，在后台直接加载大文件图片会很卡。
        $script = <<<UEDITOR
    var {$this->name} = UE.getEditor('{$id}',{$config});
    {$this->name}.ready(function(){
        this.addListener( "beforeInsertImage", function ( type, imgObjs ) {
            for(var i=0;i < imgObjs.length;i++){
                imgObjs[i].src = imgObjs[i].src.replace(".thumbnail","");
            }
        });
    });
UEDITOR;

        $this->getView()->registerJs($script);

        if ($this->hasModel()) {
            return Html::activeTextarea($this->model, $this->attribute);
        } else {
            return Html::textarea($this->name, $this->value, ['id' => $id]);
        }
    }
312146
public function init($ini) {
		/*
		 * 是否使用自定义配置
		 */
		$config = parse_ini_file(false === $ini ? __DIR__ . '/../etc/server.ini' : $ini, true);
		
		/*
		 * 如果指定服务，则合并该服务下的配置与全局配置
		 */
		if (false === empty($this->service) && true === isset($config[$this->service])) {
			$config[$this->service] = array_merge($config['global'], $config[$this->service]);
			unset($config['global']);
		}
		
		/*
		 * 设置运行模式与socket方式
		 */
		foreach ($config as $key => $value) {
			if (true === empty($value)) {
				continue 1;
			}
			if (self::SWOOLE_MODE_PROCESS == $value['mode']) {
				$value['mode'] = SWOOLE_PROCESS;
			} else {
				$value['mode'] = SWOOLE_BASE;
			}
			
			switch ($value['socket']) {
				case self::SWOOLE_SOCKET_TCP6:
					$value['socket'] = SWOOLE_TCP6;
					break;
				case self::SWOOLE_SOCKET_UDP:
					$value['socket'] = SWOOLE_UDP;
					break;
				case self::SWOOLE_SOCKET_UDP6:
					$value['socket'] = SWOOLE_UDP6;
					break;
				case self::SWOOLE_SOCKET_DGRAM:
					$value['socket'] = SWOOLE_UNIX_DGRAM;
					break;
				case self::SWOOLE_SOCKET_STREAM:
					$value['socket'] = SWOOLE_UNIX_STREAM;
					break;
				case self::SWOOLE_SOCKET_TCP:
				default:
					$value['socket'] = SWOOLE_TCP;
					break;
			}
			$this->config[$key] = $value;
		}
	}
413520
public function start()
    {
        $try = $this->tryStart();
        $this->log('debug', 'try start', [
            'result' => (int) $try,
        ]);

        if (!$try) {
            return false;
        }

        $this->log('info', 'Job start');

        // 把进程ID和开始时间记录到上下文中
        $this->setContext(self::KEY_PROC_ID, posix_getpid());
        $this->setContext(self::KEY_PROC_TIME, time());
        $this->saveContext();

        // 执行任务逻辑
        try {
            $this->execute();
        } catch (\Exception $ex) {
            $this->log('error', 'Job execute error', [
                'error' => $ex->getMessage(),
            ]);

            return false;
        }

        $this->stop();

        return true;
    }
956254
public function pushGit()
    {
        if (!isset($this->config['git_address'])) {
            Log::info('Git地址没有配置，请在Config.php文件参照如下方式配置：' );
            Log::info('$config[\'git_address\']=\'git@github.com:seeruo/seeruo.github.io.git\';','error');
        }
        $Git = new GitService($this->config);

                        
        $Git->add();
        $Git->commit();
        $Git->push();
    }
1243347
protected function preprocessSelect()
    {
        // handle fields
        if (!isset($this->query['fields']) && !isset($this->query['distinct'])) {
            if (isset($this->query['count'])) {
                $this->query['fields'] = 'count(*)';
            } else {
                $this->query['fields'] = '*';
            }
        }
        
        if (isset($this->query['count']) || (is_string($this->query['fields'][0]) && strpos('count(', $this->query['fields'][0]) !== false)) {
            return ;
        }
        
        /**
         * 检查分页
         * start 作为初始偏移量
         * 
         * -- 解析出 pagesize
         * 1 如果设置了 limit, 从中解析出 offset|pagesize, offset 可能没有值
         * 2 如果未设置 limit 则检查 pagesize 或 num 选项, 得出 pagesize
         * 
         * -- 解析出 offset, 并得出最终 limit
         * 1 如果设置了 limit 且已包含offset, 则优先使用
         * 2 否则检查 page, 解析出 offset, 结合 pagesize 生成最终 limit
         * 3 否则使用已 解析的 start pagesize, 生成最终 limit
         */
        $start = isset($this->query['start']) && intval($this->query['start'][0])>0 ? intval($this->query['start'][0]) : 0;
        if (isset($this->query['limit'])) {     // 优先使用 limit
            if (is_numeric($this->query['limit'][0])) {
                $pagesize = $this->query['limit'][0];
            } else {
                if (!is_array($this->query['limit'][0])) $limitArr = explode(',', $this->query['limit'][0]);
                if (is_numeric($limitArr[0]) && is_numeric($limitArr[1])) {
                    $offset = $limitArr[0];
                    $pagesize = $limitArr[1];
                }
            }
        }
        if (!isset($pagesize) || ! $pagesize) {                  // limit 不存在则依次判断 pagesize, num
            if (isset($this->query['pagesize']) && intval($this->query['pagesize'][0])>0 ) {
                $pagesize   = intval($this->query['pagesize'][0]);
            } elseif (isset($this->query['num']) && intval($this->query['num'][0])>0 ) {
                $pagesize   = intval($this->query['num'][0]);
            }
        }
        
        if (isset($offset)) {
            $offset += $start;
            $limit      =  $offset . ',' . $pagesize;
        } elseif (isset($this->query['page'])) {
            $page       = intval($this->query['page'][0]) > 0 ? intval($this->query['page'][0]) : 1;
            // notice: $pagesize may be still null. 此时 pagesize 仍然可能为空，因为未设置或解析不正确
            $pagesize   = !empty($pagesize) ? $pagesize : 10;
            $offset     =  $start + $pagesize * ($page - 1);
            $limit      =  $offset . ',' . $pagesize;
        } elseif (isset($pagesize)) {
            $limit = $start . ',' . $pagesize;
        }
        if (isset($limit)) {
            $this->query->remove('limit')->set('limit', $limit);     // 强制重设
        }
    }
1087502
public function lBrackets()
    {
        if ($this->sql['where'] == '') {
            $this->sql['where'] = 'WHERE ';
        } else {
            if ($this->whereNeedAddAndOrOr === 1) {
                $this->sql['where'] .= ' AND ';
            } else if ($this->whereNeedAddAndOrOr === 2) {
                $this->sql['where'] .= ' OR ';
            }
        }
        $this->sql['where'] .= ' (';
        //移除下一次where操作默认加上AND
        $this->whereNeedAddAndOrOr = 0;
        return $this;
    }
1069622
protected function _checkTableInfo() {
        // 如果不是Model类 自动记录数据表信息
        // 只在第一次执行记录
        if(empty($this->fields)) {
            // 如果数据表字段没有定义则自动获取
            if(C('DB_FIELDS_CACHE')) {
                $db   =  $this->dbName?:C('DB_NAME');
                $fields = F('_fields/'.strtolower($db.'.'.$this->tablePrefix.$this->name));
                if($fields) {
                    $this->fields   =   $fields;
                    if(!empty($fields['_pk'])){
                        $this->pk       =   $fields['_pk'];
                    }
                    return ;
                }
            }
            // 每次都会读取数据表信息
            $this->flush();
        }
    }
882065
public function handle()
    {
        $name = trim($this->argument('name'));

        $confirm = $this->ask('使用者必须谨慎使用此接口，一旦删除成功，主题内所有消息也一并删除，不可恢复；所有订阅该主题的 Subscription 也一并被删除，不可恢复。确认删除么？[y/N]', 'N');
        if ($confirm !== 'y') {
            $this->line('操作取消');

            return;
        }

        /**
         * @var Client
         */
        $client = $this->mns;
        if (!$client) {
            $this->error('请先配置阿里云MSN服务，并在DI里面注册');

            return;
        }

        try {
            $res = $client->deleteTopic($name);
            if ($res->isSucceed()) {
                $this->line("Topic $name deleted");
            }
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
    }
1095700
static public function exec() {
    
        if(!preg_match('/^[A-Za-z](\/|\w)*$/',CONTROLLER_NAME)){ // 安全检测
            $module  =  false;
        }else{
            //创建控制器实例
            $module  =  controller(CONTROLLER_NAME);                
        }

        if(!$module) {
            // 是否定义Empty控制器
            $module = A('Empty');
            if(!$module){
                E(L('_CONTROLLER_NOT_EXIST_').':'.CONTROLLER_NAME);
            }
        }

        // 获取当前操作名 支持动态路由
        $action    =   ACTION_NAME.C('ACTION_SUFFIX');  

        try{
            if(!preg_match('/^[A-Za-z](\w)*$/',$action)){
                // 非法操作
                throw new \ReflectionException();
            }
            //执行当前操作
            $method =   new \ReflectionMethod($module, $action);
            if($method->isPublic() && !$method->isStatic()) {
                $class  =   new \ReflectionClass($module);
                // URL参数绑定检测
                if($method->getNumberOfParameters()>0 && C('URL_PARAMS_BIND')){
                    switch($_SERVER['REQUEST_METHOD']) {
                        case 'POST':
                            $vars    =  array_merge($_GET,$_POST);
                            break;
                        case 'PUT':
                            parse_str(file_get_contents('php://input'), $vars);
                            break;
                        default:
                            $vars  =  $_GET;
                    }
                    $params =  $method->getParameters();
                    $paramsBindType     =   C('URL_PARAMS_BIND_TYPE');
                    foreach ($params as $param){
                        $name = $param->getName();
                        if( 1 == $paramsBindType && !empty($vars) ){
                            $args[] =   array_shift($vars);
                        }elseif( 0 == $paramsBindType && isset($vars[$name])){
                            $args[] =   $vars[$name];
                        }elseif($param->isDefaultValueAvailable()){
                            $args[] =   $param->getDefaultValue();
                        }else{
                            E(L('_PARAM_ERROR_').':'.$name);
                        }   
                    }
                    // 开启绑定参数过滤机制
                    if(C('URL_PARAMS_SAFE')){
                        $filters     =   C('URL_PARAMS_FILTER')?:C('DEFAULT_FILTER');
                        if($filters) {
                            $filters    =   explode(',',$filters);
                            foreach($filters as $filter){
                                $args   =   array_map_recursive($filter,$args); // 参数过滤
                            }
                        }                        
                    }
					array_walk_recursive($args,'think_filter');
                    $method->invokeArgs($module,$args);
                }else{
                    $method->invoke($module);
                }
            }else{
                // 操作方法不是Public 抛出异常
                throw new \ReflectionException();
            }
        } catch (\ReflectionException $e) { 
            // 方法调用发生异常后 引导到__call方法处理
            $method = new \ReflectionMethod($module,'__call');
            $method->invokeArgs($module,array($action,''));
        }
        return ;
    }
3516
public function execute($parameters = [])
    {
        $this->_fields = "*"; //重置 select
        if(X_DEBUG){
            $sql = $this->sql;
            foreach ($parameters as $k=>$v){
                $sql = str_replace(':'.$k,$v,$sql);
            }
            $this->queries[] = $sql;
        }
        try {
            $stmt = $this->pdo->prepare($this->sql);
            $stmt->execute($parameters);
            $stmt->setFetchMode(\PDO::FETCH_ASSOC);
            return $stmt;
        } catch (\PDOException $e) {
            X::app()->exception($e, $this->sql);
        }
        return false;
    }
199709
public function register()
    {
        $this->container['translator'] = function ($container) {
            $config = $container['config']->get('translator');

            $translator = new Translator($config->get('paths', [])->toArray());

            // 别名设置
            foreach ($config->get('aliases', []) as $key => $value) {
                $translator->alias($key, $value->toArray());
            }

            // 默认语言类型
            $translator->default(value($config->default));

            // 导入必须的语言包
            $translator->import($config->get('required', [])->toArray());

            return $translator;
        };
    }
322746
public function injectProps()
    {
        $className = $this->refClass->getParentClass()->getName();
        list($injects, $configs) = static::getInjects($className);

        // @inject()和@requestInject()注入
        foreach($injects as $propName => $annotations)
        {
            $annotation = reset($annotations);
            $propRef = $this->refClass->getProperty($propName);
            $propRef->setAccessible(true);
            $propRef->setValue($this->object, $annotation->getRealValue());
        }

        // 配置注入
        foreach($configs as $name => $value)
        {
            $propRef = $this->refClass->getProperty($name);
            if(null === $propRef)
            {
                continue;
            }
            $propRef->setAccessible(true);
            $propRef->setValue($this->object, $value);
        }
    }
146581
public function save()
    {
        /**
         * 使用PHP Sesion，Readonl，未启动 这3种情况下不需要保存
         */
        if ($this->use_php_session or !$this->isStart or $this->readonly)
        {
            return true;
        }
        //设置为Session关闭状态
        $this->isStart = false;
        $key = self::$cache_prefix . $this->sessID;
        return $this->cache->set($key, serialize($_SESSION), $this->session_lifetime);
    }
993028
public function handle()
    {
        $topicName = trim($this->argument('topic'));

        $prefix = trim($this->option('prefix'));
        $max = trim($this->option('max'));
        $next = trim($this->option('next'));

        /**
         * @var Client
         */
        $client = $this->mns;
        if (!$client) {
            $this->error('请先配置阿里云MSN服务，并在DI里面注册');

            return;
        }

        try {
            $data = [];
            $topic = $client->getTopicRef($topicName);
            $res = $topic->listSubscription($max, $prefix, $next);
            if ($res->isSucceed()) {
                foreach ($res->getSubscriptionNames() as $subscriptionName) {
                    $subscription['name'] = $subscriptionName;

                    $attr = $topic->getSubscriptionAttribute($subscriptionName)->getSubscriptionAttributes();

                    $subscription['endpoint'] = $attr->getEndpoint();
                    $subscription['filterTag'] = $attr->getFilterTag();
                    $subscription['strategy'] = $attr->getStrategy();
                    $subscription['contentFormat'] = $attr->getContentFormat();
                    $subscription['createTime'] = date('Y-m-d H:i:s', $attr->getCreateTime());
                    $subscription['updateTime'] = date('Y-m-d H:i:s', $attr->getLastModifyTime());
                    $data[] = $subscription;
                }
            }


            $subscriptionHeaders = ['Name', 'Endpoint', 'FilterTag', 'Strategy', 'ContentFormat', 'CreateTime', 'UpdateTime'];
            $this->line("List of Subscriptions for Topic: $topicName");
            $this->table($subscriptionHeaders, $data);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
    }
249051
public function indexAction()
    {
        $this->view->data = array();
        $s = $this->_getSelectIndex();
        if ($this->_loadColumns) {
            foreach ($this->_loadColumns as $c) {
                $s->expr($c);
            }
        }
        foreach ($this->_model->getRows($s) as $row) {
            $this->view->data[] = $this->_loadDataFromRow($row);
        }
        $this->view->total = $this->_model->countRows($s);
    }
724842
static public function init() {
        // 加载动态应用公共文件和配置
        load_ext_file(COMMON_PATH);

        // 日志目录转换为绝对路径 默认情况下存储到公共模块下面
        C('LOG_PATH',   realpath(LOG_PATH).'/Common/');

        // 定义当前请求的系统常量
        define('NOW_TIME',      $_SERVER['REQUEST_TIME']);
        define('REQUEST_METHOD',$_SERVER['REQUEST_METHOD']);
        define('IS_GET',        REQUEST_METHOD =='GET' ? true : false);
        define('IS_POST',       REQUEST_METHOD =='POST' ? true : false);
        define('IS_PUT',        REQUEST_METHOD =='PUT' ? true : false);
        define('IS_DELETE',     REQUEST_METHOD =='DELETE' ? true : false);

        // URL调度
        Dispatcher:: ();

        if(C('REQUEST_VARS_FILTER')){
			// 全局安全过滤
			array_walk_recursive($_GET,		'think_filter');
			array_walk_recursive($_POST,	'think_filter');
			array_walk_recursive($_REQUEST,	'think_filter');
		}

        // URL调度结束标签
        Hook::listen('url_dispatch');

        define('IS_AJAX',       ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')])) ? true : false);

        // TMPL_EXCEPTION_FILE 改为绝对地址
        C('TMPL_EXCEPTION_FILE',realpath(C('TMPL_EXCEPTION_FILE')));
        return ;
    }