浏览代码

update: 1. 新增:账号删除同步到本地回调处理,2. 新增:域名增删同步到本地的回调

Jackson Dou 2 年之前
父节点
当前提交
2cd4637d26

+ 1 - 0
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 . ')';
     }
     // 清理

+ 3 - 0
src/admin/views/accounts/list.php

@@ -45,6 +45,9 @@ if ($row['account_status'] == '0') {
 } elseif ($row['account_status'] == '2') {
     $btn = ['danger', 'lock'];
     echo '<span class="badge bg-danger text-white border-0">Suspended</span>';
+} elseif ($row['account_status'] == '3') {
+    $btn = ['danger', 'lock'];
+    echo '<span class="badge bg-danger text-white border-0">Deleted</span>';
 }
 ?></td>
                         <td>

+ 5 - 1
src/admin/views/accounts/view.php

@@ -13,6 +13,8 @@
             <div class="alert alert-secondary col-md-12">This account is inactive.</div>
         <?php elseif ($AccountInfo['account_status'] == '2'): ?>
             <div class="alert alert-secondary col-md-12">This account has been suspended.</div>
+        <?php elseif ($AccountInfo['account_status'] == '3'): ?>
+            <div class="alert alert-secondary col-md-12">This account has been deleted.</div>
         <?php endif;?>
             <div class="row pb-10">
                 <div class="col-md-12 pb-10 mb-10">
@@ -67,7 +69,9 @@
     echo '<span class="badge bg-success">Active</span>';
 } elseif ($AccountInfo['account_status'] == '2') {
     echo '<span class="badge bg-danger">Suspend</span>';
-}?>
+} elseif ($AccountInfo['account_status'] == '3') {
+    echo '<span class="badge bg-danger">Deleted</span>';
+} ?>
                         </span>
                     </div>
                 </div>

+ 86 - 0
src/callback/myownfreehost/delete.php

@@ -0,0 +1,86 @@
+<?php
+
+// require_once __DIR__ . '/../../core/application.php';
+
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
+
+$username = post('username');
+
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => 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 = '<p><strong>Notification</strong></p><p>You have a hosting account that has been deleted by the system, the details are below.</p>';
+} 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 = '<p><strong>Notification</strong></p><p>The system has deleted a hosting account, the details are given bellow.</p>';
+}
+
+// 记录日志
+$DB->insert('account_callback', $callback_log);
+
+$EmailDescription = '<p>Hosting Account : <pre>' . $AccountInfo['account_username'] . '</pre></p>';
+
+$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'
+));

+ 11 - 5
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 = '<p>An unassigned hosting account has successfully added a new sub domain. The details are given bellow.</p>';
 }
+
+// 同步到本地
+$DB->insert('account_domain', array(
+    'domain_account_id' => $account_id,
+    'domain_name' => $callback_log['callback_comments']
+));
+
 $EmailDescription = '<p><pre>' . $callback_log['callback_comments'] . '</pre></p>
 <p>The new sub domain is now available for use.</p>';
 
@@ -74,6 +79,7 @@ $emails_log = array(
     'email_body' => $email_body,
     'email_read' => 0
 );
+
 // print_r($emails_log);
 $DB->insert('emails', $emails_log);
 

+ 15 - 3
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 = '<p>An unassigned hosting account has successfully deleted a sub domain. The details are given bellow.</p>';
 }
+
 $EmailDescription = '<p><pre>' . $callback_log['callback_comments'] . '</pre></p>
 <p>The sub domain is no longer usable.</p>';
 

+ 3 - 3
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,