Example #1
0
function ispcfg3_TerminateAccount($params)
{
    $username = $params['username'];
    $password = $params['password'];
    $clientsdetails = $params['clientsdetails'];
    $domain = $params['domain'];
    $soapuser = $params['configoption1'];
    $soappassword = $params['configoption2'];
    $soapsvrurl = $params['configoption3'];
    $soapsvrssl = $params['configoption4'];
    $domaintool = $params['configoption10'];
    if ($soapsvrssl == 'on') {
        $soap_url = 'https://' . $soapsvrurl . '/remote/index.php';
        $soap_uri = 'https://' . $soapsvrurl . '/remote/';
    } else {
        $soap_url = 'http://' . $soapsvrurl . '/remote/index.php';
        $soap_uri = 'http://' . $soapsvrurl . '/remote/';
    }
    if (isset($username) && $username != '' && (isset($password) && $password != '')) {
        try {
            /* Connect to SOAP Server */
            $client = new SoapClient(null, array('location' => $soap_url, 'uri' => $soap_uri, 'exceptions' => 1, 'trace' => false));
            /* Authenticate with the SOAP Server */
            $session_id = $client->login($soapuser, $soappassword);
            $domain_id = $client->client_get_by_username($session_id, $username);
            $group_id = $domain_id['default_group'];
            $client_id = $domain_id['client_id'];
            if ($domaintool == 'on') {
                $result = $client->domains_get_all_by_user($session_id, $group_id);
                logModuleCall('ispconfig', 'Terminate Get Domains', 'Get Domains', $result, '', '');
                if (!empty($result)) {
                    $key = '0';
                    foreach ($result as $key => $value) {
                        if ($result[$key]['domain'] = $domain) {
                            $primary_id = $result[$key]['domain_id'];
                            continue;
                        }
                    }
                    $result = $client->domains_domain_delete($session_id, $primary_id);
                    logModuleCall('ispconfig', 'Terminate Domain', $primary_id, $result, '', '');
                }
            }
            $client_res = $client->client_delete_everything($session_id, $client_id);
            logModuleCall('ispconfig', 'Terminate Client', $client_id, $client_res, '', '');
            if ($client->logout($session_id)) {
            }
            $successful = '1';
        } catch (SoapFault $e) {
            $error = 'SOAP Error: ' . $e->getMessage();
            $successful = 0;
        }
        if ($successful == 1) {
            $result = "success";
        } else {
            $result = $error;
        }
    } else {
        /*
         * No username or password set.
         */
        $result = 'Username or Password is Blank or Not Set';
    }
    return $result;
}
<?php

require 'soap_config.php';
$client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1));
try {
    if ($session_id = $client->login($username, $password)) {
        echo 'Logged successfull. Session ID:' . $session_id . '<br />';
    }
    //* Parameters
    $client_id = 9;
    //* Delete client
    $affected_rows = $client->client_delete_everything($session_id, $client_id);
    echo "Client " . $client_id . " has been deleted.<br>";
    //print_r($affected_rows);
    if ($client->logout($session_id)) {
        echo 'Logged out.<br />';
    }
} catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: ' . $e->getMessage());
}