示例#1
0
 $apiKey = htmlentities($_POST['apiKey'], ENT_QUOTES);
 $apiSecret = htmlentities($_POST['apiSecret'], ENT_QUOTES);
 // -- If $_POST ['apiServer'] then validate for url pattern --
 if (verifyString($apiKey) && verifyString($apiSecret)) {
     if (!isNimbusecInstalled()) {
         if (verifyCredentials($apiKey, $apiSecret)) {
             // -- Get access data for WHM API --
             $hash = file_get_contents("/root/.accesshash");
             $host = gethostname();
             $serverAddr = gethostbyname($host);
             $whmApi = new WHMAPIClient($hash, $serverAddr);
             // -- Install Nimbusec (trigger installation file) --
             $res = (require_once "/usr/local/nimbusec/nimbusec/install.php");
             if ($res['status']) {
                 // Set installation flag
                 $whmApi->setNVData(array(array("NIMBUSEC_INSTALLED", "1")));
                 // Set credentials
                 $whmApi->setNVData(array(array("NIMBUSEC_APIKEY", $apiKey), array("NIMBUSEC_APISECRET", $apiSecret)));
                 array_push($res['content'], "The installation of the nimbusec cPanel / WHM has been finished successfully.");
             } else {
                 array_push($res['content'], "The installation of the nimbusec cPanel / WHM plugin has been aborted suddenly. It is advised to review the nimbusec logs files to find possible causes.");
             }
             returnResponse($res);
         } else {
             returnResponse("Please enter valid credentials to continue with the installation.");
         }
     } else {
         returnResponse("The nimbusec cPanel / WHM plugin is already installed. An installation can't be done twice.");
     }
 } else {
     returnResponse("Invalid data was passed.");
示例#2
0
    }
    $logger->info("SECOND PART completed: Removing all parts of nimbusec from the system");
    array_push($responseArray['content'], "Removed all parts of nimbusec from the system");
    // ################################## 3.) Remove rest files / nvdata ##################################
    $logger->info("THIRD PART: Removing other nimbusec files");
    // Delete later hashes temp file in /home/<user>/tmp/hashes-<domain>.txt
    // Cronjob
    if (is_file("/etc/cron.daily/nimbusec")) {
        unlink("/etc/cron.daily/nimbusec");
    } else {
        $logger->warning("Cron job path doesn't exist, hence couldn't be deleted");
    }
    $logger->info("Removing nimbusec env files");
    // WHM NVData
    $whmArr = array(array("NIMBUSEC_APIKEY", null), array("NIMBUSEC_APISECRET", null), array("NIMBUSEC_SERVERAGENTKEY", null), array("NIMBUSEC_SERVERAGENTSECRET", null), array("NIMBUSEC_INSTALLED", null));
    $whmApi->setNVData($whmArr);
    $logger->info("THIRD PART completed: Removed other nimbusec files\n");
    array_push($responseArray['content'], "Removed other nimbusec files");
    $logger->info("Nimbusec uninstalled");
    $logger->info("Nimbusec uninstallation ends...");
    $logger->close();
    $responseArray['status'] = 1;
    return $responseArray;
} catch (CUrlException $exp) {
    $logger->error("[CURL SPECIFIC ERROR] in {$exp->getFile()}: {$exp->getMessage()} at line {$exp->getLine()}");
    $logger->info("Nimbusec uninstallation aborted...");
    $logger->close();
    array_push($responseArray['content'], "Nimbusec uninstallation aborted...");
    return $responseArray;
} catch (NimbusecException $exp) {
    $logger->error("[Nimbusec SPECIFIC ERROR] in {$exp->getFile()}: {$exp->getMessage()} at line {$exp->getLine()}");