From c967c3e8cad4ade3081cef0ed8bb7c5c2b3703b0 Mon Sep 17 00:00:00 2001 From: Jackson Dou Date: Wed, 12 Jul 2023 00:28:37 +0800 Subject: [PATCH] update: add hosting hostname --- src/admin/api/application.php | 11 +- src/admin/api/clients.php | 71 ++++++++++++ src/admin/api/hosting-hostname.php | 39 ++++--- src/admin/api/login.php | 2 +- src/admin/api/logout.php | 2 +- src/admin/controllers/accounts/add.php | 0 src/admin/controllers/ssl/details.php | 10 +- src/admin/controllers/ssl/raw.php | 10 +- src/admin/views/accounts/add.php | 104 ++++++++++++++++++ src/admin/views/accounts/details.php | 2 +- src/admin/views/accounts/edit.php | 2 +- src/admin/views/accounts/list.php | 2 +- src/admin/views/clients/add.php | 96 +++++++++++++++- src/admin/views/clients/details.php | 2 +- src/admin/views/clients/edit.php | 60 +++++++++- src/admin/views/clients/list.php | 8 +- src/admin/views/hosting-hostname/list.php | 2 +- src/admin/views/hosting-provider/details.php | 4 +- src/admin/views/hosting-provider/list.php | 4 +- src/assets/css/admin.css | 6 - src/assets/css/common.css | 16 +++ src/clientarea/controllers/accounts/add.php | 2 +- src/clientarea/controllers/clients/signup.php | 2 +- src/clientarea/views/accounts/list.php | 2 +- src/clientarea/views/accounts/view.php | 2 +- src/core/library/functions.php | 2 +- src/install/function/Database.php | 5 +- 27 files changed, 410 insertions(+), 58 deletions(-) create mode 100755 src/admin/api/clients.php create mode 100644 src/admin/controllers/accounts/add.php create mode 100755 src/admin/views/accounts/add.php diff --git a/src/admin/api/application.php b/src/admin/api/application.php index 80b2705..efd3a72 100755 --- a/src/admin/api/application.php +++ b/src/admin/api/application.php @@ -1,4 +1,13 @@ find('admin', '*', array('admin_key' => base64_decode($_SESSION['UIISC_ADMIN'])), null, 1); + if (!$AdminInfo) { + unset($_SESSION['UIISC_ADMIN']); + send_response(403, null, 'need login'); + } +} else { + send_response(403, null, 'need login'); +} diff --git a/src/admin/api/clients.php b/src/admin/api/clients.php new file mode 100755 index 0000000..48ef04f --- /dev/null +++ b/src/admin/api/clients.php @@ -0,0 +1,71 @@ + post('client_fname'), + 'client_lname' => post('client_lname'), + 'client_email' => post('client_email'), + 'client_phone' => post('client_phone'), + 'client_company' => post('client_company'), + 'client_address' => post('client_address'), + 'client_country' => post('client_country'), + 'client_city' => post('client_city'), + 'client_pcode' => post('client_pcode'), + 'client_state' => post('client_state'), + 'client_password'=> hash('sha256', post('client_password', '123456')), + // 'client_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), + 'client_key' => randstr(8), + 'client_status' => post('client_status', 0), + 'client_signup_ip' => get_client_ip(), + 'client_addtime' => date('Y-m-d H:i:s'), + ); + + $client_id = $DB->insert('clients', $form_data); + + if ($client_id) { + send_response(200, array('client_id' => $client_id), 'success'); + } else { + send_response(-1, $msg = 'error'); + } + case 'edit': + $client_id = post('client_id'); + $client_password = post('client_password', ''); + $form_data = array( + 'client_fname' => post('client_fname'), + 'client_lname' => post('client_lname'), + 'client_email' => post('client_email'), + 'client_phone' => post('client_phone'), + 'client_company' => post('client_company'), + 'client_address' => post('client_address'), + 'client_country' => post('client_country'), + 'client_city' => post('client_city'), + 'client_pcode' => post('client_pcode'), + 'client_state' => post('client_state'), + // 'client_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), + 'client_status' => post('client_status', 0), + 'client_updatetime' => date('Y-m-d H:i:s'), + ); + + if ($client_password) { + $form_data['client_password'] = hash('sha256', $client_password); + } + + $result = $DB->update('clients', $form_data, array('client_id' => $client_id)); + + if ($result) { + send_response(200, array('client_id' => $client_id), 'success'); + } else { + send_response(-1, $msg = 'error'); + } + default: + send_response(-4, $msg = 'No Act'); + break; +} diff --git a/src/admin/api/hosting-hostname.php b/src/admin/api/hosting-hostname.php index 05296a7..006f42e 100755 --- a/src/admin/api/hosting-hostname.php +++ b/src/admin/api/hosting-hostname.php @@ -9,21 +9,34 @@ $act = get('act'); switch ($act) { case 'list': - $count = $DB->count('account_hostname'); + $total = $DB->count('account_hostname'); $list = array(); - if ($count > 0) { + $total = intval($total); + if ($total > 0) { $list = $DB->findAll('account_hostname', '*', array(), '`host_id` ASC'); } - exit(json_encode(['code' => 0, 'total' => $total, 'list' => $list])); + send_response(200, array('total' => $total, 'list' => $list)); + break; + case 'options': + $api_id = get('api_id'); + if (!$api_id) { + send_response(-1, array()); + } + + $where = array( + 'api_id' => $api_id + ); + $list = $DB->findAll('account_hostname', 'api_id,host_id,host_name', $where, '`host_id` ASC'); + send_response(200, $list); break; case 'add': $hostname = post('hostname'); if (!$hostname) { - exit(json_encode(['code' => -1, 'msg' => '主机名不能为空 !'])); + send_response(-1, null, '主机名不能为空 !'); } $api_id = post('api_id'); if (!$api_id) { - exit(json_encode(['code' => -1, 'msg' => '托管服务提供商不能为空 !'])); + send_response(-1, null, '托管服务提供商不能为空 !'); } $domain = strtolower($hostname); @@ -39,20 +52,20 @@ switch ($act) { $has = $DB->count('account_hostname', $data); if ($has && $has > 0) { - exit(json_encode(['code' => -1, 'msg' => 'Hostname aleady exsist !'])); + send_response(-1, null, 'Hostname aleady exsist !'); } else { $result = $DB->insert('account_hostname', $data); if ($result) { - exit(json_encode(['code' => 0, 'msg' => 'Hostname added successfully !'])); + send_response(0, null, 'Hostname added successfully !'); } else { - exit(json_encode(['code' => -1, 'msg' => 'Something went wrong !'])); + send_response(-1, null, 'Something went wrong !'); } } break; case 'delete': $host_id = post('host_id'); if (!$host_id) { - exit(json_encode(['code' => -1, 'msg' => '主机ID不能为空 !'])); + send_response(-1, null, '主机ID不能为空 !'); } $data = array( 'host_id' => $host_id @@ -60,16 +73,16 @@ switch ($act) { $has = $DB->count('account_hostname', $data); if (!$has > 0) { - exit(json_encode(['code' => -1, 'msg' => 'Hostname not found !'])); + send_response(-1, null, 'Hostname not found !'); } else { $result = $DB->delete('account_hostname', $data); if ($result) { - exit(json_encode(['code' => 0, 'msg' => 'Hostname deleted successfully !'])); + send_response(0, null, 'Hostname deleted successfully !'); } else { - exit(json_encode(['code' => -1, 'msg' => 'Something went wrong !'])); + send_response(-1, null, 'Something went wrong !'); } } default: - exit('{"code":-4,"msg":"No Act"}'); + send_response(-4, NULL, 'No Act'); break; } diff --git a/src/admin/api/login.php b/src/admin/api/login.php index cda2594..4df1cb5 100755 --- a/src/admin/api/login.php +++ b/src/admin/api/login.php @@ -1,6 +1,6 @@ Processing'; + $Status = 'Processing'; } elseif ($SSLInfo['ssl_status'] == 'active') { - $Status = 'Active'; + $Status = 'Active'; } elseif ($SSLInfo['ssl_status'] == 'incomplete') { - $Status = 'Incomplete'; + $Status = 'Incomplete'; } elseif ($SSLInfo['ssl_status'] == 'cancelled') { - $Status = 'Cancelled'; + $Status = 'Cancelled'; } elseif ($SSLInfo['ssl_status'] == 'expired') { - $Status = 'Expired'; + $Status = 'Expired'; } else { $Status = ''; } diff --git a/src/admin/controllers/ssl/raw.php b/src/admin/controllers/ssl/raw.php index b68f6e2..be35de6 100755 --- a/src/admin/controllers/ssl/raw.php +++ b/src/admin/controllers/ssl/raw.php @@ -25,15 +25,15 @@ if ($SSLApi['api_token'] && strtotime($SSLApi['api_token_expiretime']) - 180 >= $SSLInfo = $apiClient->getOrderStatus($SSLApi['ssl_key']); if ($SSLInfo['status'] == 'processing') { - $Status = 'Processing'; + $Status = 'Processing'; } elseif ($SSLInfo['status'] == 'active') { - $Status = 'Active'; + $Status = 'Active'; } elseif ($SSLInfo['status'] == 'incomplete') { - $Status = 'Incomplete'; + $Status = 'Incomplete'; } elseif ($SSLInfo['status'] == 'cancelled') { - $Status = 'Cancelled'; + $Status = 'Cancelled'; } elseif ($SSLInfo['status'] == 'expired') { - $Status = 'Expired'; + $Status = 'Expired'; } else { $Status = ''; } diff --git a/src/admin/views/accounts/add.php b/src/admin/views/accounts/add.php new file mode 100755 index 0000000..b8bb8fd --- /dev/null +++ b/src/admin/views/accounts/add.php @@ -0,0 +1,104 @@ +
+
+ +
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+

