| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- $allowed_host = 'admin.seecure.ch';
- $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
- if(substr($host, 0 - strlen($allowed_host)) != $allowed_host) {
- die("This file cannot be accessed directly");
- }
- require_once(__DIR__ . '/../../../init.php');
- require_once("api/Zm/Auth.php");
- require_once("api/Zm/Account.php");
- use WHMCS\Database\Capsule;
- $whmcs = App::self();
- $account_name = $_GET['name'] . "@" . $_GET['domain'];
- $productID = $_GET['pid'];
- $accessData = array('zimbraServer' => '', 'adminUser' => '', 'adminPass' => '');
- $serverGroupIDObj = Capsule::table('tblproducts')
- ->select('servergroup')
- ->where('id', '=', $productID)
- ->get();
- $serverGroupID = $serverGroupIDObj[0]->servergroup;
- $serverIDObj = Capsule::table('tblservergroupsrel')
- ->select('serverid')
- ->where('groupid', '=', $serverGroupID)
- ->get();
- $serverID = $serverIDObj[0]->serverid;
- $server = Capsule::table('tblservers')
- ->select('ipaddress', 'username', 'password')
- ->where('id', '=', $serverID)
- ->where('active', '=', 1)
- ->get();
- $accessData['zimbraServer'] = $server[0]->ipaddress;
- $accessData['adminUser'] = $server[0]->username;
- $adminPassCrypt = $server[0]->password;
- $adminPassDecrypt = localAPI('DecryptPassword', array('password2' => $adminPassCrypt));
- if ($adminPassDecrypt['result'] == 'success') {
- $accessData['adminPass'] = $adminPassDecrypt['password'];
- }
- $api = new Zm_Auth($accessData['zimbraServer'], $accessData['adminUser'], $accessData['adminPass'], "admin");
- $login = $api->login();
- if(is_a($login, "Exception")) {
- logModuleCall(
- 'zimbrasingle',
- __FUNCTION__,
- $accessData,
- "Error : cannot login to " . $accessData['zimbraServer'],
- $login->getMessage()
- );
- exit();
- } else {
- $apiAccountManager = new Zm_Account($api);
- if( $apiAccountManager->accountExists($account_name)) {
- echo 'no';
- } else {
- echo 'yes';
- }
- }
|