From 2cd4637d26f01c84582c406633758f1dc2f08a79 Mon Sep 17 00:00:00 2001 From: Jackson Dou Date: Tue, 13 Jun 2023 20:08:26 +0800 Subject: [PATCH] =?UTF-8?q?update:=201.=20=E6=96=B0=E5=A2=9E=EF=BC=9A?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=88=A0=E9=99=A4=E5=90=8C=E6=AD=A5=E5=88=B0?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=9B=9E=E8=B0=83=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?2.=20=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=9F=9F=E5=90=8D=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E5=90=8C=E6=AD=A5=E5=88=B0=E6=9C=AC=E5=9C=B0=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/controllers/accounts/sync.php | 1 + src/admin/views/accounts/list.php | 3 + src/admin/views/accounts/view.php | 6 +- src/callback/myownfreehost/delete.php | 86 +++++++++++++++++++++ src/callback/myownfreehost/subdomainadd.php | 16 ++-- src/callback/myownfreehost/subdomaindel.php | 18 ++++- src/install/function/Database.php | 6 +- 7 files changed, 124 insertions(+), 12 deletions(-) create mode 100755 src/callback/myownfreehost/delete.php diff --git a/src/admin/controllers/accounts/sync.php b/src/admin/controllers/accounts/sync.php index 9a77ac0..feb78f7 100755 --- a/src/admin/controllers/accounts/sync.php +++ b/src/admin/controllers/accounts/sync.php @@ -38,6 +38,7 @@ if ($AccountInfo['account_status'] == 1) { } if (count($DomainList) > 0) { foreach($DomainList as &$item) { + // 格式 ("abc.com",1234) $item = '("' . $item . '",' .$account_id . ')'; } // 清理 diff --git a/src/admin/views/accounts/list.php b/src/admin/views/accounts/list.php index 7634c05..b72ba43 100755 --- a/src/admin/views/accounts/list.php +++ b/src/admin/views/accounts/list.php @@ -45,6 +45,9 @@ if ($row['account_status'] == '0') { } elseif ($row['account_status'] == '2') { $btn = ['danger', 'lock']; echo 'Suspended'; +} elseif ($row['account_status'] == '3') { + $btn = ['danger', 'lock']; + echo 'Deleted'; } ?> diff --git a/src/admin/views/accounts/view.php b/src/admin/views/accounts/view.php index d9ab4b6..af39740 100755 --- a/src/admin/views/accounts/view.php +++ b/src/admin/views/accounts/view.php @@ -13,6 +13,8 @@
This account is inactive.
This account has been suspended.
+ +
This account has been deleted.
@@ -67,7 +69,9 @@ echo 'Active'; } elseif ($AccountInfo['account_status'] == '2') { echo 'Suspend'; -}?> +} elseif ($AccountInfo['account_status'] == '3') { + echo 'Deleted'; +} ?>
diff --git a/src/callback/myownfreehost/delete.php b/src/callback/myownfreehost/delete.php new file mode 100755 index 0000000..4b0f971 --- /dev/null +++ b/src/callback/myownfreehost/delete.php @@ -0,0 +1,86 @@ + date('Y-m-d H:i:s'), + 'callback_username' => $username, + 'callback_action' => $status, + 'callback_comments' => post('comments'), + 'callback_client_id' => 0, + 'callback_raw' => json_encode(post()) +); + +// 账号信息 +$AccountInfo = $DB->find('account', '*', array('account_username' => $username)); +if ($AccountInfo) { + // 更新账号信息 + // 0未激活1已激活2禁用3删除 + $res = $DB->update('account', array('account_status' => '3'), array('account_id' => $AccountInfo['account_id'])); + + // 查找客户信息 + $ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id'])); + if ($ClientInfo) { + $callback_log['callback_client_id'] = $AccountInfo['account_client_id']; + $EmailTo = $ClientInfo['client_email']; + $EmailToNickname = $ClientInfo['client_fname']; + } else { + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + } + $EmailContent = '

Notification

You have a hosting account that has been deleted by the system, the details are below.

'; +} else { + // 账号不存在,入库 + $AccountInfo = array( + 'account_username' => $username, + 'account_password' => '********', + 'account_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), + 'account_api_key' => $api_key, + 'account_domain' => '***.' . $AccountApi['api_server_domain'], + 'account_status' => '3', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $DB->insert('account', $AccountInfo); + + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

Notification

The system has deleted a hosting account, the details are given bellow.

'; +} + +// 记录日志 +$DB->insert('account_callback', $callback_log); + +$EmailDescription = '

Hosting Account :

' . $AccountInfo['account_username'] . '

