Browse Source

新增托管服务回调功能:账号激活、暂停deng,支持多个托管服务

Jackson Dou 2 years ago
parent
commit
a3374a79da
72 changed files with 1840 additions and 1091 deletions
  1. 3 0
      nginx.conf
  2. 10 2
      src/admin/controllers/accounts/deactivate.php
  3. 4 4
      src/admin/controllers/accounts/goftp.php
  4. 1 1
      src/admin/controllers/accounts/login.php
  5. 10 2
      src/admin/controllers/accounts/password.php
  6. 10 2
      src/admin/controllers/accounts/reactivate.php
  7. 3 4
      src/admin/controllers/accounts/view.php
  8. 1 1
      src/admin/controllers/clients/list.php
  9. 1 4
      src/admin/controllers/clients/view.php
  10. 25 7
      src/admin/controllers/hosting/add.php
  11. 70 1
      src/admin/controllers/hosting/edit.php
  12. 7 1
      src/admin/controllers/hosting/view.php
  13. 1 1
      src/admin/controllers/news/add.php
  14. 2 0
      src/admin/controllers/news/edit.php
  15. 2 0
      src/admin/controllers/news/list.php
  16. 2 0
      src/admin/controllers/news/view.php
  17. 0 2
      src/admin/controllers/profile/view.php
  18. 0 2
      src/admin/controllers/settings/view.php
  19. 0 2
      src/admin/news.php
  20. 0 1
      src/admin/tickets.php
  21. 9 1
      src/admin/views/accounts/list.php
  22. 1 1
      src/admin/views/accounts/login.php
  23. 10 10
      src/admin/views/accounts/view.php
  24. 9 7
      src/admin/views/clients/list.php
  25. 3 3
      src/admin/views/common/sidebar.php
  26. 39 13
      src/admin/views/hosting/add.php
  27. 31 13
      src/admin/views/hosting/edit.php
  28. 1 1
      src/admin/views/hosting/list.php
  29. 37 13
      src/admin/views/hosting/view.php
  30. 1 1
      src/admin/views/news/add.php
  31. 1 1
      src/admin/views/news/edit.php
  32. 1 1
      src/admin/views/news/list.php
  33. 1 1
      src/admin/views/news/view.php
  34. 4 4
      src/admin/views/profile/view.php
  35. 1 1
      src/admin/views/tickets/list.php
  36. 8 0
      src/callback/.htaccess
  37. 19 17
      src/callback/index.php
  38. 66 26
      src/callback/myownfreehost/activate.php
  39. 18 1
      src/callback/myownfreehost/app.php
  40. 86 0
      src/callback/myownfreehost/reactivate.php
  41. 87 0
      src/callback/myownfreehost/sqlcluster.php
  42. 84 0
      src/callback/myownfreehost/subdomainadd.php
  43. 84 0
      src/callback/myownfreehost/subdomaindel.php
  44. 74 16
      src/callback/myownfreehost/suspend.php
  45. 45 32
      src/clientarea/controllers/accounts/add.php
  46. 10 2
      src/clientarea/controllers/accounts/deactivate.php
  47. 2 2
      src/clientarea/controllers/accounts/goftp.php
  48. 1 1
      src/clientarea/controllers/accounts/login.php
  49. 10 2
      src/clientarea/controllers/accounts/password.php
  50. 11 3
      src/clientarea/controllers/accounts/validate_domain.php
  51. 15 9
      src/clientarea/controllers/accounts/view.php
  52. 0 1
      src/clientarea/controllers/clients/profile.php
  53. 0 2
      src/clientarea/controllers/myssl/add.php
  54. 0 2
      src/clientarea/controllers/myssl/list.php
  55. 0 2
      src/clientarea/controllers/tickets/list.php
  56. 0 1
      src/clientarea/settings.php
  57. 47 29
      src/clientarea/views/accounts/add.php
  58. 1 1
      src/clientarea/views/accounts/login.php
  59. 4 4
      src/clientarea/views/clients/profile.php
  60. 1 1
      src/clientarea/views/common/sidebar.php
  61. 12 4
      src/core/application.php
  62. 5 5
      src/core/handler/HostingHandler.php
  63. 4 0
      src/core/language/en-US/language.php
  64. 7 1
      src/core/language/zh-CN/language.php
  65. 2 0
      src/core/language/zh-TW/language.php
  66. 168 3
      src/core/library/functions.php
  67. 617 621
      src/core/library/lib/MOFHAPI.php
  68. 0 160
      src/core/library/userinfo.class.php
  69. 48 32
      src/install/function/Database.php
  70. 1 1
      src/install/function/Step1.php
  71. 1 1
      src/install/function/Step2.php
  72. 1 1
      src/install/function/configuration.php

+ 3 - 0
nginx.conf

@@ -0,0 +1,3 @@
+location /callback {
+    rewrite ^(.*)$ /callback/index.php?s=$1 last; break;
+}

+ 10 - 2
src/admin/controllers/accounts/deactivate.php

