diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..1e60ea5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,3 @@ +location /callback { + rewrite ^(.*)$ /callback/index.php?s=$1 last; break; +} \ No newline at end of file diff --git a/src/admin/controllers/accounts/deactivate.php b/src/admin/controllers/accounts/deactivate.php index 59a4c06..b27db9a 100755 --- a/src/admin/controllers/accounts/deactivate.php +++ b/src/admin/controllers/accounts/deactivate.php @@ -32,12 +32,20 @@ if (empty($AccountInfo)) { // redirect('admin/accounts', '', array('action' => 'view', 'account_id' => $account_id)); // } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); + +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; -$client = Client::create($HostingApiConfig); +$client = Client::create($AccountApiConfig); $request = $client->suspend(array( 'username' => $AccountInfo['account_key'], 'reason' => $reason, diff --git a/src/admin/controllers/accounts/goftp.php b/src/admin/controllers/accounts/goftp.php index 00997c5..3d31cb0 100755 --- a/src/admin/controllers/accounts/goftp.php +++ b/src/admin/controllers/accounts/goftp.php @@ -8,13 +8,13 @@ if (empty($account_id)) { redirect('admin/accounts'); } -$data = $DB->find('account', '*', array('account_id' => $account_id), null, 1); +$AccountInfo = $DB->find('account', '*', array('account_id' => $account_id), null, 1); -if (empty($data)) { +if (empty($AccountInfo)) { redirect('admin/accounts'); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); -$filemanager_url = get_filemanager_url($HostingApi['api_cpanel_url'], $data['account_username'], $data['account_password']); +$filemanager_url = get_filemanager_url($AccountApi['api_server_ftp_domain'], $AccountInfo['account_username'], $AccountInfo['account_password']); header("Location: " . $filemanager_url); diff --git a/src/admin/controllers/accounts/login.php b/src/admin/controllers/accounts/login.php index aa075c6..f491579 100755 --- a/src/admin/controllers/accounts/login.php +++ b/src/admin/controllers/accounts/login.php @@ -14,4 +14,4 @@ if (empty($AccountInfo)) { redirect('admin/accounts'); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); diff --git a/src/admin/controllers/accounts/password.php b/src/admin/controllers/accounts/password.php index 829a9d4..3ba5481 100755 --- a/src/admin/controllers/accounts/password.php +++ b/src/admin/controllers/accounts/password.php @@ -32,12 +32,20 @@ if ($AccountInfo['account_status'] != 1) { redirect('admin/accounts', '', array('action' => 'edit', 'account_id' => $account_id)); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); + +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; -$client = Client::create($HostingApiConfig); +$client = Client::create($AccountApiConfig); $request = $client->password([ 'username' => $AccountInfo['account_key'], 'password' => $new_password, diff --git a/src/admin/controllers/accounts/reactivate.php b/src/admin/controllers/accounts/reactivate.php index 6097064..c8ba19d 100755 --- a/src/admin/controllers/accounts/reactivate.php +++ b/src/admin/controllers/accounts/reactivate.php @@ -25,12 +25,20 @@ if ($AccountInfo['account_status'] == 1) { redirect('admin/accounts', '', array('action' => 'view', 'account_id' => $account_id)); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); + +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; -$client = Client::create($HostingApiConfig); +$client = Client::create($AccountApiConfig); $request = $client->unsuspend(array( 'username' => $AccountInfo['account_key'], )); diff --git a/src/admin/controllers/accounts/view.php b/src/admin/controllers/accounts/view.php index 9158d4d..dd13718 100755 --- a/src/admin/controllers/accounts/view.php +++ b/src/admin/controllers/accounts/view.php @@ -10,13 +10,12 @@ if (empty($account_id)) { redirect('admin/accounts'); } -require_once ROOT . '/core/handler/HostingHandler.php'; - -$PageInfo['title'] = 'View Account (#' . $account_id . ')'; - $AccountInfo = $DB->find('account', '*', array('account_id' => $account_id), null, 1); if (empty($AccountInfo)) { setMessage('not found', 'danger'); redirect('admin/accounts'); } + +$PageInfo['title'] = 'View Account (#' . $account_id . ')'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); diff --git a/src/admin/controllers/clients/list.php b/src/admin/controllers/clients/list.php index 6b06b31..53b4411 100755 --- a/src/admin/controllers/clients/list.php +++ b/src/admin/controllers/clients/list.php @@ -1,6 +1,6 @@ I18N('My Clients'); +$PageInfo['title'] = $lang->I18N('Clients List'); $count = $DB->count('clients'); diff --git a/src/admin/controllers/clients/view.php b/src/admin/controllers/clients/view.php index 4d45321..6b69668 100755 --- a/src/admin/controllers/clients/view.php +++ b/src/admin/controllers/clients/view.php @@ -1,17 +1,13 @@ find('clients', '*', array('client_id' => $client_id), null, 1); @@ -24,6 +20,7 @@ foreach ($countries as $country) { } } +$PageInfo['title'] = 'View client (' . $client_id . ')'; $count_account = $DB->count('account', array('account_client_id' => $ClientInfo['client_id'])); $count_ssl = $DB->count('ssl', array('ssl_client_id' => $ClientInfo['client_id'])); $count_tickets = $DB->count('tickets', array('ticket_client_id' => $ClientInfo['client_id'])); diff --git a/src/admin/controllers/hosting/add.php b/src/admin/controllers/hosting/add.php index 713fa1e..2c74b84 100755 --- a/src/admin/controllers/hosting/add.php +++ b/src/admin/controllers/hosting/add.php @@ -3,16 +3,6 @@ if (isset($_POST['submit'])) { require '../../application.php'; - if (!post('api_username')) { - setMessage('need field: api_username', 'danger'); - redirect('admin/hosting'); - } - - if (!post('api_password')) { - setMessage('need field: api_password', 'danger'); - redirect('admin/hosting'); - } - if (!post('api_type')) { setMessage('need field: api_type', 'danger'); redirect('admin/hosting'); @@ -23,6 +13,21 @@ if (isset($_POST['submit'])) { redirect('admin/hosting'); } + if (!post('api_username')) { + setMessage('need field: api_username', 'danger'); + redirect('admin/hosting'); + } + + if (!post('api_password')) { + setMessage('need field: api_password', 'danger'); + redirect('admin/hosting'); + } + + if (!post('api_server_domain')) { + setMessage('need field: api_server_domain', 'danger'); + redirect('admin/hosting'); + } + if (!post('api_cpanel_url')) { setMessage('need field: api_cpanel_url', 'danger'); redirect('admin/hosting'); @@ -33,6 +38,16 @@ if (isset($_POST['submit'])) { redirect('admin/hosting'); } + if (!post('api_server_ftp_domain')) { + setMessage('need field: api_server_ftp_domain', 'danger'); + redirect('admin/hosting'); + } + + if (!post('api_server_sql_domain')) { + setMessage('need field: api_server_sql_domain', 'danger'); + redirect('admin/hosting'); + } + if (!post('api_ns_1')) { setMessage('need field: api_ns_1', 'danger'); redirect('admin/hosting'); @@ -59,7 +74,10 @@ if (isset($_POST['submit'])) { 'api_password' => post('api_password'), 'api_type' => post('api_type'), 'api_key' => post('api_key'), + 'api_server_domain' => post('api_server_domain'), 'api_cpanel_url' => post('api_cpanel_url'), + 'api_server_ftp_domain' => post('api_server_ftp_domain'), + 'api_server_sql_domain' => post('api_server_sql_domain'), 'api_server_ip' => post('api_server_ip'), 'api_ns_1' => post('api_ns_1'), 'api_ns_2' => post('api_ns_2'), diff --git a/src/admin/controllers/hosting/edit.php b/src/admin/controllers/hosting/edit.php index 99180b6..8b65bef 100755 --- a/src/admin/controllers/hosting/edit.php +++ b/src/admin/controllers/hosting/edit.php @@ -7,12 +7,81 @@ if (isset($_POST['submit'])) { setMessage('need field: api_id', 'danger'); redirect('admin/hosting'); } + + if (!post('api_type')) { + setMessage('need field: api_type', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_key')) { + setMessage('need field: api_key', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_username')) { + setMessage('need field: api_username', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_password')) { + setMessage('need field: api_password', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_server_domain')) { + setMessage('need field: api_server_domain', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_cpanel_url')) { + setMessage('need field: api_cpanel_url', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_server_ip')) { + setMessage('need field: api_server_ip', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_server_ftp_domain')) { + setMessage('need field: api_server_ftp_domain', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_server_sql_domain')) { + setMessage('need field: api_server_sql_domain', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_ns_1')) { + setMessage('need field: api_ns_1', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_ns_2')) { + setMessage('need field: api_ns_2', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_package')) { + setMessage('need field: api_package', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + + if (!post('api_callback_token')) { + setMessage('need field: api_callback_token', 'danger'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); + } + $data = array( 'api_username' => post('api_username'), 'api_password' => post('api_password'), 'api_type' => post('api_type'), 'api_key' => post('api_key'), + 'api_server_domain' => post('api_server_domain'), 'api_cpanel_url' => post('api_cpanel_url'), + 'api_server_ftp_domain' => post('api_server_ftp_domain'), + 'api_server_sql_domain' => post('api_server_sql_domain'), 'api_server_ip' => post('api_server_ip'), 'api_ns_1' => post('api_ns_1'), 'api_ns_2' => post('api_ns_2'), @@ -28,7 +97,7 @@ if (isset($_POST['submit'])) { setMessage("Something went's wrong !", 'danger'); } - redirect('admin/hosting'); + redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]); } else { if (!defined('IN_CRONLITE')) { exit('Access Denied'); diff --git a/src/admin/controllers/hosting/view.php b/src/admin/controllers/hosting/view.php index c935694..4ff5bd9 100755 --- a/src/admin/controllers/hosting/view.php +++ b/src/admin/controllers/hosting/view.php @@ -5,10 +5,16 @@ if (!defined('IN_CRONLITE')) { } $api_id = get('id'); +$api_key = get('api_key'); if ($api_id > 0) { - // $PageInfo = ['title' => 'View Hosting Provider #' . $api_id, 'rel' => '']; $data = $DB->find('account_api', '*', array('api_id' => $api_id), null, 1); + $api_callback_url = "{$site_url}/callback/{$data['api_key']}/{$data['api_callback_token']}"; + $PageInfo = ['title' => 'View Hosting Provider', 'rel' => '']; +} else if (!empty($api_key)) { + $data = $DB->find('account_api', '*', array('api_key' => $api_key), null, 1); + $api_callback_url = "{$site_url}/callback/{$data['api_key']}/{$data['api_callback_token']}"; + $PageInfo = ['title' => 'View Hosting Provider', 'rel' => '']; } else { $PageInfo = ['title' => 'Unathorized Access', 'rel' => '']; $data = null; diff --git a/src/admin/controllers/news/add.php b/src/admin/controllers/news/add.php index 28dca70..6fc4f2b 100755 --- a/src/admin/controllers/news/add.php +++ b/src/admin/controllers/news/add.php @@ -19,7 +19,7 @@ if (isset($_POST['submit'])) { } redirect('admin/news'); } else { - $PageInfo['title'] = 'Add News'; + $PageInfo['title'] = $lang->I18N('News Add'); $status_types = array( "关闭", "打开", diff --git a/src/admin/controllers/news/edit.php b/src/admin/controllers/news/edit.php index b4fdbf4..4cbd6eb 100755 --- a/src/admin/controllers/news/edit.php +++ b/src/admin/controllers/news/edit.php @@ -45,3 +45,5 @@ if ($id > 0) { $news = $DB->find('news', '*', array('news_id' => $id), null, 1); } $load_editor = 1; + +$PageInfo['title'] = $lang->I18N('News Edit'); diff --git a/src/admin/controllers/news/list.php b/src/admin/controllers/news/list.php index 8736266..4c53fcf 100755 --- a/src/admin/controllers/news/list.php +++ b/src/admin/controllers/news/list.php @@ -12,3 +12,5 @@ $status_types = array( "关闭", "打开", ); + +$PageInfo['title'] = $lang->I18N('News List'); \ No newline at end of file diff --git a/src/admin/controllers/news/view.php b/src/admin/controllers/news/view.php index 3b79696..994fa30 100755 --- a/src/admin/controllers/news/view.php +++ b/src/admin/controllers/news/view.php @@ -20,3 +20,5 @@ $data = null; if ($id > 0) { $data = $DB->find('news', '*', array('news_id' => $id), null, 1); } + +$PageInfo['title'] = $lang->I18N('News Details'); \ No newline at end of file diff --git a/src/admin/controllers/profile/view.php b/src/admin/controllers/profile/view.php index e588a26..885e6ea 100755 --- a/src/admin/controllers/profile/view.php +++ b/src/admin/controllers/profile/view.php @@ -1,5 +1,3 @@ I18N('My Profile'); - -require_once ROOT . '/core/library/userinfo.class.php'; diff --git a/src/admin/controllers/settings/view.php b/src/admin/controllers/settings/view.php index c5901f0..3059344 100755 --- a/src/admin/controllers/settings/view.php +++ b/src/admin/controllers/settings/view.php @@ -1,7 +1,5 @@ 'Live', 'value' => '1'), array('name' => 'Maintaince', 'value' => '0'), diff --git a/src/admin/news.php b/src/admin/news.php index 7f48c84..a751aa5 100755 --- a/src/admin/news.php +++ b/src/admin/news.php @@ -8,8 +8,6 @@ if (!in_array($action, array('list', 'add', 'edit', 'view'))) { $action = 'list'; } -$PageInfo['title'] = 'News ' . ucfirst($action); - require __DIR__ . '/controllers/news/' . $action . '.php'; require __DIR__ . '/views/common/header.php'; require __DIR__ . '/views/common/navbar.php'; diff --git a/src/admin/tickets.php b/src/admin/tickets.php index 41e52d1..a61bf8f 100755 --- a/src/admin/tickets.php +++ b/src/admin/tickets.php @@ -1,7 +1,6 @@ ID + I18N('Clients'); ?> + I18N('Provider'); ?> I18N('Username'); ?> I18N('Domain'); ?> I18N('Deploy Date'); ?> @@ -23,7 +25,13 @@ 0): ?> - # + + + + + + + diff --git a/src/admin/views/accounts/login.php b/src/admin/views/accounts/login.php index c3b1ea8..4eaca05 100755 --- a/src/admin/views/accounts/login.php +++ b/src/admin/views/accounts/login.php @@ -7,7 +7,7 @@

Now you are going to be redirected to the control panel. It can take upto 5 seconds based on your internet connecion speed.

-
+ diff --git a/src/admin/views/accounts/view.php b/src/admin/views/accounts/view.php index 03eb16d..0cd86ed 100755 --- a/src/admin/views/accounts/view.php +++ b/src/admin/views/accounts/view.php @@ -35,13 +35,13 @@
- Cpanel Username: + Control Panel Username:
- Cpanel Password: + Control Panel Password:
@@ -53,8 +53,8 @@
- Cpanel Domain: - + Control Panel Domain: +
@@ -80,19 +80,19 @@
Server IP: - +
Your IP: - +
FTP Hostname: - +
@@ -104,7 +104,7 @@
MySQL Hostname: - +
@@ -116,13 +116,13 @@
Nameserver 1: - +
Nameserver 2: - +
diff --git a/src/admin/views/clients/list.php b/src/admin/views/clients/list.php index 2a36c45..af1b4fb 100755 --- a/src/admin/views/clients/list.php +++ b/src/admin/views/clients/list.php @@ -2,7 +2,7 @@
-

I18N('My Clients'); ?>

+

I18N('Clients List'); ?>

I18N('Return'); ?>

@@ -10,19 +10,21 @@ - - - - - + + + + + + 0): ?> - + + - + diff --git a/src/admin/views/hosting/view.php b/src/admin/views/hosting/view.php index 9ab537b..a7cc855 100755 --- a/src/admin/views/hosting/view.php +++ b/src/admin/views/hosting/view.php @@ -18,6 +18,18 @@
+
+
+ + +
+
+
+
+ + +
+
@@ -32,14 +44,26 @@
- - + +
- - + + +
+
+
+
+ + +
+
+
+
+ +
@@ -54,18 +78,6 @@
-
-
- - -
-
-
-
- - -
-
@@ -78,11 +90,23 @@
+
+
+ + +
+
+
+
+ + +
+

