소스 검색

Added Management Module

doudoudzj 6 년 전
부모
커밋
a00ca50ac9
13개의 변경된 파일1402개의 추가작업 그리고 0개의 파일을 삭제
  1. 224 0
      admin.php
  2. 32 0
      assets/css/admin.css
  3. 276 0
      controllers/admin.php
  4. 23 0
      data/config.php
  5. 0 0
      data/installed
  6. 23 0
      data/member.php
  7. 66 0
      include/admin_footer.php
  8. 76 0
      include/admin_header.php
  9. 40 0
      include/captcha.php
  10. 21 0
      include/common.php
  11. BIN
      include/fonts/elephant.ttf
  12. 0 0
      install.php
  13. 621 0
      lib/api.php

+ 224 - 0
admin.php

@@ -0,0 +1,224 @@
+<?php
+// ini_set("display_errors", false);
+
+define("IN_SYS", true);
+require_once("core.php");
+
+// $INDEX = __FILE__;
+$ROOT = __DIR__;
+
+include_once "{$ROOT}/data/config.php";
+include_once "{$ROOT}/include/common.php";
+include_once "{$ROOT}/lib/api.php";
+include_once "{$ROOT}/controllers/admin.php";
+getVersion();
+
+if (!file_exists("{$ROOT}/data/installed") || !isset($config) || $config['apiUsername'] == '#getUsername#' || $config['apiPassword'] == '#getPassword#') {
+    header('Location: ./install.php');
+}
+
+?>
+
+<?php include("include/admin_header.php"); ?>
+
+<?php if (file_exists("{$ROOT}/install.php")) { ?>
+    <div class="container">
+        <div class="alert alert-dismissible alert-danger">Please delete the <b>install.php</b> file.</div>
+    </div>
+<?php } ?>
+
+<div class="container">
+    <?php if ($is_admin) { ?>
+        <div class="row">
+            <div class="col-md-12">
+                <a class="btn btn-default" href="admin.php?s=check_domain" role="button">Check Domain</a>
+                <a class="btn btn-default" href="admin.php?s=account_list" role="button">List</a>
+                <a class="btn btn-default" href="admin.php?s=account_add" role="button">Add</a>
+                <a class="btn btn-default" href="admin.php?s=account_password" role="button">Password</a>
+                <a class="btn btn-default" href="admin.php?s=account_disable" role="button">Suspend</a>
+                <a class="btn btn-default" href="admin.php?s=account_active" role="button">Activate</a>
+                <a class="btn btn-default" href="admin.php?s=account_status" role="button">Status</a>
+                <a class="btn btn-default" href="admin.php?s=account_domain" role="button">Domains</a>
+            </div>
+        </div>
+    <?php } ?>
+    <div class="row">
+        <div class="col-md-12 col-sm-12">
+            <?php if ($section == 'main') { ?>
+                <h1>Hosting Account Management System</h1>
+                <p class="lead">This is a simple script for WHM myownfreehost made to manage hosting accounts through the api assigned to users with free reseller accounts.</p>
+                <b>Available Functions:</b>
+                <ol>
+                    <li>Verify if a domain is available.</li>
+                    <li>Creation of account hosting from the panel.</li>
+                    <li>Change password to hosting account.</li>
+                    <li>Deactivate or disable a hosting account.</li>
+                    <li>Activate or enable hosting account.</li>
+                    <li>Verify how many domain and state of the hosting account.</li>
+                </ol>
+            <?php } else { ?>
+                <h2><?php echo $section_title; ?></h2>
+                <?php if ($section == 'check_domain') { ?>
+                    <form action="" method="POST">
+                        <p>Verify the domain is available for registration</p>
+                        <label>
+                            <!-- <span>Account:</span> -->
+                            <input type="text" name="domain" class="form-control" maxlength="50" placeholder="Enter a domain or sub-domain">
+                        </label>
+                        <button type="submit" name="do_check_domain" class="btn btn-primary">Verify domain</button>
+                    </form>
+                <?php } elseif ($section == 'account_list') {; ?>
+                    <div class="table-responsive">
+                        <table class="table table-bordered table-hover">
+                            <thead>
+                                <tr>
+                                    <th>#</th>
+                                    <th>Branch</th>
+                                    <th>Account</th>
+                                    <th>Username</th>
+                                    <th>Email</th>
+                                    <th>Domain</th>
+                                    <th>Plan</th>
+                                    <th>Password</th>
+                                    <th>Nameserver</th>
+                                    <th>Operate</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                <?php foreach ($member as $key => $value) { ?>
+                                    <tr>
+                                        <th><?php echo $key + 1; ?></th>
+                                        <td><?php echo $value["branch"]; ?></td>
+                                        <td><?php echo $value["account"]; ?></td>
+                                        <td><?php echo $value["username"]; ?></td>
+                                        <td><?php echo $value["email"]; ?></td>
+                                        <td><?php echo implode(",", $value["domain"]); ?></td>
+                                        <td><?php echo $value["plan"]; ?></td>
+                                        <td><?php echo $value["password"]; ?></td>
+                                        <td><?php echo implode(",", $value["nameserver"]); ?></td>
+                                        <td style="width: 206px;">
+                                            <a class="btn btn-default btn-xs" href="#" role="button">Login</a>
+                                            <button class="btn btn-default btn-xs" type="submit">View</button>
+                                            <button class="btn btn-default btn-xs" type="submit">Active</button>
+                                            <button class="btn btn-default btn-xs" type="submit">Disable</button>
+                                        </td>
+                                    </tr>
+                                <?php } ?>
+                            </tbody>
+                        </table>
+                    </div>
+                <?php } elseif ($section == 'account_add') {; ?>
+                    <form action="" method="POST">
+                        <label>
+                            <span>Account:</span>
+                            <input type="text" name="username" value="" class="form-control" maxlength="8" placeholder="Account of 8 characters">
+                        </label>
+                        <label>
+                            <span>Password:</span>
+                            <input type="password" name="password" value="" class="form-control" maxlength="35" placeholder="Password">
+                        </label>
+                        <label>
+                            <span>Domain or Sub-domain:</span>
+                            <input type="text" name="domain" value="" class="form-control" maxlength="35" placeholder="example.com">
+                        </label>
+                        <label>
+                            <span>Email Address:</span>
+                            <input type="text" name="email" value="" class="form-control" maxlength="35" placeholder="email@example.com">
+                        </label>
+                        <label>
+                            <span>Select a Hosting Plan:</span>
+                            <select name="plan" class="form-control">
+                                <?php foreach ($config['plan'] as $key => $value) { ?>
+                                    <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
+                                <?php } ?>
+                            </select>
+                        </label>
+                        <button type="submit" name="do_reg_account" class="btn btn-primary">Register Account</button>
+                    </form>
+                <?php } elseif ($section == 'account_password') {; ?>
+                    <form action="" method="POST">
+                        <!-- Reset Password -->
+                        <label>
+                            <span>Account: <small>(It is the 8 characters)</small></span>
+                            <input type="text" name="username" class="form-control" maxlength="8" placeholder="Account: (It is the 8 characters)">
+                        </label>
+                        <label>
+                            <span>New Password:</span>
+                            <input type="password" name="password" class="form-control" maxlength="35" placeholder="Password">
+                        </label>
+                        <button type="submit" name="do_set_password" class="btn btn-primary">Set Password</button>
+                    </form>
+                <?php } elseif ($section == 'account_disable') {; ?>
+                    <form action="" method="POST">
+                        <label>
+                            <span>Account: <small>(It is the 8 characters)</small></span>
+                            <input type="text" name="username" class="form-control" maxlength="8" placeholder="Account: (It is the 8 characters)">
+                        </label>
+                        <label>
+                            <span>Reason for deactivation:</span>
+                            <input type="text" name="reason" class="form-control" maxlength="60" placeholder="Reason or some message">
+                        </label>
+                        <button type="submit" name="do_disable_account" class="btn btn-primary">Save Settings</button>
+                    </form>
+                <?php } elseif ($section == 'account_active') {; ?>
+                    <form action="" method="POST">
+                        <label>
+                            <span>Account: <small>(It is the 8 characters)</small></span>
+                            <input type="text" name="username" class="form-control" maxlength="8" placeholder="Account: (It is the 8 characters)">
+                        </label>
+                        <button type="submit" name="do_activate_account" class="btn btn-primary">Save Settings</button>
+                    </form>
+                <?php } elseif ($section == 'account_status') {; ?>
+                    <form action="" method="POST">
+                        <label>
+                            <span>VistaPanel Username: <small>(Example: uii_12345678)</small></span>
+                            <input type="text" name="username" class="form-control" maxlength="18" placeholder="VPanel Username (Example: uii_12345678)">
+                        </label>
+                        <button type="submit" name="do_check_status" class="btn btn-primary">Check Status</button>
+                    </form>
+                <?php } elseif ($section == 'account_domain') {; ?>
+                    <form action="" method="POST">
+                        <label>
+                            <span>VistaPanel Username: <small>(Example: uii_12345678)</small></span>
+                            <input type="text" name="username" class="form-control" maxlength="18" placeholder="VPanel Username (Example: uii_12345678)">
+                        </label>
+                        <button type="submit" name="do_get_domains" class="btn btn-primary">View Domain</button>
+                    </form>
+                <?php } elseif ($section == 'login') {; ?>
+                    <?php if (!$is_admin) { ?>
+                        <form action="" method="POST" class="form-horizontal">
+                            <label>
+                                <span>Admin:</span>
+                                <input type="text" name="username" class="form-control" maxlength="18" placeholder="Admin Username" autofocus>
+                            </label>
+                            <label>
+                                <span>Password:</span>
+                                <input type="password" name="password" class="form-control" maxlength="35" placeholder="Admin Password">
+                            </label>
+                            <label>
+                                <span>Captcha:</span>
+                                <input type="text" name="captcha" class="form-control" maxlength="18" placeholder="CAPTCHA" autocomplete="off">
+                            </label>
+                            <button type="submit" name="do_login" class="btn btn-primary">Login</button>
+                        </form>
+                    <?php } elseif ($is_admin && !isset($message[0])) { ?>
+                        <div class="alert alert-success">已经登录</div>
+                    <?php } ?>
+                <?php }
+            if ($message) { ?>
+                    <hr/>
+                    <div class="alert <?php echo empty($message[0]) ? 'alert-danger' : 'alert-success'; ?>">
+                        <p><?php echo $message[1]; ?></p>
+                        <?php if (isset($message[2]) && ($message[2])) {
+                            echo "<p>response data:</p><pre>";
+                            print_r($message[2]);
+                            echo "</pre>";
+                        } ?>
+                    </div>
+                <?php }
+        } ?>
+        </div>
+    </div>
+</div>
+
+<?php include("include/admin_footer.php"); ?>

