+

数据概览

-
-
注册用户总量
-

+
+
总用户数
+
-
-
待审核充值
-

+
+
总充值金额
+
$
-
-
累计接码订单
-

+
+
总订单数
+
-
-
系统用户总余额
-

$

+
+
待审核充值
+
+ +

用户管理

+
+ + + + + + + + + + + + query("SELECT * FROM users ORDER BY id DESC")->fetchAll(); + foreach ($users as $u): ?> + + + + + + + + + +
ID用户名余额角色操作
$ + +
+
+ + + + -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
用户信息 / USER申请金额 / AMOUNT交易 TXID / HASH提交时间 / TIME管理操作 / ACTION
-
-
USER_ID:
-
$ -
- - -
-
- - -
-
目前暂无任何待处理的充值申请
-
+

充值管理

+
+ + + + + + + + + + + + + + query("SELECT r.*, u.username FROM recharges r JOIN users u ON r.user_id = u.id ORDER BY r.created_at DESC")->fetchAll(); + foreach ($recharges as $r): ?> + + + + + + + + + + + +
ID用户金额TXID / 备注时间状态操作
$ + + + + + +
+ + +
+ +
+ + +

订单记录

+
+ + + + + + + + + + + + + + + query("SELECT o.*, u.username FROM sms_orders o JOIN users u ON o.user_id = u.id ORDER BY o.id DESC LIMIT 100")->fetchAll(); + foreach ($orders as $o): ?> + + + + + + + + + + + + +
ID用户项目国家号码费用状态时间
$
+
+ -
-
-
加载中...
-
-
-
-
- -

请在左侧选择一个用户开始对话

+

客服消息

+
+
+
+
+
正在加载对话...
- +
+
+
请选择一个对话
+
+
+
- + -
-
-
-
- - +

系统设置

+
+ +
设置已更新
+ + +
+
+ +
-
- - +
+ +
-
- - +
+ +
- -
- -
区块链支付钱包地址配置 / CRYPTO WALLETS
- -
- - +
+ +
-
- - +
+ +
- -
- -
LUBAN SMS API 后端配置 / API GATEWAY
-
- - +
+ + +
+
+ +
-
- -
+
- - + \ No newline at end of file diff --git a/ajax_handler.php b/ajax_handler.php index f401b45..1b96151 100644 --- a/ajax_handler.php +++ b/ajax_handler.php @@ -7,7 +7,13 @@ require_once __DIR__ . '/api/LocalLubanApi.php'; const PRICE_MULTIPLIER = 1.8; $pdo = db(); -$api = new LubanSMS(); + +// Ensure apikey is loaded +$stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'lubansms_apikey'"); +$stmt->execute(); +$db_apikey = $stmt->fetchColumn(); + +$api = new LubanSMS($db_apikey); $action = $_GET['action'] ?? ''; @@ -62,8 +68,12 @@ try { break; case 'get_countries': + if (!$db_apikey) { + echo json_encode(['code' => 500, 'msg' => 'API Key not configured in DB'], JSON_UNESCAPED_UNICODE); + break; + } $res = $api->getCountries(); - if ($res && (int)$res['code'] === 0) { + if ($res && (int)($res['code'] ?? -1) === 0) { $data = $res['msg'] ?? $res['data'] ?? []; echo json_encode(['code' => 0, 'data' => $data], JSON_UNESCAPED_UNICODE); } else { @@ -72,11 +82,15 @@ try { break; case 'get_services': + if (!$db_apikey) { + echo json_encode(['code' => 500, 'msg' => 'API Key not configured in DB'], JSON_UNESCAPED_UNICODE); + break; + } $country = $_GET['country'] ?? ''; $service = $_GET['service'] ?? ''; $res = $api->getServices($country, $service); - if ($res && (int)$res['code'] === 0) { + if ($res && (int)($res['code'] ?? -1) === 0) { $data = $res['msg'] ?? $res['data'] ?? []; if (!is_array($data)) $data = []; foreach ($data as &$item) { @@ -91,6 +105,10 @@ try { break; case 'get_number': + if (!$db_apikey) { + echo json_encode(['code' => 500, 'msg' => 'API Key not configured in DB'], JSON_UNESCAPED_UNICODE); + break; + } $service_id = $_GET['service_id'] ?? ''; $country_name = $_GET['country_name'] ?? '未知国家'; $service_name = $_GET['service_name'] ?? '未知项目'; @@ -111,7 +129,7 @@ try { } $res = $api->getNumber($service_id); - if ($res && (int)$res['code'] === 0) { + if ($res && (int)($res['code'] ?? -1) === 0) { $pdo->beginTransaction(); try { $stmt = $pdo->prepare("UPDATE users SET balance = balance - ? WHERE id = ?"); @@ -138,7 +156,7 @@ try { } $res = $api->getSms($request_id); - if ($res && (int)$res['code'] === 0 && (string)($res['msg'] ?? '') === 'success') { + if ($res && (int)($res['code'] ?? -1) === 0 && (string)($res['msg'] ?? '') === 'success') { $stmt = $pdo->prepare("UPDATE sms_orders SET sms_content = ?, status = 'received' WHERE request_id = ?"); $stmt->execute([$res['sms_code'], $request_id]); } @@ -169,7 +187,7 @@ try { } $res = $api->setStatus($request_id, 'reject'); - if ($res && (int)$res['code'] === 0) { + if ($res && (int)($res['code'] ?? -1) === 0) { $stmt = $pdo->prepare("UPDATE sms_orders SET status = 'canceled' WHERE request_id = ?"); $stmt->execute([$request_id]); } diff --git a/api/LocalLubanApi.php b/api/LocalLubanApi.php index 9b35885..0f84ea3 100644 --- a/api/LocalLubanApi.php +++ b/api/LocalLubanApi.php @@ -7,18 +7,25 @@ class LubanSMS { public function __construct($apikey = null) { if ($apikey) { - $this->apikey = $apikey; + $this->apikey = trim($apikey); } else { - $pdo = db(); - $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'lubansms_apikey'"); - $stmt->execute(); - $this->apikey = $stmt->fetchColumn(); + try { + $pdo = db(); + $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'lubansms_apikey'"); + $stmt->execute(); + $val = $stmt->fetchColumn(); + if ($val) { + $this->apikey = trim($val); + } + } catch (Exception $e) { + // Log error or handle + } } } private function request($endpoint, $params = []) { - if (!$this->apikey) { - return ['code' => 500, 'msg' => 'API Key not configured']; + if (!$this->apikey || empty($this->apikey)) { + return ['code' => 500, 'msg' => 'API Key not configured (DB check failed)']; } $params['apikey'] = $this->apikey; $url = $this->baseUrl . $endpoint . '?' . http_build_query($params);