mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 07:35:34 +08:00
😘 重构完成!!!!!!
This commit is contained in:
45
start.php
45
start.php
@@ -1,29 +1,8 @@
|
||||
<?php
|
||||
|
||||
function loadAllClass($dir) {
|
||||
$dir_obj = scandir($dir);
|
||||
unset($dir_obj[0], $dir_obj[1]);
|
||||
foreach ($dir_obj as $m) {
|
||||
$taskFileName = explode(".", $m);
|
||||
if (is_dir($dir . $m . "/")) loadAllClass($dir . $m . "/");
|
||||
else {
|
||||
if (count($taskFileName) < 2 || ($taskFileName[1] != "php" && $taskFileName[1] != "phar")) continue;
|
||||
require_once($dir . $m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//工作目录设置
|
||||
//initialize settings.
|
||||
define("WORKING_DIR", __DIR__ . "/");
|
||||
|
||||
function settings() { return json_decode(file_get_contents(WORKING_DIR . "/cqbot.json"), true); }
|
||||
|
||||
if (settings() === null) die("Start failed. Please check cqbot.json file.\n");
|
||||
|
||||
//启动时间
|
||||
define("START_TIME", time());
|
||||
|
||||
//设置dir常量
|
||||
include(WORKING_DIR."src/framework/global_functions.php");
|
||||
define("CQ_DATA", WORKING_DIR . settings()["cq_data"]);
|
||||
define("CONFIG_DIR", WORKING_DIR . settings()["config_dir"]);
|
||||
define("USER_DIR", WORKING_DIR . settings()["user_dir"]);
|
||||
@@ -33,19 +12,19 @@ define("CRASH_DIR", WORKING_DIR . settings()["crash_dir"]);
|
||||
@mkdir(USER_DIR, 0777, true);
|
||||
@mkdir(CRASH_DIR, 0777, true);
|
||||
|
||||
spl_autoload_register("class_loader");
|
||||
|
||||
if (settings() === null) die("Start failed. Please check cqbot.json file.\n");
|
||||
|
||||
//启动时间
|
||||
define("START_TIME", time());
|
||||
|
||||
//设置时区(如果非国内用户请自行注释或更改)
|
||||
date_default_timezone_set("Asia/Shanghai");
|
||||
|
||||
//加载框架
|
||||
require(WORKING_DIR . "src/framework/loader.php");
|
||||
|
||||
//加载全局函数
|
||||
require("tools.php");
|
||||
|
||||
|
||||
//如果是第一次启动或监听地址为空,则启动配置向导
|
||||
if (settings()["host"] == "" || settings()["port"] == "") include("wizard.php");
|
||||
if (settings()["swoole_host"] == "" || settings()["swoole_port"] == "") include("wizard.php");
|
||||
|
||||
//initializing framework
|
||||
$cqbot = new Framework(settings());
|
||||
$cqbot->start();
|
||||
(new Framework(settings()))->start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user