初始化
@access private
541463
function initial() {
	const self = this;

	onHashchange = onHashchange.bind(this);

	/***
   * 注册hashchange事件
   */
	window.addEventListener("hashchange", onHashchange, false);

	/***
   * 注册页面转场事件
   */
	$(window.document).on("pageBeforeChange", function (e, params) {
		self.setParameter(params);
	});
}
28160
public function run() {

		try {
			
			//初始化
			$this->init();

			//触发uri路由
			$this->make('router')->dispatch();

			//reset GET
			$_GET = $this->make('router')->getQueryArray();
			foreach ($_GET as $ik => $iv) {
				if (is_string($ik)) {
					$_REQUEST[$ik] = $iv;
				}
			}

			$this->runControllerAction();

			//结束
			$this->finish(0);

		} catch (\Exception $exception) {
			
			if ($this->currentController == null) {
				$this->currentController = new Controller($this, ''); //默认的controller
			}
			
			//触发事件
			$this->eventDispatcher->dispatchEvent(new \Fasim\Event\ExceptionEvent(\Fasim\Event\Event::$EXCEPTION, $exception));

			$config = $this->make('config');
			$view = $this->currentController->getView();
			$view->getLoader()->setPaths([ FS_PATH . 'View' ]);


			$debug = $this->make('config')->get('debug') === true;
			$traceString = str_replace("\n", "<br />\n", $traceString);
			$error = [
				'code' => $exception->getCode(),
				'message' => $exception->getMessage(),
				'file' => $exception->getFile(),
				'line' => $exception->getLine(),
				'trace' => $exception->getTrace()
			];
			$data = [
				'error' => $error,
				'debug' => $debug
			];
			
			if (file_exists(FS_PATH . 'View' . DIRECTORY_SEPARATOR . 'error' . $exception->getCode() . '.html')) {
				echo $view->render('error' . $exception->getCode() . '.html', $data);
			} else {
				echo $view->render('error500.html', $data);
			}
		
			//结束
			$this->finish(-1);
		}
	}
760449
public function actionMain()
    {
        switch (yii::$app->getDb()->driverName) {
            case "mysql":
                $dbInfo = 'MySQL ' . (new Query())->select('version()')->one()['version()'];
                break;
            case "pgsql":
                $dbInfo = (new Query())->select('version()')->one()['version'];
                break;
            default:
                $dbInfo = "Unknown";
        }
        $info = [
            'OPERATING_ENVIRONMENT' => PHP_OS . ' ' . $_SERVER['SERVER_SOFTWARE'],
            'PHP_RUN_MODE' => php_sapi_name(),
            'DB_INFO' => $dbInfo,
            'PROGRAM_VERSION' => "1.0",
            'UPLOAD_MAX_FILESIZE' => ini_get('upload_max_filesize'),
            'MAX_EXECUTION_TIME' => ini_get('max_execution_time') . "s"
        ];
        $obj = new ServerInfo();
        $serverInfo = $obj->getinfo();
        error_reporting(E_ALL);
        $status = [
            'DISK_SPACE' => [
                'NUM' => ceil( $serverInfo['diskTotal'] - $serverInfo['freeSpace'] ) . 'G' . ' / ' . ceil($serverInfo['diskTotal']) . 'G',
                'PERCENTAGE' => (floatval($serverInfo['diskTotal']) != 0) ? round(($serverInfo['diskTotal'] - $serverInfo['freeSpace']) / $serverInfo['diskTotal'] * 100, 2) : 0,
            ],
            'MEM' => [
                'NUM' => $serverInfo["UsedMemory"] . ' / ' . $serverInfo['TotalMemory'],
                'PERCENTAGE' => $serverInfo["memPercent"],
            ],
            'REAL_MEM' => [
                'NUM' => $serverInfo["memRealUsed"] . "(Cached {$serverInfo['CachedMemory']})" . ' / ' . $serverInfo['TotalMemory'],
                'PERCENTAGE' => $serverInfo['memRealPercent'] . '%',
            ],
        ];
        $temp = [
            'ARTICLE' => ArticleModel::find()->where(['type' => ArticleModel::ARTICLE])->count('id'),
            'COMMENT' => Comment::find()->count('id'),
            'USER' => User::find()->count('id'),
            'FRIEND_LINK' => FriendlyLink::find()->count('id'),
        ];
        $statics = [
            'ARTICLE' => [
                $temp['ARTICLE'],
                $temp['ARTICLE'] == 0 ? 0 :
                number_format(ArticleModel::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['ARTICLE'] * 100, 2)
            ],
            'COMMENT' => [
                $temp['COMMENT'],
                $temp['COMMENT'] == 0 ? 0 :
                number_format(Comment::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-d 00:00:00')),
                        time()
                    ])->count('id') / $temp['COMMENT'] * 100, 2)
            ],
            'USER' => [
                $temp['USER'],
                $temp['USER'] == 0 ? 0 :
                number_format(User::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['USER'] * 100, 2)
            ],
            'FRIEND_LINK' => [
                $temp['FRIEND_LINK'],
                $temp['FRIEND_LINK'] == 0 ? 0 :
                number_format(FriendlyLink::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['FRIEND_LINK'] * 100, 2)
            ],
        ];
        $comments = BackendComment::getRecentComments(6);
        return $this->render('main', [
            'info' => $info,
            'status' => $status,
            'statics' => $statics,
            'comments' => $comments,
        ]);
    }
