Esempio n. 1
0
/**
 * --- Verify credentials ---
 * Verifies the gives credentials by making a dummy request to the nimbusec API
 */
function verifyCredentials($apiKey, $apiSecret)
{
    try {
        $api = new NimbusecAPI($apiKey, $apiSecret);
        $bundles = $api->findBundles();
        return true;
    } catch (Exception $exp) {
        return false;
    }
}
Esempio n. 2
0
$pkgInfos = array();
// Contains the login name (email) + username of all users with nimbusec in their packages
$nimbuAccts = array();
$responseArray = array();
$responseArray['status'] = 0;
$responseArray['content'] = array();
try {
    $logger = new Logger("/usr/local/nimbusec/logs", "uninstall_error.log", true);
    $logger->progress("Nimbusec uninstallation begins...");
    // Get access data for WHM API - do not delete
    $hash = file_get_contents("/root/.accesshash");
    $host = gethostname();
    $serverAddr = gethostbyname($host);
    $whmApi = new WHMAPIClient($hash, $serverAddr);
    list($key, $secret, $agentKey) = $whmApi->getNVData(array("NIMBUSEC_APIKEY", "NIMBUSEC_APISECRET", "NIMBUSEC_SERVERAGENTKEY"));
    $nimbusecAPI = new NimbusecAPI($key, $secret);
    // To remind, every error will be handled in the particular method of each PHP (!) class you use
    // and catched in this class
    // So you can log after every command without needing to check whether it worked properly or not
    // because if it's not, it will be catched by the 'catch' - clause which will log it in addition
    // ################################## 1.) Remove all users and domains from database ##################################
    $logger->progress("Removing all user and domains from database...");
    // Retrieve names of all packages containing nimbusec extension into an array
    $pkgResult = $whmApi->sendRequest('listpkgs');
    $logger->info("Packages retrieved");
    $logger->debug("Resultstatus WHM API listpkgs: {$pkgResult['metadata']['result']}");
    // Loop through every package to get name + list of package extensions
    foreach ($pkgResult['data']['pkg'] as $pkg) {
        if (!empty($pkg['_PACKAGE_EXTENSIONS'])) {
            // Space-seperated list
            $extensions = explode(' ', $pkg['_PACKAGE_EXTENSIONS']);