- diff --git a/src/admin/views/news/add.php b/src/admin/views/news/add.php index 53b7b8a..651e928 100755 --- a/src/admin/views/news/add.php +++ b/src/admin/views/news/add.php @@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
-
Add News
+
I18N('Return'); ?>

diff --git a/src/admin/views/news/edit.php b/src/admin/views/news/edit.php index e4c47dd..3fc63ad 100755 --- a/src/admin/views/news/edit.php +++ b/src/admin/views/news/edit.php @@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
-
Edit News
+
I18N('Return'); ?> diff --git a/src/admin/views/news/list.php b/src/admin/views/news/list.php index 26091df..e7182f1 100755 --- a/src/admin/views/news/list.php +++ b/src/admin/views/news/list.php @@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
-
I18N('news'); ?>
+
I18N('add'); ?> diff --git a/src/admin/views/news/view.php b/src/admin/views/news/view.php index 9299b5a..d4bc9a3 100755 --- a/src/admin/views/news/view.php +++ b/src/admin/views/news/view.php @@ -10,7 +10,7 @@ if (!defined('IN_CRONLITE')) {
-
News Details #
+
#
-
I18N('IP Address'); ?>:
+
I18N('IP Address'); ?>:
Shared IP:
-
Device Type:
+
Device Type:
-
Device OS:
+
Device OS:
-
Web Browser:
+
Web Browser:

diff --git a/src/admin/views/tickets/list.php b/src/admin/views/tickets/list.php index 28c1038..73b0eb1 100755 --- a/src/admin/views/tickets/list.php +++ b/src/admin/views/tickets/list.php @@ -3,7 +3,7 @@
-

I18N('My Tickets'); ?>

+

I18N('Tickets List'); ?>

I18N('Return'); ?> diff --git a/src/callback/.htaccess b/src/callback/.htaccess new file mode 100644 index 0000000..d9ee23c --- /dev/null +++ b/src/callback/.htaccess @@ -0,0 +1,8 @@ + + Options +FollowSymlinks -Multiviews + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] + diff --git a/src/callback/index.php b/src/callback/index.php index e65f77c..2080641 100755 --- a/src/callback/index.php +++ b/src/callback/index.php @@ -1,34 +1,36 @@ find('account_api', '*', array('api_key' => $key), null, 1); - -if (!$HostingApi) { - header("status: 404"); - exit('404 Not Found'); +if (!$path_array || count($path_array) < 2) { + exit('401 Unauthorized'); } -if ($token != $HostingApi['api_callback_token']) { - header("status: 404"); - exit('404 Not Found'); +if (!isset($path_array[0]) || empty($path_array[0])) { + header("status: 401"); + exit('401 Unauthorized'); } -require_once __DIR__ . '/' . $key . '/app.php'; +if (!isset($path_array[1]) || empty($path_array[1])) { + header("status: 401"); + exit('401 Unauthorized'); +} + +$api_key = $path_array[0]; +$token = $path_array[1]; + +$AccountApi = $DB->find('account_api', '*', array('api_key' => $api_key), null, 1); + +if (!$AccountApi) { + exit('Not Found'); +} + +if ($token != $AccountApi['api_callback_token']) { + exit('Unauthorized'); +} + +file_put_contents('./log.txt', json_encode($_POST), FILE_APPEND); +file_put_contents('./log.txt', "\n", FILE_APPEND); + +require_once __DIR__ . '/' . $AccountApi['api_type'] . '/app.php'; diff --git a/src/callback/myownfreehost/activate.php b/src/callback/myownfreehost/activate.php index 7a202c4..586e149 100755 --- a/src/callback/myownfreehost/activate.php +++ b/src/callback/myownfreehost/activate.php @@ -12,49 +12,89 @@ 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, 'account_api_key' => $HostingApi['api_key'])); +$AccountInfo = $DB->find('account', '*', array('account_username' => $username)); if ($AccountInfo) { - // 账号存在 激活账号 - $res = $DB->update('account', array('account_sql' => $status, 'account_status' => '1'), array('account_id' => $AccountInfo['account_id'])); + // 更新账号信息 + $res = $DB->update('account', array('account_status' => '1'), 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']; - $EmailSubject = 'New Hosting Account'; - $EmailToPeople = $ClientInfo['client_fname']; + $EmailToNickname = $ClientInfo['client_fname']; } else { $EmailTo = $SiteConfig['site_email']; - $EmailToPeople = 'Administrator'; + $EmailToNickname = 'Administrator'; } $EmailContent = '

You have successfully created a new hosting account the details are given bellow.

'; } else { - // TODO: 账号不存在,入库 + // 账号不存在,入库 + $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' => '1', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $DB->insert('account', $AccountInfo); + $EmailTo = $SiteConfig['site_email']; - $EmailToPeople = 'Administrator'; + $EmailToNickname = 'Administrator'; $EmailContent = '

Congratulations !

You have successfully received a new hosting account, the details are given bellow.

'; } +// 记录日志 +$DB->insert('account_callback', $callback_log); + $EmailDescription = ' -cPanel Username: ' . $AccountInfo['account_username'] . '
-cPanel Password: ' . $AccountInfo['account_password'] . '
-cPanel URL : ' . $HostingApi['api_cpanel_url'] . '

-Main Domain : ' . $AccountInfo['account_domain'] . '
-Account Date : ' . $AccountInfo['account_date'] . '
-Server IP : ' . $HostingApi['api_server_ip'] . '
-Hosting Package: ' . $HostingApi['api_package'] . '

-FTP Username : ' . $AccountInfo['account_username'] . '
-FTP Password : ' . $AccountInfo['account_password'] . '
-FTP Hostname : ftpupload.net
-FTP Port : 21

-MySQL Username : ' . $AccountInfo['account_username'] . '
-MySQL Password : ' . $AccountInfo['account_password'] . '
-MySQL Hostname : ' . str_replace('cpanel', $AccountInfo['account_sql'], $HostingApi['api_cpanel_url']) . '
-MySQL Port : 3306

-Nameserver 1 : ' . $HostingApi['api_ns_1'] . '
-Nameserver 2 : ' . $HostingApi['api_ns_2'] . ''; -$email_body = email_build_body('New Hosting Account', $EmailToPeople, $EmailContent, $EmailDescription); +

Account domain : ' . $AccountInfo['account_domain'] . '
+Account date : ' . $AccountInfo['account_date'] . '
+Server IP : ' . $AccountApi['api_server_ip'] . '
+Hosting package: ' . $AccountApi['api_package'] . '

+

Control Panel username : ' . $AccountInfo['account_username'] . '
+Control Panel password : ' . $AccountInfo['account_password'] . '
+Control Panel URL : ' . $AccountApi['api_cpanel_url'] . '

+ +

SQL hostname : ***.' . $AccountApi['api_server_sql_domain'] . '
+SQL username : ' . $AccountInfo['account_username'] . '
+SQL password : ' . $AccountInfo['account_password'] . '
+SQL port : 3306

+

FTP username : ' . $AccountInfo['account_username'] . '
+FTP password : ' . $AccountInfo['account_password'] . '
+FTP hostname : ' . $AccountApi['api_server_ftp_domain'] . '
+FTP port : 21

+

Nameserver 1 : ' . $AccountApi['api_ns_1'] . '
+Nameserver 2 : ' . $AccountApi['api_ns_2'] . '

'; + +$email_body = email_build_body('New Hosting Account', $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' => 'New Hosting Account', + 'email_body' => $email_body, + 'email_read' => 0 +); +// print_r($emails_log); +$DB->insert('emails', $emails_log); send_mail(array( 'to' => $EmailTo, diff --git a/src/callback/myownfreehost/app.php b/src/callback/myownfreehost/app.php index 597d311..858b00f 100755 --- a/src/callback/myownfreehost/app.php +++ b/src/callback/myownfreehost/app.php @@ -12,10 +12,27 @@ if (!isset($_POST['comments'])) { $status = post('status'); -if (substr($status, 0, 3) == 'sql') { +if ($status == 'ACTIVATED') { + // 帐户激活,新注册 require_once __DIR__ . '/activate.php'; } elseif ($status == 'SUSPENDED') { + // 帐户暂停 require_once __DIR__ . '/suspend.php'; +} else if ($status == 'REACTIVATE') { + // 帐户解禁 + require_once __DIR__ . '/reactivate.php'; +} else if ($status == 'CLIENTSUBADD') { + // 添加子域名 + require_once __DIR__ . '/subdomainadd.php'; +} else if ($status == 'CLIENTSUBDEL') { + // 删除子域名 + require_once __DIR__ . '/subdomaindel.php'; +} else if ($status == 'DELETE') { + // 帐户已删除 + require_once __DIR__ . '/delete.php'; +} else if (substr($status, 0, 3) == 'sql') { + // 用户sql集群已开通 + require_once __DIR__ . '/sqlcluster.php'; } else { exit('Access Denied'); } diff --git a/src/callback/myownfreehost/reactivate.php b/src/callback/myownfreehost/reactivate.php new file mode 100755 index 0000000..132364b --- /dev/null +++ b/src/callback/myownfreehost/reactivate.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) { + // 更新账号信息 + $res = $DB->update('account', array('account_status' => '1'), 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']; + $EmailContent = '

