Hosting paket açımı sonrası otomatik ücretsiz ssl kurulum için gerekli hook dur. Hosting hizmetlerinde ücretsiz ssl sunan arkadaşlar için.

<?php
function auto_ssl($hostname, $access_hash, $action, $arguments) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "WHM root:" . preg_replace("'(r|n)'","", $access_hash)
    ));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, "https://$hostname:2087/cgi/letsencrypt-cpanel/letsencrypt.live.cgi?api=$action");
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arguments));
    $response = curl_exec($ch);
    if($response === false) {
        throw new Exception("SSL API Hata: " . curl_error($response));
    }
    switch(curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
        case 200:
        case 204:
            return $response;
            break;
        default:
            throw new Exception("SSL API Hata Kodu: " . $response);
    }
}
function autossl_async($hostname, $access_hash, $username) {
    return auto_ssl($hostname, $access_hash,
        "autossl_for_user_async", array("username" => $username, "retry" => "true"));
}
function ssl_hook_aftermodulecreate($vars) {
    if($vars["params"]["moduletype"] !== "cpanel") {
        return;
    }
    try {
        $username = $vars["params"]["username"];
        autossl_async(
            $vars["params"]["serverhostname"],
            $vars["params"]["serveraccesshash"],
            $vars["params"]["username"]);
        logActivity("SSL API Kurulum $username");
    } catch(Exception $e) {
        logActivity("SSL API Kurulum $username Hata: " . $e->getMessage());
    }
}
if(defined("WHMCS")) {
    add_hook("AfterModuleCreate", 1, "ssl_hook_aftermodulecreate");
}
?>