示例#1
0
function makeDomainPayment($func_domainid, $type = "")
{
    global $whmcs;
    $result = select_query("tbldomains", "", array("id" => $func_domainid));
    $data = mysql_fetch_array($result);
    $userid = $data['userid'];
    $orderid = $data['orderid'];
    $registrationperiod = $data['registrationperiod'];
    $registrationdate = $data['registrationdate'];
    $nextduedate = $data['nextduedate'];
    $recurringamount = $data['recurringamount'];
    $domain = $data['domain'];
    $paymentmethod = $data['paymentmethod'];
    $registrar = $data['registrar'];
    $status = $data['status'];
    $year = substr($nextduedate, 0, 4);
    $month = substr($nextduedate, 5, 2);
    $day = substr($nextduedate, 8, 2);
    $newnextduedate = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year + $registrationperiod));
    update_query("tbldomains", array("nextduedate" => $newnextduedate), array("id" => $func_domainid));
    $domaintype = substr($type, 6);
    $domainparts = explode(".", $domain, 2);
    $sld = $domainparts[0];
    $tld = $domainparts[1];
    $params = array();
    $params['domainid'] = $func_domainid;
    $params['sld'] = $sld;
    $params['tld'] = $tld;
    if (!function_exists("getRegistrarConfigOptions")) {
        require ROOTDIR . "/includes/registrarfunctions.php";
    }
    if ($domaintype == "Register" || $domaintype == "Transfer") {
        $result = select_query("tbldomainpricing", "autoreg", array("extension" => "." . $tld));
        $data = mysql_fetch_array($result);
        $autoreg = $data[0];
        if ($status == "Pending") {
            if (getNewClientAutoProvisionStatus($userid)) {
                if ($autoreg) {
                    update_query("tbldomains", array("registrar" => $autoreg), array("id" => $func_domainid));
                    $params['registrar'] = $autoreg;
                    if ($domaintype == "Register") {
                        logActivity("Running Automatic Domain Registration on Payment", $userid);
                        $result = RegRegisterDomain($params);
                        $emailmessage = "Domain Registration Confirmation";
                    } else {
                        if ($domaintype == "Transfer") {
                            logActivity("Running Automatic Domain Transfer on Payment", $userid);
                            $result = RegTransferDomain($params);
                            $emailmessage = "Domain Transfer Initiated";
                        }
                    }
                    $result = $result['error'];
                    if ($result) {
                        sendAdminMessage("Automatic Setup Failed", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_type" => $domaintype, "domain_name" => $domain, "error_msg" => $result), "account");
                        if ($whmcs->get_config("DomainToDoListEntries")) {
                            if ($domaintype == "Register") {
                                addToDoItem("Manual Domain Registration", "Client ID " . $userid . " has paid for the registration of domain " . $domain . " and the automated registration attempt has failed with the following error: " . $result);
                                return null;
                            }
                            if ($domaintype == "Transfer") {
                                addToDoItem("Manual Domain Transfer", "Client ID " . $userid . " has paid for the transfer of domain " . $domain . " and the automated transfer attempt has failed with the following error: " . $result);
                                return null;
                            }
                        }
                    } else {
                        sendMessage($emailmessage, $func_domainid);
                        sendAdminMessage("Automatic Setup Successful", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_type" => $domaintype, "domain_name" => $domain, "error_msg" => ""), "account");
                        return null;
                    }
                }
                if ($whmcs->get_config("DomainToDoListEntries")) {
                    if ($domaintype == "Register") {
                        addToDoItem("Manual Domain Registration", "Client ID " . $userid . " has paid for the registration of domain " . $domain);
                        return null;
                    }
                    if ($domaintype == "Transfer") {
                        addToDoItem("Manual Domain Transfer", "Client ID " . $userid . " has paid for the transfer of domain " . $domain);
                        return null;
                    }
                }
            } else {
                logActivity("Automatic Domain Registration on Payment Suppressed for New Client", $userid);
                return null;
            }
        }
        if ($autoreg) {
            logActivity("Automatic Domain Registration Suppressed as Domain Is Already Active", $userid);
            return null;
        }
    } else {
        if ($status != "Pending" && $status != "Cancelled" && $status != "Fraud") {
            if ($whmcs->get_config("AutoRenewDomainsonPayment") && $registrar) {
                if ($whmcs->get_config("FreeDomainAutoRenewRequiresProduct") && $recurringamount <= 0 && !get_query_val("tblhosting", "COUNT(*)", array("userid" => $userid, "domain" => $domain, "domainstatus" => "Active"))) {
                    logActivity("Surpressed Automatic Domain Renewal on Payment Due to Domain Being Free and having No Active Associated Product", $userid);
                    sendAdminNotification("account", "Free Domain Renewal Manual Action Required", "The domain " . $domain . " (ID: " . $func_domainid . ") was just invoiced for renewal and automatically marked paid due to it being free, but because no active Product/Service matching the domain was found in order to qualify for the free domain offer, the renewal has not been automatically submitted to the registrar.  You must login to review & process this renewal manually should it be desired.");
                    return null;
                }
                logActivity("Running Automatic Domain Renewal on Payment", $userid);
                $params['registrar'] = $registrar;
                $result = RegRenewDomain($params);
                $result = $result['error'];
                if ($result) {
                    sendAdminMessage("Domain Renewal Failed", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_name" => $domain, "error_msg" => $result), "account");
                    if ($whmcs->get_config("DomainToDoListEntries")) {
                        addToDoItem("Manual Domain Renewal", "Client ID " . $userid . " has paid for the renewal of domain " . $domain . " and the automated renewal attempt has failed with the following error: " . $result);
                        return null;
                    }
                } else {
                    sendMessage("Domain Renewal Confirmation", $func_domainid);
                    sendAdminMessage("Domain Renewal Successful", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_name" => $domain, "error_msg" => ""), "account");
                    return null;
                }
            }
            if ($whmcs->get_config("DomainToDoListEntries")) {
                addToDoItem("Manual Domain Renewal", "Client ID " . $userid . " has paid for the renewal of domain " . $domain);
            }
        }
    }
}
示例#2
0
 }
 if (!$oldlockstatus) {
     $oldlockstatus = $newlockstatus;
 }
 if ($newlockstatus != $oldlockstatus) {
     $params['lockenabled'] = $newlockstatus;
     $values = RegSaveRegistrarLock($params);
     if ($values['error']) {
         infoBox($aInt->lang("domains", "reglockfailed"), $values['error'], "error");
     } else {
         infoBox($aInt->lang("domains", "reglocksuccess"), $aInt->lang("domains", "reglockinfo"), "success");
     }
 }
 if ($regaction == "renew") {
     check_token("WHMCS.admin.default");
     $values = RegRenewDomain($params);
     wSetCookie("DomRenewRes", $values);
     redir("userid=" . $userid . "&id=" . $id . "&conf=renew");
     exit;
 }
 if ($regaction == "eppcode") {
     check_token("WHMCS.admin.default");
     $values = RegGetEPPCode($params);
     if ($values['error']) {
         infoBox($aInt->lang("domains", "eppfailed"), $values['error'], "error");
     } else {
         if ($values['eppcode']) {
             infoBox($aInt->lang("domains", "epprequest"), $_LANG['domaingeteppcodeis'] . " " . $values['eppcode']);
         } else {
             infoBox($aInt->lang("domains", "epprequest"), $_LANG['domaingeteppcodeemailconfirmation'], "success");
         }
示例#3
0
function acceptOrder($orderid, $vars = array())
{
    if (!$orderid) {
        return false;
    }
    if (!is_array($vars)) {
        $vars = array();
    }
    $errors = array();
    run_hook("AcceptOrder", array("orderid" => $orderid));
    $result = select_query("tblhosting", "", array("orderid" => $orderid, "domainstatus" => "Pending"));
    while ($data = mysql_fetch_array($result)) {
        $productid = $data['id'];
        $updateqry = array();
        if ($vars['products'][$productid]['server']) {
            $updateqry['server'] = $vars['products'][$productid]['server'];
        }
        if ($vars['products'][$productid]['username']) {
            $updateqry['username'] = $vars['products'][$productid]['username'];
        }
        if ($vars['products'][$productid]['password']) {
            $updateqry['password'] = encrypt($vars['products'][$productid]['password']);
        }
        if ($vars['api']['serverid']) {
            $updateqry['server'] = $vars['api']['serverid'];
        }
        if ($vars['api']['username']) {
            $updateqry['username'] = $vars['api']['username'];
        }
        if ($vars['api']['password']) {
            $updateqry['password'] = $vars['api']['password'];
        }
        if (count($updateqry)) {
            update_query("tblhosting", $updateqry, array("id" => $productid));
        }
        $result2 = select_query("tblhosting", "tblproducts.servertype,tblproducts.autosetup", array("tblhosting.id" => $productid), "", "", "", "tblproducts ON tblproducts.id=tblhosting.packageid");
        $data = mysql_fetch_array($result2);
        $module = $data['servertype'];
        $autosetup = $data['autosetup'];
        $autosetup = $autosetup ? true : false;
        $sendwelcome = $autosetup ? true : false;
        if (count($vars)) {
            $autosetup = $vars['products'][$productid]['runcreate'];
            $sendwelcome = $vars['products'][$productid]['sendwelcome'];
            if (isset($vars['api']['autosetup'])) {
                $autosetup = $vars['api']['autosetup'];
            }
            if (isset($vars['api']['sendemail'])) {
                $sendwelcome = $vars['api']['sendemail'];
            }
        }
        if ($autosetup) {
            if ($module) {
                logActivity("Running Module Create on Accept Pending Order");
                if (!isValidforPath($module)) {
                    exit("Invalid Server Module Name");
                }
                require_once ROOTDIR . ("/modules/servers/" . $module . "/" . $module . ".php");
                $moduleresult = ServerCreateAccount($productid);
                if ($moduleresult == "success") {
                    if ($sendwelcome) {
                        sendMessage("defaultnewacc", $productid);
                    }
                }
                $errors[] = $moduleresult;
            }
        }
        update_query("tblhosting", array("domainstatus" => "Active"), array("id" => $productid));
        if ($sendwelcome) {
            sendMessage("defaultnewacc", $productid);
        }
    }
    $result = select_query("tblhostingaddons", "", array("orderid" => $orderid, "status" => "Pending"));
    while ($data = mysql_fetch_array($result)) {
        $aid = $data['id'];
        $hostingid = $data['hostingid'];
        $addonid = $data['addonid'];
        if ($addonid) {
            $result2 = select_query("tbladdons", "", array("id" => $addonid));
            $data = mysql_fetch_array($result2);
            $welcomeemail = $data['welcomeemail'];
            $sendwelcome = $welcomeemail ? true : false;
            if (count($vars)) {
                $sendwelcome = $vars['addons'][$aid]['sendwelcome'];
            }
            if (isset($vars['api']['sendemail'])) {
                $sendwelcome = $vars['api']['sendemail'];
            }
            if ($welcomeemail && $sendwelcome) {
                $result3 = select_query("tblemailtemplates", "name", array("id" => $welcomeemail));
                $data = mysql_fetch_array($result3);
                $welcomeemailname = $data['name'];
                sendMessage($welcomeemailname, $hostingid);
            }
            if (!$userid) {
                $result3 = select_query("tblorders", "userid", array("id" => $orderid));
                $data = mysql_fetch_array($result3);
                $userid = $data['userid'];
            }
            run_hook("AddonActivation", array("id" => $aid, "userid" => $userid, "serviceid" => $hostingid, "addonid" => $addonid));
        }
    }
    update_query("tblhostingaddons", array("status" => "Active"), array("orderid" => $orderid, "status" => "Pending"));
    $result = select_query("tbldomains", "", array("orderid" => $orderid, "status" => "Pending"));
    while ($data = mysql_fetch_array($result)) {
        $domainid = $data['id'];
        $regtype = $data['type'];
        $domain = $data['domain'];
        $registrar = $data['registrar'];
        $emailmessage = $regtype == "Transfer" ? "Domain Transfer Initiated" : "Domain Registration Confirmation";
        if ($vars['domains'][$domainid]['registrar']) {
            $registrar = $vars['domains'][$domainid]['registrar'];
        }
        if ($vars['api']['registrar']) {
            $registrar = $vars['api']['registrar'];
        }
        if ($registrar) {
            update_query("tbldomains", array("registrar" => $registrar), array("id" => $domainid));
        }
        if ($vars['domains'][$domainid]['sendregistrar']) {
            $sendregistrar = "on";
        }
        if ($vars['domains'][$domainid]['sendemail']) {
            $sendemail = "on";
        }
        if (isset($vars['api']['sendregistrar'])) {
            $sendregistrar = $vars['api']['sendregistrar'];
        }
        if (isset($vars['api']['sendemail'])) {
            $sendemail = $vars['api']['sendemail'];
        }
        if ($sendregistrar && $registrar) {
            $params = array();
            $params['domainid'] = $domainid;
            $moduleresult = $regtype == "Transfer" ? RegTransferDomain($params) : RegRegisterDomain($params);
            if (!$moduleresult['error']) {
                if ($sendemail) {
                    sendMessage($emailmessage, $domainid);
                }
            }
            $errors[] = $moduleresult['error'];
        }
        update_query("tbldomains", array("status" => "Active"), array("id" => $domainid, "status" => "Pending"));
        if ($sendemail) {
            sendMessage($emailmessage, $domainid);
        }
    }
    if (is_array($vars['renewals'])) {
        foreach ($vars['renewals'] as $domainid => $options) {
            if ($vars['renewals'][$domainid]['sendregistrar']) {
                $sendregistrar = "on";
            }
            if ($vars['renewals'][$domainid]['sendemail']) {
                $sendemail = "on";
            }
            if ($sendregistrar) {
                $params = array();
                $params['domainid'] = $domainid;
                $moduleresult = RegRenewDomain($params);
                if ($moduleresult['error']) {
                    $errors[] = $moduleresult['error'];
                    continue;
                }
                if ($sendemail) {
                    sendMessage("Domain Renewal Confirmation", $domainid);
                    continue;
                }
                continue;
            }
            if ($sendemail) {
                sendMessage("Domain Renewal Confirmation", $domainid);
                continue;
            }
        }
    }
    $result = select_query("tblorders", "userid,promovalue", array("id" => $orderid));
    $data = mysql_fetch_array($result);
    $userid = $data['userid'];
    $promovalue = $data['promovalue'];
    if (substr($promovalue, 0, 2) == "DR") {
        if ($vars['domains'][$domainid]['sendregistrar']) {
            $sendregistrar = "on";
        }
        if (isset($vars['api']['autosetup'])) {
            $sendregistrar = $vars['api']['autosetup'];
        }
        if ($sendregistrar) {
            $params = array();
            $params['domainid'] = $domainid;
            $moduleresult = RegRenewDomain($params);
            if ($moduleresult['error']) {
                $errors[] = $moduleresult['error'];
            } else {
                if ($sendemail) {
                    sendMessage("Domain Renewal Confirmation", $domainid);
                }
            }
        } else {
            if ($sendemail) {
                sendMessage("Domain Renewal Confirmation", $domainid);
            }
        }
    }
    update_query("tblupgrades", array("status" => "Completed"), array("orderid" => $orderid));
    if (!count($errors)) {
        update_query("tblorders", array("status" => "Active"), array("id" => $orderid));
        logActivity("Order Accepted - Order ID: " . $orderid, $userid);
    }
    return $errors;
}