Your hosting account has been reactivated, and you can continue to use it now.

'; + } else { + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

An Unassigned hosting account has been reactivated. The details are given bellow.

'; + } +} 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' => '1', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $DB->insert('account', $AccountInfo); + + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

An Unassigned hosting account has been reactivated. 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/sqlcluster.php b/src/callback/myownfreehost/sqlcluster.php new file mode 100755 index 0000000..bac6ddb --- /dev/null +++ b/src/callback/myownfreehost/sqlcluster.php @@ -0,0 +1,87 @@ + 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) { + // 账号存在 + // 更新sql集群 + $res = $DB->update('account', array('account_sql' => $status), 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'; + } +} else { + // 账号不存在,入库 + $AccountInfo = array( + 'account_username' => $username, + 'account_password' => 0, + 'account_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), + 'account_api_key' => $api_key, + 'account_domain' => '***.' . $AccountApi['api_server_domain'], + 'account_status' => '1', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => $status + ); + $account_id = $DB->insert('account', $AccountInfo); + + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Unassigned Account'; +} + +// 记录日志 +$DB->insert('account_callback', $callback_log); + +$EmailDescription = ' +

MySQL Server Information:

+hostname : ' . $status . '.' . $AccountApi['api_server_sql_domain'] . '
+username : ' . $AccountInfo['account_username'] . '
+password : ' . $AccountInfo['account_password'] . '
+port : 3306'; + +$EmailContent = '

Your SQL Cluster is now ready for deployment and use. The details are given bellow.

'; +$email_body = email_build_body('Hosting SQL Cluster 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 SQL Cluster 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 SQL Cluster Status Changed' +)); diff --git a/src/callback/myownfreehost/subdomainadd.php b/src/callback/myownfreehost/subdomainadd.php new file mode 100755 index 0000000..e6905ba --- /dev/null +++ b/src/callback/myownfreehost/subdomainadd.php @@ -0,0 +1,84 @@ + 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) { + // 禁用账号 + // $res = $DB->update('account', array('account_status' => '2'), 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']; + $EmailContent = '

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

'; + } else { + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

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

'; + } +} 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' => '1', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $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.

'; +} +$EmailDescription = '

' . $callback_log['callback_comments'] . '

+

The new sub domain is now available for use.

'; + +// 记录日志 +$DB->insert('account_callback', $callback_log); + +$email_body = email_build_body('Hosting Account Domain Changed', $EmailToNickname, $EmailContent, $EmailDescription); + +// print_r($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 Domain 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 Domain Changed' +)); diff --git a/src/callback/myownfreehost/subdomaindel.php b/src/callback/myownfreehost/subdomaindel.php new file mode 100755 index 0000000..a7d4ad3 --- /dev/null +++ b/src/callback/myownfreehost/subdomaindel.php @@ -0,0 +1,84 @@ + 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) { + // 禁用账号 + // $res = $DB->update('account', array('account_status' => '2'), 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']; + $EmailContent = '

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

'; + } else { + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

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

'; + } +} 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' => '1', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $DB->insert('account', $AccountInfo); + + $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.

'; + +// 记录日志 +$DB->insert('account_callback', $callback_log); + +$email_body = email_build_body('Hosting Account Domain Changed', $EmailToNickname, $EmailContent, $EmailDescription); + +// print_r($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 Domain 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 Domain Changed' +)); diff --git a/src/callback/myownfreehost/suspend.php b/src/callback/myownfreehost/suspend.php index 0128258..904b311 100755 --- a/src/callback/myownfreehost/suspend.php +++ b/src/callback/myownfreehost/suspend.php @@ -1,30 +1,88 @@ find('account', '*', array('account_username' => $username, 'account_api_key' => $HostingApi['api_key'])); -if (!$AccountInfo) { - // 账号不存在 - exit(); +if (!$username) { + exit('need: username'); } -// 禁用账号 -$DB->update('account', array('account_status' => '2'), array('account_id' => $AccountInfo['account_id'])); -// 创建删除任务 -// $DB->query("CREATE EVENT " . $username . "_delete ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 30 DAY DO DELETE FROM `hosting_account` WHERE `account_id`='" . $AccountInfo['account_id'] . "'"); +$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()) +); -// 查找客户信息 -$ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id'])); +// 账号信息 +$AccountInfo = $DB->find('account', '*', array('account_username' => $username)); +if ($AccountInfo) { + // 禁用账号 + $res = $DB->update('account', array('account_status' => '2'), array('account_id' => $AccountInfo['account_id'])); -$EmailContent = '

We had a good time with you while you were with us.

'; -$EmailDescription = '

Your account(' . $username . ') have been deactivate successfully and all files and database will be deleted within 30 days.


'; -$email_body = email_build_body('Hosting Account Deactivated', $ClientInfo['client_fname'], $EmailContent, $EmailDescription); + // 查找客户信息 + $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']; + $EmailContent = '

Your hosting account has been suspended.

'; + $EmailDescription = '

the hosting account ' . $username . ' has been Deactivated.

+

All files and database will be deleted within 30 days.

+

Please perform data backup and data migration as soon as possible !

+

If you have any questions, please contact the administrator.

'; + } else { + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

An unassigned hosting account has been suspended. The details are given bellow.

'; + $EmailDescription = '

the hosting account ' . $username . ' has been Deactivated.

All files and database will be deleted within 30 days.

'; + } +} 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' => '2', + 'account_date' => $callback_log['callback_date'], + 'account_client_id' => 0, + 'account_sql' => 'sql***' + ); + $DB->insert('account', $AccountInfo); + + $EmailTo = $SiteConfig['site_email']; + $EmailToNickname = 'Administrator'; + $EmailContent = '

An unassigned hosting account has been suspended. The details are given bellow.

'; + $EmailDescription = '

the hosting account ' . $username . ' has been Deactivated.

All files and database will be deleted within 30 days.

'; +} + +// 记录日志 +$DB->insert('account_callback', $callback_log); + +$email_body = email_build_body('Hosting Account Status Changed', $EmailToNickname, $EmailContent, $EmailDescription); + +// print_r($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' => $ClientInfo['client_email'], + 'to' => $EmailTo, 'message' => $email_body, - 'subject' => 'Hosting Account Deactivated' + 'subject' => 'Hosting Account Status Changed' )); diff --git a/src/clientarea/controllers/accounts/add.php b/src/clientarea/controllers/accounts/add.php index 695cf77..dc791a0 100755 --- a/src/clientarea/controllers/accounts/add.php +++ b/src/clientarea/controllers/accounts/add.php @@ -4,34 +4,41 @@ require_once __DIR__ . '/../../application.php'; $PageInfo = ['title' => 'New Account', 'rel' => '']; -require_once ROOT . '/core/handler/HostingHandler.php'; require_once ROOT . '/modules/autoload.php'; -// require_once ROOT . '/core/library/userinfo.class.php'; - use \InfinityFree\MofhClient\Client; if (isset($_POST['submit'])) { + $api_key = post('api_key'); + if (empty($api_key)) { + send_response([500, '', 'api_key cannot be empty !']); + } $FormData = array( 'username' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), 'password' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 16), 'account_domain' => post('domain'), 'email' => $ClientInfo['client_email'], - 'plan' => post('package'), + // 'plan' => post('package'), ); if (empty($FormData['account_domain'])) { - setMessage('Domain cannot be empty !', 'danger'); - redirect('clientarea/accounts', '', array('action' => 'add')); + send_response([500, '', 'Domain cannot be empty !']); } else { $AccountList = $DB->findAll('account', '*', array('account_client_id' => $ClientInfo['client_id'])); if (count($AccountList) < 3) { - $client = Client::create($HostingApiConfig); + $AccountApi = $DB->find('account_api', '*', array('api_key' => post('api_key')), null, 1); + $AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], + ); + $client = Client::create($AccountApiConfig); $request = $client->createAccount(array( 'username' => $FormData['username'], 'password' => $FormData['password'], 'domain' => $FormData['account_domain'], 'email' => $FormData['email'], - 'plan' => $FormData['plan'], + 'plan' => $AccountApiConfig['plan'], )); $response = $request->send(); $Data = $response->getData(); @@ -39,17 +46,19 @@ if (isset($_POST['submit'])) { 'account_username' => $Data['result']['options']['vpusername'], 'message' => $Data['result']['statusmsg'], 'status' => $Data['result']['status'], - 'account_domain' => str_replace('cpanel', strtolower($FormData['username']), $HostingApi['api_cpanel_url']), + 'account_domain' => str_replace('cpanel', strtolower($FormData['username']), $AccountApi['api_cpanel_url']), 'date' => date('Y-m-d H:i:s'), ); if ($Result['status'] == 0 && strlen($Result['message']) > 1) { - setMessage($Result['message'], 'danger'); - redirect('clientarea/accounts', '', array('action' => 'add')); + send_response([500, '', $Result['message']]); + // setMessage($Result['message'], 'danger'); + // redirect('clientarea/accounts', '', array('action' => 'add')); } elseif ($Result['status'] == 1 && strlen($Result['message']) > 1) { $account_id = $DB->insert('account', array( 'account_username' => $Result['account_username'], 'account_password' => $FormData['password'], 'account_key' => $FormData['username'], + 'account_api_key' => post('api_key'), 'account_domain' => $Result['account_domain'], 'account_status' => '1', 'account_date' => $Result['date'], @@ -59,21 +68,20 @@ if (isset($_POST['submit'])) { if ($account_id) { $EmailTo = $FormData['email']; - $EmailContent = ' -

Congratulations !

+ $EmailContent = '

Congratulations !

You have successfully created a new free hosting account, more details are given below:


'; $EmailDescription = ' -cPanel Username : ' . $Result['account_username'] . '
-cPanel Password : ' . $FormData['password'] . '
+Control Panel Username : ' . $Result['account_username'] . '
+Control Panel Password : ' . $FormData['password'] . '
+Control Panel URL : ' . $AccountApi['api_cpanel_url'] . '
Main Domain : ' . $Result['account_domain'] . '
Account Date : ' . $Result['date'] . '
-cPanel URL : ' . $HostingApi['api_cpanel_url'] . '
-Server IP : ' . $HostingApi['api_server_ip'] . '
-Hosting Package : ' . $HostingApi['api_package'] . '
-FTP Hostname : ftpupload.net
-MySQL Hostname : ' . str_replace('cpanel', 'sqlxxx', $HostingApi['api_cpanel_url']) . '
-Nameserver 1 : ' . $HostingApi['api_ns_1'] . '
-Nameserver 2 : ' . $HostingApi['api_ns_2'] . ' +Server IP : ' . $AccountApi['api_server_ip'] . '
+Hosting Package : ' . $AccountApi['api_package'] . '
+FTP Hostname : ' . $AccountApi['api_server_ftp_domain'] . '
+MySQL Hostname : ' . $AccountApi['api_server_sql_domain'] . '
+Nameserver 1 : ' . $AccountApi['api_ns_1'] . '
+Nameserver 2 : ' . $AccountApi['api_ns_2'] . '