389136
static function removeAttr($html, $remove_attrs = array())
    {
        //删除所有属性
        if (!is_array($remove_attrs) or count($remove_attrs) == 0)
        {
            return preg_replace('~<([a-z]+)[^>]*>~i','<$1>', $html);
        }
        //删除部分指定的属性
        else
        {
            foreach($remove_attrs as $attr)
            {
                $regx = '~<([^>]*?)[\s\t\r\n]+('.$attr.'[\s\t\r\n]*=[\s\t\r\n]*([\"\'])[^\3]*?\3)([^>]*)>~i';
                $html = preg_replace($regx,'<$1 $4>', $html);
            }

            return $html;
        }
    }
1239169
public function init()
    {
        parent::init();
        $db = $this->getDb();
        if (!isset($this->options['user'])) {
            $this->options['user'] = $db->username;
        }
        if (!isset($this->options['password'])) {
            $this->options['password'] = $db->password;
        }
        $parsed = $this->parseConnectionString($db->connectionString);
        if (!isset($this->options['host'])) {
            $this->options['host'] = $parsed['hostName'];
        }
        if (!isset($this->options['port']) && isset($parsed['port'])) {
            $this->options['port'] = $parsed['port'];
        }
    }
1195781
public function init() {
		//触发应用开始事件
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_START));

		//初始化配置
		$this->registerFacdes();

		//设置时区
		$timezone = $this->make('config')->get('timezone', 'Asia/Shanghai');
		date_default_timezone_set($timezone);

		//设置调试模式
		$debugMode = $this->make('config')->get('debug') === true;
		$this->setDebugMode($debugMode);
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_READY));
	}
1254308
static function getRecordAccessList($authId=null,$module='') {
        if(null===$authId)   $authId = $_SESSION[C('USER_AUTH_KEY')];
        if(empty($module))  $module	=	CONTROLLER_NAME;
        //获取权限访问列表
        $accessList = self::getModuleAccessList($authId,$module);
        return $accessList;
	}
55844
static function CodingSwitch($app = "./",$charset='UTF-8',$mode = "FILES",$file_types = array(".html",".php")) {
		self::info("注意: 程序使用的文件编码检测算法可能对某些特殊字符不适用");
		$filearr = self::searchdir($app,$mode,$file_types);
		foreach($filearr as $file)
			self::DetectAndSwitch($file,$charset);
	}