+ 32 - 0
assets/css/admin.css

@@ -0,0 +1,32 @@
+
+#section {
+    float: right;
+    display: block;
+    font-size: 14px;
+    margin: 8px 0;
+    color: #FFFFFF;
+}
+
+.clear {
+    clear: both;
+    width: 100%;
+}
+
+label {
+    display: block;
+    margin-bottom: 8px;
+    font-weight: bold;
+}
+
+label input,
+label select {
+    margin-top: 6px;
+}
+
+input[name="captcha"] {
+    background: url(/include/captcha.php) no-repeat;
+    background-size: 160px 30px;
+    background-position-x: right;
+    background-position-y: center;
+    padding-right: 170px;
+}

+ 276 - 0
controllers/admin.php

@@ -0,0 +1,276 @@
+<?php
+
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../admin.php");
+    exit;
+}
+$session_name = session_name();
+if (!isset($_COOKIE[$session_name])) {
+    foreach ($_COOKIE as $key => $val) {
+        $key = strtoupper($key);
+        if (strpos($key, $session_name)) {
+            session_id($_COOKIE[$key]);
+        }
+    }
+}
+session_start();
+
+$is_admin = isset($_SESSION["is_login"]) && $_SESSION["is_login"] == true;
+$section = !$is_admin ? "login" : (empty($_GET["s"]) ? "main" : $_GET["s"]);
+
+// print(session_id());
+// echo $_COOKIE["session_id"];
+// print($_COOKIE(["session_id"]));
+// print($is_admin);
+
+$message = [];
+$section_title = "Main";
+
+switch ($section) {
+    case "main":
+        $section_title = "Main";
+        break;
+    case "check_domain":
+        $section_title = "Check domain";
+        if (isset($_POST["do_check_domain"])) {
+            $tsData = array(
+                "domain" => setProtect(strtolower($_POST["domain"])),
+            );
+            if (!isset($tsData["domain"]) || empty($tsData["domain"])) {
+                $message = [0, "The domain is required."];
+            } elseif (strlen($tsData["domain"]) < 4) {
+                $message = [0, "Enter a domain name or sub-domain."];
+            } elseif (strlen($tsData["domain"]) > 50) {
+                $message = [0, "The domain can not exceed 50 characters."];
+            } elseif (!mb_ereg("^([a-zA-Z0-9]+).([a-zA-Z0-9-]+).([a-zA-Z]{2,4})$", $tsData["domain"])) {
+                $message = [0, "The domain does not have a valid extension. Check it."];
+            } elseif (preg_match("/(^.*)\.(tk)$/i", $tsData["domain"])) {
+                // To not allow domains.tk
+                $message = [0, "The domain extension is not allowed on this server."];
+            } else {
+                $client = Api::init($config);
+                $client->availability(["domain" => $tsData["domain"]]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_add":
+        $section_title = "Account Add";
+        if (isset($_POST["do_reg_account"])) {
+            $tsData = [
+                "username" => setProtect(strtolower($_POST["username"])),
+                "password" => setProtect($_POST["password"]),
+                "domain" => setProtect(strtolower($_POST["domain"])),
+                "email" => setProtect(strtolower($_POST["email"])),
+                "plan" => setProtect($_POST["plan"]),
+            ];
+
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The Username is required"];
+            } elseif (strlen($tsData["username"]) < 8 || strlen($tsData["username"]) > 12) {
+                $message = [0, "The username must be 8 characters."];
+            } elseif (!preg_match("/^[a-zA-Z0-9]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The username does not allow strange characters."];
+            } elseif (strlen($tsData["password"]) < 6 || strlen($tsData["password"]) > 35) {
+                $message = [0, "Enter a minimum password of 6 to 35 characters."];
+            } elseif (strlen($tsData["domain"]) < 4) {
+                $message = [0, "Enter a domain name or sub-domain."];
+            } elseif (strlen($tsData["domain"]) > 35) {
+                $message = [0, "The domain can not exceed 35 characters."];
+            } elseif (!mb_ereg("^([a-zA-Z0-9]+).([a-zA-Z0-9-]+).([a-zA-Z]{2,4})$", $tsData["domain"])) {
+                $message = [0, "The domain does not have a valid extension. Check it."];
+            } elseif (preg_match("/(^.*)\.(tk)$/i", $tsData["domain"])) {
+                // To not allow domains.tk
+                $message = [0, "Domain extension is not allowed on this server."];
+            } elseif (!mb_ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $tsData["email"])) {
+                $message = [0, "The email does not have a valid format, check it."];
+            } elseif (strlen($tsData["email"]) > 35) {
+                $message = [0, "The email can not exceed 35 characters."];
+            } elseif (empty($tsData["plan"])) {
+                $message = [0, "You must select a hosting plan."];
+            } else {
+                $client = Api::init($config);
+                $client->createAccount([
+                    "username" => $tsData["username"], // A unique, 8 character identifier of the account.
+                    "password" => $tsData["password"], // A password to login to the control panel, FTP MySQL and cPanel.
+                    "domain" => $tsData["domain"], // Can be a subdomain or a custom domain.
+                    "email" => $tsData["email"], // The email address of the user.
+                    "plan" => $tsData["plan"], // A hosting plan for the account.
+                ]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_password":
+        $section_title = "Account Password";
+        if (isset($_POST["do_set_password"])) {
+            $tsData = array(
+                "username" => setProtect(strtolower($_POST["username"])),
+                "password" => setProtect($_POST["password"]),
+            );
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The username is required"];
+            } elseif (strlen($tsData["username"]) < 4 || strlen($tsData["username"]) > 8) {
+                $message = [0, "The username must be 8 characters."];
+            } elseif (!preg_match("/^[a-zA-Z0-9]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The username does not allow strange characters."];
+            } elseif (strlen($tsData["password"]) < 6 || strlen($tsData["password"]) > 35) {
+                $message = [0, "Enter a minimum password of 6 to 35 characters."];
+            } else {
+                $client = Api::init($config);
+                $client->password([
+                    "username" => $tsData["username"],
+                    "password" => $tsData["password"],
+                    "enabledigest" => 1, // [enabledigest] Change the password in cPanel - FTP - MySQL
+                ]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_disable":
+        $section_title = "Account Suspend";
+        if (isset($_POST["do_disable_account"])) {
+            $tsData = array(
+                "username" => setProtect(strtolower($_POST["username"])),
+                "reason" => setProtect($_POST["reason"]),
+            );
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The username is required."];
+            } elseif (strlen($tsData["username"]) < 4 || strlen($tsData["username"]) > 8) {
+                $message = [0, "The Username must be 8 characters"];
+            } elseif (!preg_match("/^[a-zA-Z0-9]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The Username does not allow strange characters"];
+            } elseif (strlen($tsData["reason"]) < 10 || strlen($tsData["reason"]) > 60) {
+                $message = [0, "You must enter a reason with a maximum of 60 characters"];
+            } else {
+                $client = Api::init($config);
+                $client->suspend([
+                    "username" => setProtect(strtolower($tsData["username"])),
+                    "reason" => setProtect($tsData["reason"]),
+                ]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_active":
+        $section_title = "Account Activate";
+        if (isset($_POST["do_activate_account"])) {
+            $tsData = array(
+                "username" => setProtect(strtolower($_POST["username"])),
+            );
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The username is required."];
+            } elseif (strlen($tsData["username"]) < 4 || strlen($tsData["username"]) > 8) {
+                $message = [0, "The username is invalid (8 characters maximum)."];
+            } elseif (!preg_match("/^[a-zA-Z0-9]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The username does not allow strange characters.."];
+            } else {
+                $client = Api::init($config);
+                $client->unsuspend(["username" => setProtect(strtolower($tsData["username"]))]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_status":
+        $section_title = "Account Status";
+        if (isset($_POST["do_check_status"])) {
+            $tsData = array(
+                "username" => setProtect(strtolower($_POST["username"])),
+            );
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The username is required."];
+            } elseif (strlen($tsData["username"]) < 4 || strlen($tsData["username"]) > 18) {
+                $message = [0, "Enter a username that is valid."];
+            } elseif (!preg_match("/^[a-zA-Z0-9-_]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The username does not allow strange characters."];
+            } else {
+                $client = Api::init($config);
+                $client->getUserDomains(["username" => $tsData["username"]]);
+
+                // 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;
+                // }
+                if ($client->getStatus() === "active") {
+                    $message = [1, "<b>The account </b> " . $tsData["username"] . " is Actived"];
+                } elseif ($client->getStatus() === "suspend") {
+                    $message = [1, "<b>The account </b> " . $tsData["username"] . " is Suspend"];
+                } else {
+                    "Cannot find the specified associated account";
+                    $message = [0, "The account <b>" . $tsData["username"] . "</b> does not have associated accounts."];
+                }
+            }
+        }
+        break;
+    case "account_domain":
+        $section_title = "Account Domains";
+        if (isset($_POST["do_get_domains"])) {
+            $tsData = array(
+                "username" => setProtect(strtolower($_POST["username"])),
+            );
+            if (!isset($tsData["username"]) || empty($tsData["username"])) {
+                $message = [0, "The username is required."];
+            } elseif (strlen($tsData["username"]) < 4 || strlen($tsData["username"]) > 18) {
+                $message = [0, "Enter a username that is valid."];
+            } elseif (!preg_match("/^[a-zA-Z0-9-_]{4,16}$/", $tsData["username"])) {
+                $message = [0, "The username does not allow strange characters."];
+            } else {
+                $client = Api::init($config);
+                $client->getUserDomains(["username" => $tsData["username"]]);
+                $message = $client->message;
+            }
+        }
+        break;
+    case "account_list":
+        $section_title = "Account List";
+        include_once $ROOT . "/data/member.php";
+        break;
+    case "login":
+        $section_title = "Admin Login";
+        if (isset($_POST["do_login"])) {
+            $username = setProtect(strtolower(trim($_POST["username"])));
+            $password = setProtect(strtolower(trim($_POST["password"])));
+            $captcha = setProtect(strtolower($_POST["captcha"]));
+            if (!isset($username) || empty($username)) {
+                $message = [0, "The username is required."];
+            } elseif (!isset($password) || empty($password)) {
+                $message = [0, "The password is required."];
+            } elseif (!isset($captcha) || empty($captcha)) {
+                $message = [0, "The captcha code is required."];
+            } else {
+                if (!isset($_SESSION["admincaptchacode"]) || $captcha != strtolower($_SESSION["admincaptchacode"])) {
+                    $message = [0, "The captcha code is invalid."];
+                } elseif ($username == $admin["username"] && $password == $admin["password"]) {
+                    $_SESSION["is_login"] = true;
+                    $is_admin = true;
+                    $message = [1, "Login successfully. 2 seconds later redirect to the main page"];
+                    header("refresh:2;url=admin.php");
+                } else {
+                    $is_admin = false;
+                    $message = [0, "Login failed.Please check if the account or password is correct."];
+                }
+            }
+        }
+        break;
+    case "logout":
+        $section_title = "Admin Logout";
+        unset($_SESSION);
+        session_destroy();
+        $message = [1, "Logout successfully. 2 seconds later redirect to the login page"];
+        header("refresh:2;url=admin.php");
+        break;
+    default:
+        $section_title = "Main";
+}

+ 23 - 0
data/config.php

@@ -0,0 +1,23 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../index.php");
+    exit;
+}
+
+$brandName = "UIISC";
+
+$admin = [
+    "username" => "admin",
+    "password" => "admin",
+];
+
+$config = [
+    "apiUsername" => "1",
+    "apiPassword" => "1",
+    "apiUrl" => "https://panel.myownfreehost.net:2087/xml-api/",
+    "plan" => [
+        "test_whm_api" => "test",
+        "ccc" => "test2",
+    ],
+];

+ 0 - 0
data/installed


+ 23 - 0
data/member.php

@@ -0,0 +1,23 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../index.php");
+    exit;
+}
+// test data
+
+$member = [
+    [
+        "branch" => "uiisc",
+        "account" => "testapi",
+        "username" => "uii_12345678",
+        "email" => "usitetest@uiisc.com",
+        "plan" => "test_whm_api",
+        "domain" => ["test1.uiisc.com", "testapi.uiisc.com"],
+        "password" => "abcAbc123",
+        "nameserver" => [
+            "ns1.byet.org",
+            "ns2.byet.org"
+        ]
+    ]
+];

+ 66 - 0
include/admin_footer.php

@@ -0,0 +1,66 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../admin.php");
+    exit;
+}
+?>
+
+    <footer class="footer navbar navbar-default navbar-fixed-bottom">
+        <div class="container">
+            <div class="navbar-inner navbar-content-center" style="padding-top:15px;">
+                <ul class="navbar-left list-inline text-center text-muted credit">
+                    <li>
+                        <span class="co">&copy;&nbsp;2019 <a href="/index.php"><?=$title_s?></a>&nbsp;</span>
+                        <span class="co">&nbsp;Powered by <a href="https://crogram.com" target="blank">Crogram</a>&nbsp;</span>
+                        <span class="co">&nbsp;Partnered with <a href="https://ifastnet.com/" name="jump-ifastnet" target="blank">iFastNet</a>&nbsp;</span>
+                    </li>
+                </ul>
+                <ul class="legal navbar-right list-inline text-center">
+                    <li class="dropup">
+                        <div class="dropdown-toggle" id="changelanguage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                            <span class="glyphicon glyphicon-globe"></span>
+                            <a href="#"><?php echo $languages[$current_lang][0]; ?></a>
+                        </div>
+                        <ul class="dropdown-menu language-change" aria-labelledby="changelanguage">
+                            <?php foreach ($languages as $key => $value) {
+                                $actived = $key == $current_lang ? ' class="active"' : '';
+                                echo '<li' .$actived . '><a class="language-change-click" data-language="' . $key . '" href="javascript://">' . $languages[$key][0] . '</a></li>';
+                            }?>
+
+                        </ul>
+                    </li>
+                    <li><a href="/contact.php"><?php echo $LANG['contact_us']; ?></a></li>
+                    <li><a href="/help.php"><?php echo $LANG['help']; ?></a></li>
+                </ul>
+            </div>
+        </div>
+    </footer>
+    <script src="/assets/jquery/jquery.min.js"></script>
+    <script src="/assets/bootstrap/js/bootstrap.min.js"></script>
+    <script src="/assets/js/common.js?_=<?php echo $static_release; ?>"></script>
+    <script type="text/javascript">
+        var domain = "<?php echo $lang->getDomain(); ?>";
+        var cur_lang = "<?php echo $current_lang; ?>";
+        function change_language(lang) {
+            setCookie('lang', lang, 1, '/', domain, false);
+            if (cur_lang == lang) {
+                return;
+            }
+            <?php if (!$_POST) {?>document.location.reload();<?php }?>
+
+        }
+        $(".language-change-click").click(function (x) {
+            change_language(x.target.dataset.language);
+        })
+        if (document.getElementsByName("jump-ifastnet").length) {
+            document.getElementsByName("jump-ifastnet")[0].onclick = function (x) {
+                jumpLink("https://ifastnet.com/portal/aff.php?aff=" + ifastnet_aff, null, "_target");
+                x.preventDefault();
+                x.stopPropagation();
+            };
+        }
+    </script>
+
+</body>
+</html>

+ 76 - 0
include/admin_header.php

@@ -0,0 +1,76 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../admin.php");
+    exit;
+}
+?>
+<!DOCTYPE html>
+<html lang="<?php echo $current_lang; ?>">
+
+<head>
+    <meta charset="utf-8" />
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+    <meta name="description" content="<?php echo $description; ?>">
+    <meta name="author" content="<?php echo $author; ?>">
+    <title><?php echo $title; ?> - Hosting Account Management System - <?php echo $section_title; ?></title>
+    <link href="assets/bootstrap/css/bootstrap.min.css?_=<?php echo $static_release; ?>" rel="stylesheet" />
+    <link href="assets/css/style.css?_=<?php echo $static_release; ?>" rel="stylesheet" />
+    <link href="assets/css/admin.css?_=<?php echo $static_release; ?>" rel="stylesheet" />
+    <link href="favicon.ico?_=<?php echo $static_release; ?>" type="image/x-icon" rel="icon" />
+    <link href="favicon.ico?_=<?php echo $static_release; ?>" type="image/x-icon" rel="shortcut icon" />
+    <!--[if lt IE 9]>
+    <script src="assets/html5shiv/html5shiv.min.js"></script>
+    <script src="assets/respond/respond.min.js"></script>
+    <![endif]-->
+</head>
+
+<body>
+
+    <div class="container">
+        <nav class="navbar navbar-default" role="navigation">
+            <div class="container-fluid">
+                <div class="navbar-header">
+                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
+                        <span class="sr-only">Navigation</span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </button>
+                    <a class="navbar-brand" href="admin.php"><?php echo $brandName; ?></a>
+                </div>
+                <div id="navbar" class="navbar-collapse collapse">
+                    <ul class="nav navbar-nav">
+                        <li><a href="index.php"><?php echo $LANG['home']; ?></a></li>
+                        <?php if ($is_admin) { ?>
+                            <li class="dropdown">
+                                <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">Account&nbsp;<span class="caret"></span></a>
+                                <ul class="dropdown-menu" role="menu">
+                                    <li class="dropdown-header">Account Management</li>
+                                    <li><a href="admin.php?s=check_domain">Check Domain</a></li>
+                                    <li><a href="admin.php?s=account_list">Account List</a></li>
+                                    <li><a href="admin.php?s=account_add">Account Add</a></li>
+                                    <li><a href="admin.php?s=account_password">Account Password</a></li>
+                                    <li><a href="admin.php?s=account_active">Account Activate</a></li>
+                                    <li><a href="admin.php?s=account_status">Account Status</a></li>
+                                    <li><a href="admin.php?s=account_domain">Account Domains</a></li>
+                                    <li class="divider"></li>
+                                    <li><a href="admin.php?s=account_disable">Account Suspend</a></li>
+                                </ul>
+                            </li>
+                        <?php } ?>
+                    </ul>
+                    <ul class="nav navbar-nav navbar-right">
+                        <?php if ($is_admin) { ?>
+                            <li><a href="admin.php?s=logout">Logout</a></li>
+                        <?php } else { ?>
+                            <li><a href="admin.php?s=login"><?php echo $LANG['login']; ?></a></li>
+                        <?php } ?>
+                        <li><a href="index.php"><?php echo $LANG['home']; ?></a></li>
+                    </ul>
+                </div>
+            </div>
+            <a class="hidden-xs" href="https://github.com/uiisc/uiisc.com" title="Source on Github" target="_blank"><svg class="octocat" viewBox="0 0 250 250" style="border: 0;color: #f4f5f6;fill: #5e6772;height: 5.2rem;width: 5.2rem;position: fixed;right: 0;top: 0;z-index: 1"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path class="octocat-arm" d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"></path><path class="octocat-body" d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"></path></svg></a>
+        </nav>
+    </div>

+ 40 - 0
include/captcha.php

@@ -0,0 +1,40 @@
+<?php
+
+session_start();
+
+header("Content-type: image/png");
+
+$font_file = 'fonts/elephant.ttf';
+
+$width = 160;
+$height = 30;
+$image = imagecreate($width, $height);
+
+imagecolorallocate($image, 238, 238, 238); // background color
+$font_color = imagecolorallocate($image, 0, 0, 0);
+$line_color = imagecolorallocate($image, 255, 0, 0);
+$point_color = imagecolorallocate($image, 255, 255, 255);
+
+// add point to image
+for ($i = 0; $i < $width; $i++) {
+    imagesetpixel($image, mt_rand(0, $width), mt_rand(0, $height), $point_color);
+}
+// add line to image
+for ($i = 0; $i < 10; $i++) {
+    imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $line_color);
+}
+// add text to image
+$range_chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
+$code = '';
+for ($i = 0; $i < 4; $i++) {
+    $str = $range_chars[rand(0, 61)]; // 62 chars: 0-9 and a-z and A-Z
+    $code = $code . $str;
+    $a = $width / 5 * $i;
+    $b = $width / 5 * ($i + 1);
+    imagettftext($image, 20, 0, mt_rand($a, $b), mt_rand(20, 30), $font_color, $font_file, $str);
+}
+
+$_SESSION['admincaptchacode'] = $code;
+
+imagepng($image);
+imagedestroy($image);

+ 21 - 0
include/common.php

@@ -0,0 +1,21 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../index.php");
+    exit;
+}
+/**
+ * Verify PHP version
+ */
+function getVersion()
+{
+    if ((float)phpversion() < 5.5) {
+        exit('<center style="font-family:Verdana, Geneva, sans-serif;font-size:14px;margin:10% auto;"><p><b>Oops!</b> There was a problem. Apparently <br/>You are using the php <b>version ' . phpversion() . '</b> a lower version than the one indicated <br/></p><h2>Anake script requires the php version</h2><h1 style="font-size:4em;">5.5.+</h1></center>');
+    }
+}
+
+// Protect the entered data function
+function setProtect($var)
+{
+    return htmlentities(htmlspecialchars($var));
+}

BIN
include/fonts/elephant.ttf


+ 0 - 0
install.php


+ 621 - 0
lib/api.php

@@ -0,0 +1,621 @@
+<?php
+if (!defined('IN_SYS')) {
+    // 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;
+    }
+}