diff --git a/.env.example b/.env.example index 4526ed68..30b1fafb 100644 --- a/.env.example +++ b/.env.example @@ -9,10 +9,11 @@ APP_LOCALE=zh-CN APP_FALLBACK_LOCALE=en LOG_CHANNEL=daily +# 数据库 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 -DB_DATABASE=SSRPanel_OtakuMod +DB_DATABASE=ProxyPanel DB_USERNAME=root DB_PASSWORD=root DB_STRICT=false @@ -21,22 +22,24 @@ BROADCAST_DRIVER=redis CACHE_DRIVER=redis QUEUE_CONNECTION=redis SESSION_DRIVER=redis +SESSION_CONNECTION=session SESSION_LIFETIME=120 +# Redis 设置 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 -MAIL_DRIVER=smtp +MAIL_DRIVER=smtp #或使用 mailgun +# SMTP设置 MAIL_HOST=smtp.exmail.qq.com MAIL_PORT=465 -MAIL_USERNAME=admin@ssrpanel.com +MAIL_USERNAME=admin@proxypanel.ml MAIL_PASSWORD=password MAIL_ENCRYPTION=ssl -MAIL_LOG_CHANNEL=daily -MAIL_FROM_ADDRESS=admin@ssrpanel.com -MAIL_FROM_NAME=SSRPanel - +MAIL_FROM_ADDRESS=admin@proxypanel.ml +MAIL_FROM_NAME=ProxyPanel +# Mailgun设置 MAILGUN_DOMAIN= MAILGUN_SECRET= @@ -53,4 +56,4 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -REDIRECT_HTTPS=true +REDIRECT_HTTPS=true \ No newline at end of file diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index baf4e050..406472b9 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -1205,7 +1205,7 @@ class AdminController extends Controller { // 推送通知测试 public function sendTestNotification(): JsonResponse { if(self::$systemConfig['is_notification']){ - $result = PushNotification::send('这是测试的标题', 'SSRPanel_OM测试内容'); + $result = PushNotification::send('这是测试的标题', 'ProxyPanel测试内容'); if($result == false){ return Response::json(['status' => 'fail', 'message' => '发送失败,请重新尝试!']); } @@ -1266,8 +1266,8 @@ class AdminController extends Controller { $spreadsheet = new Spreadsheet(); $spreadsheet->getProperties() - ->setCreator('SSRPanel') - ->setLastModifiedBy('SSRPanel') + ->setCreator('ProxyPanel') + ->setLastModifiedBy('ProxyPanel') ->setTitle('邀请码') ->setSubject('邀请码') ->setDescription('') diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index 8064875c..67d2a6fd 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -107,7 +107,7 @@ class LoginController extends Controller { 'text' => '', 'buy_link' => '', 'money' => '0.00', - 'sspannelName' => 'ssrpanel', + 'sspannelName' => 'proxypanel', 'usedTraffic' => flowAutoShow($user->u + $user->d), 'Traffic' => flowAutoShow($user->transfer_enable), 'all' => 1, diff --git a/app/Http/Controllers/Api/WebApi/TrojanController.php b/app/Http/Controllers/Api/WebApi/TrojanController.php index 07f00588..5c2400c5 100644 --- a/app/Http/Controllers/Api/WebApi/TrojanController.php +++ b/app/Http/Controllers/Api/WebApi/TrojanController.php @@ -18,6 +18,7 @@ class TrojanController extends BaseController { 'speed_limit' => $node->speed_limit, 'client_limit' => $node->client_limit, 'push_port' => $node->push_port, + 'redirect_url' => Helpers::systemConfig()['redirect_url'], 'trojan_port' => $node->port, 'secret' => $node->auth->secret, 'license' => Helpers::systemConfig()['trojan_license'], diff --git a/app/Http/Controllers/Api/WebApi/V2RayController.php b/app/Http/Controllers/Api/WebApi/V2RayController.php index d798faa8..4c0f5777 100644 --- a/app/Http/Controllers/Api/WebApi/V2RayController.php +++ b/app/Http/Controllers/Api/WebApi/V2RayController.php @@ -13,7 +13,7 @@ class V2RayController extends BaseController { // 获取节点信息 public function getNodeInfo($id): JsonResponse { $node = SsNode::query()->whereId($id)->first(); - $nodeTls = NodeCertificate::query()->whereId($node->server)->first(); + $nodeDv = NodeCertificate::query()->whereId($node->server)->first(); return $this->returnData('获取节点信息成功', 'success', 200, [ 'id' => $node->id, @@ -21,9 +21,10 @@ class V2RayController extends BaseController { 'speed_limit' => $node->speed_limit, 'client_limit' => $node->client_limit, 'push_port' => $node->push_port, + 'redirect_url' => Helpers::systemConfig()['redirect_url'], 'secret' => $node->auth->secret, - 'key' => $nodeTls? $nodeTls->key : '', - 'pem' => $nodeTls? $nodeTls->pem : '', + 'key' => $nodeDv? $nodeDv->key : '', + 'pem' => $nodeDv? $nodeDv->pem : '', 'v2_license' => Helpers::systemConfig()['v2ray_license'], 'v2_alter_id' => $node->v2_alter_id, 'v2_port' => $node->v2_port, diff --git a/app/Http/Controllers/Api/WebApi/VNetController.php b/app/Http/Controllers/Api/WebApi/VNetController.php index 447e6d27..7b5ebd3f 100644 --- a/app/Http/Controllers/Api/WebApi/VNetController.php +++ b/app/Http/Controllers/Api/WebApi/VNetController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api\WebApi; +use App\Components\Helpers; use App\Models\SsNode; use App\Models\User; use Illuminate\Http\JsonResponse; @@ -24,7 +25,8 @@ class VNetController extends BaseController { 'port' => strval($node->port), 'passwd' => $node->passwd?: '', 'push_port' => $node->push_port, - 'secret' => $node->auth->secret + 'secret' => $node->auth->secret, + 'redirect_url' => Helpers::systemConfig()['redirect_url'] ]); } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index 28efcac7..14ca19c8 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -8,23 +8,19 @@ use Illuminate\Database\Eloquent\Model; /** * 审计规则 * - * @property int $id - * @property int $type 类型:1-正则表达式、2-域名、3-IP、4-协议 - * @property string $name 规则描述 - * @property string $pattern 规则值 - * @property \Illuminate\Support\Carbon $created_at - * @property \Illuminate\Support\Carbon $updated_at - * @property-read mixed $type_api_label - * @property-read mixed $type_label + * @property int $id + * @property int $type 类型:1-正则表达式、2-域名、3-IP、4-协议 + * @property string $name 规则描述 + * @property string $pattern 规则值 + * @property-read string $type_api_label + * @property-read string $type_label * @method static Builder|Rule newModelQuery() * @method static Builder|Rule newQuery() * @method static Builder|Rule query() - * @method static Builder|Rule whereCreatedAt($value) * @method static Builder|Rule whereId($value) * @method static Builder|Rule whereName($value) * @method static Builder|Rule wherePattern($value) * @method static Builder|Rule whereType($value) - * @method static Builder|Rule whereUpdatedAt($value) * @mixin \Eloquent */ class Rule extends Model { diff --git a/app/Models/SsNode.php b/app/Models/SsNode.php index 9b19d60c..48a8d51a 100644 --- a/app/Models/SsNode.php +++ b/app/Models/SsNode.php @@ -53,7 +53,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne; * @property \Illuminate\Support\Carbon $created_at * @property \Illuminate\Support\Carbon $updated_at * @property-read \App\Models\NodeAuth|null $auth - * @property-read mixed $type_label + * @property-read string $type_label * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\SsNodeLabel[] $label * @property-read int|null $label_count * @method static Builder|SsNode newModelQuery() @@ -129,6 +129,9 @@ class SsNode extends Model { case 3: $type_label = 'Trojan'; break; + case 4: + $type_label = 'VNet'; + break; default: $type_label = 'UnKnown'; } diff --git a/config/version.php b/config/version.php index 990e6934..00a79ca6 100644 --- a/config/version.php +++ b/config/version.php @@ -1,6 +1,6 @@ '210', - 'name' => 'SSRPanel_OtakuMod' + 'number' => '2.4.a', + 'name' => 'ProxyPanel' ]; diff --git a/public/index.php b/public/index.php index dd3fc34e..03763714 100644 --- a/public/index.php +++ b/public/index.php @@ -7,7 +7,7 @@ * @author Taylor Otwell */ -// 判断是否安装SSRPanel +// 判断是否安装ProxyPanel if (!is_file(__DIR__.'/../.env')) { header("location:./install.php"); diff --git a/public/install.php b/public/install.php index 4a42067c..bb949fa5 100644 --- a/public/install.php +++ b/public/install.php @@ -9,17 +9,9 @@ // error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // ini_set('display_errors', '1'); -// 定义目录分隔符 -define('DS', DIRECTORY_SEPARATOR); - -// 定义根目录 -define('ROOT_PATH', __DIR__.DS.'..'.DS); - -// 定义应用目录 -define('APP_PATH', ROOT_PATH.'app'.DS); - -// 安装包目录 -define('INSTALL_PATH', ROOT_PATH.'sql'.DS); +define('DS', DIRECTORY_SEPARATOR); // 定义目录分隔符 +define('ROOT_PATH', __DIR__.DS.'..'.DS); // 定义根目录 +define('DB_PATH', ROOT_PATH.'sql'.DS.'db.sql');// 数据库 // 判断文件或目录是否有写的权限 function is_really_writable($file) { @@ -36,54 +28,9 @@ function is_really_writable($file) { return true; } -// 写配置文件 -function write_ini_file($assoc_arr, $path, $has_sections = false) { - $content = ""; - if($has_sections){ - foreach($assoc_arr as $key => $elem){ - $content .= "[".$key."]\n"; - foreach($elem as $key2 => $elem2){ - if(is_array($elem2)){ - for($i = 0; $i < count($elem2); $i++){ - $content .= $key2."[] = \"".$elem2[$i]."\"\n"; - } - }elseif($elem2 == ""){ - $content .= $key2." = \n"; - }else{ - $content .= $key2." = \"".$elem2."\"\n"; - } - } - } - }else{ - foreach($assoc_arr as $key => $elem){ - if(is_array($elem)){ - for($i = 0; $i < count($elem); $i++){ - $content .= $key."[] = \"".$elem[$i]."\"\n"; - } - }elseif($elem == ""){ - $content .= $key." = \n"; - }else{ - $content .= $key." = \"".$elem."\"\n"; - } - } - } +$name = "ProxyPanel"; - if(!$handle = fopen($path, 'w')){ - return false; - } - - if(!fwrite($handle, $content)){ - return false; - } - - fclose($handle); - - return true; -} - -$sitename = "OtakuCloud"; - -// 检测目录是否存在 +// 检测依赖组件目录是否存在 $checkDirs = [ 'vendor', ]; @@ -100,11 +47,13 @@ $exampleConfigFile = ROOT_PATH.'.env.example'; // 锁定的文件 $lockFile = ROOT_PATH.'.env'; if(is_file($lockFile)){ - $errInfo = "当前已经安装{$sitename},如果需要重新安装,请手动移除.env文件"; -}elseif(version_compare(PHP_VERSION, '7.1.3', '<')){ - $errInfo = "当前PHP版本(".PHP_VERSION.")过低,请使用PHP7.1.3及以上版本"; + $errInfo = "如果需要重新安装,请备份数据库后手动移除 .env 文件"; +}elseif(version_compare(PHP_VERSION, '7.3.0', '<')){ + $errInfo = "当前PHP版本(".PHP_VERSION.")过低,请使用PHP7.3.0及以上版本"; +}elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){ + $errInfo = "当前系统环境为Windows,无法进行安装"; }elseif(!is_file($exampleConfigFile)){ - $errInfo = "缺失标准配置文件.env.example"; + $errInfo = "缺失标准配置文件 .env.example"; }elseif(!extension_loaded("PDO")){ $errInfo = "当前PHP环境未启用PDO组件,无法进行安装"; }elseif(!is_really_writable(ROOT_PATH)){ @@ -123,7 +72,7 @@ if(is_file($lockFile)){ $dirArr = []; foreach($checkDirs as $k => $v){ if(!is_dir(ROOT_PATH.$v)){ - $errInfo = '请先在'.$sitename.'根目录下执行 php composer.phar install 安装依赖'; + $errInfo = '请先在'.$name."根目录下执行php composer.phar install 安装依赖"; break; } } @@ -138,41 +87,27 @@ if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ $err = ''; $APP_KEY = md5(time().mt_rand(1, 1000000)); - $DB_HOST = isset($_POST['mysqlHost'])? $_POST['mysqlHost'] : '127.0.0.1'; - $DB_PORT = isset($_POST['mysqlHostport'])? $_POST['mysqlHostport'] : 3306; + $DB_HOST = isset($_POST['mysqlHost'])? trim($_POST['mysqlHost']) : '127.0.0.1'; + $DB_PORT = isset($_POST['mysqlPort'])? trim($_POST['mysqlPort']) : 3306; $hostArr = explode(':', $DB_HOST); if(count($hostArr) > 1){ $DB_HOST = $hostArr[0]; $DB_PORT = $hostArr[1]; } - $DB_USERNAME = isset($_POST['mysqlUsername'])? $_POST['mysqlUsername'] : 'root'; - $DB_PASSWORD = isset($_POST['mysqlPassword'])? $_POST['mysqlPassword'] : ''; - $DB_DATABASE = isset($_POST['mysqlDatabase'])? $_POST['mysqlDatabase'] : 'proxypanel'; - // $adminUsername = isset($_POST['adminUsername']) ? $_POST['adminUsername'] : 'admin'; - // $adminPassword = isset($_POST['adminPassword']) ? $_POST['adminPassword'] : 'admin'; - // $adminPasswordConfirmation = isset($_POST['adminPasswordConfirmation']) ? $_POST['adminPasswordConfirmation'] : 'admin'; - // $adminEmail = isset($_POST['adminEmail']) ? $_POST['adminEmail'] : 'admin@admin.com'; - // if ($adminPassword !== $adminPasswordConfirmation) { - // echo "两次输入的密码不一致"; - // exit; - // } else if (!preg_match("/^\w+$/", $adminUsername)) { - // echo "用户名只能输入字母、数字、下划线"; - // exit; - // } else if (!preg_match("/^[\S]+$/", $adminPassword)) { - // echo "密码不能包含空格"; - // exit; - // } else if (strlen($adminUsername) < 3 || strlen($adminUsername) > 12) { - // echo "用户名请输入3~12位字符"; - // exit; - // } else if (strlen($adminPassword) < 6 || strlen($adminPassword) > 16 || stripos($adminPassword, ' ') !== false) { - // echo "密码请输入6~16位字符,不能包含空格"; - // exit; - // } + $DB_USERNAME = isset($_POST['mysqlUsername'])? trim($_POST['mysqlUsername']) : 'proxypanel'; + $DB_PASSWORD = isset($_POST['mysqlPassword'])? trim($_POST['mysqlPassword']) : 'proxypanel'; + $DB_DATABASE = isset($_POST['mysqlDatabase'])? trim($_POST['mysqlDatabase']) : 'proxypanel'; + try{ - // 检测能否读取安装文件 - $sql = @file_get_contents(INSTALL_PATH.'db.sql'); + // 检测能否读取数据库文件 + $sql = @file_get_contents(DB_PATH); if(!$sql){ - throw new Exception("无法读取所需的sql/db.sql,请检查是否有读权限"); + throw new Exception("无法读取所需的".DB_PATH.",请检查是否有读权限"); + } + + $config = @file_get_contents($exampleConfigFile); + if(!$config){ + throw new Exception("无法读取配置.env.example文件,请检查是否有读权限"); } $pdo = new PDO("mysql:host={$DB_HOST};port={$DB_PORT}", $DB_USERNAME, $DB_PASSWORD, [ @@ -191,21 +126,14 @@ if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ $pdo->query("USE `{$DB_DATABASE}`"); $pdo->exec($sql); - $config = @file_get_contents($exampleConfigFile); - if(!$config){ - throw new Exception("无法写入读取配置.env.example文件,请检查是否有读权限"); - } - + // 写入数据库配置到.env文件 $callback = function($matches) use ($APP_KEY, $DB_HOST, $DB_PORT, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE) { $field = $matches[1]; $replace = ${"{$field}"}; return "{$matches[1]}={$replace}".PHP_EOL; }; - $config = preg_replace_callback("/(APP_KEY|DB_HOST|DB_DATABASE|DB_USERNAME|DB_PASSWORD|DB_PORT)=(.*)(\s+)/", $callback, $config); - - // 检测能否成功写入数据库配置 $result = @file_put_contents($ConfigFile, $config); if(!$result){ throw new Exception("无法写入数据库信息到.env文件,请检查是否有写权限"); @@ -228,11 +156,11 @@ if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ 安装<?php - echo $sitename; ?> + echo $name; ?> -