635132
public function init()
    {
        $config = store('config');
        // 配置文件处理
        $config['themes_dir'] = ROOT.DIRECTORY_SEPARATOR.'Themes/'.$config['themes'];
        $config['plugin_dir'] = ROOT.DIRECTORY_SEPARATOR.'Plugins';
        $config['logs_dir']   = ROOT.DIRECTORY_SEPARATOR.'Logs';
        $config['public_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['public'];
        $config['source_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['source'];

        $this->config = $config;
        $this->page_limit = $config['page_limit'];
        $this->themes_dir = $config['themes_dir'];
        $this->public_dir = $config['public_dir'];
        $this->source_dir = $config['source_dir'];
    }
305053
private static function init()
    {
        $config = Config::getEnv("database.redis");
        if (empty($config)) {
            throw new \InvalidArgumentException("配置项'database.redis'不能为空");
        }
        $config = (array) $config;
        $db_conn_name_list = \Qp\Kernel\Database\QpDB::getConnectionNameList();

        foreach ($config as $name => $data) {
            $name = strval($name);
            if (in_array($name, $db_conn_name_list)) {
                throw new \InvalidArgumentException("配置项'database.redis'的连接名'{$name}'和其他类型的数据库连接名冲突");
            }

            $data = (array) $data;
            if (empty($data)) {
                throw new \InvalidArgumentException("配置项'database.redis.{$name}'必须为非空数组");
            }
            $conn_name = $name;
            self::handleConfigArr($data, 'host', $host);
            self::handleConfigArr($data, 'auth', $auth);
            self::handleConfigArr($data, 'database', $database);
            self::handleConfigArr($data, 'port', $port);
            self::handleConfigArr($data, 'prefix', $prefix);

            $prefix = strval($prefix);
            if ($prefix == "") {
                $data['prefix'] = ":";
            } else {
                $data['prefix'] = "_" . $prefix . ":";
            }

            self::$config_list[$conn_name] = new ConfigObj($conn_name, $host, $auth, $database, $port, $data['prefix'], $data);
        }

        if (self::$frontCache === null) {
            self::$frontCache = new \Phalcon\Cache\Frontend\Data(self::$frontCacheData);
        }
    }
77895
public function initCliAction()
    {
        clearstatcache();

        $app = 'app/' . Config::get('app.name') . '/';

        $assets = array(
            BASE_PATH . $app . '_session/',
            BASE_PATH . $app . '_cache/',
            BASE_PATH . $app . '_database/',
            BASE_PATH . $app . '_templates/',
        );

        echo 'Check app assets' . PHP_EOL;

        foreach ($assets as $asset) {

            if (!is_dir($asset)) {
                echo "[ Please create '$asset' directory! ]" . PHP_EOL;
            }

            if (!is_writable($asset)) {
                echo "[ Please make '$asset' writable! ]" . PHP_EOL;
            }
        }

        echo 'Secure root directory' . PHP_EOL;
        chmod(BASE_PATH, 0755);

        echo 'Secure .htaccess' . PHP_EOL;
        chmod(BASE_PATH . '.htaccess', 0644);

        echo 'Secure index.php' . PHP_EOL;
        chmod(BASE_PATH . 'index.php', 0644);

        echo 'Secure autoload.core.php' . PHP_EOL;
        chmod(BASE_PATH . 'pimf-framework/autoload.core.php', 0644);

        echo 'Create logging files' . PHP_EOL;

        $directory = Config::get('bootstrap.local_temp_directory');

        $handle = fopen($file = $directory . 'pimf-logs.txt', "at+");
        fclose($handle);
        chmod($file, 0777);
        $handle = fopen($file = $directory . 'pimf-warnings.txt', "at+");
        fclose($handle);
        chmod($file, 0777);
        $handle = fopen($file = $directory . 'pimf-errors.txt', "at+");
        fclose($handle);
        chmod($file, 0777);

        clearstatcache();
    }
1135510
static function saveAccessList($authId=null) {
        if(null===$authId)   $authId = $_SESSION[C('USER_AUTH_KEY')];
        // 如果使用普通权限模式，保存当前用户的访问权限列表
        // 对管理员开发所有权限
        if(C('USER_AUTH_TYPE') !=2 && !$_SESSION[C('ADMIN_AUTH_KEY')] )
            $_SESSION['_ACCESS_LIST']	=	self::getAccessList($authId);
        return ;
    }
798662
public function bootstrap($app)
    {
        /** @var Module $module */
        /** @var \yii\db\ActiveRecord $modelName */
        if ($app->hasModule('system') && ($module = $app->getModule('system')) instanceof Module) {
            if ($app instanceof \yii\console\Application) {

            } else if (class_exists('\yuncms\admin\Application') && $app instanceof \yuncms\admin\Application) {

            } elseif ($module instanceof Module) {//前台判断放最后
                $app->urlManager->addRules([
                    'page' => 'system/page/view',
                ]);
                //注册Url管理
                $app->urlManager->addRules([
                    [
                        'class' => 'yuncms\system\components\SlugUrlRule',
                    ]
                ], true);
            }
        }
//        $app->set('settings', [
//            'class' => 'yuncms\system\components\Settings',
//        ]);

        /**
         * 注册语言包
         */
        if (!isset($app->get('i18n')->translations['system*'])) {
            $app->get('i18n')->translations['system*'] = [
                'class' => PhpMessageSource::className(),
                'sourceLanguage' => 'en-US',
                'basePath' => __DIR__ . '/messages',
            ];
        }
    }
293127
static public function init() {

        // 日志目录转换为绝对路径 默认情况下存储到公共模块下面
        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::dispatch();

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

        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 ;
    }
109194
public function pushServer()
    {
        if (!isset($this->config['ssh_user'])) {
            Log::info( 'SSH账户没有配置，请在Config.php文件参照如下方式配置：' );
            Log::info( '$config[\'ssh_user\']=\'root\';' );
            die();
        }
        if (!isset($this->config['ssh_address'])) {
            Log::info( 'SSH地址没有配置，请在Config.php文件参照如下方式配置：' );
            Log::info( '$config[\'ssh_address\']=\'127.0.0.1\';' );
            die();
        }
        if (!isset($this->config['ssh_path'])) {
            Log::info( 'SSH路径没有配置，请在Config.php文件参照如下方式配置：' );
            Log::info( '$config[\'ssh_path\']=\'/usr/www/html\';' );
            die();
        }

        // 网站根目录
        $web_root = ROOT.DIRECTORY_SEPARATOR.$this->config['public'].DIRECTORY_SEPARATOR;
        if (strstr(PHP_OS, 'WIN')) {
            $web_root = str_replace("\\","/", $web_root);
            $web_root = iconv('UTF-8', 'gbk', $web_root);
        }
        // 上传指令
        $cmd = 'scp -r '. $web_root . '* ';
        $cmd .= $this->config['ssh_user'] . '@'.$this->config['ssh_address'] . ':';
        $cmd .= $this->config['ssh_path'];
        // 最终需要执行的命令
        $cmd = "cd ".$web_root." && ".$cmd;
        system($cmd, $out);
        if ($out === false) {
            throw new Exception('指令执行失败，请坚持是否配置错误');
        }
    }
288050
public static function ini()
    {
        $files = glob(static::path().'*.php');

        foreach ($files as $file) {
            $table = need($file);

            foreach ($table as $key => $value) {
                $file = static::getFileName($file);

                self::$links[$file][$key] = $value;
            }
        }
    }
432833
function put($params)
    {
        if(isset($params['put']))
        {
            Error::info('SelectDB Error!','Params put() cannot call put()!');
        }
        //处理where条件
        if (isset($params['where']))
        {
            $wheres = $params['where'];
            if (is_array($wheres))
            {
                foreach ($wheres as $where)
                {
                    $this->_where($where);
                }
            }
            else
            {
                $this->_where($wheres);
            }
            unset($params['where']);
        }
        //处理orwhere条件
        if(isset($params['orwhere']))
        {
            $orwheres = $params['orwhere'];
            if(is_array($orwheres)) foreach($orwheres as $orwhere) $this->orwhere($orwhere);
            else $this->$orwheres($orwheres);
            unset($params['orwhere']);
        }
        //处理walk调用
        if (isset($params['walk']))
        {
            foreach($params['walk'] as $call)
            {
                list($key, $value) = each($call);
                if (strpos($key, '_') !== 0)
                {
                    $this->_call($key, $value);
                }
                else
                {
                    $this->extraParmas[substr($key, 1)] = $value;
                }
            }
            unset($params['walk']);
        }
        //处理其他参数
        foreach ($params as $key => $value)
        {
            if (strpos($key, '_') !== 0)
            {
                $this->_call($key, $value);
            }
            else
            {
                $this->extraParmas[substr($key, 1)] = $value;
            }
        }
    }