fix: 修复两处SQL执行与登录逻辑的问题
3 个文件变更
+22
-4
13172193298@163.com
| •MPHX/plugin.php | +11 -2 |
| •admin/api/login.php | +2 -2 |
| •app_plugins/zjmfmanager_reserve/bootstrap.php | +9 -0 |
变更内容
diff --git a/MPHX/plugin.php b/MPHX/plugin.php
index b0f3217..249acc3 100644
--- a/MPHX/plugin.php
+++ b/MPHX/plugin.php
@@ -231,8 +231,17 @@ function mnbt_plugin_run_sql_file($file)
}
$parts = preg_split('/;\s*[\r\n]+/', $sql);
foreach ($parts as $stmt) {
- $stmt = trim($stmt);
- if ($stmt === '' || strpos($stmt, '--') === 0) {
+ // 逐行剔除 `--` 注释行,避免「注释 + SQL」同段被整体误判为注释而跳过建表/删表语句
+ $lines = [];
+ foreach (explode("\n", $stmt) as $line) {
+ $trimmed = ltrim($line);
+ if ($trimmed === '' || strpos($trimmed, '--') === 0) {
+ continue;
+ }
+ $lines[] = $line;
+ }
+ $stmt = trim(implode("\n", $lines));
+ if ($stmt === '') {
continue;
}
@$DB->query($stmt);
diff --git a/admin/api/login.php b/admin/api/login.php
index 2009bd0..589f14f 100644
--- a/admin/api/login.php
+++ b/admin/api/login.php
@@ -7,7 +7,7 @@ if($egn=='login') {
if ($conf['yzm']=='true' && $code != $_SESSION['authcode']) {
unset($_SESSION['authcode']);
@header('Content-Type: text/html; charset=UTF-8');
- json_exit('验证码错误');
+ json_exit_error('验证码错误');
} elseif($user==$conf['user'] && $pass==$conf['pwd']) {
unset($_SESSION['authcode']);
$session=md5($user.$pass.$password_hash);
@@ -19,7 +19,7 @@ if($egn=='login') {
} else {
unset($_SESSION['authcode']);
@header('Content-Type: text/html; charset=UTF-8');
- json_exit('用户名或密码错误');
+ json_exit_error('用户名或密码错误');
}
} elseif(isset($_POST['logout'])) {
mnbt_set_auth_cookie("admin_token", "", time() - 604800);
diff --git a/app_plugins/zjmfmanager_reserve/bootstrap.php b/app_plugins/zjmfmanager_reserve/bootstrap.php
index df2b03a..ec6d809 100644
--- a/app_plugins/zjmfmanager_reserve/bootstrap.php
+++ b/app_plugins/zjmfmanager_reserve/bootstrap.php
@@ -19,6 +19,15 @@ if (!defined('IN_CRONLITE')) {
require_once __DIR__ . '/lib/zjmf.php';
require_once __DIR__ . '/lib/upstream.php';
+// 确保插件数据表存在:修复历史版本安装时 install.sql 首段(注释 + CREATE TABLE)
+// 被 mnbt_plugin_run_sql_file 整体跳过导致缺表(如 MN_plugin_zjmf_supplier)的问题。
+// install.sql 全部为 IF NOT EXISTS 建表,幂等,可安全重复执行。
+static $zjmf_tables_ready = false;
+if (!$zjmf_tables_ready && function_exists('mnbt_plugin_run_sql_file')) {
+ $zjmf_tables_ready = true;
+ mnbt_plugin_run_sql_file(__DIR__ . '/install.sql');
+}
+
mnbt_plugin_register('zjmfmanager_reserve', [
'name' => '魔方财务代理分销',
'description' => '商品同步加价、本地余额购买、代理商直通开通、主机管理与升降级',