+ +
+ +
+
+ + +
+
+
+
+ + +
+
+ +
+
+
+
+ + +
Your account will be deleted after 30 days of your account deactivation and all of the account data will be removed completely(This action cannot be undo).
+ +
+
+ +
+
+ +
+ +
+
+ + +
+
+
+ +
+
+
+
diff --git a/src/admin/views/accounts/details.php b/src/admin/views/accounts/details.php index 44deb32..2d2482f 100755 --- a/src/admin/views/accounts/details.php +++ b/src/admin/views/accounts/details.php @@ -78,7 +78,7 @@
Creation Date: - +
diff --git a/src/admin/views/accounts/edit.php b/src/admin/views/accounts/edit.php index 77ef295..8a399c6 100755 --- a/src/admin/views/accounts/edit.php +++ b/src/admin/views/accounts/edit.php @@ -101,7 +101,7 @@
- +
diff --git a/src/admin/views/accounts/list.php b/src/admin/views/accounts/list.php index 1bfd8d4..6124bf5 100755 --- a/src/admin/views/accounts/list.php +++ b/src/admin/views/accounts/list.php @@ -41,7 +41,7 @@ - + I18N('Inactive'); ?> diff --git a/src/admin/views/clients/add.php b/src/admin/views/clients/add.php index 7f26b70..7d1dd24 100644 --- a/src/admin/views/clients/add.php +++ b/src/admin/views/clients/add.php @@ -4,7 +4,7 @@
@@ -16,12 +16,100 @@
-
-
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + diff --git a/src/admin/views/clients/details.php b/src/admin/views/clients/details.php index 4da3ac4..966a7e9 100755 --- a/src/admin/views/clients/details.php +++ b/src/admin/views/clients/details.php @@ -66,7 +66,7 @@
-
-
+
+
+ + +
+
+ + +
+
@@ -55,6 +67,10 @@
+
+ + +
@@ -63,11 +79,47 @@
-
+
+ + diff --git a/src/admin/views/clients/list.php b/src/admin/views/clients/list.php index 8b52d0c..564d1a9 100755 --- a/src/admin/views/clients/list.php +++ b/src/admin/views/clients/list.php @@ -32,7 +32,7 @@ - + I18N('Inactive'); ?> @@ -45,12 +45,12 @@ I18N('edit'); ?> - - I18N('login'); ?> - I18N('details'); ?> + + I18N('login'); ?> + diff --git a/src/admin/views/hosting-hostname/list.php b/src/admin/views/hosting-hostname/list.php index f7a9150..9061532 100755 --- a/src/admin/views/hosting-hostname/list.php +++ b/src/admin/views/hosting-hostname/list.php @@ -51,7 +51,7 @@ if (!defined('IN_CRONLITE')) { diff --git a/src/admin/views/hosting-provider/details.php b/src/admin/views/hosting-provider/details.php index dbc3254..361f36f 100755 --- a/src/admin/views/hosting-provider/details.php +++ b/src/admin/views/hosting-provider/details.php @@ -13,7 +13,9 @@ if (!defined('IN_CRONLITE')) {
- I18N('Hostname'); ?> + + I18N('Hostname'); ?> + I18N('edit'); ?> diff --git a/src/admin/views/hosting-provider/list.php b/src/admin/views/hosting-provider/list.php index 3355bd0..b86aa27 100755 --- a/src/admin/views/hosting-provider/list.php +++ b/src/admin/views/hosting-provider/list.php @@ -21,6 +21,7 @@ if (!defined('IN_CRONLITE')) {
+ @@ -31,6 +32,7 @@ if (!defined('IN_CRONLITE')) { 0): ?> + @@ -38,7 +40,7 @@ if (!defined('IN_CRONLITE')) { diff --git a/src/assets/css/admin.css b/src/assets/css/admin.css index 39e6cef..9d0e65d 100755 --- a/src/assets/css/admin.css +++ b/src/assets/css/admin.css @@ -2,12 +2,6 @@ body { padding-top: 51px; padding-bottom: 60px; } -.badge, -.badge-pill, -.btn-rounded { - border-radius: 4px !important; - border: none; -} #hidden-area { position: fixed; diff --git a/src/assets/css/common.css b/src/assets/css/common.css index eb37f2b..d724de1 100755 --- a/src/assets/css/common.css +++ b/src/assets/css/common.css @@ -140,4 +140,20 @@ button { .footer .co { display: inline-block; +} + +pre, +.badge, +.breadcrumb, +.btn, +.dropdown-menu, +.form-control, +.label, +.panel, +.panel-footer, +.panel-heading { + border-top-left-radius: 0; + border-top-right-radius: 0; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } \ No newline at end of file diff --git a/src/clientarea/controllers/accounts/add.php b/src/clientarea/controllers/accounts/add.php index 8741eb2..a12fb02 100755 --- a/src/clientarea/controllers/accounts/add.php +++ b/src/clientarea/controllers/accounts/add.php @@ -61,7 +61,7 @@ if (isset($_POST['submit'])) { 'account_api_key' => post('api_key'), 'account_domain' => $Result['account_domain'], 'account_status' => '1', - 'account_date' => $Result['date'], + 'account_addtime' => $Result['date'], 'account_client_id' => $ClientInfo['client_id'], 'account_sql' => 'NULL', )); diff --git a/src/clientarea/controllers/clients/signup.php b/src/clientarea/controllers/clients/signup.php index 91eee0e..569ea32 100755 --- a/src/clientarea/controllers/clients/signup.php +++ b/src/clientarea/controllers/clients/signup.php @@ -44,7 +44,7 @@ if (isset($_POST['signup'])) { // 'client_phone' => 'null', // 'client_state' => 'null', 'client_password' => hash('sha256', post('password')), - 'client_date' => date('Y-m-d H:i:s'), + 'client_addtime' => date('Y-m-d H:i:s'), 'client_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), 'client_status' => 0, ); diff --git a/src/clientarea/views/accounts/list.php b/src/clientarea/views/accounts/list.php index faf830b..6292f79 100755 --- a/src/clientarea/views/accounts/list.php +++ b/src/clientarea/views/accounts/list.php @@ -31,7 +31,7 @@ if (!defined('IN_CRONLITE')) { - +
ID Key I18N('Type'); ?> Panel URL
I18N('edit'); ?> I18N('details'); ?> - I18N('Hostname'); ?> + I18N('Hostname'); ?>
#
Creation Date: - +
diff --git a/src/core/library/functions.php b/src/core/library/functions.php index ad8334b..99ed84a 100755 --- a/src/core/library/functions.php +++ b/src/core/library/functions.php @@ -237,7 +237,7 @@ function post($field = '', $default = '') /** * API Response */ -function send_response($code = 200, $data = NULL, $msg = 'Error') +function send_response($code = 200, $data = NULL, $msg = '') { header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); diff --git a/src/install/function/Database.php b/src/install/function/Database.php index b26655c..db48710 100755 --- a/src/install/function/Database.php +++ b/src/install/function/Database.php @@ -9,7 +9,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account` ( `account_domain` VARCHAR(70) NOT NULL, `account_sql` VARCHAR(8) NOT NULL, `account_status` INT(1) NOT NULL COMMENT "0未激活1已激活2禁用3删除", - `account_date` VARCHAR(20) NOT NULL, + `account_addtime` DATETIME NOT NULL, `account_signup_ip` varchar(20) DEFAULT NULL COMMENT "注册IP", PRIMARY KEY (`account_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;'); @@ -91,11 +91,12 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_clients` ( `client_pcode` VARCHAR(20) NOT NULL, `client_key` VARCHAR(8) NOT NULL, `client_state` VARCHAR(30) NOT NULL, - `client_date` VARCHAR(30) NOT NULL, `client_status` INT(1) NOT NULL, `client_company` VARCHAR(50) NOT NULL, `client_password` VARCHAR(64) NOT NULL, `client_signup_ip` varchar(20) DEFAULT NULL COMMENT "注册IP", + `client_addtime` DATETIME NOT NULL, + `client_updatetime` DATETIME DEFAULT NULL, PRIMARY KEY (`client_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');