'; + +$email_body = email_build_body('Hosting Account Status Changed', $EmailToNickname, $EmailContent, $EmailDescription); + +// print($email_body); + +$emails_log = array( + 'email_client_id' => $AccountInfo['account_client_id'], + 'email_date' => date('Y-m-d H:i:s'), + 'email_to' => $EmailTo, + 'email_subject' => 'Hosting Account Status Changed', + 'email_body' => $email_body, + 'email_read' => 0 +); +// print_r($emails_log); +$DB->insert('emails', $emails_log); + +send_mail(array( + 'to' => $EmailTo, + 'message' => $email_body, + 'subject' => 'Hosting Account Status Changed' +)); diff --git a/src/callback/myownfreehost/subdomainadd.php b/src/callback/myownfreehost/subdomainadd.php index e6905ba..43f8604 100755 --- a/src/callback/myownfreehost/subdomainadd.php +++ b/src/callback/myownfreehost/subdomainadd.php @@ -14,7 +14,7 @@ $callback_log = array( 'callback_date' => date('Y-m-d H:i:s'), 'callback_username' => $username, 'callback_action' => $status, - 'callback_comments' => post('comments'), + 'callback_comments' => post('comments'), // domain name 'callback_client_id' => 0, 'callback_raw' => json_encode(post()) ); @@ -22,9 +22,7 @@ $callback_log = array( // 账号信息 $AccountInfo = $DB->find('account', '*', array('account_username' => $username)); if ($AccountInfo) { - // 禁用账号 - // $res = $DB->update('account', array('account_status' => '2'), array('account_id' => $AccountInfo['account_id'])); - + $account_id = $AccountInfo['account_id']; // 查找客户信息 $ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id'])); if ($ClientInfo) { @@ -50,12 +48,19 @@ if ($AccountInfo) { 'account_client_id' => 0, 'account_sql' => 'sql***' ); - $DB->insert('account', $AccountInfo); + $account_id = $DB->insert('account', $AccountInfo); $EmailTo = $SiteConfig['site_email']; $EmailToNickname = 'Administrator'; $EmailContent = '

An unassigned hosting account has successfully added a new sub domain. The details are given bellow.

'; } + +// 同步到本地 +$DB->insert('account_domain', array( + 'domain_account_id' => $account_id, + 'domain_name' => $callback_log['callback_comments'] +)); + $EmailDescription = '

' . $callback_log['callback_comments'] . '

The new sub domain is now available for use.

'; @@ -74,6 +79,7 @@ $emails_log = array( 'email_body' => $email_body, 'email_read' => 0 ); + // print_r($emails_log); $DB->insert('emails', $emails_log); diff --git a/src/callback/myownfreehost/subdomaindel.php b/src/callback/myownfreehost/subdomaindel.php index a7d4ad3..574d41a 100755 --- a/src/callback/myownfreehost/subdomaindel.php +++ b/src/callback/myownfreehost/subdomaindel.php @@ -22,8 +22,13 @@ $callback_log = array( // 账号信息 $AccountInfo = $DB->find('account', '*', array('account_username' => $username)); if ($AccountInfo) { - // 禁用账号 - // $res = $DB->update('account', array('account_status' => '2'), array('account_id' => $AccountInfo['account_id'])); + $account_id = $AccountInfo['account_id']; + + // 同步到本地 + $DB->delete('account_domain', array( + 'domain_account_id' => $account_id, + 'domain_name' => $callback_log['callback_comments'] + )); // 查找客户信息 $ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id'])); @@ -50,12 +55,19 @@ if ($AccountInfo) { 'account_client_id' => 0, 'account_sql' => 'sql***' ); - $DB->insert('account', $AccountInfo); + $account_id = $DB->insert('account', $AccountInfo); + + // 同步到本地 + $DB->delete('account_domain', array( + // 'domain_account_id' => $account_id, + 'domain_name' => $callback_log['callback_comments'] + )); $EmailTo = $SiteConfig['site_email']; $EmailToNickname = 'Administrator'; $EmailContent = '

An unassigned hosting account has successfully deleted a sub domain. The details are given bellow.

'; } + $EmailDescription = '

' . $callback_log['callback_comments'] . '

The sub domain is no longer usable.

'; diff --git a/src/install/function/Database.php b/src/install/function/Database.php index ba78551..5b6ed8a 100755 --- a/src/install/function/Database.php +++ b/src/install/function/Database.php @@ -8,7 +8,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account` ( `account_password` VARCHAR(16) NOT NULL, `account_domain` VARCHAR(70) NOT NULL, `account_sql` VARCHAR(8) NOT NULL, - `account_status` INT(1) NOT NULL, + `account_status` INT(1) NOT NULL COMMENT "0未激活1已激活2禁用3删除", `account_date` VARCHAR(20) NOT NULL, `account_signup_ip` varchar(20) DEFAULT NULL COMMENT "注册IP", PRIMARY KEY (`account_id`) @@ -46,10 +46,10 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_callbac $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_domain` ( `domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主机账号ID", - `domain_name` varchar(255) NOT NULL COMMENT "域名", `domain_account_id` int(11) NOT NULL COMMENT "托管账号ID", + `domain_name` varchar(255) NOT NULL COMMENT "域名", PRIMARY KEY (`domain_id`) -) ENGINE=MyISAM AUTO_INCREMENT=1071 DEFAULT CHARSET=utf8mb4;'); +) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;'); $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_config` ( `site_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,