Next,


'; @@ -85,25 +93,30 @@ if (isset($_POST['submit'])) { 'message' => $email_body, 'subject' => 'New Hosting Account' )); - - setMessage('Account created successfully !', 'success'); - redirect('clientarea/accounts', '', array('action' => 'view', 'account_id' => $account_id)); + send_response([500, '', 'Account created successfully !']); } else { - setMessage('Something went' . "'" . 's wrong !', 'danger'); - redirect('clientarea/accounts', '', array('action' => 'add')); + send_response([500, '', 'Something went' . "'" . 's wrong !']); } } elseif ($Result['status'] == 0 && $Result['message'] == 0) { - setMessage('Something went' . "'" . 's wrong !', 'danger'); - redirect('clientarea/accounts', '', array('action' => 'add')); + send_response([500, '', 'Something went' . "'" . 's wrong !']); } } else { - setMessage('Free account limit reached !', 'danger'); - redirect('clientarea/accounts', '', array('action' => 'add')); + send_response([500, '', 'Free account limit reached !']); } } } else { + $api_key = get('api_key'); + if (empty($api_key)) { + setMessage('api_key cannot be empty !', 'danger'); + redirect('clientarea/accounts'); + } $ExtensionInfo = $DB->findAll('domain_extensions', '*', array(), 'extension_id'); - + $AccountApi = $DB->find('account_api', '*', array('api_key' => get('api_key')), null, 1); + $AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + 'plan' => $AccountApi['api_package'], + ); if (empty($ExtensionInfo)) { $ExtensionInfo = array( 'extension_value' => '.html-5.me', diff --git a/src/clientarea/controllers/accounts/deactivate.php b/src/clientarea/controllers/accounts/deactivate.php index b182303..1da0859 100755 --- a/src/clientarea/controllers/accounts/deactivate.php +++ b/src/clientarea/controllers/accounts/deactivate.php @@ -32,12 +32,20 @@ if ($AccountInfo['account_status'] != 1) { redirect('clientarea/accounts', '', array('action' => 'view', 'account_id' => $account_id)); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); + +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; -$client = Client::create($HostingApiConfig); +$client = Client::create($AccountApiConfig); $request = $client->suspend(array( 'username' => $AccountInfo['account_key'], 'reason' => $reason, diff --git a/src/clientarea/controllers/accounts/goftp.php b/src/clientarea/controllers/accounts/goftp.php index 6ef01e1..7c7a43e 100755 --- a/src/clientarea/controllers/accounts/goftp.php +++ b/src/clientarea/controllers/accounts/goftp.php @@ -21,7 +21,7 @@ if ($AccountInfo['account_status'] != 1) { redirect('clientarea/accounts', '', array('action' => 'view', 'account_id' => $account_id)); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); -$filemanager_url = get_filemanager_url($HostingApi['api_cpanel_url'], $AccountInfo['account_username'], $AccountInfo['account_password'], $domain); +$filemanager_url = get_filemanager_url($AccountApi['api_server_ftp_domain'], $AccountInfo['account_username'], $AccountInfo['account_password'], $domain); header("Location: " . $filemanager_url); diff --git a/src/clientarea/controllers/accounts/login.php b/src/clientarea/controllers/accounts/login.php index 9d3af38..b4b9dad 100755 --- a/src/clientarea/controllers/accounts/login.php +++ b/src/clientarea/controllers/accounts/login.php @@ -21,6 +21,6 @@ if ($AccountInfo['account_status'] != 1) { redirect('clientarea/accounts', '', array('action' => 'view', 'account_id' => $account_id)); } -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', 'api_cpanel_url', array('api_key' => $AccountInfo['account_api_key']), null, 1); $PageInfo['title'] = 'Login to Control Panel'; diff --git a/src/clientarea/controllers/accounts/password.php b/src/clientarea/controllers/accounts/password.php index 6ea2cb7..49feee0 100755 --- a/src/clientarea/controllers/accounts/password.php +++ b/src/clientarea/controllers/accounts/password.php @@ -32,13 +32,21 @@ $FormData = array( 'account_username' => $AccountInfo['account_username'] ); -require_once ROOT . '/core/handler/HostingHandler.php'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); + +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; if ($FormData['old_password'] == $AccountInfo['account_password']) { - $client = Client::create($HostingApiConfig); + $client = Client::create($AccountApiConfig); $request = $client->password([ 'username' => $AccountInfo['account_key'], 'password' => $FormData['new_password'], diff --git a/src/clientarea/controllers/accounts/validate_domain.php b/src/clientarea/controllers/accounts/validate_domain.php index e33a8fa..7966f9a 100755 --- a/src/clientarea/controllers/accounts/validate_domain.php +++ b/src/clientarea/controllers/accounts/validate_domain.php @@ -1,15 +1,23 @@ find('account_api', '*', array('api_key' => 'ttkl.cf'), null, 1); + + $AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], + ); + + $client = Client::create($AccountApiConfig); $request = $client->availability(array('domain' => $domain)); $response = $request->send(); if ($response->isSuccessful() == 0 && strlen($response->getMessage()) > 1) { diff --git a/src/clientarea/controllers/accounts/view.php b/src/clientarea/controllers/accounts/view.php index ade27c9..0e68e5e 100755 --- a/src/clientarea/controllers/accounts/view.php +++ b/src/clientarea/controllers/accounts/view.php @@ -19,33 +19,39 @@ if (empty($AccountInfo)) { redirect('clientarea/accounts'); } -// require_once ROOT . '/core/library/userinfo.class.php'; // TODO: Change to an asynchronous request -require_once ROOT . '/core/handler/HostingHandler.php'; require_once ROOT . '/modules/autoload.php'; use \InfinityFree\MofhClient\Client; $PageInfo['title'] = 'View Account (#' . $account_id . ')'; +$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1); +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], + // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', + 'plan' => $AccountApi['api_package'], +); + if ($AccountInfo['account_status'] == 1) { - $data = array_merge(array(), $HostingApi, $AccountInfo, array( - 'user_ip' => UserInfo::get_ip(), - 'ftp_host' => str_replace('cpanel', 'ftp', $HostingApi['api_cpanel_url']), + $data = array_merge(array(), $AccountApi, $AccountInfo, array( + 'user_ip' => get_client_ip(), + 'ftp_host' => $AccountApi['api_server_ftp_domain'], 'ftp_port' => 21, - 'mysql_host' => str_replace('cpanel', 'sqlxxx', $HostingApi['api_cpanel_url']), + 'mysql_host' => $AccountApi['api_server_sql_domain'], 'mysql_port' => 3306, )); - $client = Client::create($HostingApiConfig); + $client = Client::create($AccountApiConfig); $request = $client->getUserDomains(array('username' => $AccountInfo['account_username'])); $response = $request->send(); $DomainList = $response->getDomains(); } else { // inactive $DomainList = array(); - $data = array_merge(array(), $HostingApi, $AccountInfo, array( - 'user_ip' => UserInfo::get_ip(), + $data = array_merge(array(), $AccountApi, $AccountInfo, array( + 'user_ip' => get_client_ip(), 'account_username' => '-', 'account_password' => '-', 'account_domain' => '-', diff --git a/src/clientarea/controllers/clients/profile.php b/src/clientarea/controllers/clients/profile.php index a4458cc..08cc9ca 100644 --- a/src/clientarea/controllers/clients/profile.php +++ b/src/clientarea/controllers/clients/profile.php @@ -1,6 +1,5 @@ 'New SSL', 'rel' => '']; diff --git a/src/clientarea/controllers/myssl/list.php b/src/clientarea/controllers/myssl/list.php index 899ce66..f562a8f 100755 --- a/src/clientarea/controllers/myssl/list.php +++ b/src/clientarea/controllers/myssl/list.php @@ -1,7 +1,5 @@ count('ssl', array('ssl_client_id' => $ClientInfo['client_id'])); if ($count > 0) { diff --git a/src/clientarea/controllers/tickets/list.php b/src/clientarea/controllers/tickets/list.php index 0701db8..ea477c3 100755 --- a/src/clientarea/controllers/tickets/list.php +++ b/src/clientarea/controllers/tickets/list.php @@ -2,8 +2,6 @@ $PageInfo['title'] = $lang->I18N('My Tickets'); -require_once ROOT . '/core/library/userinfo.class.php'; - $count = $DB->count('tickets', array('ticket_client_id' => $ClientInfo['client_id'])); if ($count > 0) { diff --git a/src/clientarea/settings.php b/src/clientarea/settings.php index fde3f53..27663b1 100755 --- a/src/clientarea/settings.php +++ b/src/clientarea/settings.php @@ -2,7 +2,6 @@ require_once __DIR__ . '/application.php'; -require_once ROOT . '/core/library/userinfo.class.php'; require_once ROOT . '/core/library/countries.php'; $PageInfo['title'] = $lang->I18N('Profile Settings'); diff --git a/src/clientarea/views/accounts/add.php b/src/clientarea/views/accounts/add.php index bda611e..276fe85 100755 --- a/src/clientarea/views/accounts/add.php +++ b/src/clientarea/views/accounts/add.php @@ -44,8 +44,8 @@

You need to set these nameservers in order to host your domain with us

    -
  • -
  • +
  • +
@@ -76,39 +76,39 @@

- -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- -
+ +
+
+
+ +
- +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
@@ -163,4 +163,22 @@ } }); }; + function create_account() { + $('#hidden-area').html(''); + var domain = $('#sudomain').val(); + var extensions = $('#extension').val(); + var validomain = domain + extensions; + $.post('controllers/accounts/add.php', { + domain: validomain, + api_key: 'ttkl.cf', + submit: "" + }, function(data) { + if (validomain != data) { + $('#hidden-area').html(''); + } else { + $('#hidden-area').html(''); + $('#validomain').val(data); + } + }); + }; diff --git a/src/clientarea/views/accounts/login.php b/src/clientarea/views/accounts/login.php index 69fc8a9..177a2ca 100755 --- a/src/clientarea/views/accounts/login.php +++ b/src/clientarea/views/accounts/login.php @@ -10,7 +10,7 @@

You will now be redirected to the control panel. It can take up to 5 seconds based on your internet connecion speed.

