Browse Source

Merge branch 'rc1' of https://git.symbionet.de/andre/whmcsZimbraSingle into rc1

Andre Genrich 5 years ago
parent
commit
0514fea6bb
5 changed files with 89 additions and 37 deletions
  1. 12 3
      api/Zm/Auth.php
  2. 4 4
      api/config.php
  3. 32 0
      api/zmtest.php
  4. 39 29
      zimbraSingle.inc
  5. 2 1
      zimbraSingle.php

+ 12 - 3
api/Zm/Auth.php

@@ -72,6 +72,15 @@ class Zm_Auth
 	 */
 	function __construct($server, $username, $password, $authas="admin", $attempts=3)
 	{
+		$ssl_context = stream_context_create([
+			'ssl' => [
+			// set some SSL/TLS specific options
+			'verify_peer' => false,
+			'verify_peer_name' => false,
+			'allow_self_signed' => true
+			]
+		]);
+
 		if ($authas == "admin")
 		{
 			$location = "https://" . $server . ":7071/service/admin/soap/";
@@ -94,6 +103,7 @@ class Zm_Auth
 				'soap_version' => SOAP_1_2,
 				'style' => SOAP_RPC,
 				'use' => SOAP_LITERAL,
+				'stream_context' => $ssl_context,
 		    )
 		);
 
@@ -241,9 +251,8 @@ class Zm_Auth
 				$this->setSoapHeader();
 
 				$result = $this->client->__soapCall("AuthRequest", $this->params, null, $this->getSoapHeader());
-				//$result = $this->client->__getLastResponse();
-				//print_var($result);
-
+				// $result = $this->client->__getLastResponse();
+				// print_var($result);
 				// Save the soapHeader with token
 				$this->setSoapHeader($result['authToken']);
 				break;

+ 4 - 4
api/config.php

@@ -3,9 +3,9 @@
 // Config //
 ////////////
 
-$domain = "yourdomain.com";
-$zimbraserver = "zcs.".$domain;
-$zimbraadminemail = "admin@".$domain;
-$zimbraadminpassword = "admpassword";
+$domain = "thurdata.local";
+$zimbraServer = "192.168.16.225";
+$zimbraAdminEmail = "admin@".$domain;
+$zimbraAdminPassword = "Technics2312";
 
 ?>

+ 32 - 0
api/zmtest.php

@@ -0,0 +1,32 @@
+<?php
+ini_set('soap.wsdl_cache_enabled',0);
+ini_set('soap.wsdl_cache_ttl',0);
+
+
+require_once("config.php");
+
+require_once("Zm/Auth.php");
+require_once("Zm/Account.php");
+require_once("Zm/Domain.php");
+require_once("Zm/Server.php");
+
+$auth = new Zm_Auth($zimbraServer, $zimbraAdminEmail, $zimbraAdminPassword, "admin");
+
+$l = $auth->login();
+
+if(is_a($l, "Exception")) {
+
+    echo "Error : cannot login to $zimbraServer\n";
+
+    echo $l->getMessage()."\n";
+
+    exit();
+
+}
+
+$accountManager = new Zm_Account($auth);
+$r = $accountManager->accountExists("test3@thurdata.local");
+echo "$r\n";
+$r = $accountManager->accountExists("test5@thurdata.local");
+echo "$r\n";
+

+ 39 - 29
zimbraSingle.inc

@@ -327,21 +327,46 @@ function zimbraSingleClientArea($userData)
             ""
         );
         return false;
+    } else {
+        $apiAccountManager = new Zm_Account($api);
+        $response = $apiAccountManager->getAccountInfo($account_name);
+        if(is_a($response, "Exception")) {
+            logModuleCall(
+                'zimbrasingle',
+                __FUNCTION__,
+                $params,
+                "Error : could not gather informations for  $account_name",
+                ""
+            );
+            return false;
+        } else {
+            $webMailURL = recursiveFindAll( $response, 'PUBLICMAILURL');
+            logModuleCall(
+                'zimbrasingle',
+                __FUNCTION__,
+                $params,
+                "debug",
+                $webMailURL
+            );
+            return $webMailURL;
+        }
     }
-    $apiAccountManager = new Zm_Account($api);
-    $response = $apiAccountManager->getAccountInfo($account_name);
-    if(is_a($response, "Exception")) {
-        logModuleCall(
-            'zimbrasingle',
-            __FUNCTION__,
-            $params,
-            "Error : could not gather informations for $account_name",
-            ""
-        );
-        return false;
+}
+
+function recursiveFindAll($haystack, $needle)
+{
+    $values = array();
+    $iterator  = new RecursiveArrayIterator($haystack);
+    $recursive = new RecursiveIteratorIterator(
+        $iterator,
+        RecursiveIteratorIterator::SELF_FIRST
+    );
+    foreach ($recursive as $key => $value) {
+        if ($key === $needle) {
+            array_push($values, $value);
+        }
     }
-    $webMailURL = recursiveFindAll( $response, 'PUBLICMAILURL');
-    return $webMailURL[0]['DATA'];
+    return $values;
 }
 
 function zimbraSingleConfigOptions() {
@@ -415,23 +440,8 @@ function zimbraSingleCheckPassword($pwd)
     return $message;
 }
 
-function recursiveFindAll($haystack, $needle)
-{
-    $values = array();
-    $iterator  = new RecursiveArrayIterator($haystack);
-    $recursive = new RecursiveIteratorIterator(
-        $iterator,
-        RecursiveIteratorIterator::SELF_FIRST
-    );
-    foreach ($recursive as $key => $value) {
-        if ($key === $needle) {
-            array_push($values, $value);
-        }
-    }
-    return $values;
-}
-
 function zimbraSingleTestFunction()
 {
     return 'blubb';
 }
+

+ 2 - 1
zimbraSingle.php

@@ -49,7 +49,7 @@ function zimbraSingle_ClientArea($params)
     return array(
         'templatefile' => 'clientarea',
         'vars' => array(
-            'webmailURL' => $response,
+            'webmailURL' => $response[0]['DATA'],
         ),
     );
 }
@@ -137,3 +137,4 @@ function zimbraSingle_genUsername($name)
 
     return $name; */
 }
+