|
|
@@ -0,0 +1,52 @@
|
|
|
+<?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");
|
|
|
+}
|
|
|
+
|
|
|
+use WHMCS\Database\Capsule;
|
|
|
+define("CLIENTAREA", true);
|
|
|
+require_once(__DIR__ . '/../../../init.php');
|
|
|
+require_once(ROOTDIR . '/includes/dbfunctions.php');
|
|
|
+require_once dirname(__FILE__) . '/zimbraSingle.inc';
|
|
|
+
|
|
|
+$whmcs = App::self();
|
|
|
+$productID = $_GET['pid'];
|
|
|
+$accessData = array('zimbraServer' => '', 'adminUser' => '', 'adminPass' => '');
|
|
|
+$serverIDObj = Capsule::table('tblhosting')
|
|
|
+ ->select('server')
|
|
|
+ ->where('id', '=', $productID)
|
|
|
+ ->get();
|
|
|
+$serverID = $serverIDObj[0]->server;
|
|
|
+$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__,
|
|
|
+ $params,
|
|
|
+ "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';
|
|
|
+ }
|
|
|
+}
|