apiUrl = rtrim($apiUrl, '/'); $this->apiKey = $apiKey; } /** * Check accessibility to the Server * * @param string $adminName The Super-Admin User of the CRM System (usually the e-mail of the customer * @param string $adminPassword A self randomly generated password * * @return string 'pong' on success * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function ping($adminName, $adminPassword) { $url = "$this->apiUrl/ping/test/test"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Deploy the website to customers webspace * * @param string $username The username * @param string $domain The site to deploy * @param string $adminName The Super-Admin User of the CRM System (usually the e-mail of the customer * @param string $adminPassword A self randomly generated password * * @return array with ['status' => $httpCode,'response' => $response']; * * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function deploy($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/deploy/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Initially deploy the placeholder site and config for the new website * * @param string $username The username * @param string $domain The site to init * @param string $adminName The Super-Admin User of the CRM System (usually the e-mail of the customer * @param string $adminPassword A self randomly generated password * * @return array with ['status' => $httpCode,'response' => $response']; * * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function init($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/init/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Re-init the site for the customer * * @param string $username The username * @param string $domain The site to revert * @param string $adminName The Super-Admin User of the CRM System (usually the e-mail of the customer * @param string $adminPassword A self randomly generated password * * @return array with ['status' => $httpCode,'response' => $response']; * * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function revert($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/revert/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Removes the site for the customer * * @param string $username The username * @param string $domain The site to remove * @param string $adminName The Super-Admin User of the CRM System (usually the e-mail of the customer * @param string $adminPassword A self randomly generated password * * @return array with ['status' => $httpCode,'response' => $response']; * * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function undeploy($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/undeploy/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Disables the webpage * * @param string $username The username * @param string $domain The site to disable * * @return array with ['status' => $httpCode,'response' => $response']; * */ public function disable($username, $domain) { $url = "$this->apiUrl/disable/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Creates a user and base configuration * * @param string $username The username * @param string $domain The site to create * * @return array with ['status' => $httpCode,'response' => $response']; * */ public function create($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/create/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Removes a user and user configuration * * @param string $username The username * @param string $domain The base domain of the service * * @return array with ['status' => $httpCode,'response' => $response']; * */ public function terminate($username, $domain) { $url = "$this->apiUrl/terminate/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Enables the webpage * * @param string $username The username * @param string $domain The site to enable * * @return array with ['status' => $httpCode,'response' => $response']; * */ public function enable($username, $domain) { $url = "$this->apiUrl/enable/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Check a webpage for enabled state * * @param string $username The username * @param string $domain The site to check about * * @return array with ['status' => $httpCode,'response' => $response']; * */ public function isenabled($username, $domain) { $url = "$this->apiUrl/isenabled/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Return users quota * * @param string $username The username * * @return array with ['status' => $httpCode,'response' => $response']; */ public function getQuota($username) { $url = "$this->apiUrl/getquota/$username"; return $this->sendRequest('GET', $url); } /** * Set users quota * * @param string $username The username * @param string $quota Quota in MegaBytes (MB) * @param string $adminName Admin user * @param string $adminPassword Admin password * * @return array with ['status' => $httpCode,'response' => $response']; */ public function setQuota($username, $quota, $adminName, $adminPassword) { $url = "$this->apiUrl/setquota/$username"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword, 'quota' => $quota, ]; return $this->sendRequest('POST', $url, $data); } /** * Return users quota * * @return array with ['status' => $httpCode,'response' => $response']; */ public function getStats() { $url = "$this->apiUrl/getstats"; return $this->sendRequest('GET', $url); } /** * Return SSL informations * * @param string $username The username * @param string $domain The site to gater informations about * * @return array with ['status' => $httpCode,'response' => $response']; */ public function getSSLDays($username, $domain) { $url = "$this->apiUrl/getssldays/$username/$domain"; return $this->sendRequest('GET', $url); } // send request private function sendRequest($method, $url, $data = []) { $ch = curl_init(); $options = [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "X-Api-Key: $this->apiKey", "Content-Type: application/json" ], CURLOPT_CUSTOMREQUEST => $method, CURLOPT_SSL_VERIFYPEER => false, // Deaktiviert die Überprüfung des SSL-Zertifikats CURLOPT_SSL_VERIFYHOST => false // Akzeptiert alle Hostnamen ]; if ($method === 'POST' && !empty($data)) { $options[CURLOPT_POSTFIELDS] = json_encode($data); } curl_setopt_array($ch, $options); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return [ 'status' => $httpCode, 'response' => json_decode($response, true) ]; } }