@@ -32,12 +32,20 @@ if (empty($AccountInfo)) {
 //     redirect('admin/accounts', '', array('action' => 'view', 'account_id' => $account_id));
 //     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';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
-$client = Client::create($HostingApiConfig);
+$client = Client::create($AccountApiConfig);
 $request = $client->suspend(array(
 $request = $client->suspend(array(
     'username' => $AccountInfo['account_key'],
     'username' => $AccountInfo['account_key'],
     'reason' => $reason,
     'reason' => $reason,

+ 4 - 4
src/admin/controllers/accounts/goftp.php

@@ -8,13 +8,13 @@ if (empty($account_id)) {
     redirect('admin/accounts');
     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');
     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);
 header("Location: " . $filemanager_url);

+ 1 - 1
src/admin/controllers/accounts/login.php

@@ -14,4 +14,4 @@ if (empty($AccountInfo)) {
     redirect('admin/accounts');
     redirect('admin/accounts');
 }
 }
 
 
-require_once ROOT . '/core/handler/HostingHandler.php';
+$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1);

+ 10 - 2
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));
     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';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
-$client = Client::create($HostingApiConfig);
+$client = Client::create($AccountApiConfig);
 $request = $client->password([
 $request = $client->password([
     'username' => $AccountInfo['account_key'],
     'username' => $AccountInfo['account_key'],
     'password' => $new_password,
     'password' => $new_password,

+ 10 - 2
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));
     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';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
-$client = Client::create($HostingApiConfig);
+$client = Client::create($AccountApiConfig);
 $request = $client->unsuspend(array(
 $request = $client->unsuspend(array(
     'username' => $AccountInfo['account_key'],
     'username' => $AccountInfo['account_key'],
 ));
 ));

+ 3 - 4
src/admin/controllers/accounts/view.php

@@ -10,13 +10,12 @@ if (empty($account_id)) {
     redirect('admin/accounts');
     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);
 $AccountInfo = $DB->find('account', '*', array('account_id' => $account_id), null, 1);
 
 
 if (empty($AccountInfo)) {
 if (empty($AccountInfo)) {
     setMessage('not found', 'danger');
     setMessage('not found', 'danger');
     redirect('admin/accounts');
     redirect('admin/accounts');
 }
 }
+
+$PageInfo['title'] = 'View Account (#' . $account_id . ')';
+$AccountApi = $DB->find('account_api', '*', array('api_key' => $AccountInfo['account_api_key']), null, 1);

+ 1 - 1
src/admin/controllers/clients/list.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-$PageInfo['title'] = $lang->I18N('My Clients');
+$PageInfo['title'] = $lang->I18N('Clients List');
 
 
 $count = $DB->count('clients');
 $count = $DB->count('clients');
 
 

+ 1 - 4
src/admin/controllers/clients/view.php

@@ -1,17 +1,13 @@
 <?php
 <?php
 
 
-require_once ROOT . '/core/handler/HostingHandler.php';
-require_once ROOT . '/core/library/userinfo.class.php';
 require_once ROOT . '/core/library/countries.php';
 require_once ROOT . '/core/library/countries.php';
 
 
 $client_id = get('client_id');
 $client_id = get('client_id');
 
 
 if (empty($client_id)) {
 if (empty($client_id)) {
     redirect('admin/clients');
     redirect('admin/clients');
-    exit();
 }
 }
 
 
-$PageInfo['title'] = 'View client (' . $client_id . ')';
 
 
 $ClientInfo = $DB->find('clients', '*', array('client_id' => $client_id), null, 1);
 $ClientInfo = $DB->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_account = $DB->count('account', array('account_client_id' => $ClientInfo['client_id']));
 $count_ssl = $DB->count('ssl', array('ssl_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']));
 $count_tickets = $DB->count('tickets', array('ticket_client_id' => $ClientInfo['client_id']));

+ 25 - 7
src/admin/controllers/hosting/add.php

@@ -3,6 +3,16 @@
 if (isset($_POST['submit'])) {
 if (isset($_POST['submit'])) {
     require '../../application.php';
     require '../../application.php';
 
 
+    if (!post('api_type')) {
+        setMessage('need field: api_type', 'danger');
+        redirect('admin/hosting');
+    }
+
+    if (!post('api_key')) {
+        setMessage('need field: api_key', 'danger');
+        redirect('admin/hosting');
+    }
+
     if (!post('api_username')) {
     if (!post('api_username')) {
         setMessage('need field: api_username', 'danger');
         setMessage('need field: api_username', 'danger');
         redirect('admin/hosting');
         redirect('admin/hosting');
@@ -13,13 +23,8 @@ if (isset($_POST['submit'])) {
         redirect('admin/hosting');
         redirect('admin/hosting');
     }
     }
 
 
-    if (!post('api_type')) {
-        setMessage('need field: api_type', 'danger');
-        redirect('admin/hosting');
-    }
-
-    if (!post('api_key')) {
-        setMessage('need field: api_key', 'danger');
+    if (!post('api_server_domain')) {
+        setMessage('need field: api_server_domain', 'danger');
         redirect('admin/hosting');
         redirect('admin/hosting');
     }
     }
 
 
@@ -33,6 +38,16 @@ if (isset($_POST['submit'])) {
         redirect('admin/hosting');
         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')) {
     if (!post('api_ns_1')) {
         setMessage('need field: api_ns_1', 'danger');
         setMessage('need field: api_ns_1', 'danger');
         redirect('admin/hosting');
         redirect('admin/hosting');
@@ -59,7 +74,10 @@ if (isset($_POST['submit'])) {
         'api_password' => post('api_password'),
         'api_password' => post('api_password'),
         'api_type' => post('api_type'),
         'api_type' => post('api_type'),
         'api_key' => post('api_key'),
         'api_key' => post('api_key'),
+        'api_server_domain' => post('api_server_domain'),
         'api_cpanel_url' => post('api_cpanel_url'),
         '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_server_ip' => post('api_server_ip'),
         'api_ns_1' => post('api_ns_1'),
         'api_ns_1' => post('api_ns_1'),
         'api_ns_2' => post('api_ns_2'),
         'api_ns_2' => post('api_ns_2'),

+ 70 - 1
src/admin/controllers/hosting/edit.php

@@ -7,12 +7,81 @@ if (isset($_POST['submit'])) {
         setMessage('need field: api_id', 'danger');
         setMessage('need field: api_id', 'danger');
         redirect('admin/hosting');
         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(
     $data = array(
         'api_username' => post('api_username'),
         'api_username' => post('api_username'),
         'api_password' => post('api_password'),
         'api_password' => post('api_password'),
         'api_type' => post('api_type'),
         'api_type' => post('api_type'),
         'api_key' => post('api_key'),
         'api_key' => post('api_key'),
+        'api_server_domain' => post('api_server_domain'),
         'api_cpanel_url' => post('api_cpanel_url'),
         '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_server_ip' => post('api_server_ip'),
         'api_ns_1' => post('api_ns_1'),
         'api_ns_1' => post('api_ns_1'),
         'api_ns_2' => post('api_ns_2'),
         'api_ns_2' => post('api_ns_2'),
@@ -28,7 +97,7 @@ if (isset($_POST['submit'])) {
         setMessage("Something went's wrong !", 'danger');
         setMessage("Something went's wrong !", 'danger');
     }
     }
 
 
-    redirect('admin/hosting');
+    redirect('admin/hosting', '', ['action' => 'edit', 'id' => $api_id]);
 } else {
 } else {
     if (!defined('IN_CRONLITE')) {
     if (!defined('IN_CRONLITE')) {
         exit('Access Denied');
         exit('Access Denied');

+ 7 - 1
src/admin/controllers/hosting/view.php

@@ -5,10 +5,16 @@ if (!defined('IN_CRONLITE')) {
 }
 }
 
 
 $api_id = get('id');
 $api_id = get('id');
+$api_key = get('api_key');
 
 
 if ($api_id > 0) {
 if ($api_id > 0) {
-    // $PageInfo = ['title' => 'View Hosting Provider #' . $api_id, 'rel' => ''];
     $data = $DB->find('account_api', '*', array('api_id' => $api_id), null, 1);
     $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 {
 } else {
     $PageInfo = ['title' => 'Unathorized Access', 'rel' => ''];
     $PageInfo = ['title' => 'Unathorized Access', 'rel' => ''];
     $data = null;
     $data = null;

+ 1 - 1
src/admin/controllers/news/add.php

@@ -19,7 +19,7 @@ if (isset($_POST['submit'])) {
     }
     }
     redirect('admin/news');
     redirect('admin/news');
 } else {
 } else {
-    $PageInfo['title'] = 'Add News';
+    $PageInfo['title'] = $lang->I18N('News Add');
     $status_types = array(
     $status_types = array(
         "关闭",
         "关闭",
         "打开",
         "打开",

+ 2 - 0
src/admin/controllers/news/edit.php

@@ -45,3 +45,5 @@ if ($id > 0) {
     $news = $DB->find('news', '*', array('news_id' => $id), null, 1);
     $news = $DB->find('news', '*', array('news_id' => $id), null, 1);
 }
 }
 $load_editor = 1;
 $load_editor = 1;
+
+$PageInfo['title'] = $lang->I18N('News Edit');

+ 2 - 0
src/admin/controllers/news/list.php

@@ -12,3 +12,5 @@ $status_types = array(
     "关闭",
     "关闭",
     "打开",
     "打开",
 );
 );
+
+$PageInfo['title'] = $lang->I18N('News List');

+ 2 - 0
src/admin/controllers/news/view.php

@@ -20,3 +20,5 @@ $data = null;
 if ($id > 0) {
 if ($id > 0) {
     $data = $DB->find('news', '*', array('news_id' => $id), null, 1);
     $data = $DB->find('news', '*', array('news_id' => $id), null, 1);
 }
 }
+
+$PageInfo['title'] = $lang->I18N('News Details');

+ 0 - 2
src/admin/controllers/profile/view.php

@@ -1,5 +1,3 @@
 <?php
 <?php
 
 
 $PageInfo['title'] = $lang->I18N('My Profile');
 $PageInfo['title'] = $lang->I18N('My Profile');
-
-require_once ROOT . '/core/library/userinfo.class.php';

+ 0 - 2
src/admin/controllers/settings/view.php

@@ -1,7 +1,5 @@
 <?php
 <?php
 
 
-// require_once ROOT . '/library/userinfo.class.php';
-
 $Statuses = array(
 $Statuses = array(
     array('name' => 'Live', 'value' => '1'),
     array('name' => 'Live', 'value' => '1'),
     array('name' => 'Maintaince', 'value' => '0'),
     array('name' => 'Maintaince', 'value' => '0'),

+ 0 - 2
src/admin/news.php

@@ -8,8 +8,6 @@ if (!in_array($action, array('list', 'add', 'edit', 'view'))) {
     $action = 'list';
     $action = 'list';
 }
 }
 
 
-$PageInfo['title'] = 'News ' . ucfirst($action);
-
 require __DIR__ . '/controllers/news/' . $action . '.php';
 require __DIR__ . '/controllers/news/' . $action . '.php';
 require __DIR__ . '/views/common/header.php';
 require __DIR__ . '/views/common/header.php';
 require __DIR__ . '/views/common/navbar.php';
 require __DIR__ . '/views/common/navbar.php';

+ 0 - 1
src/admin/tickets.php

@@ -1,7 +1,6 @@
 <?php
 <?php
 
 
 require_once __DIR__ . '/application.php';
 require_once __DIR__ . '/application.php';
-require_once ROOT . '/core/library/userinfo.class.php';
 require_once ROOT . '/core/library/tickets.php';
 require_once ROOT . '/core/library/tickets.php';
 
 
 $action = get('action', 'list');
 $action = get('action', 'list');

+ 9 - 1
src/admin/views/accounts/list.php

@@ -13,6 +13,8 @@
             <table class="table table-stripped table-bordered table-hover">
             <table class="table table-stripped table-bordered table-hover">
                 <thead>
                 <thead>
                     <th>ID</th>
                     <th>ID</th>
+                    <th><?php echo $lang->I18N('Clients'); ?></th>
+                    <th><?php echo $lang->I18N('Provider'); ?></th>
                     <th><?php echo $lang->I18N('Username'); ?></th>
                     <th><?php echo $lang->I18N('Username'); ?></th>
                     <th><?php echo $lang->I18N('Domain'); ?></th>
                     <th><?php echo $lang->I18N('Domain'); ?></th>
                     <th><?php echo $lang->I18N('Deploy Date'); ?></th>
                     <th><?php echo $lang->I18N('Deploy Date'); ?></th>
@@ -23,7 +25,13 @@
 <?php if ($count > 0): ?>
 <?php if ($count > 0): ?>
     <?php foreach ($rows as $row): ?>
     <?php foreach ($rows as $row): ?>
                     <tr>
                     <tr>
-                        <td># <?php $row['account_id'];?></td>
+                        <td><?php echo $row['account_id'];?></td>
+                        <td><?php echo $row['account_client_id']; ?></td>
+                        <td>
+                            <a href="hosting.php?action=view&api_key=<?php echo $row['account_api_key']; ?>">
+                                <?php echo $row['account_api_key']; ?>
+                            </a>
+                        </td>
                         <td><?php echo $row['account_username']; ?></td>
                         <td><?php echo $row['account_username']; ?></td>
                         <td><?php echo $row['account_domain']; ?></td>
                         <td><?php echo $row['account_domain']; ?></td>
                         <td><?php echo $row['account_date']; ?></td>
                         <td><?php echo $row['account_date']; ?></td>

+ 1 - 1
src/admin/views/accounts/login.php

@@ -7,7 +7,7 @@
             <hr />
             <hr />
             <div class="card-body">
             <div class="card-body">
                 <p>Now you are going to be redirected to the control panel. It can take upto 5 seconds based on your internet connecion speed.</p>
                 <p>Now you are going to be redirected to the control panel. It can take upto 5 seconds based on your internet connecion speed.</p>
-                <form name="login" action="https://<?php echo $HostingApi['api_cpanel_url'] ?>/login.php" id="account_ogin" method="post">
+                <form name="login" action="https://<?php echo $AccountApi['api_cpanel_url'] ?>/login.php" id="account_ogin" method="post">
                     <input type="hidden" name="uname" value="<?php echo $AccountInfo['account_username']; ?>">
                     <input type="hidden" name="uname" value="<?php echo $AccountInfo['account_username']; ?>">
                     <input type="hidden" name="passwd" value="<?php echo $AccountInfo['account_password']; ?>">
                     <input type="hidden" name="passwd" value="<?php echo $AccountInfo['account_password']; ?>">
                     <input type="hidden" name="language" value="<?php echo $lang->get_language_value(); ?>">
                     <input type="hidden" name="language" value="<?php echo $lang->get_language_value(); ?>">

+ 10 - 10
src/admin/views/accounts/view.php

@@ -35,13 +35,13 @@
                 <hr />
                 <hr />
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="m-5">
                     <div class="m-5">
-                        <b>Cpanel Username:</b>
+                        <b>Control Panel Username:</b>
                         <span><?php echo $AccountInfo['account_username']; ?></span>
                         <span><?php echo $AccountInfo['account_username']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
-                        <b>Cpanel Password:</b>
+                        <b>Control Panel Password:</b>
                         <span><kbd><?php echo $AccountInfo['account_password']; ?></kbd></span>
                         <span><kbd><?php echo $AccountInfo['account_password']; ?></kbd></span>
                     </div>
                     </div>
                 </div>
                 </div>
@@ -53,8 +53,8 @@
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
-                        <b>Cpanel Domain:</b>
-                        <span><?php echo $HostingApi['api_cpanel_url']; ?></span>
+                        <b>Control Panel Domain:</b>
+                        <span><?php echo $AccountApi['api_cpanel_url']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6 col-md-6">
                 <div class="col-md-4 col-sm-6 col-md-6">
@@ -80,19 +80,19 @@
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>Server IP:</b>
                         <b>Server IP:</b>
-                        <span><?php echo $HostingApi['api_server_ip']; ?></span>
+                        <span><?php echo $AccountApi['api_server_ip']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>Your IP:</b>
                         <b>Your IP:</b>
-                        <span><?php echo UserInfo::get_ip() ?></span>
+                        <span><?php echo get_client_ip(); ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>FTP Hostname:</b>
                         <b>FTP Hostname:</b>
-                        <span><?php echo str_replace('cpanel', 'ftp', $HostingApi['api_cpanel_url']) ?></span>
+                        <span><?php echo $AccountApi['api_server_ftp_domain']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
@@ -104,7 +104,7 @@
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>MySQL Hostname:</b>
                         <b>MySQL Hostname:</b>
-                        <span><?php echo str_replace('cpanel', 'sqlxxx', $HostingApi['api_cpanel_url']) ?></span>
+                        <span><?php echo $AccountInfo['account_sql'] . '.' . $AccountApi['api_server_sql_domain']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
@@ -116,13 +116,13 @@
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>Nameserver 1:</b>
                         <b>Nameserver 1:</b>
-                        <span><?php echo $HostingApi['api_ns_1']; ?></span>
+                        <span><?php echo $AccountApi['api_ns_1']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-4 col-sm-6">
                 <div class="col-md-4 col-sm-6">
                     <div class="d-flex justify-content-between align-items-center m-5">
                     <div class="d-flex justify-content-between align-items-center m-5">
                         <b>Nameserver 2:</b>
                         <b>Nameserver 2:</b>
-                        <span><?php echo $HostingApi['api_ns_2']; ?></span>
+                        <span><?php echo $AccountApi['api_ns_2']; ?></span>
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>

+ 9 - 7
src/admin/views/clients/list.php

@@ -2,7 +2,7 @@
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card m-20 p-20">
     <div class="card m-20 p-20">
         <div class="card-header d-flex justify-content-between align-items-center">
         <div class="card-header d-flex justify-content-between align-items-center">
-            <h3 class="m-0"><?php echo $lang->I18N('My Clients'); ?></h3>
+            <h3 class="m-0"><?php echo $lang->I18N('Clients List'); ?></h3>
             <a href="index.php" class="btn btn-danger btn-sm pull-right"><i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?></a>
             <a href="index.php" class="btn btn-danger btn-sm pull-right"><i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?></a>
         </div>
         </div>
         <hr />
         <hr />
@@ -10,19 +10,21 @@
             <table class="table table-stripped table-bordered table-hover">
             <table class="table table-stripped table-bordered table-hover">
                 <thead>
                 <thead>
                     <th>ID</th>
                     <th>ID</th>
-                    <th>Name</th>
-                    <th>Email</th>
-                    <th>Date</th>
-                    <th>Status</th>
-                    <th>Action</th>
+                    <th><?php echo $lang->I18N('Name'); ?></th>
+                    <th><?php echo $lang->I18N('Email'); ?></th>
+                    <th><?php echo $lang->I18N('Phone'); ?></th>
+                    <th><?php echo $lang->I18N('Date'); ?></th>
+                    <th><?php echo $lang->I18N('Status'); ?></th>
+                    <th><?php echo $lang->I18N('Action'); ?></th>
                 </thead>
                 </thead>
                 <tbody>
                 <tbody>
 <?php if ($count > 0): ?>
 <?php if ($count > 0): ?>
 <?php foreach ($rows as $value): ?>
 <?php foreach ($rows as $value): ?>
                     <tr>
                     <tr>
-                        <td># <?php echo $value['client_id']; ?></td>
+                        <td><?php echo $value['client_id']; ?></td>
                         <td><?php echo $value['client_fname'] . " " . $value['client_lname']; ?></td>
                         <td><?php echo $value['client_fname'] . " " . $value['client_lname']; ?></td>
                         <td><?php echo $value['client_email']; ?></td>
                         <td><?php echo $value['client_email']; ?></td>
+                        <td><?php echo $value['client_phone']; ?></td>
                         <td><?php echo $value['client_date']; ?></td>
                         <td><?php echo $value['client_date']; ?></td>
                         <td><?php
                         <td><?php
 if ($value['client_status'] == '0') {
 if ($value['client_status'] == '0') {

+ 3 - 3
src/admin/views/common/sidebar.php

@@ -23,11 +23,11 @@ $avatar_path = $AdminInfo['admin_email'] ? md5($AdminInfo['admin_email']) : 'def
         </a>
         </a>
         <a href="clients.php" class="sidebar-link sidebar-link-with-icon">
         <a href="clients.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-users" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-users" aria-hidden="true"></i></span>
-            <?php echo $lang->I18N('Clients'); ?>
+            <?php echo $lang->I18N('Clients List'); ?>
         </a>
         </a>
         <a href="tickets.php" class="sidebar-link sidebar-link-with-icon">
         <a href="tickets.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-ticket-alt" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-ticket-alt" aria-hidden="true"></i></span>
-            <?php echo $lang->I18N('Tickets'); ?>
+            <?php echo $lang->I18N('Tickets List'); ?>
         </a>
         </a>
         <a href="sslcert.php" class="sidebar-link sidebar-link-with-icon">
         <a href="sslcert.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-shield-alt" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-shield-alt" aria-hidden="true"></i></span>
@@ -43,7 +43,7 @@ $avatar_path = $AdminInfo['admin_email'] ? md5($AdminInfo['admin_email']) : 'def
         </a>
         </a>
         <a href="news.php" class="sidebar-link sidebar-link-with-icon">
         <a href="news.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-newspaper" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-newspaper" aria-hidden="true"></i></span>
-            <?php echo $lang->I18N('News'); ?>
+            <?php echo $lang->I18N('News List'); ?>
         </a>
         </a>
         <a href="hosting.php" class="sidebar-link sidebar-link-with-icon">
         <a href="hosting.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-server" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-server" aria-hidden="true"></i></span>

+ 39 - 13
src/admin/views/hosting/add.php

@@ -12,6 +12,20 @@
         <hr />
         <hr />
         <form class="card-body" action="controllers/hosting/add.php" method="post">
         <form class="card-body" action="controllers/hosting/add.php" method="post">
             <div class="row">
             <div class="row">
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required"><?php echo $lang->I18N('Provider Type'); ?></label>
+                        <select name="api_type" class="form-control" required>
+                            <option value="myownfreehost" selected>MyOwnFreeHost</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">Hosting Key</label>
+                        <input type="text" name="api_key" class="form-control" required>
+                    </div>
+                </div>
                 <div class="col-md-12">
                 <div class="col-md-12">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
                         <label class="form-label required">MOFH API Username</label>
                         <label class="form-label required">MOFH API Username</label>
@@ -26,38 +40,38 @@
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Type</label>
-                        <input type="text" name="api_type" class="form-control" required>
+                        <label class="form-label required">Server domain</label>
+                        <input type="text" name="api_server_domain" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Key</label>
-                        <input type="text" name="api_key" class="form-control" required>
+                        <label class="form-label required">Server IP</label>
+                        <input type="text" name="api_server_ip" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">cPanel URL</label>
-                        <input type="text" name="api_cpanel_url" class="form-control" required>
+                        <label class="form-label required">FTP Server</label>
+                        <input type="text" name="api_server_ftp_domain" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Package</label>
-                        <input type="text" name="api_package" class="form-control" required>
+                        <label class="form-label required">SQL Server</label>
+                        <input type="text" name="api_server_sql_domain" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Server IP</label>
-                        <input type="text" name="api_server_ip" class="form-control" required>
+                        <label class="form-label required">Control Panel URL</label>
+                        <input type="text" name="api_cpanel_url" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">API Callback Token</label>
-                        <input type="text" name="api_callback_token" class="form-control" maxlength="32" required>
+                        <label class="form-label required">Hosting Package</label>
+                        <input type="text" name="api_package" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
@@ -72,11 +86,23 @@
                         <input type="text" name="api_ns_2" class="form-control" required>
                         <input type="text" name="api_ns_2" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
+                <div class="col-md-12">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">API Callback Token</label>
+                        <input type="text" name="api_callback_token" class="form-control" maxlength="32" required>
+                    </div>
+                </div>
+                <div class="col-md-12">
+                    <div class="mb-10 px-10">
+                        <label class="form-label">API Callback URL</label>
+                        <input type="text" class="form-control" value="<?php echo $site_url ?>/callback/[Hosting Key]/[API Callback Token]" readonly>
+                    </div>
+                </div>
             </div>
             </div>
             <hr />
             <hr />
             <div class="row">
             <div class="row">
                 <div class="col-md-12">
                 <div class="col-md-12">
-                    <div class="mb-10 px-10">
+                    <div class="my-10 px-10">
                         <button name="submit" class="btn btn-primary"><?php echo $lang->I18N('Save'); ?></button>
                         <button name="submit" class="btn btn-primary"><?php echo $lang->I18N('Save'); ?></button>
                     </div>
                     </div>
                 </div>
                 </div>

+ 31 - 13
src/admin/views/hosting/edit.php

@@ -13,6 +13,18 @@
         <form class="card-body" action="controllers/hosting/edit.php" method="post">
         <form class="card-body" action="controllers/hosting/edit.php" method="post">
             <input type="hidden" name="api_id" value="<?php echo $data['api_id']; ?>" style="display:none;">
             <input type="hidden" name="api_id" value="<?php echo $data['api_id']; ?>" style="display:none;">
             <div class="row">
             <div class="row">
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required"><?php echo $lang->I18N('Provider Type'); ?></label>
+                        <input type="text" name="api_type" value="<?php echo $data['api_type']; ?>" class="form-control" required readonly>
+                    </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">Hosting Key</label>
+                        <input type="text" name="api_key" value="<?php echo $data['api_key']; ?>" class="form-control" required readonly>
+                    </div>
+                </div>
                 <div class="col-md-12">
                 <div class="col-md-12">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
                         <label class="form-label required">MOFH API Username</label>
                         <label class="form-label required">MOFH API Username</label>
@@ -27,38 +39,38 @@
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Type</label>
-                        <input type="text" name="api_type" value="<?php echo $data['api_type']; ?>" class="form-control" required>
+                        <label class="form-label required">Server domain</label>
+                        <input type="text" name="api_server_domain" value="<?php echo $data['api_server_domain']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Key</label>
-                        <input type="text" name="api_key" value="<?php echo $data['api_key']; ?>" class="form-control" required>
+                        <label class="form-label required">Server IP</label>
+                        <input type="text" name="api_server_ip" value="<?php echo $data['api_server_ip']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">cPanel URL</label>
-                        <input type="text" name="api_cpanel_url" value="<?php echo $data['api_cpanel_url']; ?>" class="form-control" required>
+                        <label class="form-label required">FTP Server</label>
+                        <input type="text" name="api_server_ftp_domain" value="<?php echo $data['api_server_ftp_domain']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Hosting Package</label>
-                        <input type="text" name="api_package" value="<?php echo $data['api_package']; ?>" class="form-control" required>
+                        <label class="form-label required">SQL Server</label>
+                        <input type="text" name="api_server_sql_domain" value="<?php echo $data['api_server_sql_domain']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">Server IP</label>
-                        <input type="text" name="api_server_ip" value="<?php echo $data['api_server_ip']; ?>" class="form-control" required>
+                        <label class="form-label required">Control Panel URL</label>
+                        <input type="text" name="api_cpanel_url" value="<?php echo $data['api_cpanel_url']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label required">API Callback Token</label>
-                        <input type="text" name="api_callback_token" value="<?php echo $data['api_callback_token']; ?>" class="form-control" maxlength="32" required>
+                        <label class="form-label required">Hosting Package</label>
+                        <input type="text" name="api_package" value="<?php echo $data['api_package']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
@@ -73,11 +85,17 @@
                         <input type="text" name="api_ns_2" value="<?php echo $data['api_ns_2']; ?>" class="form-control" required>
                         <input type="text" name="api_ns_2" value="<?php echo $data['api_ns_2']; ?>" class="form-control" required>
                     </div>
                     </div>
                 </div>
                 </div>
+                <div class="col-md-12">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">API Callback Token</label>
+                        <input type="text" name="api_callback_token" value="<?php echo $data['api_callback_token']; ?>" class="form-control" maxlength="32" required>
+                    </div>
+                </div>
             </div>
             </div>
             <hr />
             <hr />
             <div class="row">
             <div class="row">
                 <div class="col-md-12">
                 <div class="col-md-12">
-                    <div class="mb-10 px-10">
+                    <div class="my-10 px-10">
                         <button name="submit" class="btn btn-primary"><?php echo $lang->I18N('Save'); ?></button>
                         <button name="submit" class="btn btn-primary"><?php echo $lang->I18N('Save'); ?></button>
                     </div>
                     </div>
                 </div>
                 </div>

+ 1 - 1
src/admin/views/hosting/list.php

@@ -13,7 +13,7 @@
                 <thead>
                 <thead>
                     <th>Key</th>
                     <th>Key</th>
                     <th>Type</th>
                     <th>Type</th>
-                    <th>Cpanel URL</th>
+                    <th>Panel URL</th>
                     <th>Package</th>
                     <th>Package</th>
                     <th>Action</th>
                     <th>Action</th>
                 </thead>
                 </thead>

+ 37 - 13
src/admin/views/hosting/view.php

@@ -18,6 +18,18 @@
         <hr />
         <hr />
         <div class="card-body">
         <div class="card-body">
             <div class="row">
             <div class="row">
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label"><?php echo $lang->I18N('Provider Type'); ?></label>
+                        <input type="text" name="api_type" value="<?php echo $data['api_type']; ?>" class="form-control" readonly>
+                    </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label">Hosting Key</label>
+                        <input type="text" name="api_key" value="<?php echo $data['api_key']; ?>" class="form-control" readonly>
+                    </div>
+                </div>
                 <div class="col-md-12">
                 <div class="col-md-12">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
                         <label class="form-label">MOFH API Username</label>
                         <label class="form-label">MOFH API Username</label>
@@ -32,38 +44,38 @@
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">Hosting Type</label>
-                        <input type="text" name="api_type" value="<?php echo $data['api_type']; ?>" class="form-control" readonly>
+                        <label class="form-label">Hosting Server</label>
+                        <input type="text" name="api_server_domain" value="<?php echo $data['api_server_domain']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">Hosting Key</label>
-                        <input type="text" name="api_key" value="<?php echo $data['api_key']; ?>" class="form-control" readonly>
+                        <label class="form-label">Server IP</label>
+                        <input type="text" name="api_server_ip" value="<?php echo $data['api_server_ip']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">Control Panel URL</label>
-                        <input type="text" name="api_cpanel_url" value="<?php echo $data['api_cpanel_url']; ?>" class="form-control" readonly>
+                        <label class="form-label">FTP Server</label>
+                        <input type="text" name="api_server_ftp_domain" value="<?php echo $data['api_server_ftp_domain']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">Hosting Package</label>
-                        <input type="text" name="api_package" value="<?php echo $data['api_package']; ?>" class="form-control" readonly>
+                        <label class="form-label">SQL Server</label>
+                        <input type="text" name="api_server_sql_domain" value="<?php echo $data['api_server_sql_domain']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">Server IP</label>
-                        <input type="text" name="api_server_ip" value="<?php echo $data['api_server_ip']; ?>" class="form-control" readonly>
+                        <label class="form-label">Control Panel URL</label>
+                        <input type="text" name="api_cpanel_url" value="<?php echo $data['api_cpanel_url']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <div class="mb-10 px-10">
                     <div class="mb-10 px-10">
-                        <label class="form-label">API Callback Token</label>
-                        <input type="text" name="api_callback_token" value="<?php echo $data['api_callback_token']; ?>" class="form-control" maxlength="32" readonly>
+                        <label class="form-label">Hosting Package</label>
+                        <input type="text" name="api_package" value="<?php echo $data['api_package']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
@@ -78,11 +90,23 @@
                         <input type="text" name="api_ns_2" value="<?php echo $data['api_ns_2']; ?>" class="form-control" readonly>
                         <input type="text" name="api_ns_2" value="<?php echo $data['api_ns_2']; ?>" class="form-control" readonly>
                     </div>
                     </div>
                 </div>
                 </div>
+                <div class="col-md-12">
+                    <div class="mb-10 px-10">
+                        <label class="form-label">API Callback Token</label>
+                        <input type="text" name="api_callback_token" value="<?php echo $data['api_callback_token']; ?>" class="form-control" maxlength="32" readonly>
+                    </div>
+                </div>
+                <div class="col-md-12">
+                    <div class="mb-10 px-10">
+                        <label class="form-label">API Callback URL</label>
+                        <input type="text" class="form-control" value="<?php echo $api_callback_url; ?>" readonly>
+                    </div>
+                </div>
             </div>
             </div>
             <hr />
             <hr />
             <div class="row">
             <div class="row">
                 <div class="col-md-12">
                 <div class="col-md-12">
-                    <div class="mb-10 px-10">
+                    <div class="mb-20 px-10">
                         <a href="<?php echo setURL('admin/hosting', '', array('action' => 'edit', 'id' => $data['api_id'])); ?>" class="btn btn-sm btn-secondary mx-5 btn-rounded"><i class="fa fa-edit"></i> <?php echo $lang->I18N('edit'); ?></a>
                         <a href="<?php echo setURL('admin/hosting', '', array('action' => 'edit', 'id' => $data['api_id'])); ?>" class="btn btn-sm btn-secondary mx-5 btn-rounded"><i class="fa fa-edit"></i> <?php echo $lang->I18N('edit'); ?></a>
                     </div>
                     </div>
                 </div>
                 </div>

+ 1 - 1
src/admin/views/news/add.php

@@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card py-0">
     <div class="card py-0">
         <div class="d-flex justify-content-between align-items-center pt-15">
         <div class="d-flex justify-content-between align-items-center pt-15">
-            <h5 class="m-0">Add News</h5>
+            <h5 class="m-0"><?php echo $PageInfo['title']; ?></h5>
             <a href="news.php" class="btn btn-sm btn-danger"><i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?></a>
             <a href="news.php" class="btn btn-sm btn-danger"><i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?></a>
         </div>
         </div>
         <hr>
         <hr>

+ 1 - 1
src/admin/views/news/edit.php

@@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card py-0">
     <div class="card py-0">
         <div class="d-flex justify-content-between align-items-center pt-15">
         <div class="d-flex justify-content-between align-items-center pt-15">
-            <h5 class="m-0">Edit News</h5>
+            <h5 class="m-0"><?php echo $PageInfo['title']; ?></h5>
             <div>
             <div>
                 <a href="news.php" class="btn btn-sm btn-danger">
                 <a href="news.php" class="btn btn-sm btn-danger">
                     <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>
                     <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>

+ 1 - 1
src/admin/views/news/list.php

@@ -8,7 +8,7 @@ if (!defined('IN_CRONLITE')) {
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card py-0">
     <div class="card py-0">
         <div class="d-flex justify-content-between align-items-center pt-15">
         <div class="d-flex justify-content-between align-items-center pt-15">
-            <h5 class="m-0"><?php echo $lang->I18N('news'); ?></h5>
+            <h5 class="m-0"><?php echo $PageInfo['title']; ?></h5>
             <a href="news.php?action=add" class="btn text-white btn-success btn-sm">
             <a href="news.php?action=add" class="btn text-white btn-success btn-sm">
                 <i class="fa fa-plus"></i> <?php echo $lang->I18N('add'); ?>
                 <i class="fa fa-plus"></i> <?php echo $lang->I18N('add'); ?>
             </a>
             </a>

+ 1 - 1
src/admin/views/news/view.php

@@ -10,7 +10,7 @@ if (!defined('IN_CRONLITE')) {
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card py-0">
     <div class="card py-0">
         <div class="d-flex justify-content-between align-items-center pt-15">
         <div class="d-flex justify-content-between align-items-center pt-15">
-            <h5 class="m-0">News Details #<?php echo $id; ?></h5>
+            <h5 class="m-0"><?php echo $PageInfo['title']; ?> #<?php echo $id; ?></h5>
             <div>
             <div>
                 <a href="news.php" class="btn btn-sm btn-danger">
                 <a href="news.php" class="btn btn-sm btn-danger">
                     <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>
                     <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>

+ 4 - 4
src/admin/views/profile/view.php

@@ -19,19 +19,19 @@
                     <h6 class="mb-0"><b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $AdminInfo['admin_email']; ?></h6>
                     <h6 class="mb-0"><b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $AdminInfo['admin_email']; ?></h6>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
-                    <h6 class="mb-0"><b><?php echo $lang->I18N('IP Address'); ?>:</b> <?php echo UserInfo::get_ip(); ?></h6>
+                    <h6 class="mb-0"><b><?php echo $lang->I18N('IP Address'); ?>:</b> <?php echo get_client_ip(); ?></h6>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
                     <h6 class="mb-0"><b>Shared IP:</b> <?php echo gethostbyname($_SERVER['HTTP_HOST']); ?></h6>
                     <h6 class="mb-0"><b>Shared IP:</b> <?php echo gethostbyname($_SERVER['HTTP_HOST']); ?></h6>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
-                    <h6 class="mb-0"><b>Device Type:</b> <?php echo UserInfo::get_device(); ?></h6>
+                    <h6 class="mb-0"><b>Device Type:</b> <?php echo get_client_device(); ?></h6>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
-                    <h6 class="mb-0"><b>Device OS:</b> <?php echo UserInfo::get_os(); ?></h6>
+                    <h6 class="mb-0"><b>Device OS:</b> <?php echo get_client_os(); ?></h6>
                 </div>
                 </div>
                 <div class="col-md-6">
                 <div class="col-md-6">
-                    <h6 class="mb-0"><b>Web Browser:</b> <?php echo UserInfo::get_browser(); ?></h6>
+                    <h6 class="mb-0"><b>Web Browser:</b> <?php echo get_client_browser(); ?></h6>
                 </div>
                 </div>
                 <div class="col-md-12"><hr></div>
                 <div class="col-md-12"><hr></div>
                 <div class="col-md-6">
                 <div class="col-md-6">

+ 1 - 1
src/admin/views/tickets/list.php

@@ -3,7 +3,7 @@
 <div class="container-fluid">
 <div class="container-fluid">
     <div class="card">
     <div class="card">
         <div class="card-header d-flex justify-content-between align-items-center">
         <div class="card-header d-flex justify-content-between align-items-center">
-            <h3 class="m-0"><?php echo $lang->I18N('My Tickets'); ?></h3>
+            <h3 class="m-0"><?php echo $lang->I18N('Tickets List'); ?></h3>
             <a href="index.php" class="btn text-white btn-danger btn-sm">
             <a href="index.php" class="btn text-white btn-danger btn-sm">
                 <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>
                 <i class="fa fa-backward"></i> <?php echo $lang->I18N('Return'); ?>
             </a>
             </a>

+ 8 - 0
src/callback/.htaccess

@@ -0,0 +1,8 @@
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks -Multiviews
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
+</IfModule>

+ 19 - 17
src/callback/index.php

@@ -1,34 +1,36 @@
 <?php
 <?php
 
 
-header("X-Powered-By: UIISC");
-header("Server: UIISC");
-header("Content-Type: text/html; charset=UTF-8");
+require_once __DIR__ . '/../core/application.php';
+$path_array = explode('/', trim($path_info, '/'));
 
 
-if (!isset($_GET['token']) || empty($_GET['token'])) {
-    header("status: 401");
+if (!$path_array || count($path_array) < 2) {
     exit('401 Unauthorized');
     exit('401 Unauthorized');
 }
 }
 
 
-if (!isset($_GET['key']) || empty($_GET['key'])) {
+if (!isset($path_array[0]) || empty($path_array[0])) {
     header("status: 401");
     header("status: 401");
     exit('401 Unauthorized');
     exit('401 Unauthorized');
 }
 }
 
 
-require_once __DIR__ . '/../core/application.php';
+if (!isset($path_array[1]) || empty($path_array[1])) {
+    header("status: 401");
+    exit('401 Unauthorized');
+}
 
 
-$token = get('token');
-$key = get('key');
+$api_key = $path_array[0];
+$token = $path_array[1];
 
 
-$HostingApi = $DB->find('account_api', '*', array('api_key' => $key), null, 1);
+$AccountApi = $DB->find('account_api', '*', array('api_key' => $api_key), null, 1);
 
 
-if (!$HostingApi) {
-    header("status: 404");
-    exit('404 Not Found');
+if (!$AccountApi) {
+    exit('Not Found');
 }
 }
 
 
-if ($token != $HostingApi['api_callback_token']) {
-    header("status: 404");
-    exit('404 Not Found');
+if ($token != $AccountApi['api_callback_token']) {
+    exit('Unauthorized');
 }
 }
 
 
-require_once __DIR__ . '/' . $key . '/app.php';
+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';

+ 66 - 26
src/callback/myownfreehost/activate.php

@@ -12,49 +12,89 @@ if (!$username) {
     exit('need: 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) {
 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']));
     $ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id']));
     if ($ClientInfo) {
     if ($ClientInfo) {
+        $callback_log['callback_client_id'] = $AccountInfo['account_client_id'];
         $EmailTo = $ClientInfo['client_email'];
         $EmailTo = $ClientInfo['client_email'];
-        $EmailSubject = 'New Hosting Account';
-        $EmailToPeople = $ClientInfo['client_fname'];
+        $EmailToNickname = $ClientInfo['client_fname'];
     } else {
     } else {
         $EmailTo = $SiteConfig['site_email'];
         $EmailTo = $SiteConfig['site_email'];
-        $EmailToPeople = 'Administrator';
+        $EmailToNickname = 'Administrator';
     }
     }
     $EmailContent = '<p>You have successfully created a new hosting account the details are given bellow.</p>';
     $EmailContent = '<p>You have successfully created a new hosting account the details are given bellow.</p>';
 } else {
 } 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'];
     $EmailTo = $SiteConfig['site_email'];
-    $EmailToPeople = 'Administrator';
+    $EmailToNickname = 'Administrator';
     $EmailContent = '<p>Congratulations !</p><p>You have successfully received a new hosting account, the details are given bellow.</p>';
     $EmailContent = '<p>Congratulations !</p><p>You have successfully received a new hosting account, the details are given bellow.</p>';
 }
 }
 
 
+// 记录日志
+$DB->insert('account_callback', $callback_log);
+
 $EmailDescription = '
 $EmailDescription = '
-<b>cPanel Username: </b><span>' . $AccountInfo['account_username'] . '</span><br />
-<b>cPanel Password: </b><span>' . $AccountInfo['account_password'] . '</span><br />
-<b>cPanel URL     : </b><span>' . $HostingApi['api_cpanel_url'] . '</span><br /><br />
-<b>Main Domain    : </b><span>' . $AccountInfo['account_domain'] . '</span><br />
-<b>Account Date   : </b><span>' . $AccountInfo['account_date'] . '</span><br />
-<b>Server IP      : </b><span>' . $HostingApi['api_server_ip'] . '</span><br />
-<b>Hosting Package: </b><span>' . $HostingApi['api_package'] . '</span><br /><br />
-<b>FTP Username   : </b><span>' . $AccountInfo['account_username'] . '</span><br />
-<b>FTP Password   : </b><span>' . $AccountInfo['account_password'] . '</span><br />
-<b>FTP Hostname   : </b><span>ftpupload.net</span><br />
-<b>FTP Port       : </b><span>21</span><br /><br />
-<b>MySQL Username : </b><span>' . $AccountInfo['account_username'] . '</span><br />
-<b>MySQL Password : </b><span>' . $AccountInfo['account_password'] . '</span><br />
-<b>MySQL Hostname : </b><span>' . str_replace('cpanel', $AccountInfo['account_sql'], $HostingApi['api_cpanel_url']) . '</span><br />
-<b>MySQL Port     : </b><span>3306</span><br /><br />
-<b>Nameserver 1   : </b><span>' . $HostingApi['api_ns_1'] . '</span><br />
-<b>Nameserver 2   : </b><span>' . $HostingApi['api_ns_2'] . '</span>';
-$email_body = email_build_body('New Hosting Account', $EmailToPeople, $EmailContent, $EmailDescription);
+<p>Account domain    : ' . $AccountInfo['account_domain'] . '<br />
+Account date   : ' . $AccountInfo['account_date'] . '<br />
+Server IP      : ' . $AccountApi['api_server_ip'] . '<br />
+Hosting package: ' . $AccountApi['api_package'] . '<br /></p>
+<p>Control Panel username : ' . $AccountInfo['account_username'] . '<br />
+Control Panel password : ' . $AccountInfo['account_password'] . '<br />
+Control Panel URL      : ' . $AccountApi['api_cpanel_url'] . '<br /></p>
+
+<p>SQL hostname : ***.' . $AccountApi['api_server_sql_domain'] . '<br />
+SQL username : ' . $AccountInfo['account_username'] . '<br />
+SQL password : ' . $AccountInfo['account_password'] . '<br />
+SQL port : 3306</p>
+<p>FTP username   : ' . $AccountInfo['account_username'] . '<br />
+FTP password   : ' . $AccountInfo['account_password'] . '<br />
+FTP hostname   : ' . $AccountApi['api_server_ftp_domain'] . '<br />
+FTP port       : 21<br /></p>
+<p>Nameserver 1   : ' . $AccountApi['api_ns_1'] . '<br />
+Nameserver 2   : ' . $AccountApi['api_ns_2'] . '</p>';
+
+$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(
 send_mail(array(
     'to' => $EmailTo,
     'to' => $EmailTo,

+ 18 - 1
src/callback/myownfreehost/app.php

@@ -12,10 +12,27 @@ if (!isset($_POST['comments'])) {
 
 
 $status = post('status');
 $status = post('status');
 
 
-if (substr($status, 0, 3) == 'sql') {
+if ($status == 'ACTIVATED') {
+    // 帐户激活,新注册
     require_once __DIR__ . '/activate.php';
     require_once __DIR__ . '/activate.php';
 } elseif ($status == 'SUSPENDED') {
 } elseif ($status == 'SUSPENDED') {
+    // 帐户暂停
     require_once __DIR__ . '/suspend.php';
     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 {
 } else {
     exit('Access Denied');
     exit('Access Denied');
 }
 }

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

@@ -0,0 +1,86 @@
+<?php
+
+// require_once __DIR__ . '/../../core/application.php';
+
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
+
+$username = post('username');
+
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => date('Y-m-d H:i:s'),
+    'callback_username'  => $username,
+    'callback_action'    => $status,
+    'callback_comments'  => post('comments'),
+    'callback_client_id' => 0,
+    'callback_raw'       => json_encode(post())
+);
+
+// 账号信息
+$AccountInfo = $DB->find('account', '*', array('account_username' => $username));
+if ($AccountInfo) {
+    // 更新账号信息
+    $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 = '<p>Your hosting account has been reactivated, and you can continue to use it now.</p>';
+    } else {
+        $EmailTo = $SiteConfig['site_email'];
+        $EmailToNickname = 'Administrator';
+        $EmailContent = '<p>An Unassigned hosting account has been reactivated. The details are given bellow.</p>';
+    }
+} else {
+    // 账号不存在,入库
+    $AccountInfo = array(
+        'account_username' => $username,
+        'account_password' => '********',
+        'account_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
+        'account_api_key' => $api_key,
+        'account_domain' => '***.' . $AccountApi['api_server_domain'],
+        'account_status' => '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 = '<p>An Unassigned hosting account has been reactivated. The details are given bellow.</p>';
+}
+
+// 记录日志
+$DB->insert('account_callback', $callback_log);
+
+$EmailDescription = '<p>Hosting Account : ' . $AccountInfo['account_username'] . '</p>';
+
+$email_body = email_build_body('Hosting Account Status Changed', $EmailToNickname, $EmailContent, $EmailDescription);
+
+// print($email_body);
+
+$emails_log = array(
+    'email_client_id' => $AccountInfo['account_client_id'],
+    'email_date' => date('Y-m-d H:i:s'),
+    'email_to' => $EmailTo,
+    'email_subject' => 'Hosting Account Status Changed',
+    'email_body' => $email_body,
+    'email_read' => 0
+);
+// print_r($emails_log);
+$DB->insert('emails', $emails_log);
+
+send_mail(array(
+    'to' => $EmailTo,
+    'message' => $email_body,
+    'subject' => 'Hosting Account Status Changed'
+));

+ 87 - 0
src/callback/myownfreehost/sqlcluster.php

@@ -0,0 +1,87 @@
+<?php
+
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
+
+$username = post('username');
+
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => date('Y-m-d H:i:s'),
+    'callback_username'  => $username,
+    'callback_action'    => $status,
+    'callback_comments'  => post('comments'),
+    'callback_client_id' => 0,
+    'callback_raw'       => json_encode(post())
+);
+
+// 账号信息
+$AccountInfo = $DB->find('account', '*', array('account_username' => $username));
+if ($AccountInfo) {
+    // 账号存在
+    // 更新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 = '
+<p>MySQL Server Information:</p>
+hostname : ' . $status . '.' . $AccountApi['api_server_sql_domain'] . '<br />
+username : ' . $AccountInfo['account_username'] . '<br />
+password : ' . $AccountInfo['account_password'] . '<br />
+port : 3306';
+
+$EmailContent = '<p>Your SQL Cluster is now ready for deployment and use. The details are given bellow.</p>';
+$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'
+));

+ 84 - 0
src/callback/myownfreehost/subdomainadd.php

@@ -0,0 +1,84 @@
+<?php
+
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
+
+$username = post('username');
+
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => date('Y-m-d H:i:s'),
+    'callback_username'  => $username,
+    'callback_action'    => $status,
+    'callback_comments'  => post('comments'),
+    'callback_client_id' => 0,
+    'callback_raw'       => json_encode(post())
+);
+
+// 账号信息
+$AccountInfo = $DB->find('account', '*', array('account_username' => $username));
+if ($AccountInfo) {
+    // 禁用账号
+    // $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 = '<p>Your hosting account has successfully added a new sub domain. The details are given bellow.</p>';
+    } else {
+        $EmailTo = $SiteConfig['site_email'];
+        $EmailToNickname = 'Administrator';
+        $EmailContent = '<p>An unassigned hosting account has successfully added a new sub domain. The details are given bellow.</p>';
+    }
+} 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 = '<p>An unassigned hosting account has successfully added a new sub domain. The details are given bellow.</p>';
+}
+$EmailDescription = '<p><pre>' . $callback_log['callback_comments'] . '</pre></p>
+<p>The new sub domain is now available for use.</p>';
+
+// 记录日志
+$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'
+));

+ 84 - 0
src/callback/myownfreehost/subdomaindel.php

@@ -0,0 +1,84 @@
+<?php
+
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
+
+$username = post('username');
+
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => date('Y-m-d H:i:s'),
+    'callback_username'  => $username,
+    'callback_action'    => $status,
+    'callback_comments'  => post('comments'),
+    'callback_client_id' => 0,
+    'callback_raw'       => json_encode(post())
+);
+
+// 账号信息
+$AccountInfo = $DB->find('account', '*', array('account_username' => $username));
+if ($AccountInfo) {
+    // 禁用账号
+    // $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 = '<p>Your hosting account has successfully deleted a sub domain. The details are given bellow.</p>';
+    } else {
+        $EmailTo = $SiteConfig['site_email'];
+        $EmailToNickname = 'Administrator';
+        $EmailContent = '<p>An unassigned hosting account has successfully deleted a sub domain. The details are given bellow.</p>';
+    }
+} else {
+    // 账号不存在,入库
+    $AccountInfo = array(
+        'account_username' => $username,
+        'account_password' => '********',
+        'account_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
+        'account_api_key' => $api_key,
+        'account_domain' => '***.' . $AccountApi['api_server_domain'],
+        'account_status' => '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 = '<p>An unassigned hosting account has successfully deleted a sub domain. The details are given bellow.</p>';
+}
+$EmailDescription = '<p><pre>' . $callback_log['callback_comments'] . '</pre></p>
+<p>The sub domain is no longer usable.</p>';
+
+// 记录日志
+$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'
+));

+ 74 - 16
src/callback/myownfreehost/suspend.php

@@ -1,30 +1,88 @@
 <?php
 <?php
 
 
-require_once __DIR__ . '/../../core/application.php';
+if (!defined('IN_CRONLITE')) {
+    exit('Access Denied');
+}
 
 
 $username = post('username');
 $username = post('username');
 
 
+if (!$username) {
+    exit('need: username');
+}
+
+$callback_log = array(
+    'callback_date'      => date('Y-m-d H:i:s'),
+    'callback_username'  => $username,
+    'callback_action'    => $status,
+    'callback_comments'  => post('comments'),
+    'callback_client_id' => 0,
+    'callback_raw'       => json_encode(post())
+);
+
 // 账号信息
 // 账号信息
-$AccountInfo = $DB->find('account', '*', array('account_username' => $username, 'account_api_key' => $HostingApi['api_key']));
-if (!$AccountInfo) {
-    // 账号不存在
-    exit();
+$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 = '<p>Your hosting account has been suspended.</p>';
+        $EmailDescription = '<p>the hosting account ' . $username . ' has been Deactivated.</p>
+        <p>All files and database will be deleted within 30 days.</p>
+        <p>Please perform data backup and data migration as soon as possible !</p>
+        <p>If you have any questions, please contact the administrator.</p>';
+    } else {
+        $EmailTo = $SiteConfig['site_email'];
+        $EmailToNickname = 'Administrator';
+        $EmailContent = '<p>An unassigned hosting account has been suspended. The details are given bellow.</p>';
+        $EmailDescription = '<p>the hosting account ' . $username . ' has been Deactivated.</p><p>All files and database will be deleted within 30 days.</p>';
+    }
+} else {
+    // 账号不存在,入库
+    $AccountInfo = array(
+        'account_username' => $username,
+        'account_password' => '********',
+        'account_key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
+        'account_api_key' => $api_key,
+        'account_domain' => '***.' . $AccountApi['api_server_domain'],
+        'account_status' => '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 = '<p>An unassigned hosting account has been suspended. The details are given bellow.</p>';
+    $EmailDescription = '<p>the hosting account ' . $username . ' has been Deactivated.</p><p>All files and database will be deleted within 30 days.</p>';
 }
 }
 
 
-// 禁用账号
-$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'] . "'");
+// 记录日志
+$DB->insert('account_callback', $callback_log);
+
+$email_body = email_build_body('Hosting Account Status Changed', $EmailToNickname, $EmailContent, $EmailDescription);
 
 
-// 查找客户信息
-$ClientInfo = $DB->find('clients', 'client_email, client_fname', array('client_id' => $AccountInfo['account_client_id']));
+// print_r($email_body);
 
 
-$EmailContent = '<p>We had a good time with you while you were with us. </p>';
-$EmailDescription = '<p>Your account(' . $username . ') have been deactivate successfully and all files and database will be deleted within 30 days.</p><br>';
-$email_body = email_build_body('Hosting Account Deactivated', $ClientInfo['client_fname'], $EmailContent, $EmailDescription);
+$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(
 send_mail(array(
-    'to' => $ClientInfo['client_email'],
+    'to' => $EmailTo,
     'message' => $email_body,
     'message' => $email_body,
-    'subject' => 'Hosting Account Deactivated'
+    'subject' => 'Hosting Account Status Changed'
 ));
 ));

+ 45 - 32
src/clientarea/controllers/accounts/add.php

@@ -4,34 +4,41 @@ require_once __DIR__ . '/../../application.php';
 
 
 $PageInfo = ['title' => 'New Account', 'rel' => ''];
 $PageInfo = ['title' => 'New Account', 'rel' => ''];
 
 
-require_once ROOT . '/core/handler/HostingHandler.php';
 require_once ROOT . '/modules/autoload.php';
 require_once ROOT . '/modules/autoload.php';
 
 
-// require_once ROOT . '/core/library/userinfo.class.php';
-
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
 if (isset($_POST['submit'])) {
 if (isset($_POST['submit'])) {
+    $api_key = post('api_key');
+    if (empty($api_key)) {
+        send_response([500, '', 'api_key cannot be <b>empty</b> !']);
+    }
     $FormData = array(
     $FormData = array(
         'username' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
         'username' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
         'password' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 16),
         'password' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 16),
         'account_domain' => post('domain'),
         'account_domain' => post('domain'),
         'email' => $ClientInfo['client_email'],
         'email' => $ClientInfo['client_email'],
-        'plan' => post('package'),
+        // 'plan' => post('package'),
     );
     );
     if (empty($FormData['account_domain'])) {
     if (empty($FormData['account_domain'])) {
-        setMessage('Domain cannot be <b>empty</b> !', 'danger');
-        redirect('clientarea/accounts', '', array('action' => 'add'));
+        send_response([500, '', 'Domain cannot be <b>empty</b> !']);
     } else {
     } else {
         $AccountList = $DB->findAll('account', '*', array('account_client_id' => $ClientInfo['client_id']));
         $AccountList = $DB->findAll('account', '*', array('account_client_id' => $ClientInfo['client_id']));
         if (count($AccountList) < 3) {
         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(
             $request = $client->createAccount(array(
                 'username' => $FormData['username'],
                 'username' => $FormData['username'],
                 'password' => $FormData['password'],
                 'password' => $FormData['password'],
                 'domain' => $FormData['account_domain'],
                 'domain' => $FormData['account_domain'],
                 'email' => $FormData['email'],
                 'email' => $FormData['email'],
-                'plan' => $FormData['plan'],
+                'plan' => $AccountApiConfig['plan'],
             ));
             ));
             $response = $request->send();
             $response = $request->send();
             $Data = $response->getData();
             $Data = $response->getData();
@@ -39,17 +46,19 @@ if (isset($_POST['submit'])) {
                 'account_username' => $Data['result']['options']['vpusername'],
                 'account_username' => $Data['result']['options']['vpusername'],
                 'message' => $Data['result']['statusmsg'],
                 'message' => $Data['result']['statusmsg'],
                 'status' => $Data['result']['status'],
                 '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'),
                 'date' => date('Y-m-d H:i:s'),
             );
             );
             if ($Result['status'] == 0 && strlen($Result['message']) > 1) {
             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) {
             } elseif ($Result['status'] == 1 && strlen($Result['message']) > 1) {
                 $account_id = $DB->insert('account', array(
                 $account_id = $DB->insert('account', array(
                     'account_username' => $Result['account_username'],
                     'account_username' => $Result['account_username'],
                     'account_password' => $FormData['password'],
                     'account_password' => $FormData['password'],
                     'account_key' => $FormData['username'],
                     'account_key' => $FormData['username'],
+                    'account_api_key' => post('api_key'),
                     'account_domain' => $Result['account_domain'],
                     'account_domain' => $Result['account_domain'],
                     'account_status' => '1',
                     'account_status' => '1',
                     'account_date' => $Result['date'],
                     'account_date' => $Result['date'],
@@ -59,21 +68,20 @@ if (isset($_POST['submit'])) {
                 if ($account_id) {
                 if ($account_id) {
                     $EmailTo = $FormData['email'];
                     $EmailTo = $FormData['email'];
 
 
-                    $EmailContent = '
-<p>Congratulations !</p>
+                    $EmailContent = '<p>Congratulations !</p>
 <p>You have successfully created a new free hosting account, more details are given below:</p><br />';
 <p>You have successfully created a new free hosting account, more details are given below:</p><br />';
                     $EmailDescription = '
                     $EmailDescription = '
-<b>cPanel Username : </b><span>' . $Result['account_username'] . '</span><br />
-<b>cPanel Password : </b><span>' . $FormData['password'] . '</span><br />
+<b>Control Panel Username : </b><span>' . $Result['account_username'] . '</span><br />
+<b>Control Panel Password : </b><span>' . $FormData['password'] . '</span><br />
+<b>Control Panel URL      : </b><span>' . $AccountApi['api_cpanel_url'] . '</span><br />
 <b>Main Domain     : </b><span>' . $Result['account_domain'] . '</span><br />
 <b>Main Domain     : </b><span>' . $Result['account_domain'] . '</span><br />
 <b>Account Date    : </b><span>' . $Result['date'] . '</span><br />
 <b>Account Date    : </b><span>' . $Result['date'] . '</span><br />
-<b>cPanel URL      : </b><span>' . $HostingApi['api_cpanel_url'] . '</span><br />
-<b>Server IP       : </b><span>' . $HostingApi['api_server_ip'] . '</span><br />
-<b>Hosting Package : </b><span>' . $HostingApi['api_package'] . '</span><br />
-<b>FTP Hostname    : </b><span>ftpupload.net</span><br />
-<b>MySQL Hostname  : </b><span>' . str_replace('cpanel', 'sqlxxx', $HostingApi['api_cpanel_url']) . '</span><br />
-<b>Nameserver 1    : </b><span>' . $HostingApi['api_ns_1'] . '</span><br />
-<b>Nameserver 2    : </b><span>' . $HostingApi['api_ns_2'] . '</span>
+<b>Server IP       : </b><span>' . $AccountApi['api_server_ip'] . '</span><br />
+<b>Hosting Package : </b><span>' . $AccountApi['api_package'] . '</span><br />
+<b>FTP Hostname    : </b><span>' . $AccountApi['api_server_ftp_domain'] . '</span><br />
+<b>MySQL Hostname  : </b><span>' . $AccountApi['api_server_sql_domain'] . '</span><br />
+<b>Nameserver 1    : </b><span>' . $AccountApi['api_ns_1'] . '</span><br />
+<b>Nameserver 2    : </b><span>' . $AccountApi['api_ns_2'] . '</span>
 <br />
 <br />
 <p>Next, </p>
 <p>Next, </p>
 <br />';
 <br />';
@@ -85,25 +93,30 @@ if (isset($_POST['submit'])) {
                         'message' => $email_body,
                         'message' => $email_body,
                         'subject' => 'New Hosting Account'
                         'subject' => 'New Hosting Account'
                     ));
                     ));
-                    
-                    setMessage('Account created <b>successfully</b> !', 'success');
-                    redirect('clientarea/accounts', '', array('action' => 'view', 'account_id' => $account_id));
+                    send_response([500, '', 'Account created <b>successfully</b> !']);
                 } else {
                 } else {
-                    setMessage('Something went' . "'" . 's <b>wrong</b> !', 'danger');
-                    redirect('clientarea/accounts', '', array('action' => 'add'));
+                    send_response([500, '', 'Something went' . "'" . 's <b>wrong</b> !']);
                 }
                 }
             } elseif ($Result['status'] == 0 && $Result['message'] == 0) {
             } elseif ($Result['status'] == 0 && $Result['message'] == 0) {
-                setMessage('Something went' . "'" . 's <b>wrong</b> !', 'danger');
-                redirect('clientarea/accounts', '', array('action' => 'add'));
+                send_response([500, '', 'Something went' . "'" . 's <b>wrong</b> !']);
             }
             }
         } else {
         } else {
-            setMessage('Free account limit <b>reached</b> !', 'danger');
-            redirect('clientarea/accounts', '', array('action' => 'add'));
+            send_response([500, '', 'Free account limit <b>reached</b> !']);
         }
         }
     }
     }
 } else {
 } else {
+    $api_key = get('api_key');
+    if (empty($api_key)) {
+        setMessage('api_key cannot be <b>empty</b> !', 'danger');
+        redirect('clientarea/accounts');
+    }
     $ExtensionInfo = $DB->findAll('domain_extensions', '*', array(), 'extension_id');
     $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)) {
     if (empty($ExtensionInfo)) {
         $ExtensionInfo = array(
         $ExtensionInfo = array(
             'extension_value' => '.html-5.me',
             'extension_value' => '.html-5.me',

+ 10 - 2
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));
     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';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
-$client = Client::create($HostingApiConfig);
+$client = Client::create($AccountApiConfig);
 $request = $client->suspend(array(
 $request = $client->suspend(array(
     'username' => $AccountInfo['account_key'],
     'username' => $AccountInfo['account_key'],
     'reason' => $reason,
     'reason' => $reason,

+ 2 - 2
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));
     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);
 header("Location: " . $filemanager_url);

+ 1 - 1
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));
     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';
 $PageInfo['title'] = 'Login to Control Panel';

+ 10 - 2
src/clientarea/controllers/accounts/password.php

@@ -32,13 +32,21 @@ $FormData = array(
     'account_username' => $AccountInfo['account_username']
     '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';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
 if ($FormData['old_password'] == $AccountInfo['account_password']) {
 if ($FormData['old_password'] == $AccountInfo['account_password']) {
-    $client = Client::create($HostingApiConfig);
+    $client = Client::create($AccountApiConfig);
     $request = $client->password([
     $request = $client->password([
         'username' => $AccountInfo['account_key'],
         'username' => $AccountInfo['account_key'],
         'password' => $FormData['new_password'],
         'password' => $FormData['new_password'],

+ 11 - 3
src/clientarea/controllers/accounts/validate_domain.php

@@ -1,15 +1,23 @@
 <?php
 <?php
 
 
 require_once __DIR__ . '/../../application.php';
 require_once __DIR__ . '/../../application.php';
-
-require_once ROOT . '/core/handler/HostingHandler.php';
 require_once ROOT . '/modules/autoload.php';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
 if (isset($_POST['submit'])) {
 if (isset($_POST['submit'])) {
     $domain = post('domain');
     $domain = post('domain');
-    $client = Client::create($HostingApiConfig);
+
+    $AccountApi = $DB->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));
     $request = $client->availability(array('domain' => $domain));
     $response = $request->send();
     $response = $request->send();
     if ($response->isSuccessful() == 0 && strlen($response->getMessage()) > 1) {
     if ($response->isSuccessful() == 0 && strlen($response->getMessage()) > 1) {

+ 15 - 9
src/clientarea/controllers/accounts/view.php

@@ -19,33 +19,39 @@ if (empty($AccountInfo)) {
     redirect('clientarea/accounts');
     redirect('clientarea/accounts');
 }
 }
 
 
-// require_once ROOT . '/core/library/userinfo.class.php';
 // TODO: Change to an asynchronous request
 // TODO: Change to an asynchronous request
-require_once ROOT . '/core/handler/HostingHandler.php';
 require_once ROOT . '/modules/autoload.php';
 require_once ROOT . '/modules/autoload.php';
 
 
 use \InfinityFree\MofhClient\Client;
 use \InfinityFree\MofhClient\Client;
 
 
 $PageInfo['title'] = 'View Account (#' . $account_id . ')';
 $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) {
 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,
         'ftp_port' => 21,
-        'mysql_host' => str_replace('cpanel', 'sqlxxx', $HostingApi['api_cpanel_url']),
+        'mysql_host' => $AccountApi['api_server_sql_domain'],
         'mysql_port' => 3306,
         'mysql_port' => 3306,
     ));
     ));
 
 
-    $client = Client::create($HostingApiConfig);
+    $client = Client::create($AccountApiConfig);
     $request = $client->getUserDomains(array('username' => $AccountInfo['account_username']));
     $request = $client->getUserDomains(array('username' => $AccountInfo['account_username']));
     $response = $request->send();
     $response = $request->send();
     $DomainList = $response->getDomains();
     $DomainList = $response->getDomains();
 } else {
 } else {
     // inactive
     // inactive
     $DomainList = array();
     $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_username' => '-',
         'account_password' => '-',
         'account_password' => '-',
         'account_domain' => '-',
         'account_domain' => '-',

+ 0 - 1
src/clientarea/controllers/clients/profile.php

@@ -1,6 +1,5 @@
 <?php
 <?php
 
 
-require_once ROOT . '/core/library/userinfo.class.php';
 require_once ROOT . '/core/library/countries.php';
 require_once ROOT . '/core/library/countries.php';
 
 
 $CountryName = 'Not Defined';
 $CountryName = 'Not Defined';

+ 0 - 2
src/clientarea/controllers/myssl/add.php

@@ -1,5 +1,3 @@
 <?php
 <?php
 
 
-require_once ROOT . '/core/library/userinfo.class.php';
-
 // $PageInfo = ['title' => 'New SSL', 'rel' => ''];
 // $PageInfo = ['title' => 'New SSL', 'rel' => ''];

+ 0 - 2
src/clientarea/controllers/myssl/list.php

@@ -1,7 +1,5 @@
 <?php
 <?php
 
 
-require ROOT . '/core/library/userinfo.class.php';
-
 $count = $DB->count('ssl', array('ssl_client_id' => $ClientInfo['client_id']));
 $count = $DB->count('ssl', array('ssl_client_id' => $ClientInfo['client_id']));
 
 
 if ($count > 0) {
 if ($count > 0) {

+ 0 - 2
src/clientarea/controllers/tickets/list.php

@@ -2,8 +2,6 @@
 
 
 $PageInfo['title'] = $lang->I18N('My Tickets');
 $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']));
 $count = $DB->count('tickets', array('ticket_client_id' => $ClientInfo['client_id']));
 
 
 if ($count > 0) {
 if ($count > 0) {

+ 0 - 1
src/clientarea/settings.php

@@ -2,7 +2,6 @@
 
 
 require_once __DIR__ . '/application.php';
 require_once __DIR__ . '/application.php';
 
 
-require_once ROOT . '/core/library/userinfo.class.php';
 require_once ROOT . '/core/library/countries.php';
 require_once ROOT . '/core/library/countries.php';
 
 
 $PageInfo['title'] = $lang->I18N('Profile Settings');
 $PageInfo['title'] = $lang->I18N('Profile Settings');

+ 47 - 29
src/clientarea/views/accounts/add.php

@@ -44,8 +44,8 @@
                     <div class="alert alert-secondary my-5">
                     <div class="alert alert-secondary my-5">
                         <p>You need to set these nameservers in order to host your domain with us</p>
                         <p>You need to set these nameservers in order to host your domain with us</p>
                         <ul class="mb-0">
                         <ul class="mb-0">
-                            <li class="mb-0"><?php echo $HostingApi['api_ns_1'] ?></li>
-                            <li class="mb-0"><?php echo $HostingApi['api_ns_2'] ?></li>
+                            <li class="mb-0"><?php echo $AccountApi['api_ns_1'] ?></li>
+                            <li class="mb-0"><?php echo $AccountApi['api_ns_2'] ?></li>
                         </ul>
                         </ul>
                     </div>
                     </div>
                     <label class="form-label required">Custom Domain Name</label>
                     <label class="form-label required">Custom Domain Name</label>
@@ -76,39 +76,39 @@
         </div>
         </div>
         <hr>
         <hr>
         <div class="col-md-12 mb-15">
         <div class="col-md-12 mb-15">
-            <form action="controllers/accounts/add.php" method="post">
-                <div class="row">
-                    <div class="col-md-6">
-                        <div class="mb-10 px-10">
-                            <label class="form-label required">Hosting Package</label>
-                            <input type="text" name="package" value="<?php echo $HostingApi['api_package']; ?>" class="form-control disabled" readonly>
-                        </div>
+            <!-- <form action="controllers/accounts/add.php" method="post"> -->
+            <div class="row">
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">Hosting Package</label>
+                        <input type="text" name="package" value="<?php echo $AccountApi['api_package']; ?>" class="form-control disabled" readonly>
                     </div>
                     </div>
-                    <div class="col-md-6">
-                        <div class="mb-10 px-10">
-                            <label class="form-label required">Domain Name</label>
-                            <input type="text" name="domain" id="validomain" placeholder="Domain will show here..." class="form-control disabled" readonly required>
-                        </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">Domain Name</label>
+                        <input type="text" name="domain" id="validomain" placeholder="Domain will show here..." class="form-control disabled" readonly required>
                     </div>
                     </div>
-                    <div class="col-md-6">
-                        <div class="mb-10 px-10">
-                            <label class="form-label required">Username</label>
-                            <input type="text" name="username" placeholder="(generated automatically)" class="form-control disabled" readonly>
-                        </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label required">Username</label>
+                        <input type="text" name="username" placeholder="(generated automatically)" class="form-control disabled" readonly>
                     </div>
                     </div>
-                    <div class="col-md-6">
-                        <div class="mb-10 px-10">
-                            <label class="form-label">Password</label>
-                            <input type="password" name="password" placeholder="Something unique, leave empty to generate random" class="form-control">
-                        </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <label class="form-label">Password</label>
+                        <input type="password" name="password" placeholder="Something unique, leave empty to generate random" class="form-control">
                     </div>
                     </div>
-                    <div class="col-md-6">
-                        <div class="mb-10 px-10">
-                            <button class="btn btn-primary" name="submit">Request Account</button>
-                        </div>
+                </div>
+                <div class="col-md-6">
+                    <div class="mb-10 px-10">
+                        <button class="btn btn-primary" onclick="create_account()">Request Account</button>
                     </div>
                     </div>
                 </div>
                 </div>
-            </form>
+            </div>
+            <!-- </form> -->
         </div>
         </div>
     </div>
     </div>
 </div>
 </div>
@@ -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('<div class="alert alert-danger" role="alert"><button class="close" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+data+'</div>');
+            } else {
+                $('#hidden-area').html('<div class="alert alert-success" role="alert"><button class="close" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">&times;</span></button>Domain is available and selected  <b>successfully!</b></div>');
+                $('#validomain').val(data);
+            }
+        });
+    };
 </script>
 </script>

+ 1 - 1
src/clientarea/views/accounts/login.php

@@ -10,7 +10,7 @@
         <hr>
         <hr>
         <div class="mb-15">
         <div class="mb-15">
             <p>You will now be redirected to the control panel. It can take up to 5 seconds based on your internet connecion speed.</p>
             <p>You will now be redirected to the control panel. It can take up to 5 seconds based on your internet connecion speed.</p>
-            <form id="Login" action="https://<?php echo $HostingApi['api_cpanel_url']; ?>/login.php" method="post" name="login">
+            <form id="Login" action="https://<?php echo $AccountApi['api_cpanel_url']; ?>/login.php" method="post" name="login">
             <input type="hidden" name="uname" value="<?php echo $AccountInfo['account_username']; ?>">
             <input type="hidden" name="uname" value="<?php echo $AccountInfo['account_username']; ?>">
             <input type="hidden" name="passwd" value="<?php echo $AccountInfo['account_password']; ?>">
             <input type="hidden" name="passwd" value="<?php echo $AccountInfo['account_password']; ?>">
             <input type="hidden" name="language" value="<?php echo $lang->get_language_value(); ?>">
             <input type="hidden" name="language" value="<?php echo $lang->get_language_value(); ?>">

+ 4 - 4
src/clientarea/views/clients/profile.php

@@ -34,16 +34,16 @@
                 <h6 class="mb-0"><b>Postal Code:</b> <?php echo $ClientInfo['client_pcode'];?></h6>
                 <h6 class="mb-0"><b>Postal Code:</b> <?php echo $ClientInfo['client_pcode'];?></h6>
             </div>
             </div>
             <div class="col-md-6">
             <div class="col-md-6">
-                <h6 class="mb-0"><b><?php echo $lang->I18N('IP Address'); ?>:</b> <?php echo UserInfo::get_ip();?></h6>
+                <h6 class="mb-0"><b><?php echo $lang->I18N('IP Address'); ?>:</b> <?php echo get_client_ip();?></h6>
             </div>
             </div>
             <div class="col-md-6">
             <div class="col-md-6">
-                <h6 class="mb-0"><b>Device Type:</b> <?php echo UserInfo::get_device();?></h6>
+                <h6 class="mb-0"><b>Device Type:</b> <?php echo get_client_device();?></h6>
             </div>
             </div>
             <div class="col-md-6">
             <div class="col-md-6">
-                <h6 class="mb-0"><b>Device OS:</b> <?php echo UserInfo::get_os();?></h6>
+                <h6 class="mb-0"><b>Device OS:</b> <?php echo get_client_os();?></h6>
             </div>
             </div>
             <div class="col-md-6">
             <div class="col-md-6">
-                <h6 class="mb-0"><b>Web Browser:</b> <?php echo UserInfo::get_browser();?></h6>
+                <h6 class="mb-0"><b>Web Browser:</b> <?php echo get_client_browser();?></h6>
             </div>
             </div>
             <div class="col-md-12 pb-5">
             <div class="col-md-12 pb-5">
                 <a href="settings.php" class="btn m5t btn-sm btn-primary">Update Profile</a>
                 <a href="settings.php" class="btn m5t btn-sm btn-primary">Update Profile</a>

+ 1 - 1
src/clientarea/views/common/sidebar.php

@@ -37,7 +37,7 @@ $avatar_path = $ClientInfo['client_email'] ? md5($ClientInfo['client_email']) :
         </a>
         </a>
         <a href="tickets.php" class="sidebar-link sidebar-link-with-icon">
         <a href="tickets.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-ticket-alt" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-ticket-alt" aria-hidden="true"></i></span>
-            <?php echo $lang->I18N('Tickets'); ?>
+            <?php echo $lang->I18N('Tickets List'); ?>
         </a>
         </a>
         <a href="tools.php" class="sidebar-link sidebar-link-with-icon">
         <a href="tools.php" class="sidebar-link sidebar-link-with-icon">
             <span class="sidebar-icon bg-transparent"><i class="fa fa-tools" aria-hidden="true"></i></span>
             <span class="sidebar-icon bg-transparent"><i class="fa fa-tools" aria-hidden="true"></i></span>

+ 12 - 4
src/core/application.php

@@ -12,6 +12,7 @@ $start_time = explode(' ', microtime());
 $static_release = '1559728996134';
 $static_release = '1559728996134';
 
 
 header("X-Powered-By: UIISC");
 header("X-Powered-By: UIISC");
+header("Server: UIISC");
 header("Content-Type: text/html; charset=UTF-8");
 header("Content-Type: text/html; charset=UTF-8");
 
 
 date_default_timezone_set('Asia/Shanghai');
 date_default_timezone_set('Asia/Shanghai');
@@ -47,13 +48,20 @@ if (!function_exists('is_https')) {
 }
 }
 
 
 define('HTTP_PROTOCOL', is_https() ? 'https' : 'http');
 define('HTTP_PROTOCOL', is_https() ? 'https' : 'http');
-
 $site_domain = $_SERVER['HTTP_HOST'];
 $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;
 $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);
 define('SITEURL', $site_url);
 
 
 include_once ROOT . '/data/config.php';
 include_once ROOT . '/data/config.php';

+ 5 - 5
src/core/handler/HostingHandler.php

@@ -1,10 +1,10 @@
 <?php
 <?php
 
 
-$HostingApi = $DB->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/',
     // 'apiUrl' => 'https://panel.myownfreehost.net/xml-api/',
-    'plan' => $HostingApi['api_package'],
+    'plan' => $AccountApi['api_package'],
 );
 );

+ 4 - 0
src/core/language/en-US/language.php

@@ -72,7 +72,11 @@ return array(
     'managearea'          => 'Manage Area',
     'managearea'          => 'Manage Area',
     'delete'              => 'Delete',
     'delete'              => 'Delete',
     'details'             => 'Details',
     'details'             => 'Details',
+    'Clients'             => 'Clients',
+    'Clients List'        => 'Clients',
+    'News List'           => 'News',
     'Tickets'             => 'Tickets',
     'Tickets'             => 'Tickets',
+    'Tickets List'        => 'Tickets',
     'My Tickets'          => 'My Tickets',
     'My Tickets'          => 'My Tickets',
     'Tickets Details'     => 'Tickets Details',
     'Tickets Details'     => 'Tickets Details',
     'member'              => 'Member',
     'member'              => 'Member',

+ 7 - 1
src/core/language/zh-CN/language.php

@@ -4,6 +4,10 @@ return array(
     "solution"            => "方案",
     "solution"            => "方案",
     "news"                => "新闻",
     "news"                => "新闻",
     "News"                => "新闻",
     "News"                => "新闻",
+    'News List'           => '新闻管理',
+    'News Details'        => '新闻详情',
+    'News Add'            => '新闻添加',
+    'News Edit'           => '新闻编辑',
     "contact"             => "联系",
     "contact"             => "联系",
     "Contact Us"          => "联系我们",
     "Contact Us"          => "联系我们",
     "help"                => "帮助",
     "help"                => "帮助",
@@ -79,7 +83,8 @@ return array(
     'managearea'          => '管理中心',
     'managearea'          => '管理中心',
     'delete'              => '删除',
     'delete'              => '删除',
     'details'             => '详情',
     'details'             => '详情',
-    'Tickets'             => '工单管理',
+    'Tickets'             => '工单',
+    'Tickets List'        => '工单管理',
     'My Tickets'          => '我的工单',
     'My Tickets'          => '我的工单',
     'Tickets Details'     => '工单详情',
     'Tickets Details'     => '工单详情',
     'member'              => '客户',
     'member'              => '客户',
@@ -90,6 +95,7 @@ return array(
     'Return'              => '返回',
     'Return'              => '返回',
     'Save'                => '保存',
     'Save'                => '保存',
     'Clients'             => '客户',
     'Clients'             => '客户',
+    'Clients List'        => '客户管理',
     'Hosting Accounts'    => '托管帐户',
     'Hosting Accounts'    => '托管帐户',
     'System Settings'     => '系统配置',
     'System Settings'     => '系统配置',
     'Company Name'        => '公司名称',
     'Company Name'        => '公司名称',

+ 2 - 0
src/core/language/zh-TW/language.php

@@ -4,6 +4,7 @@ return array(
     'solution'            => '方案',
     'solution'            => '方案',
     'news'                => '新聞',
     'news'                => '新聞',
     'News'                => '新聞',
     'News'                => '新聞',
+    'News List'           => '新闻管理',
     'contact'             => '聯繫',
     'contact'             => '聯繫',
     'Contact Us'          => '聯繫我們',
     'Contact Us'          => '聯繫我們',
     'help'                => '幫助',
     'help'                => '幫助',
@@ -74,6 +75,7 @@ return array(
     'delete'              => '刪除',
     'delete'              => '刪除',
     'details'             => '詳情',
     'details'             => '詳情',
     'Tickets'             => '工單',
     'Tickets'             => '工單',
+    'Tickets List'        => '工單管理',
     'Tickets Details'     => '工單詳情',
     'Tickets Details'     => '工單詳情',
     'member'              => '客戶',
     'member'              => '客戶',
     'members'             => '客戶',
     'members'             => '客戶',

+ 168 - 3
src/core/library/functions.php

@@ -1,8 +1,154 @@
 <?php
 <?php
 
 
-function get_filemanager_url($api_cpanel_url, $account_username, $account_password, $domain = '')
+function get_client_ip()
+{
+    $ip = '';
+    if (getenv('HTTP_CLIENT_IP')) {
+        $ip = getenv('HTTP_CLIENT_IP');
+    } else if (getenv('HTTP_X_FORWARDED_FOR')) {
+        $ip = getenv('HTTP_X_FORWARDED_FOR');
+    } else if (getenv('HTTP_X_FORWARDED')) {
+        $ip = getenv('HTTP_X_FORWARDED');
+    } else if (getenv('HTTP_FORWARDED_FOR')) {
+        $ip = getenv('HTTP_FORWARDED_FOR');
+    } else if (getenv('HTTP_FORWARDED')) {
+        $ip = getenv('HTTP_FORWARDED');
+    } else if (getenv('REMOTE_ADDR')) {
+        $ip = getenv('REMOTE_ADDR');
+    } else {
+        $ip = 'UNKNOWN';
+    }
+
+    return $ip;
+}
+
+function get_client_os()
+{
+
+    $os_platform = "Unknown OS Platform";
+    $os_array = array(
+        '/windows nt 11/i' => '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(
     $params = base64_encode(
         json_encode(
         json_encode(
             array(
             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)
 function upload_image($image)
@@ -88,6 +234,25 @@ function post($field = '', $default = '')
     return $_POST[$field];
     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 = '')
 function dump($data = '')
 {
 {

+ 617 - 621
src/core/library/api.php → src/core/library/lib/MOFHAPI.php

@@ -1,621 +1,617 @@
-<?php
-if (!defined('IN_CRONLITE')) {
-    // exit('禁止访问');
-    header("Location: ../index.php");
-    exit;
-}
-
-/**
- * mofh-whm-api-client
- */
-class Api
-{
-
-    public $message = [];
-    public $domain;
-
-    protected $parameters;
-    protected $data;
-    protected $response;
-    protected $status;
-    protected $config = array(
-        "apiUsername" => "",
-        "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 <b>" . $data["username"] . "</b> 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 <b>" . $data["username"] . "</b> 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 <b>" . $data["user"] . "</b> is NOT currently suspended";
-                    } else {
-                        $msg = "The account <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been suspended successfully.<br/><i>- Remember that in 30 days the account will be completely removed from the server.</i>";
-            } 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 <b>" . $data["user"] . "</b> is NOT currently suspended";
-                    } else {
-                        // This account is NOT currently suspended (status : r ) .  .  
-                        $msg = "The account <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been activated successfully.<br/><i>Remember to wait 5 minutes while the server restarts to view the account.</i>"];
-                }
-            } 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 <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been changed successfully.<br/>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 <b>" . $data["user"] . "</b> 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 <b>" . $data["domain"] . "</b> is available to register."];
-        } elseif ((int)$this->response == 0) {
-            if (strlen((string)$this->response) == 1) {
-                $this->message = [0, "The domain <b>" . $data["domain"] . "</b> 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 <b>" . $data["username"] . "</b> 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 . ": <b>" . $value["status"] . "</b> - " . $value["domain"] . "<br/>";
-            }
-            $this->message = array(1, "The account <b>" . $data["username"] . "</b> has " . count($this->domain) . " domains.<br/>" . $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 <b>" . $this->getUserName() . "</b>." . $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;
-    }
-}
+<?php
+namespace lib;
+
+/**
+ * mofh-whm-api-client
+ */
+class MOFHAPI
+{
+
+    public $message = [];
+    public $domain;
+
+    protected $parameters;
+    protected $data;
+    protected $response;
+    protected $status;
+    protected $config = array(
+        "apiUsername" => "",
+        "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 <b>" . $data["username"] . "</b> 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 <b>" . $data["username"] . "</b> 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 <b>" . $data["user"] . "</b> is NOT currently suspended";
+                    } else {
+                        $msg = "The account <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been suspended successfully.<br/><i>- Remember that in 30 days the account will be completely removed from the server.</i>";
+            } 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 <b>" . $data["user"] . "</b> is NOT currently suspended";
+                    } else {
+                        // This account is NOT currently suspended (status : r ) .  .  
+                        $msg = "The account <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been activated successfully.<br/><i>Remember to wait 5 minutes while the server restarts to view the account.</i>"];
+                }
+            } 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 <b>" . $data["user"] . "</b> 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 <b>" . $data["user"] . "</b> has been changed successfully.<br/>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 <b>" . $data["user"] . "</b> 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 <b>" . $data["domain"] . "</b> is available to register."];
+        } elseif ((int)$this->response == 0) {
+            if (strlen((string)$this->response) == 1) {
+                $this->message = [0, "The domain <b>" . $data["domain"] . "</b> 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 <b>" . $data["username"] . "</b> 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 . ": <b>" . $value["status"] . "</b> - " . $value["domain"] . "<br/>";
+            }
+            $this->message = array(1, "The account <b>" . $data["username"] . "</b> has " . count($this->domain) . " domains.<br/>" . $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 <b>" . $this->getUserName() . "</b>." . $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;
+    }
+}

+ 0 - 160
src/core/library/userinfo.class.php

@@ -1,160 +0,0 @@
-<?php
-class UserInfo
-{
-    private static function get_user_agent()
-    {
-        return $_SERVER['HTTP_USER_AGENT'];
-    }
-
-    public static function get_ip()
-    {
-        $mainIp = '';
-        if (getenv('HTTP_CLIENT_IP')) {
-            $mainIp = getenv('HTTP_CLIENT_IP');
-        } else if (getenv('HTTP_X_FORWARDED_FOR')) {
-            $mainIp = getenv('HTTP_X_FORWARDED_FOR');
-        } else if (getenv('HTTP_X_FORWARDED')) {
-            $mainIp = getenv('HTTP_X_FORWARDED');
-        } else if (getenv('HTTP_FORWARDED_FOR')) {
-            $mainIp = getenv('HTTP_FORWARDED_FOR');
-        } else if (getenv('HTTP_FORWARDED')) {
-            $mainIp = getenv('HTTP_FORWARDED');
-        } else if (getenv('REMOTE_ADDR')) {
-            $mainIp = getenv('REMOTE_ADDR');
-        } else {
-            $mainIp = 'UNKNOWN';
-        }
-
-        return $mainIp;
-    }
-
-    public static function get_os()
-    {
-
-        $user_agent = self::get_user_agent();
-        $os_platform = "Unknown OS Platform";
-        $os_array = array(
-            '/windows nt 11/i' => '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';
-        }
-    }
-
-}

+ 48 - 32
src/install/function/Database.php

@@ -1,5 +1,5 @@
 <?php
 <?php
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_account` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account` (
   `account_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT "主机账号ID",
   `account_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT "主机账号ID",
   `account_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `account_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `account_key` VARCHAR(8) NOT NULL,
   `account_key` VARCHAR(8) NOT NULL,
@@ -13,22 +13,37 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_account` (
   PRIMARY KEY (`account_id`)
   PRIMARY KEY (`account_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_account_api` (
-  `api_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_api` (
+  `api_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `api_type` varchar(30) NOT NULL,
   `api_key` varchar(30) NOT NULL,
   `api_key` varchar(30) NOT NULL,
-  `api_username` VARCHAR(256) NOT NULL,
-  `api_password` VARCHAR(256) NOT NULL,
-  `api_cpanel_url` VARCHAR(100) NOT NULL,
-  `api_server_ip` VARCHAR(15) NOT NULL,
-  `api_ns_1` VARCHAR(30) NOT NULL,
-  `api_ns_2` VARCHAR(30) NOT NULL,
+  `api_username` varchar(256) NOT NULL,
+  `api_password` varchar(256) NOT NULL,
+  `api_cpanel_url` varchar(100) NOT NULL,
+  `api_server_ip` varchar(15) NOT NULL,
+  `api_server_domain` varchar(100) NOT NULL,
+  `api_server_ftp_domain` varchar(100) NOT NULL,
+  `api_server_sql_domain` varchar(100) NOT NULL,
+  `api_ns_1` varchar(30) NOT NULL,
+  `api_ns_2` varchar(30) NOT NULL,
   `api_ns_3` varchar(30) NOT NULL,
   `api_ns_3` varchar(30) NOT NULL,
-  `api_package` VARCHAR(20) NOT NULL,
+  `api_package` varchar(20) NOT NULL,
   `api_callback_token` varchar(32) NOT NULL,
   `api_callback_token` varchar(32) NOT NULL,
   PRIMARY KEY (`api_id`)
   PRIMARY KEY (`api_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_config` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_callback` (
+  `callback_id` int(11) NOT NULL AUTO_INCREMENT,
+  `callback_date` varchar(30) NOT NULL COMMENT "日期",
+  `callback_client_id` int(11) DEFAULT NULL COMMENT "所属客户ID",
+  `callback_username` varchar(22) NOT NULL COMMENT "主机账号用户名",
+  `callback_action` varchar(30) NOT NULL COMMENT "操作事件",
+  `callback_comments` varchar(500) DEFAULT NULL COMMENT "备注信息",
+  `callback_raw` text NOT NULL COMMENT "接收的完整数据",
+  PRIMARY KEY (`callback_id`)
+) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
+
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_config` (
   `site_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `site_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `site_key` varchar(20) NOT NULL,
   `site_key` varchar(20) NOT NULL,
   `site_status` int(2) NOT NULL,
   `site_status` int(2) NOT NULL,
@@ -47,7 +62,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_config` (
   PRIMARY KEY (`site_id`)
   PRIMARY KEY (`site_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_builder_api` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_builder_api` (
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `builder_id` VARCHAR(7) NOT NULL,
   `builder_id` VARCHAR(7) NOT NULL,
   `builder_username` VARCHAR(100) NOT NULL,
   `builder_username` VARCHAR(100) NOT NULL,
@@ -55,7 +70,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_builder_api`
   PRIMARY KEY (`id`)
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_clients` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_clients` (
   `client_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `client_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `client_fname` VARCHAR(30) NOT NULL,
   `client_fname` VARCHAR(30) NOT NULL,
   `client_lname` VARCHAR(30) NOT NULL,
   `client_lname` VARCHAR(30) NOT NULL,
@@ -74,13 +89,13 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_clients` (
   PRIMARY KEY (`client_id`)
   PRIMARY KEY (`client_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_domain_extensions` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_domain_extensions` (
   `extension_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `extension_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `extension_value` VARCHAR(70) NOT NULL,
   `extension_value` VARCHAR(70) NOT NULL,
   PRIMARY KEY (`extension_id`)
   PRIMARY KEY (`extension_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_smtp` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_smtp` (
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `smtp_key` VARCHAR(4) NOT NULL,
   `smtp_key` VARCHAR(4) NOT NULL,
   `smtp_host` VARCHAR(50) NOT NULL,
   `smtp_host` VARCHAR(50) NOT NULL,
@@ -91,14 +106,14 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_smtp` (
   PRIMARY KEY (`id`)
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_ssl` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_ssl` (
   `ssl_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `ssl_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `ssl_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `ssl_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `ssl_key` INT(12) NOT NULL,
   `ssl_key` INT(12) NOT NULL,
   PRIMARY KEY (`ssl_id`)
   PRIMARY KEY (`ssl_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_ssl_api` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_ssl_api` (
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
   `api_key` VARCHAR(7) NOT NULL,
   `api_key` VARCHAR(7) NOT NULL,
   `api_username` VARCHAR(256) NOT NULL,
   `api_username` VARCHAR(256) NOT NULL,
@@ -106,7 +121,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_ssl_api` (
   PRIMARY KEY (`id`)
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_tickets` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_tickets` (
   `ticket_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `ticket_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `ticket_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `ticket_client_id` INT(11) NOT NULL COMMENT "所属客户ID",
   `ticket_subject` VARCHAR(50) NOT NULL,
   `ticket_subject` VARCHAR(50) NOT NULL,
@@ -118,7 +133,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_tickets` (
   PRIMARY KEY (`ticket_id`)
   PRIMARY KEY (`ticket_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_ticket_replies` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_ticket_replies` (
   `reply_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `reply_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `reply_for` INT(11) NOT NULL,
   `reply_for` INT(11) NOT NULL,
   `reply_from` VARCHAR(8) NOT NULL,
   `reply_from` VARCHAR(8) NOT NULL,
@@ -127,7 +142,7 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_ticket_replie
   PRIMARY KEY (`reply_id`)
   PRIMARY KEY (`reply_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_admin` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_admin` (
   `admin_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `admin_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `admin_fname` VARCHAR(30) NOT NULL,
   `admin_fname` VARCHAR(30) NOT NULL,
   `admin_lname` VARCHAR(30) NOT NULL,
   `admin_lname` VARCHAR(30) NOT NULL,
@@ -137,11 +152,11 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_admin` (
   PRIMARY KEY (`admin_id`)
   PRIMARY KEY (`admin_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, "INSERT INTO `hosting_account_api`(`api_key`, `api_username`, `api_password`, `api_cpanel_url`, `api_server_ip`, `api_ns_1`, `api_ns_2`, `api_package`) VALUES ('myownfreehost','MOFH API Username','MOFH API Password','cpanel.example.com','185.27.134.46','ns1.byet.org','ns2.byet.org','freehosting')");
+$sql = mysqli_query($connect, "INSERT INTO `uiisc_account_api`(`api_key`, `api_username`, `api_password`, `api_cpanel_url`, `api_server_ip`, `api_ns_1`, `api_ns_2`, `api_package`) VALUES ('myownfreehost','MOFH API Username','MOFH API Password','cpanel.example.com','185.27.134.46','ns1.byet.org','ns2.byet.org','freehosting')");
 
 
-$sql = mysqli_query($connect, "INSERT INTO `hosting_smtp`(`smtp_key`, `smtp_host`, `smtp_username`, `smtp_password`, `smtp_port`, `smtp_from`) VALUES ('SMTP','smtp.gmail.com','example@gmail.com','example123','587','example@gmail.com')");
+$sql = mysqli_query($connect, "INSERT INTO `uiisc_smtp`(`smtp_key`, `smtp_host`, `smtp_username`, `smtp_password`, `smtp_port`, `smtp_from`) VALUES ('SMTP','smtp.gmail.com','example@gmail.com','example123','587','example@gmail.com')");
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_knowledgebase` (
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_knowledgebase` (
   `knowledgebase_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `knowledgebase_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
   `knowledgebase_subject` VARCHAR(200) NOT NULL,
   `knowledgebase_subject` VARCHAR(200) NOT NULL,
   `knowledgebase_content` VARCHAR(10000) NOT NULL,
   `knowledgebase_content` VARCHAR(10000) NOT NULL,
@@ -149,13 +164,13 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_knowledgebase
   PRIMARY KEY (`knowledgebase_id`)
   PRIMARY KEY (`knowledgebase_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, "INSERT INTO `hosting_ssl_api`(`api_key`, `api_username`, `api_password`) VALUES ('FREESSL','example@gmail.com','SSL API Password')");
+$sql = mysqli_query($connect, "INSERT INTO `uiisc_ssl_api`(`api_key`, `api_username`, `api_password`) VALUES ('FREESSL','example@gmail.com','SSL API Password')");
 
 
-$sql = mysqli_query($connect, "INSERT INTO `hosting_builder_api`(`builder_id`, `builder_username`, `builder_password`) VALUES ('SITEPRO','apikey0','API Password')");
+$sql = mysqli_query($connect, "INSERT INTO `uiisc_builder_api`(`builder_id`, `builder_username`, `builder_password`) VALUES ('SITEPRO','apikey0','API Password')");
 
 
-$sql = mysqli_query($connect, "INSERT INTO `hosting_domain_extensions`(`extension_value`) VALUES ('.example.com')");
+$sql = mysqli_query($connect, "INSERT INTO `uiisc_domain_extensions`(`extension_value`) VALUES ('.example.com')");
 
 
-$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_news`(
+$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_news`(
   `news_id` INT(11) NOT NULL AUTO_INCREMENT,
   `news_id` INT(11) NOT NULL AUTO_INCREMENT,
   `news_subject` VARCHAR(255) NOT NULL,
   `news_subject` VARCHAR(255) NOT NULL,
   `news_content` VARCHAR(5000) NOT NULL,
   `news_content` VARCHAR(5000) NOT NULL,
@@ -165,12 +180,13 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `hosting_news`(
   PRIMARY KEY(`news_id`)
   PRIMARY KEY(`news_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
 
 
-$sql = mysqli_query($connect, "CREATE TABLE IF NOT EXISTS `hosting_emails`(
+$sql = mysqli_query($connect, "CREATE TABLE IF NOT EXISTS `uiisc_emails`(
   `email_id` INT(11) NOT NULL AUTO_INCREMENT,
   `email_id` INT(11) NOT NULL AUTO_INCREMENT,
   `email_client_id` INT(11) NOT NULL COMMENT '所属客户ID',
   `email_client_id` INT(11) NOT NULL COMMENT '所属客户ID',
-  `email_date` VARCHAR(255) NOT NULL,
-  `email_subject` VARCHAR(255) NOT NULL,
-  `email_body` VARCHAR(5000) NOT NULL,
-  `email_read` INT(1) NOT NULL DEFAULT '0',
+  `email_date` VARCHAR(255) NOT NULL COMMENT '邮件发送日期',
+  `email_to` VARCHAR(255) NOT NULL COMMENT '邮件接收人',
+  `email_subject` VARCHAR(255) NOT NULL COMMENT '邮件主题',
+  `email_body` TEXT NOT NULL COMMENT '邮件内容',
+  `email_read` INT(1) NOT NULL DEFAULT '0' COMMENT '站内消息是否阅读',
   PRIMARY KEY(`email_id`)
   PRIMARY KEY(`email_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;");
 ) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;");

+ 1 - 1
src/install/function/Step1.php

@@ -14,7 +14,7 @@ $FormData = array(
     'site_email' => $_POST['site_email'],
     'site_email' => $_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
 VALUES
 ('UIISC','" . $FormData['site_name'] . "','" . $FormData['site_brand'] . "','" . $FormData['site_company'] . "','" . $FormData['site_path'] . "','" . $FormData['site_email'] . "','1')"
 ('UIISC','" . $FormData['site_name'] . "','" . $FormData['site_brand'] . "','" . $FormData['site_company'] . "','" . $FormData['site_path'] . "','" . $FormData['site_email'] . "','1')"
 );
 );

+ 1 - 1
src/install/function/Step2.php

@@ -14,7 +14,7 @@ $FormData = array(
     'key' => substr(str_shuffle('qwertyuioplkjhgfdsazxcvbnm012345789QWERTYUIOPLKJHGFDSAZXCVBNM'), 0, 8),
     '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'] . "')");
 ('" . $FormData['fname'] . "', '" . $FormData['lname'] . "', '" . $FormData['email'] . "','" . $FormData['key'] . "', '" . $FormData['password'] . "')");
 
 
 if ($sql) {
 if ($sql) {

+ 1 - 1
src/install/function/configuration.php

@@ -11,7 +11,7 @@ $username = $_POST['username'];
 $password = $_POST['password'];
 $password = $_POST['password'];
 $dbname = $_POST['dbname'];
 $dbname = $_POST['dbname'];
 $dbport = !empty($_POST['dbport']) ? $_POST['dbport'] : 3306;
 $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, "<?php
 @file_put_contents(CONFIG_FILE, "<?php
 \$dbconfig = array(
 \$dbconfig = array(