├── .gitignore ├── .php_cs ├── .php_cs.cache ├── GDM └── ISPConfig │ ├── AbstractSoapClient.php │ ├── DomainStatus.php │ ├── SoapClient.php │ ├── SoapClientInterface.php │ └── UsernameStatus.php ├── README.md ├── composer.json └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject/* -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | setRiskyAllowed(true) 4 | ->setRules([ 5 | '@PHP56Migration' => true, 6 | '@PSR2' => true, 7 | 'array_syntax' => [ 8 | 'syntax' => 'short' 9 | ], 10 | 'binary_operator_spaces' => [ 11 | 'align_double_arrow' => true, 12 | 'align_equals' => true 13 | ], 14 | 'single_quote' => true, 15 | 'no_blank_lines_after_class_opening' => false, 16 | ]) 17 | ->setFinder(PhpCsFixer\Finder::create()->in(__DIR__ . '/GDM/')); 18 | -------------------------------------------------------------------------------- /.php_cs.cache: -------------------------------------------------------------------------------- 1 | {"php":"5.6.30","version":"2.3.2:v2.3.2#597745f744bcce1aed59dfd1bb4603de2a06cda9","rules":{"pow_to_exponentiation":true,"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":{"align_double_arrow":true,"align_equals":true},"single_quote":true},"hashes":{"GDM\\\\ISPConfig\\AbstractSoapClient.php":-1210159584,"GDM\\\\ISPConfig\\DomainStatus.php":2082351212,"GDM\\\\ISPConfig\\SoapClient.php":-74157975,"GDM\\\\ISPConfig\\SoapClientInterface.php":-1333723600,"GDM\\\\ISPConfig\\UsernameStatus.php":1245686121}} -------------------------------------------------------------------------------- /GDM/ISPConfig/AbstractSoapClient.php: -------------------------------------------------------------------------------- 1 | Remote Users ) 15 | */ 16 | protected $ispConfigUser = ''; 17 | 18 | /** 19 | * 20 | * @var string Password to login to ISPConfig with ( Create/Update in ISPConfigs web interface under System > Remote Users ) 21 | */ 22 | protected $ispConfigPassword = ''; 23 | 24 | /** 25 | * 26 | * @var \SoapClient Refernce to the SOAP interface 27 | */ 28 | public $soapClient; 29 | 30 | /** 31 | * 32 | * @var string Session ID generated by logging in and used in subsequent requests 33 | */ 34 | public $sessionId; 35 | 36 | /** 37 | * 38 | * @var array Cache of client IDs 39 | */ 40 | public $clientIds = []; 41 | 42 | /** 43 | * 44 | * @var array Cache of clients 45 | */ 46 | public $clients = []; 47 | 48 | /** 49 | * 50 | * Holds the last exception encounted 51 | * 52 | * @var \Exception 53 | */ 54 | protected $lastException; 55 | 56 | /** 57 | * The server ID to run these commands on 58 | * @var int 59 | */ 60 | protected $serverId; 61 | 62 | /** 63 | * 64 | * Returns the current Session Id 65 | * 66 | * @return string 67 | * @throws Exception 68 | */ 69 | public function getSessionId() 70 | { 71 | if (!$this->sessionId) { 72 | throw new Exception('Tried to call method when not logged in'); 73 | } 74 | return $this->sessionId; 75 | } 76 | 77 | /** 78 | * 79 | * Returns the last exception encounted 80 | * 81 | * @return \Exception 82 | */ 83 | public function getLastException() 84 | { 85 | return $this->lastException ?: new \Exception(''); 86 | } 87 | 88 | /** 89 | * 90 | * Logs in to ISPConfig creating a SoapClient and retrieves a Session Id 91 | * 92 | * @param string $ispConfigSoapLocation Url to ISP configs SOAP remote API ( usually https://your-ip:8080/remote/index.php ) 93 | * @param string $ispConfigUser Username to login to ISPConfig with ( Create one in ISPConfigs web interface under System > Remote Users ) 94 | * @param string $ispConfigPassword Password to login to ISPConfig with ( Create/Update in ISPConfigs web interface under System > Remote Users ) 95 | */ 96 | public function __construct($ispConfigSoapLocation, $ispConfigUser, $ispConfigPassword, $context = null) 97 | { 98 | $this->ispConfigUser = $ispConfigUser; 99 | $this->ispConfigPassword = $ispConfigPassword; 100 | $this->ispConfigSoapLocation = $ispConfigSoapLocation; 101 | $this->soapClient = new \SoapClient(null, [ 102 | 'location' => $this->ispConfigSoapLocation, 103 | 'uri' => $this->ispConfigSoapLocation, 104 | 'stream_context' => $context 105 | ]); 106 | $this->sessionId = $this->login($this->ispConfigUser, $this->ispConfigPassword); 107 | if (!$this->sessionId) { 108 | throw new \Exception('Login failed: ' . ($this->lastException ? $this->lastException->getMessage() : '')); 109 | } 110 | } 111 | 112 | abstract public function login($username, $password); 113 | 114 | abstract public function logout(); 115 | 116 | public function getAllClients($update = false) 117 | { 118 | if (empty($this->clients) || $update) { 119 | $clientIds = $this->clientGetAll(); 120 | if ($clientIds) { 121 | foreach ($clientIds as $i => $clientId) { 122 | if ($i % 20 == 0) { 123 | } 124 | $client = $this->clientGet($clientId); 125 | if ($client !== false) { 126 | $this->clients[] = $client; 127 | } else { 128 | echo "$clientId failed!
"; 129 | } 130 | } 131 | } 132 | } 133 | return $this->clients; 134 | } 135 | 136 | public function userNameExits($usernamesToCheck) 137 | { 138 | $args = func_get_args(); 139 | if (count($args > 1)) { 140 | $usernamesToCheck = $args[1]; 141 | } 142 | 143 | $usernamesToCheck = is_array($usernamesToCheck) ? $usernamesToCheck : [$usernamesToCheck]; 144 | $result = []; 145 | foreach ($usernamesToCheck as $username) { 146 | $result[] = UsernameStatus::create($username, $this->clientGetByUsername($username) ? 1 : 0); 147 | } 148 | return $result; 149 | } 150 | 151 | /** 152 | * 153 | * @param type $domainsToCheck 154 | * @return DomainStatus[] 155 | */ 156 | public function domainExists($domainsToCheck) 157 | { 158 | $domainsToCheck = is_array($domainsToCheck) ? $domainsToCheck : [$domainsToCheck]; 159 | $reservedDomains = ['test.gdmedia.tv']; 160 | $domains = array_merge($reservedDomains, array_map(function ($s) { 161 | return $s['domain']; 162 | }, $this->getSites() 163 | ), $this->getAllClients() 164 | ); 165 | $result = []; 166 | foreach ($domainsToCheck as $domain) { 167 | $domain = strtolower(trim($domain)); 168 | $result[] = DomainStatus::create($domain, in_array($domain, $domains) ? 1 : 0); 169 | } 170 | return $result; 171 | } 172 | 173 | /** 174 | * Calls the remote SOAP call 175 | * Will pass from the second params and any after directly to the remote call 176 | * 177 | * @param type $function

The function name to call

178 | * @param type $param1

First remote param

179 | * @param type $param2

Second remote param

180 | * @return mixed The result of the remote function or false on failure. If an exception occurs false is returned and the exception can queried by getLastException. 181 | */ 182 | public function makeCall($function) 183 | { 184 | $args = func_get_args(); 185 | array_shift($args); 186 | try { 187 | $result = call_user_func_array([$this->soapClient, $function], $args); 188 | } catch (\Exception $exc) { 189 | $result = false; 190 | $this->lastException = $exc; 191 | } 192 | return $result; 193 | } 194 | 195 | public function createSite($serverId, $domain, $dbname, $dbuser, $dbpass = null) 196 | { 197 | if (!is_int($serverId)) { 198 | $server = $this->serverGetServeridByName($serverId); 199 | if (isset($server[0]['server_id'])) { 200 | $serverId = $server[0]['server_id']; 201 | } else { 202 | throw new \InvalidArgumentException('Unable to find the server ' . $serverId); 203 | } 204 | } 205 | 206 | return []; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /GDM/ISPConfig/DomainStatus.php: -------------------------------------------------------------------------------- 1 | domain = $domain; 19 | $this->exists = $exists; 20 | } 21 | 22 | public function __toString() 23 | { 24 | return $this->domain . ' ' . ($this->exists ? 'true' : 'false'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /GDM/ISPConfig/SoapClient.php: -------------------------------------------------------------------------------- 1 | makeCall('login', $username, $password); 9 | } 10 | 11 | public function logout() 12 | { 13 | return $this->makeCall('logout', $this->getSessionId()); 14 | } 15 | 16 | public function monitorJobqueueCount($serverId) 17 | { 18 | return $this->makeCall('monitor_jobqueue_count', $this->getSessionId(), $serverId); 19 | } 20 | 21 | public function serverGet($serverId, $section = '') 22 | { 23 | return $this->makeCall('server_get', $this->getSessionId(), $serverId, $section); 24 | } 25 | 26 | public function serverGetAll() 27 | { 28 | return $this->makeCall('server_get_all', $this->getSessionId()); 29 | } 30 | 31 | public function serverGetServeridByName($serverName) 32 | { 33 | return $this->makeCall('server_get_serverid_by_name', $this->getSessionId(), $serverName); 34 | } 35 | 36 | public function serverGetFunctions($serverId) 37 | { 38 | return $this->makeCall('server_get_functions', $this->getSessionId(), $serverId); 39 | } 40 | 41 | public function updateRecordPermissions($tablename, $indexField, $indexValue, $permissions) 42 | { 43 | return $this->makeCall('update_record_permissions', $tablename, $indexField, $indexValue, $permissions); 44 | } 45 | 46 | public function serverGetAppVersion() 47 | { 48 | return $this->makeCall('server_get_app_version', $this->getSessionId()); 49 | } 50 | 51 | public function serverGetServeridByIp($ipaddress) 52 | { 53 | return $this->makeCall('server_get_serverid_by_ip', $this->getSessionId(), $ipaddress); 54 | } 55 | 56 | public function serverIpGet($primaryId) 57 | { 58 | return $this->makeCall('server_ip_get', $this->getSessionId(), $primaryId); 59 | } 60 | 61 | public function serverIpAdd($clientId, $params) 62 | { 63 | return $this->makeCall('server_ip_add', $this->getSessionId(), $clientId, $params); 64 | } 65 | 66 | public function serverIpUpdate($clientId, $ipId, $params) 67 | { 68 | return $this->makeCall('server_ip_update', $this->getSessionId(), $clientId, $ipId, $params); 69 | } 70 | 71 | public function serverIpDelete($ipId) 72 | { 73 | return $this->makeCall('server_ip_delete', $this->getSessionId(), $ipId); 74 | } 75 | 76 | public function mailDomainGet($primaryId) 77 | { 78 | return $this->makeCall('mail_domain_get', $this->getSessionId(), $primaryId); 79 | } 80 | 81 | public function mailDomainAdd($clientId, $params) 82 | { 83 | return $this->makeCall('mail_domain_add', $this->getSessionId(), $clientId, $params); 84 | } 85 | 86 | public function mailDomainUpdate($clientId, $primaryId, $params) 87 | { 88 | return $this->makeCall('mail_domain_update', $this->getSessionId(), $clientId, $primaryId, $params); 89 | } 90 | 91 | public function mailDomainDelete($primaryId) 92 | { 93 | return $this->makeCall('mail_domain_delete', $this->getSessionId(), $primaryId); 94 | } 95 | 96 | public function mailAliasdomainGet($primaryId) 97 | { 98 | return $this->makeCall('mail_aliasdomain_get', $this->getSessionId(), $primaryId); 99 | } 100 | 101 | public function mailAliasdomainAdd($clientId, $params) 102 | { 103 | return $this->makeCall('mail_aliasdomain_add', $this->getSessionId(), $clientId, $params); 104 | } 105 | 106 | public function mailAliasdomainUpdate($clientId, $primaryId, $params) 107 | { 108 | return $this->makeCall('mail_aliasdomain_update', $this->getSessionId(), $clientId, $primaryId, $params); 109 | } 110 | 111 | public function mailAliasdomainDelete($primaryId) 112 | { 113 | return $this->makeCall('mail_aliasdomain_delete', $this->getSessionId(), $primaryId); 114 | } 115 | 116 | public function mailMailinglistGet($primaryId) 117 | { 118 | return $this->makeCall('mail_mailinglist_get', $this->getSessionId(), $primaryId); 119 | } 120 | 121 | public function mailMailinglistAdd($clientId, $params) 122 | { 123 | return $this->makeCall('mail_mailinglist_add', $this->getSessionId(), $clientId, $params); 124 | } 125 | 126 | public function mailMailinglistUpdate($clientId, $primaryId, $params) 127 | { 128 | return $this->makeCall('mail_mailinglist_update', $this->getSessionId(), $clientId, $primaryId, $params); 129 | } 130 | 131 | public function mailMailinglistDelete($primaryId) 132 | { 133 | return $this->makeCall('mail_mailinglist_delete', $this->getSessionId(), $primaryId); 134 | } 135 | 136 | public function mailUserGet($primaryId) 137 | { 138 | return $this->makeCall('mail_user_get', $this->getSessionId(), $primaryId); 139 | } 140 | 141 | public function mailUserAdd($clientId, $params) 142 | { 143 | return $this->makeCall('mail_user_add', $this->getSessionId(), $clientId, $params); 144 | } 145 | 146 | public function mailUserUpdate($clientId, $primaryId, $params) 147 | { 148 | return $this->makeCall('mail_user_update', $this->getSessionId(), $clientId, $primaryId, $params); 149 | } 150 | 151 | public function mailUserDelete($primaryId) 152 | { 153 | return $this->makeCall('mail_user_delete', $this->getSessionId(), $primaryId); 154 | } 155 | 156 | public function mailUserFilterGet($primaryId) 157 | { 158 | return $this->makeCall('mail_user_filter_get', $this->getSessionId(), $primaryId); 159 | } 160 | 161 | public function mailUserFilterAdd($clientId, $params) 162 | { 163 | return $this->makeCall('mail_user_filter_add', $this->getSessionId(), $clientId, $params); 164 | } 165 | 166 | public function mailUserFilterUpdate($clientId, $primaryId, $params) 167 | { 168 | return $this->makeCall('mail_user_filter_update', $this->getSessionId(), $clientId, $primaryId, $params); 169 | } 170 | 171 | public function mailUserFilterDelete($primaryId) 172 | { 173 | return $this->makeCall('mail_user_filter_delete', $this->getSessionId(), $primaryId); 174 | } 175 | 176 | public function mailAliasGet($primaryId) 177 | { 178 | return $this->makeCall('mail_alias_get', $this->getSessionId(), $primaryId); 179 | } 180 | 181 | public function mailAliasAdd($clientId, $params) 182 | { 183 | return $this->makeCall('mail_alias_add', $this->getSessionId(), $clientId, $params); 184 | } 185 | 186 | public function mailAliasUpdate($clientId, $primaryId, $params) 187 | { 188 | return $this->makeCall('mail_alias_update', $this->getSessionId(), $clientId, $primaryId, $params); 189 | } 190 | 191 | public function mailAliasDelete($primaryId) 192 | { 193 | return $this->makeCall('mail_alias_delete', $this->getSessionId(), $primaryId); 194 | } 195 | 196 | public function mailForwardGet($primaryId) 197 | { 198 | return $this->makeCall('mail_forward_get', $this->getSessionId(), $primaryId); 199 | } 200 | 201 | public function mailForwardAdd($clientId, $params) 202 | { 203 | return $this->makeCall('mail_forward_add', $this->getSessionId(), $clientId, $params); 204 | } 205 | 206 | public function mailForwardUpdate($clientId, $primaryId, $params) 207 | { 208 | return $this->makeCall('mail_forward_update', $this->getSessionId(), $clientId, $primaryId, $params); 209 | } 210 | 211 | public function mailForwardDelete($primaryId) 212 | { 213 | return $this->makeCall('mail_forward_delete', $this->getSessionId(), $primaryId); 214 | } 215 | 216 | public function mailCatchallGet($primaryId) 217 | { 218 | return $this->makeCall('mail_catchall_get', $this->getSessionId(), $primaryId); 219 | } 220 | 221 | public function mailCatchallAdd($clientId, $params) 222 | { 223 | return $this->makeCall('mail_catchall_add', $this->getSessionId(), $clientId, $params); 224 | } 225 | 226 | public function mailCatchallUpdate($clientId, $primaryId, $params) 227 | { 228 | return $this->makeCall('mail_catchall_update', $this->getSessionId(), $clientId, $primaryId, $params); 229 | } 230 | 231 | public function mailCatchallDelete($primaryId) 232 | { 233 | return $this->makeCall('mail_catchall_delete', $this->getSessionId(), $primaryId); 234 | } 235 | 236 | public function mailTransportGet($primaryId) 237 | { 238 | return $this->makeCall('mail_transport_get', $this->getSessionId(), $primaryId); 239 | } 240 | 241 | public function mailTransportAdd($clientId, $params) 242 | { 243 | return $this->makeCall('mail_transport_add', $this->getSessionId(), $clientId, $params); 244 | } 245 | 246 | public function mailTransportUpdate($clientId, $primaryId, $params) 247 | { 248 | return $this->makeCall('mail_transport_update', $this->getSessionId(), $clientId, $primaryId, $params); 249 | } 250 | 251 | public function mailTransportDelete($primaryId) 252 | { 253 | return $this->makeCall('mail_transport_delete', $this->getSessionId(), $primaryId); 254 | } 255 | 256 | public function mailRelayRecipientGet($primaryId) 257 | { 258 | return $this->makeCall('mail_relay_recipient_get', $this->getSessionId(), $primaryId); 259 | } 260 | 261 | public function mailRelayRecipientAdd($clientId, $params) 262 | { 263 | return $this->makeCall('mail_relay_recipient_add', $this->getSessionId(), $clientId, $params); 264 | } 265 | 266 | public function mailRelayRecipientUpdate($clientId, $primaryId, $params) 267 | { 268 | return $this->makeCall('mail_relay_recipient_update', $this->getSessionId(), $clientId, $primaryId, $params); 269 | } 270 | 271 | public function mailRelayRecipientDelete($primaryId) 272 | { 273 | return $this->makeCall('mail_relay_recipient_delete', $this->getSessionId(), $primaryId); 274 | } 275 | 276 | public function mailSpamfilterWhitelistGet($primaryId) 277 | { 278 | return $this->makeCall('mail_spamfilter_whitelist_get', $this->getSessionId(), $primaryId); 279 | } 280 | 281 | public function mailSpamfilterWhitelistAdd($clientId, $params) 282 | { 283 | return $this->makeCall('mail_spamfilter_whitelist_add', $this->getSessionId(), $clientId, $params); 284 | } 285 | 286 | public function mailSpamfilterWhitelistUpdate($clientId, $primaryId, $params) 287 | { 288 | return $this->makeCall('mail_spamfilter_whitelist_update', $this->getSessionId(), $clientId, $primaryId, $params); 289 | } 290 | 291 | public function mailSpamfilterWhitelistDelete($primaryId) 292 | { 293 | return $this->makeCall('mail_spamfilter_whitelist_delete', $this->getSessionId(), $primaryId); 294 | } 295 | 296 | public function mailSpamfilterBlacklistGet($primaryId) 297 | { 298 | return $this->makeCall('mail_spamfilter_blacklist_get', $this->getSessionId(), $primaryId); 299 | } 300 | 301 | public function mailSpamfilterBlacklistAdd($clientId, $params) 302 | { 303 | return $this->makeCall('mail_spamfilter_blacklist_add', $this->getSessionId(), $clientId, $params); 304 | } 305 | 306 | public function mailSpamfilterBlacklistUpdate($clientId, $primaryId, $params) 307 | { 308 | return $this->makeCall('mail_spamfilter_blacklist_update', $this->getSessionId(), $clientId, $primaryId, $params); 309 | } 310 | 311 | public function mailSpamfilterBlacklistDelete($primaryId) 312 | { 313 | return $this->makeCall('mail_spamfilter_blacklist_delete', $this->getSessionId(), $primaryId); 314 | } 315 | 316 | public function mailSpamfilterUserGet($primaryId) 317 | { 318 | return $this->makeCall('mail_spamfilter_user_get', $this->getSessionId(), $primaryId); 319 | } 320 | 321 | public function mailSpamfilterUserAdd($clientId, $params) 322 | { 323 | return $this->makeCall('mail_spamfilter_user_add', $this->getSessionId(), $clientId, $params); 324 | } 325 | 326 | public function mailSpamfilterUserUpdate($clientId, $primaryId, $params) 327 | { 328 | return $this->makeCall('mail_spamfilter_user_update', $this->getSessionId(), $clientId, $primaryId, $params); 329 | } 330 | 331 | public function mailSpamfilterUserDelete($primaryId) 332 | { 333 | return $this->makeCall('mail_spamfilter_user_delete', $this->getSessionId(), $primaryId); 334 | } 335 | 336 | public function mailPolicyGet($primaryId) 337 | { 338 | return $this->makeCall('mail_policy_get', $this->getSessionId(), $primaryId); 339 | } 340 | 341 | public function mailPolicyAdd($clientId, $params) 342 | { 343 | return $this->makeCall('mail_policy_add', $this->getSessionId(), $clientId, $params); 344 | } 345 | 346 | public function mailPolicyUpdate($clientId, $primaryId, $params) 347 | { 348 | return $this->makeCall('mail_policy_update', $this->getSessionId(), $clientId, $primaryId, $params); 349 | } 350 | 351 | public function mailPolicyDelete($primaryId) 352 | { 353 | return $this->makeCall('mail_policy_delete', $this->getSessionId(), $primaryId); 354 | } 355 | 356 | public function mailFetchmailGet($primaryId) 357 | { 358 | return $this->makeCall('mail_fetchmail_get', $this->getSessionId(), $primaryId); 359 | } 360 | 361 | public function mailFetchmailAdd($clientId, $params) 362 | { 363 | return $this->makeCall('mail_fetchmail_add', $this->getSessionId(), $clientId, $params); 364 | } 365 | 366 | public function mailFetchmailUpdate($clientId, $primaryId, $params) 367 | { 368 | return $this->makeCall('mail_fetchmail_update', $this->getSessionId(), $clientId, $primaryId, $params); 369 | } 370 | 371 | public function mailFetchmailDelete($primaryId) 372 | { 373 | return $this->makeCall('mail_fetchmail_delete', $this->getSessionId(), $primaryId); 374 | } 375 | 376 | public function mailWhitelistGet($primaryId) 377 | { 378 | return $this->makeCall('mail_whitelist_get', $this->getSessionId(), $primaryId); 379 | } 380 | 381 | public function mailWhitelistAdd($clientId, $params) 382 | { 383 | return $this->makeCall('mail_whitelist_add', $this->getSessionId(), $clientId, $params); 384 | } 385 | 386 | public function mailWhitelistUpdate($clientId, $primaryId, $params) 387 | { 388 | return $this->makeCall('mail_whitelist_update', $this->getSessionId(), $clientId, $primaryId, $params); 389 | } 390 | 391 | public function mailWhitelistDelete($primaryId) 392 | { 393 | return $this->makeCall('mail_whitelist_delete', $this->getSessionId(), $primaryId); 394 | } 395 | 396 | public function mailBlacklistGet($primaryId) 397 | { 398 | return $this->makeCall('mail_blacklist_get', $this->getSessionId(), $primaryId); 399 | } 400 | 401 | public function mailBlacklistAdd($clientId, $params) 402 | { 403 | return $this->makeCall('mail_blacklist_add', $this->getSessionId(), $clientId, $params); 404 | } 405 | 406 | public function mailBlacklistUpdate($clientId, $primaryId, $params) 407 | { 408 | return $this->makeCall('mail_blacklist_update', $this->getSessionId(), $clientId, $primaryId, $params); 409 | } 410 | 411 | public function mailBlacklistDelete($primaryId) 412 | { 413 | return $this->makeCall('mail_blacklist_delete', $this->getSessionId(), $primaryId); 414 | } 415 | 416 | public function mailFilterGet($primaryId) 417 | { 418 | return $this->makeCall('mail_filter_get', $this->getSessionId(), $primaryId); 419 | } 420 | 421 | public function mailFilterAdd($clientId, $params) 422 | { 423 | return $this->makeCall('mail_filter_add', $this->getSessionId(), $clientId, $params); 424 | } 425 | 426 | public function mailFilterUpdate($clientId, $primaryId, $params) 427 | { 428 | return $this->makeCall('mail_filter_update', $this->getSessionId(), $clientId, $primaryId, $params); 429 | } 430 | 431 | public function mailFilterDelete($primaryId) 432 | { 433 | return $this->makeCall('mail_filter_delete', $this->getSessionId(), $primaryId); 434 | } 435 | 436 | public function clientGet($clientId) 437 | { 438 | return $this->makeCall('client_get', $this->getSessionId(), $clientId); 439 | } 440 | 441 | public function clientGetId($sysUserid) 442 | { 443 | return $this->makeCall('client_get_id', $this->getSessionId(), $sysUserid); 444 | } 445 | 446 | public function clientGetGroupid($clientId) 447 | { 448 | return $this->makeCall('client_get_groupid', $this->getSessionId(), $clientId); 449 | } 450 | 451 | public function clientAdd($contact_name, $company_name, $user_name, $password, $email, $telephone, $limit_client = 0, $web_php_options = ['no', 'fast-cgi', 'cgi', 'mod', 'suphp', 'php-fpm'], $ssh_chroot = ['no', 'jailkit'], $language = 'en', $usertheme = 'default', $country = 'NZ', $resellerId = 0, $template_master = 0) 452 | { 453 | $params = [ 454 | 'contact_name' => $contact_name, 455 | 'username' => $user_name, 456 | 'password' => $password, 457 | 'company_name' => $company_name, 458 | 'email' => $email, 459 | 'telephone' => $telephone, 460 | 'limit_client' => $limit_client, 461 | 'web_php_options' => $web_php_options, 462 | 'ssh_chroot' => $ssh_chroot, 463 | 'language' => $language, 464 | 'usertheme' => $usertheme, 465 | 'country' => $country, 466 | 'template_master' => $template_master, 467 | ]; 468 | return $this->makeCall('client_add', $this->getSessionId(), $resellerId, $params); 469 | } 470 | 471 | public function clientUpdate($clientId, $resellerId, $params) 472 | { 473 | return $this->makeCall('client_update', $this->getSessionId(), $clientId, $resellerId, $params); 474 | } 475 | 476 | public function clientTemplateAdditionalGet($clientId) 477 | { 478 | return $this->makeCall('client_template_additional_get', $this->getSessionId(), $clientId); 479 | } 480 | 481 | public function SetClientFormdata($clientId) 482 | { 483 | return $this->makeCall('_set_client_formdata', $clientId); 484 | } 485 | 486 | public function clientTemplateAdditionalAdd($clientId, $templateId) 487 | { 488 | return $this->makeCall('client_template_additional_add', $this->getSessionId(), $clientId, $templateId); 489 | } 490 | 491 | public function clientTemplateAdditionalDelete($clientId, $assignedTemplateId) 492 | { 493 | return $this->makeCall('client_template_additional_delete', $this->getSessionId(), $clientId, $assignedTemplateId); 494 | } 495 | 496 | public function clientDelete($clientId) 497 | { 498 | return $this->makeCall('client_delete', $this->getSessionId(), $clientId); 499 | } 500 | 501 | public function clientDeleteEverything($clientId) 502 | { 503 | return $this->makeCall('client_delete_everything', $this->getSessionId(), $clientId); 504 | } 505 | 506 | public function sitesCronGet($cronId) 507 | { 508 | return $this->makeCall('sites_cron_get', $this->getSessionId(), $cronId); 509 | } 510 | 511 | public function sitesCronAdd($clientId, $params) 512 | { 513 | return $this->makeCall('sites_cron_add', $this->getSessionId(), $clientId, $params); 514 | } 515 | 516 | public function sitesCronUpdate($clientId, $cronId, $params) 517 | { 518 | return $this->makeCall('sites_cron_update', $this->getSessionId(), $clientId, $cronId, $params); 519 | } 520 | 521 | public function sitesCronDelete($cronId) 522 | { 523 | return $this->makeCall('sites_cron_delete', $this->getSessionId(), $cronId); 524 | } 525 | 526 | public function sitesDatabaseGet($primaryId) 527 | { 528 | return $this->makeCall('sites_database_get', $this->getSessionId(), $primaryId); 529 | } 530 | 531 | public function sitesDatabaseAdd($clientId, $serverId, $site, $dbName, $dbUserId, $type = 'mysql', $charset = 'utf8', $active = 'y') 532 | { 533 | $params = [ 534 | 'server_id' => $serverId, 535 | 'parent_domain_id' => $site, 536 | 'database_user_id' => $dbUserId, 537 | 'type' => $type, 538 | 'database_name' => $dbName, 539 | 'database_charset' => $charset, 540 | 'active' => $active, 541 | ]; 542 | return $this->makeCall('sites_database_add', $this->getSessionId(), $clientId, $params); 543 | } 544 | 545 | public function sitesDatabaseUpdate($clientId, $primaryId, $params) 546 | { 547 | return $this->makeCall('sites_database_update', $this->getSessionId(), $clientId, $primaryId, $params); 548 | } 549 | 550 | public function sitesDatabaseDelete($primaryId) 551 | { 552 | return $this->makeCall('sites_database_delete', $this->getSessionId(), $primaryId); 553 | } 554 | 555 | public function sitesDatabaseUserGet($primaryId) 556 | { 557 | return $this->makeCall('sites_database_user_get', $this->getSessionId(), $primaryId); 558 | } 559 | 560 | public function sitesDatabaseUserAdd($clientId, $serverId, $dbUser, $dbPass) 561 | { 562 | $params = [ 563 | 'server_id' => $serverId, 564 | 'database_user' => $dbUser, 565 | 'database_password' => $dbPass, 566 | 'repeat_password' => $dbPass 567 | ]; 568 | return $this->makeCall('sites_database_user_add', $this->getSessionId(), $clientId, $params); 569 | } 570 | 571 | public function sitesDatabaseUserUpdate($clientId, $dbUserId, $serverId, $dbUser, $dbPass) 572 | { 573 | $params = [ 574 | 'server_id' => $serverId, 575 | 'database_user' => $dbUser, 576 | 'database_password' => $dbPass, 577 | 'repeat_password' => $dbPass 578 | ]; 579 | return $this->makeCall('sites_database_user_update', $this->getSessionId(), $clientId, $dbUserId, $params); 580 | } 581 | 582 | public function sitesDatabaseUserDelete($primaryId) 583 | { 584 | return $this->makeCall('sites_database_user_delete', $this->getSessionId(), $primaryId); 585 | } 586 | 587 | public function sitesFtpUserGet($primaryId) 588 | { 589 | return $this->makeCall('sites_ftp_user_get', $this->getSessionId(), $primaryId); 590 | } 591 | 592 | public function sitesFtpUserAdd($clientId, $siteId, $userName, $password, $quotaSize = '-1', $active = 'y') 593 | { 594 | $result = false; 595 | $site = $this->sitesWebDomainGet($siteId); 596 | if ($site !== false) { 597 | $params = [ 598 | 'server_id' => $site['server_id'], 599 | 'parent_domain_id' => $siteId, 600 | 'username' => $userName, 601 | 'password' => $password, 602 | 'quota_size' => $quotaSize, 603 | 'active' => $active, 604 | 'uid' => $site['system_user'], 605 | 'gid' => $site['system_group'], 606 | 'dir' => $site['document_root'], 607 | 'sys_userid' => $site['sys_userid'], 608 | 'sys_groupid' => $site['sys_groupid'], 609 | ]; 610 | $result = $this->makeCall('sites_ftp_user_add', $this->getSessionId(), $clientId, $params); 611 | } 612 | return $result; 613 | } 614 | 615 | public function sitesFtpUserUpdate($clientId, $primaryId, $params) 616 | { 617 | return $this->makeCall('sites_ftp_user_update', $this->getSessionId(), $clientId, $primaryId, $params); 618 | } 619 | 620 | public function sitesFtpUserDelete($primaryId) 621 | { 622 | return $this->makeCall('sites_ftp_user_delete', $this->getSessionId(), $primaryId); 623 | } 624 | 625 | public function sitesFtpUserServerGet($ftpUser) 626 | { 627 | return $this->makeCall('sites_ftp_user_server_get', $this->getSessionId(), $ftpUser); 628 | } 629 | 630 | public function sitesShellUserGet($primaryId) 631 | { 632 | return $this->makeCall('sites_shell_user_get', $this->getSessionId(), $primaryId); 633 | } 634 | 635 | public function sitesShellUserAdd($clientId, $params) 636 | { 637 | return $this->makeCall('sites_shell_user_add', $this->getSessionId(), $clientId, $params); 638 | } 639 | 640 | public function sitesShellUserUpdate($clientId, $primaryId, $params) 641 | { 642 | return $this->makeCall('sites_shell_user_update', $this->getSessionId(), $clientId, $primaryId, $params); 643 | } 644 | 645 | public function sitesShellUserDelete($primaryId) 646 | { 647 | return $this->makeCall('sites_shell_user_delete', $this->getSessionId(), $primaryId); 648 | } 649 | 650 | public function sitesWebDomainGet($primaryId) 651 | { 652 | return $this->makeCall('sites_web_domain_get', $this->getSessionId(), $primaryId); 653 | } 654 | 655 | /** 656 | * 657 | * @param type $clientId 658 | * @param type $domain 659 | * @param type $serverId 660 | * @param type $ipAddress 661 | * @param type $subdomain 662 | * @param type $hd_quota 663 | * @param type $traffic_quota 664 | * @param type $allow_override 665 | * @param type $pm_max_children 666 | * @param type $pm_start_servers 667 | * @param type $pm_min_spare_servers 668 | * @param type $pm_max_spare_servers 669 | * @param type $pm_process_idle_timeout 670 | * @param type $pm_max_requests 671 | * @param type $errordocs 672 | * @param type $php 673 | * @param type $stats_type 674 | * @param type $pm 675 | * @param type $active 676 | * @param type $suexec 677 | * @param type $vhost_type 678 | * @param type $type 679 | * @param type $fastcgi_php_version 680 | * @param type $readonly 681 | * @param type $http_port 682 | * @param type $https_port 683 | * @return type 684 | */ 685 | public function sitesWebDomainAdd($clientId, $domain, $serverId = 1, $ipAddress = '*', $subdomain = 'www', $hd_quota = '-1', $traffic_quota = '-1', $allow_override = 'All', $pm_max_children = '10', $pm_start_servers = '2', $pm_min_spare_servers = '1', $pm_max_spare_servers = '5', $pm_process_idle_timeout = '10', $pm_max_requests = '0', $errordocs = '1', $php = 'fast-cgi', $stats_type = 'webalizer', $pm = 'dynamic', $active = 'y', $suexec = 'y', $vhost_type = 'name', $type = 'vhost', $fastcgi_php_version = '', $readonly = '0', $http_port = 80, $https_port = 443, $apache_directives = '') 686 | { 687 | $params = [ 688 | 'server_id' => $serverId, 689 | 'ip_address' => $ipAddress, 690 | 'domain' => $domain, 691 | 'type' => $type, 692 | // 'parent_domain_id' => 0, 693 | // 'vhost_type' => 'name', 694 | 'vhost_type' => $vhost_type, 695 | 'hd_quota' => $hd_quota, 696 | 'traffic_quota' => $traffic_quota, 697 | // 'cgi' => 'y', 698 | // 'ssi' => 'y', 699 | // 'suexec' => 'y', 700 | 'errordocs' => $errordocs, 701 | // 'is_subdomainwww' => 1, 702 | 'subdomain' => $subdomain, 703 | 'php' => $php, 704 | // 'ruby' => 'n', 705 | // 'redirect_type' => '', 706 | // 'redirect_path' => '', 707 | // 'ssl' => 'n', 708 | // 'ssl_state' => '', 709 | // 'ssl_locality' => '', 710 | // 'ssl_organisation' => '', 711 | // 'ssl_organisation_unit' => '', 712 | // 'ssl_country' => '', 713 | // 'ssl_domain' => '', 714 | // 'ssl_request' => '', 715 | // 'ssl_key' => '', 716 | // 'ssl_cert' => '', 717 | // 'ssl_bundle' => '', 718 | // 'ssl_action' => '', 719 | // 'stats_password' => '', 720 | 'stats_type' => $stats_type, 721 | 'allow_override' => $allow_override, 722 | 'apache_directives' => $apache_directives, 723 | // 'php_open_basedir' => '/', 724 | // 'pm_max_requests' => 0, 725 | // 'pm_process_idle_timeout' => 10, 726 | 'pm' => $pm, 727 | 'pm_max_children' => $pm_max_children, 728 | 'pm_start_servers' => $pm_start_servers, 729 | 'pm_min_spare_servers' => $pm_min_spare_servers, 730 | 'pm_max_spare_servers' => $pm_max_spare_servers, 731 | 'pm_process_idle_timeout' => $pm_process_idle_timeout, 732 | 'pm_max_requests' => $pm_max_requests, 733 | // 'custom_php_ini' => '', 734 | // 'backup_interval' => '', 735 | // 'backup_copies' => 1, 736 | 'active' => 'y', 737 | // 'traffic_quota_lock' => 'n' 738 | 'suexec' => $suexec, 739 | 'fastcgi_php_version' => $fastcgi_php_version, 740 | 'http_port' => $http_port, 741 | 'https_port' => $https_port, 742 | ]; 743 | return $this->makeCall('sites_web_domain_add', $this->getSessionId(), $clientId, $params, $readonly); 744 | } 745 | 746 | public function sitesWebDomainUpdate($clientId, $primaryId, $params) 747 | { 748 | return $this->makeCall('sites_web_domain_update', $this->getSessionId(), $clientId, $primaryId, $params); 749 | } 750 | 751 | public function sitesWebDomainDelete($primaryId) 752 | { 753 | return $this->makeCall('sites_web_domain_delete', $this->getSessionId(), $primaryId); 754 | } 755 | 756 | public function sitesWebVhostSubdomainGet($primaryId) 757 | { 758 | return $this->makeCall('sites_web_vhost_subdomain_get', $this->getSessionId(), $primaryId); 759 | } 760 | 761 | public function sitesWebVhostSubdomainAdd($clientId, $params) 762 | { 763 | return $this->makeCall('sites_web_vhost_subdomain_add', $this->getSessionId(), $clientId, $params); 764 | } 765 | 766 | public function sitesWebVhostSubdomainUpdate($clientId, $primaryId, $params) 767 | { 768 | return $this->makeCall('sites_web_vhost_subdomain_update', $this->getSessionId(), $clientId, $primaryId, $params); 769 | } 770 | 771 | public function sitesWebVhostSubdomainDelete($primaryId) 772 | { 773 | return $this->makeCall('sites_web_vhost_subdomain_delete', $this->getSessionId(), $primaryId); 774 | } 775 | 776 | public function sitesWebAliasdomainGet($primaryId) 777 | { 778 | return $this->makeCall('sites_web_aliasdomain_get', $this->getSessionId(), $primaryId); 779 | } 780 | 781 | public function sitesWebAliasdomainAdd($clientId, $siteId, $alias) 782 | { 783 | $result = false; 784 | $site = $this->sitesWebDomainGet($siteId); 785 | if ($site !== false) { 786 | $params = [ 787 | 'server_id' => $site['server_id'], 788 | 'domain' => $alias, 789 | 'type' => 'alias', 790 | 'parent_domain_id' => $site['domain_id'], 791 | 'active' => 'y', 792 | 'subdomain' => 'www', 793 | ]; 794 | try { 795 | $result = $this->makeCall('sites_web_aliasdomain_add', $this->getSessionId(), $clientId, $params); 796 | } catch (Exception $exc) { 797 | $result = false; 798 | $this->lastException = $exc; 799 | } 800 | } 801 | return $result; 802 | } 803 | 804 | public function sitesWebAliasdomainUpdate($clientId, $primaryId, $params) 805 | { 806 | return $this->makeCall('sites_web_aliasdomain_update', $this->getSessionId(), $clientId, $primaryId, $params); 807 | } 808 | 809 | public function sitesWebAliasdomainDelete($primaryId) 810 | { 811 | return $this->makeCall('sites_web_aliasdomain_delete', $this->getSessionId(), $primaryId); 812 | } 813 | 814 | public function sitesWebSubdomainGet($primaryId) 815 | { 816 | return $this->makeCall('sites_web_subdomain_get', $this->getSessionId(), $primaryId); 817 | } 818 | 819 | public function sitesWebSubdomainAdd($clientId, $params) 820 | { 821 | return $this->makeCall('sites_web_subdomain_add', $this->getSessionId(), $clientId, $params); 822 | } 823 | 824 | public function sitesWebSubdomainUpdate($clientId, $primaryId, $params) 825 | { 826 | return $this->makeCall('sites_web_subdomain_update', $this->getSessionId(), $clientId, $primaryId, $params); 827 | } 828 | 829 | public function sitesWebSubdomainDelete($primaryId) 830 | { 831 | return $this->makeCall('sites_web_subdomain_delete', $this->getSessionId(), $primaryId); 832 | } 833 | 834 | public function sitesWebFolderGet($primaryId) 835 | { 836 | return $this->makeCall('sites_web_folder_get', $this->getSessionId(), $primaryId); 837 | } 838 | 839 | public function sitesWebFolderAdd($clientId, $params) 840 | { 841 | return $this->makeCall('sites_web_folder_add', $this->getSessionId(), $clientId, $params); 842 | } 843 | 844 | public function sitesWebFolderUpdate($clientId, $primaryId, $params) 845 | { 846 | return $this->makeCall('sites_web_folder_update', $this->getSessionId(), $clientId, $primaryId, $params); 847 | } 848 | 849 | public function sitesWebFolderDelete($primaryId) 850 | { 851 | return $this->makeCall('sites_web_folder_delete', $this->getSessionId(), $primaryId); 852 | } 853 | 854 | public function sitesWebFolderUserGet($primaryId) 855 | { 856 | return $this->makeCall('sites_web_folder_user_get', $this->getSessionId(), $primaryId); 857 | } 858 | 859 | public function sitesWebFolderUserAdd($clientId, $params) 860 | { 861 | return $this->makeCall('sites_web_folder_user_add', $this->getSessionId(), $clientId, $params); 862 | } 863 | 864 | public function sitesWebFolderUserUpdate($clientId, $primaryId, $params) 865 | { 866 | return $this->makeCall('sites_web_folder_user_update', $this->getSessionId(), $clientId, $primaryId, $params); 867 | } 868 | 869 | public function sitesWebFolderUserDelete($primaryId) 870 | { 871 | return $this->makeCall('sites_web_folder_user_delete', $this->getSessionId(), $primaryId); 872 | } 873 | 874 | public function domainsDomainGet($primaryId) 875 | { 876 | return $this->makeCall('domains_domain_get', $this->getSessionId(), $primaryId); 877 | } 878 | 879 | public function domainsDomainAdd($clientId, $params) 880 | { 881 | return $this->makeCall('domains_domain_add', $this->getSessionId(), $clientId, $params); 882 | } 883 | 884 | public function domainsDomainDelete($primaryId) 885 | { 886 | return $this->makeCall('domains_domain_delete', $this->getSessionId(), $primaryId); 887 | } 888 | 889 | public function domainsGetAllByUser($groupId) 890 | { 891 | return $this->makeCall('domains_get_all_by_user', $this->getSessionId(), $groupId); 892 | } 893 | 894 | public function dnsTemplatezoneAdd($clientId, $templateId, $domain, $ip, $ns1, $ns2, $email) 895 | { 896 | return $this->makeCall('dns_templatezone_add', $this->getSessionId(), $clientId, $templateId, $domain, $ip, $ns1, $ns2, $email); 897 | } 898 | 899 | public function dnsZoneGet($primaryId) 900 | { 901 | return $this->makeCall('dns_zone_get', $this->getSessionId(), $primaryId); 902 | } 903 | 904 | public function dnsZoneGetId($origin) 905 | { 906 | return $this->makeCall('dns_zone_get_id', $this->getSessionId(), $origin); 907 | } 908 | 909 | public function dnsZoneAdd($clientId, $params) 910 | { 911 | return $this->makeCall('dns_zone_add', $this->getSessionId(), $clientId, $params); 912 | } 913 | 914 | public function dnsZoneUpdate($clientId, $primaryId, $params) 915 | { 916 | return $this->makeCall('dns_zone_update', $this->getSessionId(), $clientId, $primaryId, $params); 917 | } 918 | 919 | public function dnsZoneDelete($primaryId) 920 | { 921 | return $this->makeCall('dns_zone_delete', $this->getSessionId(), $primaryId); 922 | } 923 | 924 | public function dnsAaaaGet($primaryId) 925 | { 926 | return $this->makeCall('dns_aaaa_get', $this->getSessionId(), $primaryId); 927 | } 928 | 929 | public function dnsAaaaAdd($clientId, $params) 930 | { 931 | return $this->makeCall('dns_aaaa_add', $this->getSessionId(), $clientId, $params); 932 | } 933 | 934 | public function dnsAaaaUpdate($clientId, $primaryId, $params) 935 | { 936 | return $this->makeCall('dns_aaaa_update', $this->getSessionId(), $clientId, $primaryId, $params); 937 | } 938 | 939 | public function dnsAaaaDelete($primaryId) 940 | { 941 | return $this->makeCall('dns_aaaa_delete', $this->getSessionId(), $primaryId); 942 | } 943 | 944 | public function dnsAGet($primaryId) 945 | { 946 | return $this->makeCall('dns_a_get', $this->getSessionId(), $primaryId); 947 | } 948 | 949 | public function dnsAAdd($clientId, $params) 950 | { 951 | return $this->makeCall('dns_a_add', $this->getSessionId(), $clientId, $params); 952 | } 953 | 954 | public function dnsAUpdate($clientId, $primaryId, $params) 955 | { 956 | return $this->makeCall('dns_a_update', $this->getSessionId(), $clientId, $primaryId, $params); 957 | } 958 | 959 | public function dnsADelete($primaryId) 960 | { 961 | return $this->makeCall('dns_a_delete', $this->getSessionId(), $primaryId); 962 | } 963 | 964 | public function dnsAliasGet($primaryId) 965 | { 966 | return $this->makeCall('dns_alias_get', $this->getSessionId(), $primaryId); 967 | } 968 | 969 | public function dnsAliasAdd($clientId, $params) 970 | { 971 | return $this->makeCall('dns_alias_add', $this->getSessionId(), $clientId, $params); 972 | } 973 | 974 | public function dnsAliasUpdate($clientId, $primaryId, $params) 975 | { 976 | return $this->makeCall('dns_alias_update', $this->getSessionId(), $clientId, $primaryId, $params); 977 | } 978 | 979 | public function dnsAliasDelete($primaryId) 980 | { 981 | return $this->makeCall('dns_alias_delete', $this->getSessionId(), $primaryId); 982 | } 983 | 984 | public function dnsCnameGet($primaryId) 985 | { 986 | return $this->makeCall('dns_cname_get', $this->getSessionId(), $primaryId); 987 | } 988 | 989 | public function dnsCnameAdd($clientId, $params) 990 | { 991 | return $this->makeCall('dns_cname_add', $this->getSessionId(), $clientId, $params); 992 | } 993 | 994 | public function dnsCnameUpdate($clientId, $primaryId, $params) 995 | { 996 | return $this->makeCall('dns_cname_update', $this->getSessionId(), $clientId, $primaryId, $params); 997 | } 998 | 999 | public function dnsCnameDelete($primaryId) 1000 | { 1001 | return $this->makeCall('dns_cname_delete', $this->getSessionId(), $primaryId); 1002 | } 1003 | 1004 | public function dnsHinfoGet($primaryId) 1005 | { 1006 | return $this->makeCall('dns_hinfo_get', $this->getSessionId(), $primaryId); 1007 | } 1008 | 1009 | public function dnsHinfoAdd($clientId, $params) 1010 | { 1011 | return $this->makeCall('dns_hinfo_add', $this->getSessionId(), $clientId, $params); 1012 | } 1013 | 1014 | public function dnsHinfoUpdate($clientId, $primaryId, $params) 1015 | { 1016 | return $this->makeCall('dns_hinfo_update', $this->getSessionId(), $clientId, $primaryId, $params); 1017 | } 1018 | 1019 | public function dnsHinfoDelete($primaryId) 1020 | { 1021 | return $this->makeCall('dns_hinfo_delete', $this->getSessionId(), $primaryId); 1022 | } 1023 | 1024 | public function dnsMxGet($primaryId) 1025 | { 1026 | return $this->makeCall('dns_mx_get', $this->getSessionId(), $primaryId); 1027 | } 1028 | 1029 | public function dnsMxAdd($clientId, $params) 1030 | { 1031 | return $this->makeCall('dns_mx_add', $this->getSessionId(), $clientId, $params); 1032 | } 1033 | 1034 | public function dnsMxUpdate($clientId, $primaryId, $params) 1035 | { 1036 | return $this->makeCall('dns_mx_update', $this->getSessionId(), $clientId, $primaryId, $params); 1037 | } 1038 | 1039 | public function dnsMxDelete($primaryId) 1040 | { 1041 | return $this->makeCall('dns_mx_delete', $this->getSessionId(), $primaryId); 1042 | } 1043 | 1044 | public function dnsNsGet($primaryId) 1045 | { 1046 | return $this->makeCall('dns_ns_get', $this->getSessionId(), $primaryId); 1047 | } 1048 | 1049 | public function dnsNsAdd($clientId, $params) 1050 | { 1051 | return $this->makeCall('dns_ns_add', $this->getSessionId(), $clientId, $params); 1052 | } 1053 | 1054 | public function dnsNsUpdate($clientId, $primaryId, $params) 1055 | { 1056 | return $this->makeCall('dns_ns_update', $this->getSessionId(), $clientId, $primaryId, $params); 1057 | } 1058 | 1059 | public function dnsNsDelete($primaryId) 1060 | { 1061 | return $this->makeCall('dns_ns_delete', $this->getSessionId(), $primaryId); 1062 | } 1063 | 1064 | public function dnsPtrGet($primaryId) 1065 | { 1066 | return $this->makeCall('dns_ptr_get', $this->getSessionId(), $primaryId); 1067 | } 1068 | 1069 | public function dnsPtrAdd($clientId, $params) 1070 | { 1071 | return $this->makeCall('dns_ptr_add', $this->getSessionId(), $clientId, $params); 1072 | } 1073 | 1074 | public function dnsPtrUpdate($clientId, $primaryId, $params) 1075 | { 1076 | return $this->makeCall('dns_ptr_update', $this->getSessionId(), $clientId, $primaryId, $params); 1077 | } 1078 | 1079 | public function dnsPtrDelete($primaryId) 1080 | { 1081 | return $this->makeCall('dns_ptr_delete', $this->getSessionId(), $primaryId); 1082 | } 1083 | 1084 | public function dnsRpGet($primaryId) 1085 | { 1086 | return $this->makeCall('dns_rp_get', $this->getSessionId(), $primaryId); 1087 | } 1088 | 1089 | public function dnsRpAdd($clientId, $params) 1090 | { 1091 | return $this->makeCall('dns_rp_add', $this->getSessionId(), $clientId, $params); 1092 | } 1093 | 1094 | public function dnsRpUpdate($clientId, $primaryId, $params) 1095 | { 1096 | return $this->makeCall('dns_rp_update', $this->getSessionId(), $clientId, $primaryId, $params); 1097 | } 1098 | 1099 | public function dnsRpDelete($primaryId) 1100 | { 1101 | return $this->makeCall('dns_rp_delete', $this->getSessionId(), $primaryId); 1102 | } 1103 | 1104 | public function dnsSrvGet($primaryId) 1105 | { 1106 | return $this->makeCall('dns_srv_get', $this->getSessionId(), $primaryId); 1107 | } 1108 | 1109 | public function dnsSrvAdd($clientId, $params) 1110 | { 1111 | return $this->makeCall('dns_srv_add', $this->getSessionId(), $clientId, $params); 1112 | } 1113 | 1114 | public function dnsSrvUpdate($clientId, $primaryId, $params) 1115 | { 1116 | return $this->makeCall('dns_srv_update', $this->getSessionId(), $clientId, $primaryId, $params); 1117 | } 1118 | 1119 | public function dnsSrvDelete($primaryId) 1120 | { 1121 | return $this->makeCall('dns_srv_delete', $this->getSessionId(), $primaryId); 1122 | } 1123 | 1124 | public function dnsTxtGet($primaryId) 1125 | { 1126 | return $this->makeCall('dns_txt_get', $this->getSessionId(), $primaryId); 1127 | } 1128 | 1129 | public function dnsTxtAdd($clientId, $params) 1130 | { 1131 | return $this->makeCall('dns_txt_add', $this->getSessionId(), $clientId, $params); 1132 | } 1133 | 1134 | public function dnsTxtUpdate($clientId, $primaryId, $params) 1135 | { 1136 | return $this->makeCall('dns_txt_update', $this->getSessionId(), $clientId, $primaryId, $params); 1137 | } 1138 | 1139 | public function dnsTxtDelete($primaryId) 1140 | { 1141 | return $this->makeCall('dns_txt_delete', $this->getSessionId(), $primaryId); 1142 | } 1143 | 1144 | public function klientadd($formdefFile, $resellerId, $params) 1145 | { 1146 | return $this->makeCall('klientadd', $formdefFile, $resellerId, $params); 1147 | } 1148 | 1149 | public function insertQuery($formdefFile, $clientId, $params, $eventIdentifier) 1150 | { 1151 | return $this->makeCall('insertQuery', $formdefFile, $clientId, $params, $eventIdentifier); 1152 | } 1153 | 1154 | public function insertQueryPrepare($formdefFile, $clientId, $params) 1155 | { 1156 | return $this->makeCall('insertQueryPrepare', $formdefFile, $clientId, $params); 1157 | } 1158 | 1159 | public function insertQueryExecute($sql, $params, $eventIdentifier) 1160 | { 1161 | return $this->makeCall('insertQueryExecute', $sql, $params, $eventIdentifier); 1162 | } 1163 | 1164 | public function updateQuery($formdefFile, $clientId, $primaryId, $params, $eventIdentifier) 1165 | { 1166 | return $this->makeCall('updateQuery', $formdefFile, $clientId, $primaryId, $params, $eventIdentifier); 1167 | } 1168 | 1169 | public function updateQueryPrepare($formdefFile, $clientId, $primaryId, $params) 1170 | { 1171 | return $this->makeCall('updateQueryPrepare', $formdefFile, $clientId, $primaryId, $params); 1172 | } 1173 | 1174 | public function updateQueryExecute($sql, $primaryId, $params, $eventIdentifier) 1175 | { 1176 | return $this->makeCall('updateQueryExecute', $sql, $primaryId, $params, $eventIdentifier); 1177 | } 1178 | 1179 | public function deleteQuery($formdefFile, $primaryId, $eventIdentifier) 1180 | { 1181 | return $this->makeCall('deleteQuery', $formdefFile, $primaryId, $eventIdentifier); 1182 | } 1183 | 1184 | public function checkPerm($functionName) 1185 | { 1186 | return $this->makeCall('checkPerm', $this->getSessionId(), $functionName); 1187 | } 1188 | 1189 | public function getSession() 1190 | { 1191 | return $this->makeCall('getSession', $this->getSessionId()); 1192 | } 1193 | 1194 | public function clientGetSitesByUser($sysUserid, $sysGroupid) 1195 | { 1196 | return $this->makeCall('client_get_sites_by_user', $this->getSessionId(), $sysUserid, $sysGroupid); 1197 | } 1198 | 1199 | public function sitesGetAll() 1200 | { 1201 | return $this->makeCall('sites_get_all', $this->getSessionId()); 1202 | } 1203 | 1204 | public function sitesWebDomainSetStatus($primaryId, $status) 1205 | { 1206 | return $this->makeCall('sites_web_domain_set_status', $this->getSessionId(), $primaryId, $status); 1207 | } 1208 | 1209 | public function clientGetByUsername($username) 1210 | { 1211 | return $this->makeCall('client_get_by_username', $this->getSessionId(), $username); 1212 | } 1213 | 1214 | public function clientGetAll() 1215 | { 1216 | return $this->makeCall('client_get_all', $this->getSessionId()); 1217 | } 1218 | 1219 | public function clientChangePassword($clientId, $newPassword) 1220 | { 1221 | return $this->makeCall('client_change_password', $this->getSessionId(), $clientId, $newPassword); 1222 | } 1223 | 1224 | public function mailDomainGetByDomain($domain) 1225 | { 1226 | return $this->makeCall('mail_domain_get_by_domain', $this->getSessionId(), $domain); 1227 | } 1228 | 1229 | public function getFunctionList() 1230 | { 1231 | return $this->makeCall('get_function_list', $this->getSessionId()); 1232 | } 1233 | 1234 | public function sitesDatabaseGetAllByUser($clientId) 1235 | { 1236 | return $this->makeCall('sites_database_get_all_by_user', $this->getSessionId(), $clientId); 1237 | } 1238 | 1239 | public function clientTemplatesGetAll() 1240 | { 1241 | return $this->makeCall('client_templates_get_all', $this->getSessionId()); 1242 | } 1243 | 1244 | public function dnsZoneGetByUser($clientId, $serverId) 1245 | { 1246 | return $this->makeCall('dns_zone_get_by_user', $this->getSessionId(), $clientId, $serverId); 1247 | } 1248 | 1249 | public function dnsRrGetAllByZone($zoneId) 1250 | { 1251 | return $this->makeCall('dns_rr_get_all_by_zone', $this->getSessionId(), $zoneId); 1252 | } 1253 | 1254 | public function dnsZoneSetStatus($primaryId, $status) 1255 | { 1256 | return $this->makeCall('dns_zone_set_status', $this->getSessionId(), $primaryId, $status); 1257 | } 1258 | 1259 | public function mailDomainSetStatus($primaryId, $status) 1260 | { 1261 | return $this->makeCall('mail_domain_set_status', $this->getSessionId(), $primaryId, $status); 1262 | } 1263 | 1264 | public function openvzOstemplateGet($ostemplateId) 1265 | { 1266 | return $this->makeCall('openvz_ostemplate_get', $this->getSessionId(), $ostemplateId); 1267 | } 1268 | 1269 | public function openvzOstemplateAdd($clientId, $params) 1270 | { 1271 | return $this->makeCall('openvz_ostemplate_add', $this->getSessionId(), $clientId, $params); 1272 | } 1273 | 1274 | public function openvzOstemplateUpdate($clientId, $ostemplateId, $params) 1275 | { 1276 | return $this->makeCall('openvz_ostemplate_update', $this->getSessionId(), $clientId, $ostemplateId, $params); 1277 | } 1278 | 1279 | public function openvzOstemplateDelete($ostemplateId) 1280 | { 1281 | return $this->makeCall('openvz_ostemplate_delete', $this->getSessionId(), $ostemplateId); 1282 | } 1283 | 1284 | public function openvzTemplateGet($templateId) 1285 | { 1286 | return $this->makeCall('openvz_template_get', $this->getSessionId(), $templateId); 1287 | } 1288 | 1289 | public function openvzTemplateAdd($clientId, $params) 1290 | { 1291 | return $this->makeCall('openvz_template_add', $this->getSessionId(), $clientId, $params); 1292 | } 1293 | 1294 | public function openvzTemplateUpdate($clientId, $templateId, $params) 1295 | { 1296 | return $this->makeCall('openvz_template_update', $this->getSessionId(), $clientId, $templateId, $params); 1297 | } 1298 | 1299 | public function openvzTemplateDelete($templateId) 1300 | { 1301 | return $this->makeCall('openvz_template_delete', $this->getSessionId(), $templateId); 1302 | } 1303 | 1304 | public function openvzIpGet($ipId) 1305 | { 1306 | return $this->makeCall('openvz_ip_get', $this->getSessionId(), $ipId); 1307 | } 1308 | 1309 | public function openvzGetFreeIp($serverId) 1310 | { 1311 | return $this->makeCall('openvz_get_free_ip', $this->getSessionId(), $serverId); 1312 | } 1313 | 1314 | public function openvzIpAdd($clientId, $params) 1315 | { 1316 | return $this->makeCall('openvz_ip_add', $this->getSessionId(), $clientId, $params); 1317 | } 1318 | 1319 | public function openvzIpUpdate($clientId, $ipId, $params) 1320 | { 1321 | return $this->makeCall('openvz_ip_update', $this->getSessionId(), $clientId, $ipId, $params); 1322 | } 1323 | 1324 | public function openvzIpDelete($ipId) 1325 | { 1326 | return $this->makeCall('openvz_ip_delete', $this->getSessionId(), $ipId); 1327 | } 1328 | 1329 | public function openvzVmGet($vmId) 1330 | { 1331 | return $this->makeCall('openvz_vm_get', $this->getSessionId(), $vmId); 1332 | } 1333 | 1334 | public function openvzVmGetByClient($clientId) 1335 | { 1336 | return $this->makeCall('openvz_vm_get_by_client', $this->getSessionId(), $clientId); 1337 | } 1338 | 1339 | public function openvzVmAdd($clientId, $params) 1340 | { 1341 | return $this->makeCall('openvz_vm_add', $this->getSessionId(), $clientId, $params); 1342 | } 1343 | 1344 | public function openvzVmAddFromTemplate($clientId, $ostemplateId, $templateId, $overrideParams) 1345 | { 1346 | return $this->makeCall('openvz_vm_add_from_template', $this->getSessionId(), $clientId, $ostemplateId, $templateId, $overrideParams); 1347 | } 1348 | 1349 | public function openvzVmUpdate($clientId, $vmId, $params) 1350 | { 1351 | return $this->makeCall('openvz_vm_update', $this->getSessionId(), $clientId, $vmId, $params); 1352 | } 1353 | 1354 | public function openvzVmDelete($vmId) 1355 | { 1356 | return $this->makeCall('openvz_vm_delete', $this->getSessionId(), $vmId); 1357 | } 1358 | 1359 | public function openvzVmStart($vmId) 1360 | { 1361 | return $this->makeCall('openvz_vm_start', $this->getSessionId(), $vmId); 1362 | } 1363 | 1364 | public function openvzVmStop($vmId) 1365 | { 1366 | return $this->makeCall('openvz_vm_stop', $this->getSessionId(), $vmId); 1367 | } 1368 | 1369 | public function openvzVmRestart($vmId) 1370 | { 1371 | return $this->makeCall('openvz_vm_restart', $this->getSessionId(), $vmId); 1372 | } 1373 | 1374 | public function getAllGroupIds() 1375 | { 1376 | $clientIds = $this->getAllClientIds(); 1377 | $groupIds = []; 1378 | $groupIds[] = 0; 1379 | foreach ($clientIds as $clientId) { 1380 | $groupIds[] = $this->getClientGroupId($clientId); 1381 | } 1382 | return $groupIds; 1383 | } 1384 | 1385 | public function getAllClientIds($update = false) 1386 | { 1387 | if (empty($this->clientIds) || $update) { 1388 | $this->clientIds = $this->soapClient->clientGetAll($this->getSessionId()); 1389 | } 1390 | return $this->clientIds; 1391 | } 1392 | } 1393 | -------------------------------------------------------------------------------- /GDM/ISPConfig/SoapClientInterface.php: -------------------------------------------------------------------------------- 1 | username = $username; 19 | $this->exists = $exists; 20 | } 21 | 22 | public function __toString() 23 | { 24 | return $this->username . ' ' . ($this->exists ? 'true' : 'false'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ispconfig-remote-api 2 | ==================== 3 | 4 | A simple wrapper around the ISPConfig Remote API 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gdm/ispconfig-soap-client", 3 | "description": "A simple wrapper around ISPConfigs Remote API using Soap", 4 | "authors": [ 5 | { 6 | "name": "Corey Sewell", 7 | "email": "corey@gdmedia.tv" 8 | } 9 | ], 10 | "autoload": { 11 | "psr-0": { 12 | "GDM": "./" 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | clientAdd("My Client", "My Clients Company", "myclient", "myclientspassword", "contact@myclient.com", "000000"); 7 | $siteId = false; 8 | if ($clientId) { 9 | $siteId = $cp->sitesWebDomainAdd($clientId, "myclient.com", "255.255.255.1"); 10 | } else { 11 | echo "Failed to create client " . $cp->getLastException()->getMessage(); 12 | } 13 | 14 | if ($siteId) { 15 | echo "Created client with id $clientId "; 16 | echo "Created site with id $siteId "; 17 | } else { 18 | echo "Failed to create site " . $cp->getLastException()->getMessage(); 19 | } 20 | 21 | --------------------------------------------------------------------------------