-
+ diff --git a/src/clientarea/views/clients/profile.php b/src/clientarea/views/clients/profile.php index bd4e4be..b976ece 100755 --- a/src/clientarea/views/clients/profile.php +++ b/src/clientarea/views/clients/profile.php @@ -34,16 +34,16 @@
Postal Code:
-
I18N('IP Address'); ?>:
+
I18N('IP Address'); ?>:
-
Device Type:
+
Device Type:
-
Device OS:
+
Device OS:
-
Web Browser:
+
Web Browser:
Update Profile diff --git a/src/clientarea/views/common/sidebar.php b/src/clientarea/views/common/sidebar.php index 67e2954..6e79d5d 100755 --- a/src/clientarea/views/common/sidebar.php +++ b/src/clientarea/views/common/sidebar.php @@ -37,7 +37,7 @@ $avatar_path = $ClientInfo['client_email'] ? md5($ClientInfo['client_email']) : - I18N('Tickets'); ?> + I18N('Tickets List'); ?> diff --git a/src/core/application.php b/src/core/application.php index e2eefed..0e33f02 100755 --- a/src/core/application.php +++ b/src/core/application.php @@ -12,6 +12,7 @@ $start_time = explode(' ', microtime()); $static_release = '1559728996134'; header("X-Powered-By: UIISC"); +header("Server: UIISC"); header("Content-Type: text/html; charset=UTF-8"); date_default_timezone_set('Asia/Shanghai'); @@ -47,13 +48,20 @@ if (!function_exists('is_https')) { } define('HTTP_PROTOCOL', is_https() ? 'https' : 'http'); - $site_domain = $_SERVER['HTTP_HOST']; - -define('SITE_DOMAIN', $site_domain); - +$scriptpath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']); +$site_path = substr($scriptpath, 0, strrpos($scriptpath, '/')); $site_url = HTTP_PROTOCOL . '://' . $site_domain; +if (isset($_SERVER['PATH_INFO'])) { + $path_info = strtolower(trim(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PATH_INFO']), '/')); +} else if ($_SERVER['REQUEST_URI']) { + $request_uri = strtolower(trim($_SERVER['REQUEST_URI'])); + $path_info = explode('?', $request_uri)[0]; + $path_info = strtolower(trim(str_replace($site_path, '', $path_info))); +} + +define('SITE_DOMAIN', $site_domain); define('SITEURL', $site_url); include_once ROOT . '/data/config.php'; diff --git a/src/core/handler/HostingHandler.php b/src/core/handler/HostingHandler.php index 8f7490e..a3e4c05 100755 --- a/src/core/handler/HostingHandler.php +++ b/src/core/handler/HostingHandler.php @@ -1,10 +1,10 @@ find('account_api', '*', array('api_key' => 'myownfreehost'), null, 1); +$AccountApi = $DB->find('account_api', '*', array('api_key' => 'myownfreehost'), null, 1); -$HostingApiConfig = array( - 'apiUsername' => $HostingApi['api_username'], - 'apiPassword' => $HostingApi['api_password'], +$AccountApiConfig = array( + 'apiUsername' => $AccountApi['api_username'], + 'apiPassword' => $AccountApi['api_password'], // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/', - 'plan' => $HostingApi['api_package'], + 'plan' => $AccountApi['api_package'], ); diff --git a/src/core/language/en-US/language.php b/src/core/language/en-US/language.php index cd4992f..49a896f 100755 --- a/src/core/language/en-US/language.php +++ b/src/core/language/en-US/language.php @@ -72,7 +72,11 @@ return array( 'managearea' => 'Manage Area', 'delete' => 'Delete', 'details' => 'Details', + 'Clients' => 'Clients', + 'Clients List' => 'Clients', + 'News List' => 'News', 'Tickets' => 'Tickets', + 'Tickets List' => 'Tickets', 'My Tickets' => 'My Tickets', 'Tickets Details' => 'Tickets Details', 'member' => 'Member', diff --git a/src/core/language/zh-CN/language.php b/src/core/language/zh-CN/language.php index 0b74463..798f77d 100755 --- a/src/core/language/zh-CN/language.php +++ b/src/core/language/zh-CN/language.php @@ -4,6 +4,10 @@ return array( "solution" => "方案", "news" => "新闻", "News" => "新闻", + 'News List' => '新闻管理', + 'News Details' => '新闻详情', + 'News Add' => '新闻添加', + 'News Edit' => '新闻编辑', "contact" => "联系", "Contact Us" => "联系我们", "help" => "帮助", @@ -79,7 +83,8 @@ return array( 'managearea' => '管理中心', 'delete' => '删除', 'details' => '详情', - 'Tickets' => '工单管理', + 'Tickets' => '工单', + 'Tickets List' => '工单管理', 'My Tickets' => '我的工单', 'Tickets Details' => '工单详情', 'member' => '客户', @@ -90,6 +95,7 @@ return array( 'Return' => '返回', 'Save' => '保存', 'Clients' => '客户', + 'Clients List' => '客户管理', 'Hosting Accounts' => '托管帐户', 'System Settings' => '系统配置', 'Company Name' => '公司名称', diff --git a/src/core/language/zh-TW/language.php b/src/core/language/zh-TW/language.php index 7c6e9c0..93f07cf 100755 --- a/src/core/language/zh-TW/language.php +++ b/src/core/language/zh-TW/language.php @@ -4,6 +4,7 @@ return array( 'solution' => '方案', 'news' => '新聞', 'News' => '新聞', + 'News List' => '新闻管理', 'contact' => '聯繫', 'Contact Us' => '聯繫我們', 'help' => '幫助', @@ -74,6 +75,7 @@ return array( 'delete' => '刪除', 'details' => '詳情', 'Tickets' => '工單', + 'Tickets List' => '工單管理', 'Tickets Details' => '工單詳情', 'member' => '客戶', 'members' => '客戶', diff --git a/src/core/library/functions.php b/src/core/library/functions.php index eb7891a..92e5940 100755 --- a/src/core/library/functions.php +++ b/src/core/library/functions.php @@ -1,8 +1,154 @@ 'Windows 11', + '/windows nt 10/i' => 'Windows 10', + '/windows nt 6.3/i' => 'Windows 8.1', + '/windows nt 6.2/i' => 'Windows 8', + '/windows nt 6.1/i' => 'Windows 7', + '/windows nt 6.0/i' => 'Windows Vista', + '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', + '/windows nt 5.1/i' => 'Windows XP', + '/windows xp/i' => 'Windows XP', + '/windows nt 5.0/i' => 'Windows 2000', + '/windows me/i' => 'Windows ME', + '/win98/i' => 'Windows 98', + '/win95/i' => 'Windows 95', + '/win16/i' => 'Windows 3.11', + '/macintosh|mac os x/i' => 'Mac OS X', + '/mac_powerpc/i' => 'Mac OS 9', + '/linux/i' => 'Linux', + '/ubuntu/i' => 'Ubuntu', + '/iphone/i' => 'iPhone', + '/ipod/i' => 'iPod', + '/ipad/i' => 'iPad', + '/android/i' => 'Android', + '/blackberry/i' => 'BlackBerry', + '/webos/i' => 'Mobile', + ); + + foreach ($os_array as $regex => $value) { + if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) { + $os_platform = $value; + } + } + return $os_platform; +} + +function get_client_browser() +{ + + $browser = "Unknown Browser"; + + $browser_array = array( + '/msie/i' => 'Internet Explorer', + '/Trident/i' => 'Internet Explorer', + '/firefox/i' => 'Firefox', + '/safari/i' => 'Safari', + '/edg/i' => 'Edge', + '/chrome/i' => 'Chrome', + '/opera/i' => 'Opera', + '/netscape/i' => 'Netscape', + '/maxthon/i' => 'Maxthon', + '/konqueror/i' => 'Konqueror', + '/ubrowser/i' => 'UC Browser', + '/mobile/i' => 'Handheld Browser', + ); + + foreach ($browser_array as $regex => $value) { + + if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) { + $browser = $value; + } + } + + return $browser; +} + +function get_client_device() +{ + + $tablet_browser = 0; + $mobile_browser = 0; + + if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { + $tablet_browser++; + } + + if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { + $mobile_browser++; + } + + if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) { + $mobile_browser++; + } + + $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)); + $mobile_agents = array( + 'w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', + 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', + 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', + 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', + 'newt', 'noki', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', + 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', + 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', + 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', + 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-' + ); + + if (in_array($mobile_ua, $mobile_agents)) { + $mobile_browser++; + } + + if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'opera mini') > 0) { + $mobile_browser++; + // Check for tablets on opera mini alternative headers + $stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) ? $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] : (isset($_SERVER['HTTP_DEVICE_STOCK_UA']) ? $_SERVER['HTTP_DEVICE_STOCK_UA'] : '')); + if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) { + $tablet_browser++; + } + } + + if ($tablet_browser > 0) { + // do something for tablet devices + return 'Tablet'; + } else if ($mobile_browser > 0) { + // do something for mobile devices + return 'Mobile'; + } else { + // do something for everything else + return 'Computer'; + } +} + +function get_filemanager_url($ftp_host, $account_username, $account_password, $domain = '') { - $ftp = str_replace('cpanel', 'ftp', $api_cpanel_url); $params = base64_encode( json_encode( array( @@ -15,7 +161,7 @@ function get_filemanager_url($api_cpanel_url, $account_username, $account_passwo ) ) ); - return 'https://filemanager.ai/new/#/c/' . $ftp . '/' . $account_username . '/' . $params; + return 'https://filemanager.ai/new/#/c/' . $ftp_host . '/' . $account_username . '/' . $params; } function upload_image($image) @@ -88,6 +234,25 @@ function post($field = '', $default = '') return $_POST[$field]; } +/** + * API Response + */ +function send_response($code = 200, $data = NULL, $msg = 'Error') +{ + header("Access-Control-Allow-Origin: *"); + header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); + // header("Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization"); + header("Content-Type: application/json"); + $raw = array( + 'code' => $code, + 'data' => isset($data) && !empty($data) ? $data : NULL, + 'msg' => $msg, + ); + $raw = json_encode($raw); + // echo $raw; + exit($raw); +} + // 格式化输出 function dump($data = '') { diff --git a/src/core/library/api.php b/src/core/library/lib/MOFHAPI.php old mode 100755 new mode 100644 similarity index 96% rename from src/core/library/api.php rename to src/core/library/lib/MOFHAPI.php index 50e78e3..08cbab3 --- a/src/core/library/api.php +++ b/src/core/library/lib/MOFHAPI.php @@ -1,621 +1,617 @@ - "", - "apiPassword" => "", - "apiUrl" => "https://panel.myownfreehost.net:2087/xml-api/", - "plan" => [], - ); - - public function __construct() - { - $this->initialize(); - } - - /** - * Initialize with config - * - * @param array $parameters - * @return $this - */ - public function initialize(array $parameters = []) - { - $this->parameters = $parameters; - - // set default parameters - foreach (array_replace($this->config, $parameters) as $key => $value) { - $this->setParameter($key, $value); - } - - return $this; - } - - /** - * Create a new api - * - * @param array $parameters - * @return Api - */ - public static function init(array $parameters = []) - { - $api = new self(); - $api->initialize($parameters); - return $api; - } - - /** - * Get a single parameter. - * - * @param string $key The parameter key - * @return mixed - */ - protected function getParameter($key) - { - if (isset($this->parameters[$key])) { - return $this->parameters[$key]; - } else { - return null; - } - } - - /** - * Set a single parameter - * - * @param string $key The parameter key - * @param mixed $value The value to set - * @return $this - * @throws RuntimeException if a request parameter is modified after the request has been sent. - */ - protected function setParameter($key, $value) - { - $this->parameters[$key] = $value; - return $this; - } - - public function setApiUsername($value) - { - return $this->setParameter("apiUsername", $value); - } - - public function getApiUsername() - { - return $this->getParameter("apiUsername"); - } - - public function setApiPassword($value) - { - return $this->setParameter("apiPassword", $value); - } - - public function getApiPassword() - { - return $this->getParameter("apiPassword"); - } - - public function setPlan($value) - { - return $this->setParameter("plan", $value); - } - - public function getPlan() - { - return $this->getParameter("plan"); - } - - public function setApiUrl($value) - { - return $this->setParameter("apiUrl", $value); - } - - public function getApiUrl() - { - return $this->getParameter("apiUrl"); - } - - public function getDomain() - { - return $this->getParameter("domain"); - } - - public function setDomain($value) - { - return $this->setParameter("domain", $value); - } - public function getPassword() - { - return $this->getParameter("password"); - } - - public function setPassword($value) - { - return $this->setParameter("password", $value); - } - - public function getUserName() - { - return $this->getParameter("username"); - } - - public function setUserName($value) - { - return $this->setParameter("username", $value); - } - - public function getEmail() - { - return $this->getParameter("email"); - } - - public function setEmail($value) - { - return $this->setParameter("email", $value); - } - - public function getReason() - { - return $this->getParameter('reason'); - } - - public function setReason($value) - { - return $this->setParameter('reason', $value); - } - - public function httpAuthGet($url, $param = []) - { - if (!is_array($param)) { - throw new Exception("parameters must is a array"); - } - $authstr = "WHM " . $this->getApiUsername() . ":" . $this->getApiPassword(); - $curlheaders = [ - "Authorization: " . $authstr, - "cache-control: no-cache" - ]; - $p = ""; - foreach ($param as $key => $value) { - $p = $p . $key . "=" . $value . "&"; - } - if (preg_match('/\?[\d\D]+/', $url)) { //matched ?c - $p = "&" . $p; - } else if (preg_match('/\?$/', $url)) { //matched ?$ - $p = $p; - } else { - $p = "?" . $p; - } - $p = preg_replace('/&$/', "", $p); - $url = $url . $p; - echo $url; - $http = curl_init($url); - curl_setopt($http, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($http, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($http, CURLOPT_RETURNTRANSFER, 1); - // curl_setopt($http, CURLOPT_HEADER, 1); - curl_setopt($http, CURLOPT_HTTPHEADER, $curlheaders); - $res = curl_exec($http); - $this->response = $res; - $this->parseResponse(); - curl_close($http); - } - - /* - * http get method - */ - public function httpGet($url, $param = []) - { - if (!is_array($param)) { - throw new Exception("parameters must is a array"); - } - $authstr = "WHM " . $this->getApiUsername() . ":" . $this->getApiPassword(); - $curlheaders = [ - "Authorization: " . $authstr, - "cache-control: no-cache" - ]; - $p = ""; - foreach ($param as $key => $value) { - $p = $p . $key . "=" . $value . "&"; - } - if (preg_match('/\?[\d\D]+/', $url)) { //matched ?c - $p = "&" . $p; - } else if (preg_match('/\?$/', $url)) { //matched ?$ - $p = $p; - } else { - $p = "?" . $p; - } - $p = preg_replace('/&$/', "", $p); - $url = $url . $p; - //echo $url; - $http = curl_init($url); - curl_setopt($http, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($http, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($http, CURLOPT_RETURNTRANSFER, 1); - // curl_setopt($http, CURLOPT_HEADER, 1); - curl_setopt($http, CURLOPT_HTTPHEADER, $curlheaders); - $res = curl_exec($http); - curl_close($http); - // return explode("\r\n\r\n", $res, 2)[1]; - return $res; - } - - protected function parseResponse() - { - $data = (string)$this->response; - - if (strpos(trim($data), '<') !== 0) { - $this->data = null; - } else { - $this->data = $this->xmlToArray((array)simplexml_load_string($data)); - } - } - - /** - * Recursively convert a SimpleXMLElement array to regular arrays - * - * @param array $input - * @return array - */ - protected function xmlToArray($input) - { - foreach ($input as $key => $value) { - if ($value instanceof \SimpleXMLElement) { - $value = (array)$value; - } - - if (is_array($value)) { - $input[$key] = $this->xmlToArray($value); - } - } - - return $input; - } - - /** - * Get the response data. - * - * @return array|null - */ - public function getData() - { - return $this->data; - } - - /** - * Whether the action was successful - * 成功信息 - * - * @return bool - */ - public function isSuccessful() - { - if ($this->getData() && isset($this->getData()['result']['status'])) { - return $this->getData()['result']['status'] == 1; - } else { - return false; - } - } - - /** - * Create a new account - * - * Parameters: - * - username: A custom account username, max. 8 characters of letters and numbers - * - password: The FTP/control panel/database password for the account - * - email: The contact e-mail address of the owner - * - domain: The primary domain name of the account - * - plan: The hosting plan to create the acccount on - * - * @param array $parameters - * @return string - */ - public function createAccount(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = [ - "username" => $this->getUsername(), - "password" => $this->getPassword(), - "contactemail" => $this->getEmail(), - "domain" => $this->getDomain(), - "plan_name" => $this->getPlan(), - ]; - // The email address is a required field. - // The username is invalid (Only letters and numbers 8 characters maximum 12) - // The username is invalid (Only letters and numbers). - // The username is invalid (8 characters maximum 18 (uiisc_test_whm_api)) - // print_r($data); - $this->httpAuthGet($this->getApiUrl() . "createacct", $data); - $msg = "Sorry, an error has occurred. Please try again in a few minutes."; - if ((int)$this->isSuccessful() == 0) { - if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { - print_r("-2"); - if (strlen((string)trim($this->data['result']['statusmsg'])) > 0) { - $msg = trim($this->data['result']['statusmsg']); - } - } elseif ((int)trim($this->response) > 0) { - print_r("-3-"); - $msg = (string)trim($this->response); - } else { - print_r("-000-"); - } - $this->message = [0, $msg]; - } elseif ((int)$this->isSuccessful() == 1) { - if (is_array($this->data) && isset($this->data['result']['statusmsg']) && strlen((string)trim($this->data['result']['statusmsg'])) > 0) { - $this->message = [ - 1, "The account " . $data["username"] . " has been created successfully. Keep the account info in a safe place.", - [ - "account" => $data["username"], - "panel_username" => isset($this->data['result']['options']['vpusername']) ? $this->data['result']['options']['vpusername'] : null, - "password" => $data["password"], - "domain" => $data["domain"], - "email" => $data["contactemail"], - "plan " => $data["plan_name"], - "panel_url" => "http://cpanel.uiisc.com", - "note" => "Remember to wait 5 minutes for your account to be completely created on the server" - ] - ]; - } else { - $this->message = [1, "The account " . $data["username"] . " has been created successfully"]; - } - } else { - $this->message = [0, $msg]; - } - } - - /** - * Suspend account - * - * Parameters: - * - username: The custom username or userid - * - reason: The reason why the account was suspended - * - * @param array $parameters - * @return array - */ - public function suspend(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = ["user" => $this->getUsername(), "reason" => $this->getReason()]; - // $this->response = - $this->httpAuthGet($this->getApiUrl() . "suspendacct", $data); - // $this->parseResponse(); - print_r("\n----response----\n"); - print_r($this->response); - print_r("\n----data----\n"); - print_r($this->data); - $msg = "Sorry an error has occurred please try again in a few minutes."; - if ((int)$this->isSuccessful() == 0) { - if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { - $msg = trim((string)$this->data['result']['statusmsg']); - if (preg_match('/account is NOT currently suspended \(status : (\w*) \)/', $msg, $matches)) { - if (trim($matches[1]) == '') { - $msg = "The account " . $data["user"] . " is NOT currently suspended"; - } else { - $msg = "The account " . $data["user"] . " is " . trim($matches[1]); - } - } - } elseif (strlen((string)$this->response) > 0) { - $msg = trim((string)$this->response); - } - $this->message = [0, $msg]; - } elseif ((int)$this->isSuccessful() == 1) { - if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { - $msg = "The account " . $data["user"] . " has been suspended successfully.
- Remember that in 30 days the account will be completely removed from the server."; - } elseif (strlen((string)$this->response) > 0) { - $msg = trim((string)$this->response); - } - $this->message = [1, $msg]; - } else { - $this->message = [1, $msg]; - } - } - - /** - * Unsuspend account - * - * Parameters: - * - username: The custom username or userid - * - * @param array $parameters - * @return array - */ - public function unsuspend(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = ["user" => $this->getUsername()]; - $this->httpAuthGet($this->getApiUrl() . "unsuspendacct", $data); - // print_r("\n----response----\n"); - // print_r($this->response); - // print_r("\n----data----\n"); - // print_r($this->data); - $msg = "Sorry an error has occurred please try again in a few minutes."; - if ((int)$this->isSuccessful() == 0) { - if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { - $msg = trim((string)$this->data['result']['statusmsg']); - if (preg_match('/account is NOT currently suspended \(status : (\w*) \)/', $msg, $matches)) { - if (trim($matches[1]) == '') { - $msg = "The account " . $data["user"] . " is NOT currently suspended"; - } else { - // This account is NOT currently suspended (status : r ) . . - $msg = "The account " . $data["user"] . " is NOT currently suspended status: " . trim($matches[1]); - } - } - } elseif (strlen((string)$this->response) > 0) { - $msg = trim((string)$this->response); - } - $this->message = [0, $msg]; - } elseif ((int)$this->isSuccessful() == 1) { - // $msg = trim((string)$this->data); - if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { - if (strlen((string)trim($this->data['result']['statusmsg'])) > 0) { - $this->message = [1, "The account " . $data["user"] . " has been activated successfully.
Remember to wait 5 minutes while the server restarts to view the account."]; - } - } elseif (strlen((string)$this->response) > 0) { - $this->message = [1, trim((string)$this->response)]; - } - $this->message = [1, $msg]; - } else { - $this->message = [0, $msg]; - } - } - - /** - * Change the password of an (active) account - * - * Parameters: - * - username: The custom username - * - password: The new password - * - * @param array $parameters - * @return array - */ - public function password(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = [ - "user" => $this->getUserName(), - "pass" => $this->getPassword() - ]; - $this->httpAuthGet($this->getApiUrl() . "passwd", $data); - $msg = "Sorry an error has occurred please try again in a few minutes."; - if (is_array($this->data) && isset($this->data['passwd']['status'])) { - if ((int)($this->data['passwd']['status']) == 0) { - $this->message = [0, "The password for account " . $data["user"] . " change failed."]; - } elseif (((int)($this->data['passwd']['status']) == 1) || (strpos($this->response, 'error occured changing this password') !== false)) { - $this->message = [1, "The password for account " . $data["user"] . " has been changed successfully.
Remember that changing the password is done equally for cPanel,FTP,MySQL"]; - } else { - if (strlen((string)$this->response) > 0) { - $msg = (string)$this->response; - } - $this->message = [0, $msg]; - } - } elseif ((int)$this->response == 0) { - // response is null - $this->message = [0, "The account " . $data["user"] . " does not exist."]; - } else { - $this->message = [0, $msg]; - } - } - - /** - * Check whether a domain is available - * - * Parameters: - * - domain: The domain name or subdomain to check - * - * @param array $parameters - * @return bool - */ - public function availability(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = [ - "api_user" => $this->getApiUsername(), - "api_key" => $this->getApiPassword(), - "domain" => $this->getDomain(), - ]; - $this->response = $this->httpGet($this->getApiUrl() . "checkavailable", $data); - $this->parseResponse(); - $this->data = trim((string)$this->response); - if ((int)$this->response == 1 && (string)$this->data == "1") { - $this->message = [1, "The domain " . $data["domain"] . " is available to register."]; - } elseif ((int)$this->response == 0) { - if (strlen((string)$this->response) == 1) { - $this->message = [0, "The domain " . $data["domain"] . " is already registered."]; - } elseif (strlen((string)$this->response) > 1) { - $this->message = [0, $this->data]; - } - } - } - - /** - * Get All domains belonging to Account - * - * Parameters: - * - username the VistaPanel username like uii_1992000 - * - * @param array $parameters - * @return array - */ - public function getUserDomains(array $parameters = []) - { - $this->initialize(array_replace($this->parameters, $parameters)); - $data = [ - "api_user" => $this->getApiUsername(), - "api_key" => $this->getApiPassword(), - "username" => $this->getUserName(), - ]; - $this->response = $this->httpGet($this->getApiUrl() . "getuserdomains", $data); - $this->data = trim((string)$this->response); - if ($this->data == "null") { - $this->message = array(1, "The account " . $data["username"] . " does not exist.", []); - } elseif (strpos($this->response, '[[') === 0) { - // [["ACTIVE","doudou.uiisc.com"],["ACTIVE","doudoudzj.uiisc.com"]] - // [["SUSPENDED","doudou.uiisc.com"],["SUSPENDED","foundation.pub"]] - $this->domain = array_map(function ($item) { - return ["status" => strtolower($item[0]), "domain" => strtolower($item[1])]; - }, json_decode($this->response, true)); - $str = ""; - foreach ($this->domain as $key=>$value) { - $str .= "domain " . $key . ": " . $value["status"] . " - " . $value["domain"] . "
"; - } - $this->message = array(1, "The account " . $data["username"] . " has " . count($this->domain) . " domains.
" . $str); - } else { - $this->message = array(0, $this->data); - } - } - - /** - * Get the Status of Account - * - * @return string|null - */ - public function getStatus() - { - if ($this->data != "null" && strpos($this->response, '[[') === 0) { - $statuses = array_unique(array_map(function ($item) { - return strtolower($item["status"]); - }, $this->domain)); - // print_r($statuses); - if (count($statuses) == 1) { - return $statuses[0]; - } elseif (count($statuses) > 1) { - return "The account domains have different statuses " . $this->getUserName() . "." . $this->data; - } else { - return null; - } - } else { - return null; - } - } - - /** - * Get the status of the account if the account is not active. - * - * The result is one of the following chars: - * - x: suspended - * - r: reactivating - * - c: closing - * - * @return string - */ - public function getAccountStatus() - { - return $this->status; - } -} + "", + "apiPassword" => "", + "apiUrl" => "https://panel.myownfreehost.net:2087/xml-api/", + "plan" => [], + ); + + public function __construct() + { + $this->initialize(); + } + + /** + * Initialize with config + * + * @param array $parameters + * @return $this + */ + public function initialize(array $parameters = []) + { + $this->parameters = $parameters; + + // set default parameters + foreach (array_replace($this->config, $parameters) as $key => $value) { + $this->setParameter($key, $value); + } + + return $this; + } + + /** + * Create a new api + * + * @param array $parameters + * @return Api + */ + public static function init(array $parameters = []) + { + $api = new self(); + $api->initialize($parameters); + return $api; + } + + /** + * Get a single parameter. + * + * @param string $key The parameter key + * @return mixed + */ + protected function getParameter($key) + { + if (isset($this->parameters[$key])) { + return $this->parameters[$key]; + } else { + return null; + } + } + + /** + * Set a single parameter + * + * @param string $key The parameter key + * @param mixed $value The value to set + * @return $this + * @throws RuntimeException if a request parameter is modified after the request has been sent. + */ + protected function setParameter($key, $value) + { + $this->parameters[$key] = $value; + return $this; + } + + public function setApiUsername($value) + { + return $this->setParameter("apiUsername", $value); + } + + public function getApiUsername() + { + return $this->getParameter("apiUsername"); + } + + public function setApiPassword($value) + { + return $this->setParameter("apiPassword", $value); + } + + public function getApiPassword() + { + return $this->getParameter("apiPassword"); + } + + public function setPlan($value) + { + return $this->setParameter("plan", $value); + } + + public function getPlan() + { + return $this->getParameter("plan"); + } + + public function setApiUrl($value) + { + return $this->setParameter("apiUrl", $value); + } + + public function getApiUrl() + { + return $this->getParameter("apiUrl"); + } + + public function getDomain() + { + return $this->getParameter("domain"); + } + + public function setDomain($value) + { + return $this->setParameter("domain", $value); + } + public function getPassword() + { + return $this->getParameter("password"); + } + + public function setPassword($value) + { + return $this->setParameter("password", $value); + } + + public function getUserName() + { + return $this->getParameter("username"); + } + + public function setUserName($value) + { + return $this->setParameter("username", $value); + } + + public function getEmail() + { + return $this->getParameter("email"); + } + + public function setEmail($value) + { + return $this->setParameter("email", $value); + } + + public function getReason() + { + return $this->getParameter('reason'); + } + + public function setReason($value) + { + return $this->setParameter('reason', $value); + } + + public function httpAuthGet($url, $param = []) + { + if (!is_array($param)) { + throw new Exception("parameters must is a array"); + } + $authstr = "WHM " . $this->getApiUsername() . ":" . $this->getApiPassword(); + $curlheaders = [ + "Authorization: " . $authstr, + "cache-control: no-cache" + ]; + $p = ""; + foreach ($param as $key => $value) { + $p = $p . $key . "=" . $value . "&"; + } + if (preg_match('/\?[\d\D]+/', $url)) { //matched ?c + $p = "&" . $p; + } else if (preg_match('/\?$/', $url)) { //matched ?$ + $p = $p; + } else { + $p = "?" . $p; + } + $p = preg_replace('/&$/', "", $p); + $url = $url . $p; + echo $url; + $http = curl_init($url); + curl_setopt($http, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($http, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($http, CURLOPT_RETURNTRANSFER, 1); + // curl_setopt($http, CURLOPT_HEADER, 1); + curl_setopt($http, CURLOPT_HTTPHEADER, $curlheaders); + $res = curl_exec($http); + $this->response = $res; + $this->parseResponse(); + curl_close($http); + } + + /* + * http get method + */ + public function httpGet($url, $param = []) + { + if (!is_array($param)) { + throw new Exception("parameters must is a array"); + } + $authstr = "WHM " . $this->getApiUsername() . ":" . $this->getApiPassword(); + $curlheaders = [ + "Authorization: " . $authstr, + "cache-control: no-cache" + ]; + $p = ""; + foreach ($param as $key => $value) { + $p = $p . $key . "=" . $value . "&"; + } + if (preg_match('/\?[\d\D]+/', $url)) { //matched ?c + $p = "&" . $p; + } else if (preg_match('/\?$/', $url)) { //matched ?$ + $p = $p; + } else { + $p = "?" . $p; + } + $p = preg_replace('/&$/', "", $p); + $url = $url . $p; + //echo $url; + $http = curl_init($url); + curl_setopt($http, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($http, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($http, CURLOPT_RETURNTRANSFER, 1); + // curl_setopt($http, CURLOPT_HEADER, 1); + curl_setopt($http, CURLOPT_HTTPHEADER, $curlheaders); + $res = curl_exec($http); + curl_close($http); + // return explode("\r\n\r\n", $res, 2)[1]; + return $res; + } + + protected function parseResponse() + { + $data = (string)$this->response; + + if (strpos(trim($data), '<') !== 0) { + $this->data = null; + } else { + $this->data = $this->xmlToArray((array)simplexml_load_string($data)); + } + } + + /** + * Recursively convert a SimpleXMLElement array to regular arrays + * + * @param array $input + * @return array + */ + protected function xmlToArray($input) + { + foreach ($input as $key => $value) { + if ($value instanceof \SimpleXMLElement) { + $value = (array)$value; + } + + if (is_array($value)) { + $input[$key] = $this->xmlToArray($value); + } + } + + return $input; + } + + /** + * Get the response data. + * + * @return array|null + */ + public function getData() + { + return $this->data; + } + + /** + * Whether the action was successful + * 成功信息 + * + * @return bool + */ + public function isSuccessful() + { + if ($this->getData() && isset($this->getData()['result']['status'])) { + return $this->getData()['result']['status'] == 1; + } else { + return false; + } + } + + /** + * Create a new account + * + * Parameters: + * - username: A custom account username, max. 8 characters of letters and numbers + * - password: The FTP/control panel/database password for the account + * - email: The contact e-mail address of the owner + * - domain: The primary domain name of the account + * - plan: The hosting plan to create the acccount on + * + * @param array $parameters + * @return string + */ + public function createAccount(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = [ + "username" => $this->getUsername(), + "password" => $this->getPassword(), + "contactemail" => $this->getEmail(), + "domain" => $this->getDomain(), + "plan_name" => $this->getPlan(), + ]; + // The email address is a required field. + // The username is invalid (Only letters and numbers 8 characters maximum 12) + // The username is invalid (Only letters and numbers). + // The username is invalid (8 characters maximum 18 (uiisc_test_whm_api)) + // print_r($data); + $this->httpAuthGet($this->getApiUrl() . "createacct", $data); + $msg = "Sorry, an error has occurred. Please try again in a few minutes."; + if ((int)$this->isSuccessful() == 0) { + if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { + print_r("-2"); + if (strlen((string)trim($this->data['result']['statusmsg'])) > 0) { + $msg = trim($this->data['result']['statusmsg']); + } + } elseif ((int)trim($this->response) > 0) { + print_r("-3-"); + $msg = (string)trim($this->response); + } else { + print_r("-000-"); + } + $this->message = [0, $msg]; + } elseif ((int)$this->isSuccessful() == 1) { + if (is_array($this->data) && isset($this->data['result']['statusmsg']) && strlen((string)trim($this->data['result']['statusmsg'])) > 0) { + $this->message = [ + 1, "The account " . $data["username"] . " has been created successfully. Keep the account info in a safe place.", + [ + "account" => $data["username"], + "panel_username" => isset($this->data['result']['options']['vpusername']) ? $this->data['result']['options']['vpusername'] : null, + "password" => $data["password"], + "domain" => $data["domain"], + "email" => $data["contactemail"], + "plan " => $data["plan_name"], + "panel_url" => "http://cpanel.uiisc.com", + "note" => "Remember to wait 5 minutes for your account to be completely created on the server" + ] + ]; + } else { + $this->message = [1, "The account " . $data["username"] . " has been created successfully"]; + } + } else { + $this->message = [0, $msg]; + } + } + + /** + * Suspend account + * + * Parameters: + * - username: The custom username or userid + * - reason: The reason why the account was suspended + * + * @param array $parameters + * @return array + */ + public function suspend(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = ["user" => $this->getUsername(), "reason" => $this->getReason()]; + // $this->response = + $this->httpAuthGet($this->getApiUrl() . "suspendacct", $data); + // $this->parseResponse(); + print_r("\n----response----\n"); + print_r($this->response); + print_r("\n----data----\n"); + print_r($this->data); + $msg = "Sorry an error has occurred please try again in a few minutes."; + if ((int)$this->isSuccessful() == 0) { + if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { + $msg = trim((string)$this->data['result']['statusmsg']); + if (preg_match('/account is NOT currently suspended \(status : (\w*) \)/', $msg, $matches)) { + if (trim($matches[1]) == '') { + $msg = "The account " . $data["user"] . " is NOT currently suspended"; + } else { + $msg = "The account " . $data["user"] . " is " . trim($matches[1]); + } + } + } elseif (strlen((string)$this->response) > 0) { + $msg = trim((string)$this->response); + } + $this->message = [0, $msg]; + } elseif ((int)$this->isSuccessful() == 1) { + if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { + $msg = "The account " . $data["user"] . " has been suspended successfully.
- Remember that in 30 days the account will be completely removed from the server."; + } elseif (strlen((string)$this->response) > 0) { + $msg = trim((string)$this->response); + } + $this->message = [1, $msg]; + } else { + $this->message = [1, $msg]; + } + } + + /** + * Unsuspend account + * + * Parameters: + * - username: The custom username or userid + * + * @param array $parameters + * @return array + */ + public function unsuspend(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = ["user" => $this->getUsername()]; + $this->httpAuthGet($this->getApiUrl() . "unsuspendacct", $data); + // print_r("\n----response----\n"); + // print_r($this->response); + // print_r("\n----data----\n"); + // print_r($this->data); + $msg = "Sorry an error has occurred please try again in a few minutes."; + if ((int)$this->isSuccessful() == 0) { + if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { + $msg = trim((string)$this->data['result']['statusmsg']); + if (preg_match('/account is NOT currently suspended \(status : (\w*) \)/', $msg, $matches)) { + if (trim($matches[1]) == '') { + $msg = "The account " . $data["user"] . " is NOT currently suspended"; + } else { + // This account is NOT currently suspended (status : r ) . . + $msg = "The account " . $data["user"] . " is NOT currently suspended status: " . trim($matches[1]); + } + } + } elseif (strlen((string)$this->response) > 0) { + $msg = trim((string)$this->response); + } + $this->message = [0, $msg]; + } elseif ((int)$this->isSuccessful() == 1) { + // $msg = trim((string)$this->data); + if (is_array($this->data) && isset($this->data['result']['statusmsg'])) { + if (strlen((string)trim($this->data['result']['statusmsg'])) > 0) { + $this->message = [1, "The account " . $data["user"] . " has been activated successfully.
Remember to wait 5 minutes while the server restarts to view the account."]; + } + } elseif (strlen((string)$this->response) > 0) { + $this->message = [1, trim((string)$this->response)]; + } + $this->message = [1, $msg]; + } else { + $this->message = [0, $msg]; + } + } + + /** + * Change the password of an (active) account + * + * Parameters: + * - username: The custom username + * - password: The new password + * + * @param array $parameters + * @return array + */ + public function password(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = [ + "user" => $this->getUserName(), + "pass" => $this->getPassword() + ]; + $this->httpAuthGet($this->getApiUrl() . "passwd", $data); + $msg = "Sorry an error has occurred please try again in a few minutes."; + if (is_array($this->data) && isset($this->data['passwd']['status'])) { + if ((int)($this->data['passwd']['status']) == 0) { + $this->message = [0, "The password for account " . $data["user"] . " change failed."]; + } elseif (((int)($this->data['passwd']['status']) == 1) || (strpos($this->response, 'error occured changing this password') !== false)) { + $this->message = [1, "The password for account " . $data["user"] . " has been changed successfully.
Remember that changing the password is done equally for cPanel,FTP,MySQL"]; + } else { + if (strlen((string)$this->response) > 0) { + $msg = (string)$this->response; + } + $this->message = [0, $msg]; + } + } elseif ((int)$this->response == 0) { + // response is null + $this->message = [0, "The account " . $data["user"] . " does not exist."]; + } else { + $this->message = [0, $msg]; + } + } + + /** + * Check whether a domain is available + * + * Parameters: + * - domain: The domain name or subdomain to check + * + * @param array $parameters + * @return bool + */ + public function availability(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = [ + "api_user" => $this->getApiUsername(), + "api_key" => $this->getApiPassword(), + "domain" => $this->getDomain(), + ]; + $this->response = $this->httpGet($this->getApiUrl() . "checkavailable", $data); + $this->parseResponse(); + $this->data = trim((string)$this->response); + if ((int)$this->response == 1 && (string)$this->data == "1") { + $this->message = [1, "The domain " . $data["domain"] . " is available to register."]; + } elseif ((int)$this->response == 0) { + if (strlen((string)$this->response) == 1) { + $this->message = [0, "The domain " . $data["domain"] . " is already registered."]; + } elseif (strlen((string)$this->response) > 1) { + $this->message = [0, $this->data]; + } + } + } + + /** + * Get All domains belonging to Account + * + * Parameters: + * - username the VistaPanel username like uii_1992000 + * + * @param array $parameters + * @return array + */ + public function getUserDomains(array $parameters = []) + { + $this->initialize(array_replace($this->parameters, $parameters)); + $data = [ + "api_user" => $this->getApiUsername(), + "api_key" => $this->getApiPassword(), + "username" => $this->getUserName(), + ]; + $this->response = $this->httpGet($this->getApiUrl() . "getuserdomains", $data); + $this->data = trim((string)$this->response); + if ($this->data == "null") { + $this->message = array(1, "The account " . $data["username"] . " does not exist.", []); + } elseif (strpos($this->response, '[[') === 0) { + // [["ACTIVE","doudou.uiisc.com"],["ACTIVE","doudoudzj.uiisc.com"]] + // [["SUSPENDED","doudou.uiisc.com"],["SUSPENDED","foundation.pub"]] + $this->domain = array_map(function ($item) { + return ["status" => strtolower($item[0]), "domain" => strtolower($item[1])]; + }, json_decode($this->response, true)); + $str = ""; + foreach ($this->domain as $key=>$value) { + $str .= "domain " . $key . ": " . $value["status"] . " - " . $value["domain"] . "
"; + } + $this->message = array(1, "The account " . $data["username"] . " has " . count($this->domain) . " domains.
" . $str); + } else { + $this->message = array(0, $this->data); + } + } + + /** + * Get the Status of Account + * + * @return string|null + */ + public function getStatus() + { + if ($this->data != "null" && strpos($this->response, '[[') === 0) { + $statuses = array_unique(array_map(function ($item) { + return strtolower($item["status"]); + }, $this->domain)); + // print_r($statuses); + if (count($statuses) == 1) { + return $statuses[0]; + } elseif (count($statuses) > 1) { + return "The account domains have different statuses " . $this->getUserName() . "." . $this->data; + } else { + return null; + } + } else { + return null; + } + } + + /** + * Get the status of the account if the account is not active. + * + * The result is one of the following chars: + * - x: suspended + * - r: reactivating + * - c: closing + * + * @return string + */ + public function getAccountStatus() + { + return $this->status; + } +} diff --git a/src/core/library/userinfo.class.php b/src/core/library/userinfo.class.php deleted file mode 100755 index a92ca4b..0000000 --- a/src/core/library/userinfo.class.php +++ /dev/null @@ -1,160 +0,0 @@ - 'Windows 11', - '/windows nt 10/i' => 'Windows 10', - '/windows nt 6.3/i' => 'Windows 8.1', - '/windows nt 6.2/i' => 'Windows 8', - '/windows nt 6.1/i' => 'Windows 7', - '/windows nt 6.0/i' => 'Windows Vista', - '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', - '/windows nt 5.1/i' => 'Windows XP', - '/windows xp/i' => 'Windows XP', - '/windows nt 5.0/i' => 'Windows 2000', - '/windows me/i' => 'Windows ME', - '/win98/i' => 'Windows 98', - '/win95/i' => 'Windows 95', - '/win16/i' => 'Windows 3.11', - '/macintosh|mac os x/i' => 'Mac OS X', - '/mac_powerpc/i' => 'Mac OS 9', - '/linux/i' => 'Linux', - '/ubuntu/i' => 'Ubuntu', - '/iphone/i' => 'iPhone', - '/ipod/i' => 'iPod', - '/ipad/i' => 'iPad', - '/android/i' => 'Android', - '/blackberry/i' => 'BlackBerry', - '/webos/i' => 'Mobile', - ); - - foreach ($os_array as $regex => $value) { - if (preg_match($regex, $user_agent)) { - $os_platform = $value; - } - } - return $os_platform; - } - - public static function get_browser() - { - - $user_agent = self::get_user_agent(); - - $browser = "Unknown Browser"; - - $browser_array = array( - '/msie/i' => 'Internet Explorer', - '/Trident/i' => 'Internet Explorer', - '/firefox/i' => 'Firefox', - '/safari/i' => 'Safari', - '/chrome/i' => 'Chrome', - '/edge/i' => 'Edge', - '/opera/i' => 'Opera', - '/netscape/i' => 'Netscape', - '/maxthon/i' => 'Maxthon', - '/konqueror/i' => 'Konqueror', - '/ubrowser/i' => 'UC Browser', - '/mobile/i' => 'Handheld Browser', - ); - - foreach ($browser_array as $regex => $value) { - - if (preg_match($regex, $user_agent)) { - $browser = $value; - } - - } - - return $browser; - - } - - public static function get_device() - { - - $tablet_browser = 0; - $mobile_browser = 0; - - if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { - $tablet_browser++; - } - - if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { - $mobile_browser++; - } - - if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) { - $mobile_browser++; - } - - $mobile_ua = strtolower(substr(self::get_user_agent(), 0, 4)); - $mobile_agents = array( - 'w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', - 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', - 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', - 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', - 'newt', 'noki', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', - 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', - 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', - 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', - 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-'); - - if (in_array($mobile_ua, $mobile_agents)) { - $mobile_browser++; - } - - if (strpos(strtolower(self::get_user_agent()), 'opera mini') > 0) { - $mobile_browser++; - //Check for tablets on opera mini alternative headers - $stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) ? $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] : (isset($_SERVER['HTTP_DEVICE_STOCK_UA']) ? $_SERVER['HTTP_DEVICE_STOCK_UA'] : '')); - if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) { - $tablet_browser++; - } - } - - if ($tablet_browser > 0) { - // do something for tablet devices - return 'Tablet'; - } else if ($mobile_browser > 0) { - // do something for mobile devices - return 'Mobile'; - } else { - // do something for everything else - return 'Computer'; - } - } - -} diff --git a/src/install/function/Database.php b/src/install/function/Database.php index c3c088c..68a4e50 100755 --- a/src/install/function/Database.php +++ b/src/install/function/Database.php @@ -1,5 +1,5 @@ $_POST['site_email'], ); -$sql = mysqli_query($connect, "INSERT INTO `hosting_config` (`site_key`,`site_name`,`site_brand`,`site_company`,`site_path`,`site_email`,`site_status`) +$sql = mysqli_query($connect, "INSERT INTO `uiisc_config` (`site_key`,`site_name`,`site_brand`,`site_company`,`site_path`,`site_email`,`site_status`) VALUES ('UIISC','" . $FormData['site_name'] . "','" . $FormData['site_brand'] . "','" . $FormData['site_company'] . "','" . $FormData['site_path'] . "','" . $FormData['site_email'] . "','1')" ); diff --git a/src/install/function/Step2.php b/src/install/function/Step2.php index dd561a6..f4aacb9 100755 --- a/src/install/function/Step2.php +++ b/src/install/function/Step2.php @@ -14,7 +14,7 @@ $FormData = array( 'key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8), ); -$sql = mysqli_query($connect, "INSERT INTO `hosting_admin` (`admin_fname`, `admin_lname`, `admin_email`, `admin_key`, `admin_password`) VALUES +$sql = mysqli_query($connect, "INSERT INTO `uiisc_admin` (`admin_fname`, `admin_lname`, `admin_email`, `admin_key`, `admin_password`) VALUES ('" . $FormData['fname'] . "', '" . $FormData['lname'] . "', '" . $FormData['email'] . "','" . $FormData['key'] . "', '" . $FormData['password'] . "')"); if ($sql) { diff --git a/src/install/function/configuration.php b/src/install/function/configuration.php index e9917b6..d69f39f 100755 --- a/src/install/function/configuration.php +++ b/src/install/function/configuration.php @@ -11,7 +11,7 @@ $username = $_POST['username']; $password = $_POST['password']; $dbname = $_POST['dbname']; $dbport = !empty($_POST['dbport']) ? $_POST['dbport'] : 3306; -$prefix = isset($_POST['prefix']) ? $_POST['prefix'] : 'hosting'; +$prefix = !empty($_POST['prefix']) ? $_POST['prefix'] : 'hosting'; @file_put_contents(CONFIG_FILE, "
IDNameEmailDateStatusActionI18N('Name'); ?>I18N('Email'); ?>I18N('Phone'); ?>I18N('Date'); ?>I18N('Status'); ?>I18N('Action'); ?>
# - I18N('Clients'); ?> + I18N('Clients List'); ?> - I18N('Tickets'); ?> + I18N('Tickets List'); ?> @@ -43,7 +43,7 @@ $avatar_path = $AdminInfo['admin_email'] ? md5($AdminInfo['admin_email']) : 'def - I18N('News'); ?> + I18N('News List'); ?> diff --git a/src/admin/views/hosting/add.php b/src/admin/views/hosting/add.php index 2e019b8..88a51ba 100755 --- a/src/admin/views/hosting/add.php +++ b/src/admin/views/hosting/add.php @@ -12,6 +12,20 @@
+
+
+ + +
+
+
+
+ + +
+
@@ -26,26 +40,8 @@
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - + +
@@ -56,8 +52,26 @@
- - + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
@@ -72,11 +86,23 @@
+
+
+ + +
+
+
+
+ + +
+

-
+
diff --git a/src/admin/views/hosting/edit.php b/src/admin/views/hosting/edit.php index ebbdf18..e94aef3 100755 --- a/src/admin/views/hosting/edit.php +++ b/src/admin/views/hosting/edit.php @@ -13,6 +13,18 @@
+
+
+ + +
+
+
+
+ + +
+
@@ -27,26 +39,8 @@
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - + +
@@ -57,8 +51,26 @@
- - + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
@@ -73,11 +85,17 @@
+
+
+ + +
+

-
+
diff --git a/src/admin/views/hosting/list.php b/src/admin/views/hosting/list.php index 935360d..42ab850 100755 --- a/src/admin/views/hosting/list.php +++ b/src/admin/views/hosting/list.php @@ -13,7 +13,7 @@
Key TypeCpanel URLPanel URL Package Action