Exemplo n.º 1
0
 public function loadServerTypes()
 {
     self::$_namecheapSSLTypesAdvanced = namecheapssl_getSslTypes(true);
     if (!self::$_namecheapSSLTypesAdvanced) {
         return false;
     } else {
         return true;
     }
 }
Exemplo n.º 2
0
function namecheapssl_CreateAccount($params)
{
    if (!namecheapssl_check_install()) {
        return "Namecheap SSL Module error. Addon Module Namecheap SSL Module Addon hasn't been activated/upgraded. Please go to Setup - Addon Modules and perform activation/go to addon page.";
    }
    global $CONFIG;
    $_namecheapSSLTypes = namecheapssl_getSslTypes();
    if (!$_namecheapSSLTypes) {
        return 'Unable to retrieve list of supported certificate-types. Please try again in several minutes.';
    }
    $_fields = namecheapssl_getModuleConfigFields();
    $_webServerTypes = namecheapssl_getWebServerTypes();
    $sql = "SELECT id FROM tblsslorders WHERE serviceid='" . (int) $params['serviceid'] . "'";
    if (NcSql::sqlNumRows($sql)) {
        return "An SSL Order already exists for this order";
    }
    if (!empty($params["configoptions"]["Certificate Type"])) {
        $tblproducts_cert_type = $params["configoptions"]["Certificate Type"];
    } else {
        $tblproducts_cert_type = $params["configoption5"];
    }
    // certificate type labels are stored in product configuration
    // it equal to label of dropdownlist in product configuration
    $certtype = $_namecheapSSLTypes[$tblproducts_cert_type];
    if (empty($certtype)) {
        foreach ($_namecheapSSLTypes as $label => $nc_type) {
            if (strtolower($tblproducts_cert_type) == strtolower($label)) {
                $certtype = $nc_type;
                break;
            }
        }
    }
    if (empty($certtype)) {
        return "Undefined certificate type";
    }
    $cycles = array('Annually' => 1, 'Biennially' => 2, 'Triennially' => 3);
    $sql = "SELECT * FROM tblhosting WHERE id = '" . (int) $params['serviceid'] . "'";
    $service = NcSql::sql2row($sql);
    $certyears = !empty($cycles[$service['billingcycle']]) ? $cycles[$service['billingcycle']] : 1;
    // Certificate id equals to 0
    $certificateId = 0;
    // 1. Create record at WHMCS tblssorders table
    $queryData = array("userid" => $params["clientsdetails"]["userid"], "serviceid" => $params["serviceid"], "remoteid" => $certificateId, "module" => "namecheapssl", "certtype" => $certtype, "status" => _namecheapssl_getIncompleteStatus());
    $sslorderid = NcSql::insert('tblsslorders', $queryData);
    // 2. Create record at custom module table
    $queryData = array('id' => $sslorderid, 'user_id' => $params["clientsdetails"]["userid"], 'certificate_id' => $certificateId, 'type' => $certtype, 'period' => $certyears);
    NcSql::insert('mod_namecheapssl', $queryData);
    // 3. Send certificate welcome email
    //
    $sendWelcome = false;
    if (!empty($_POST) && !empty($_POST['vars']['products'][$params['serviceid']]) && !empty($_POST['vars']['products'][$params['serviceid']]['sendwelcome'])) {
        $sendWelcome = true;
    }
    if (empty($_POST['vars']['products'][$params['serviceid']])) {
        $sql = "SELECT autosetup FROM tblproducts WHERE id = '" . (int) $params['packageid'] . "' LIMIT 1";
        $product = NcSql::sql2row($sql);
        $sendWelcome = $product['autosetup'] == 'payment' || $product['autosetup'] == 'order';
    }
    if ($sendWelcome) {
        $sslconfigurationlink = $CONFIG["SystemURL"] . "/configuressl.php?cert=" . md5($sslorderid);
        $sslconfigurationlink = "<a href=\"{$sslconfigurationlink}\">{$sslconfigurationlink}</a>";
        sendMessage("SSL Certificate Configuration Required", $params["serviceid"], array("ssl_configuration_link" => $sslconfigurationlink));
    }
    namecheapssl_log('admin.create', 'admin_create', null, $params['serviceid']);
    return "success";
}