Ejemplo n.º 1
0
    echo ")</td></tr>";
}
echo "<tr><td class=\"fieldlabel\">";
echo $aInt->lang("orders", "sendconfirmation");
echo "</td><td class=\"fieldarea\"><input type=\"checkbox\" name=\"sendregisterconfirm\" checked /> ";
echo $aInt->lang("domains", "sendregisterconfirm");
echo "</td></tr>\n</table>\n\n";
if ($action == "do") {
    $i = 1;
    while ($i <= 5) {
        $params["ns" . $i] = $_POST["ns" . $i];
        ++$i;
    }
    $params['transfersecret'] = $_POST['transfersecret'];
    if (!$ac) {
        $result = RegRegisterDomain($params);
    } else {
        $result = RegTransferDomain($params);
    }
    if ($result['error']) {
        infoBox($aInt->lang("global", "erroroccurred"), $result['error']);
        echo $infobox;
    } else {
        if (!$ac) {
            infoBox($aInt->lang("global", "success"), $aInt->lang("domains", "regsuccess"));
        } else {
            infoBox($aInt->lang("global", "success"), $aInt->lang("domains", "transuccess"));
        }
        echo "<br />" . $infobox;
        echo "\n<p align=\"center\"><input type=\"button\" value=\"";
        echo $aInt->lang("global", "continue");
Ejemplo n.º 2
0
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
if (!defined("WHMCS")) {
    exit("This file cannot be accessed directly");
}
if (!function_exists("RegRegisterDomain")) {
    require ROOTDIR . "/includes/registrarfunctions.php";
}
if ($domainid) {
    $result = select_query("tbldomains", "id", array("id" => $domainid));
} else {
    $result = select_query("tbldomains", "id", array("domain" => $domain));
}
$data = mysql_fetch_array($result);
$domainid = $data[0];
if (!$domainid) {
    $apiresults = array("result" => "error", "message" => "Domain Not Found");
    return false;
}
$params = array("domainid" => $domainid);
$values = RegRegisterDomain($params);
if ($values['error']) {
    $apiresults = array("result" => "error", "message" => "Registrar Error Message", "error" => $values['error']);
    return false;
}
$apiresults = array_merge(array("result" => "success"), $values);
Ejemplo n.º 3
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);
            }
        }
    }
}
function domaincloud_output($vars)
{
    require_once "config.php";
    $uid = isset($_REQUEST['userid']) ? $_REQUEST['userid'] : "";
    $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : "";
    $domainid = isset($_REQUEST['domainid']) ? $_REQUEST['domainid'] : "";
    $document_download = isset($_REQUEST['dl']) ? $_REQUEST['dl'] : "";
    $document_name = isset($_REQUEST['doc_name']) ? $_REQUEST['doc_name'] : "";
    $domainname = isset($_POST["domainname"]) ? $_POST["domainname"] : "";
    $domain_status = isset($_POST["domain_status"]) ? $_POST["domain_status"] : "";
    $transfersecret = isset($_POST["transfersecret"]) ? $_POST["transfersecret"] : "";
    $current_date = date('Y-m-d');
    $aInt = new WHMCS_Admin();
    $name = "";
    $orderby = "id";
    $sort = "DESC";
    $pageObj = new WHMCS_Pagination($name, $orderby, $sort);
    $pageObj->digestCookieData();
    $domainsModel = new WHMCS_DomainDocuments($pageObj);
    ob_start();
    echo "\n    <a href=\"addonmodules.php?module=domaincloud\" style=\"text-decoration: none\">\n        <span style=\"background-color: #84B429; padding: 5px; color: #fff;\">\n            &larr;<i class=\"fa fa-home\"></i> Go to Dashboard\n        </span>\n    </a><br /><br />";
    echo $aInt->Tabs(array($aInt->lang("global", "searchfilter")), true) . "\n    <div id=\"tab0box\" class=\"tabbox\" style=\"display: block;\">\n        <div id=\"tab_content\">\n            <form action=\"addonmodules.php?module=domaincloud\" method=\"post\">\n                <table class=\"form\" width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"3\">\n                    <tbody>\n                        <tr>\n                            <td width=\"15%\" class=\"fieldlabel\">Domain Name</td>\n                            <td class=\"fieldarea\"><input type=\"text\" name=\"domainname\" size=\"30\" value=\"\"></td>\n                        </tr>\n                    </tbody>\n                </table>\n                <p align=\"center\"><input type=\"submit\" id=\"search-clients\" value=\"Search\" class=\"button\"></p>\n            </form>\n        </div>\n    </div>\n    <br />\n    <script type=\"text/javascript\">\n        \$(document).ready(function() {\n            \$(\".tabbox\").css(\"display\",\"none\");\n            var selectedTab;\n            \$(\".tab\").click(function(){\n                var elid = \$(this).attr(\"id\");\n                \$(\".tab\").removeClass(\"tabselected\");\n                \$(\"#\"+elid).addClass(\"tabselected\");\n                \$(\".tabbox\").slideUp();\n                if (elid != selectedTab) {\n                    selectedTab = elid;\n                    \$(\"#\"+elid+\"box\").slideDown();\n                } else {\n                    selectedTab = null;\n                    \$(\".tab\").removeClass(\"tabselected\");\n                }\n                \$(\"#tab\").val(elid.substr(3));\n            });\n        });\n    </script>\n    ";
    $criteria = array("domainname" => $domainname, "domainid" => $domainid);
    $section = new WHMCS_DomainCloudFunctions($domainid);
    $tbl = new WHMCS_AddonListTable($pageObj);
    $tbl->setColumns(array("checkall", "Domain", "Identity Document", "Legality Document", "Other Document", "Registration Date", "Special Action", "Domain Status", "Payment"));
    $domainsModel->execute($criteria);
    $numresults = $pageObj->getNumResults();
    $domainlist = $pageObj->getData();
    foreach ($domainlist as $dom) {
        $linkopen = "<a href=\"clientsdomains.php?userid=" . $dom['userid'] . "&id=" . $dom['id'] . "\">";
        $linkclose = "</a>";
        $actionlink = "<a href=\"addonmodules.php?module=domaincloudReseller&amp;userid=" . $dom['id'] . "&amp;action=generate_key\" style=\"text-decoration: none;\"><span class=\"label active\">Generate New Key <i class=\"fa fa-comment-o\"></i></span></a> " . ($dom['disabled'] ? "<a href=\"addonmodules.php?module=domaincloudReseller&amp;userid=" . $dom['id'] . "&amp;action=enable_api\" style=\"text-decoration: none;\"><span class=\"label upload\">Enable API <i class=\"fa fa-comment-o\"></i></span></a>" : "<a href=\"addonmodules.php?module=domaincloudReseller&amp;userid=" . $dom['id'] . "&amp;action=disable_api\" style=\"text-decoration: none;\"><span class=\"label closed\">Disable API <i class=\"fa fa-comment-o\"></i></span></a>");
        $tbl->addRow(array("<input type=\"checkbox\" name=\"selecteddomains[]\" value=\"" . $dom['id'] . "\" class=\"checkall\">", $linkopen . $dom['domain'] . $linkclose, ($dom['id_doc_storage_name'] ? "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=download_1&amp;domainid=" . $dom['id'] . "&amp;doc_name=" . $dom['id_doc_storage_name'] . "\" style=\"text-decoration: none;\"><span class=\"label check\">Manage <i class=\"fa fa-comment-o\"></i></span></a> &#124; " : "") . "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=upload_1&amp;domainid=" . $dom['id'] . "\" style=\"text-decoration: none;\"><span class=\"label upload\">Upload <i class=\"fa fa-upload\"></i></span></a>", ($dom['le_doc_storage_name'] ? "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=download_2&amp;domainid=" . $dom['id'] . "&amp;doc_name=" . $dom['le_doc_storage_name'] . "\" style=\"text-decoration: none;\"><span class=\"label check\">Manage <i class=\"fa fa-comment-o\"></i></span></a> &#124; " : "") . "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=upload_2&amp;domainid=" . $dom['id'] . "\" style=\"text-decoration: none;\"><span class=\"label upload\">Upload <i class=\"fa fa-upload\"></i></span></a>", ($dom['su_doc_storage_name'] ? "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=download_3&amp;domainid=" . $dom['id'] . "&amp;doc_name=" . $dom['su_doc_storage_name'] . "\" style=\"text-decoration: none;\"><span class=\"label check\">Manage <i class=\"fa fa-comment-o\"></i></span></a> &#124; " : "") . "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=upload_3&amp;domainid=" . $dom['id'] . "\" style=\"text-decoration: none;\"><span class=\"label upload\">Upload <i class=\"fa fa-upload\"></i></span></a>", $dom['registrationdate'], "<a href=\"addonmodules.php?module=domaincloud&amp;userid=" . $dom['userid'] . "&amp;a=transfer&amp;domainid=" . $dom['id'] . "\" style=\"text-decoration: none;\"><span class=\"label check\">Renew via Transfer</span></a>", $dom['domain_status'] == 3 ? "<span class=\"label active\">Approved</span>" : ($dom['domain_status'] == 2 ? "<span class=\"label pending\">Review</span>" : ($dom['domain_status'] == 1 ? "<span class=\"label closed\">Rejected</span>" : "")), $dom['status'] == 'Paid' ? "<span class=\"label active\">" . $dom['status'] . "</span>" : "<span class=\"label cancelled\">" . $dom['status'] . "</span>"));
    }
    echo $tbl->output("domaincloud");
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
    if ($uid && $action && $domainid) {
        $query = full_query("\n            SELECT t.*, m.domain AS coza_domain, m.id_doc_storage_name, m.le_doc_storage_name, m.su_doc_storage_name, m.domain_approval_date, m.domain_status\n                FROM tbldomains t\n                LEFT JOIN mod_domaincloudregistrar m ON t.id = m.domainid\n                WHERE t.id = " . $domainid . "\n            ");
        $rows = mysql_fetch_array($query);
        $domain = $rows['domain'];
        if ($_FILES["file"]["error"] > 0) {
            echo "Error: " . $_FILES["file"]["error"] . "<br>";
        } else {
            if ($_FILES["file"]["name"] != null) {
                $ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
                $filename = md5($uid . $domain . $action) . "." . $ext;
                move_uploaded_file($_FILES["file"]["tmp_name"], $upload_path . $filename);
                $domainparts = explode(".", $domain, 2);
                $config = getregistrarconfigoptions('domainku');
                $data = array("action" => 'UploadFile', "token" => $config['Token'], "authemail" => $config['AuthEmail'], "sld" => $domainparts[0], "tld" => $domainparts[1], "file" => '@' . $upload_path . $filename . ';filename=' . $filename . ';type=' . $_FILES['file']['type'], "user_action" => $action, "doc_type" => $_POST['doc_type']);
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $api_endpoint);
                curl_setopt($ch, CURLOPT_TIMEOUT, 0);
                curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
                curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HEADER, false);
                $output = curl_exec($ch);
                if ($output == false) {
                    $res = array("error" => curl_error($ch));
                } else {
                    $res = json_decode($output, true);
                }
                curl_close($ch);
                if (empty($res['error'])) {
                    $values = array("userid" => $uid, "domain" => $domain);
                    if ($action == "upload_1") {
                        $values["id_doc_storage_name"] = $filename;
                        $values["id_doc_type"] = $_POST["doc_type"];
                    }
                    if ($action == "upload_2") {
                        $values["le_doc_storage_name"] = $filename;
                        $values["le_doc_type"] = $_POST["doc_type"];
                    }
                    if ($action == "upload_3") {
                        $values["su_doc_storage_name"] = $filename;
                        $values["su_doc_type"] = $_POST["doc_type"];
                    }
                    if ($rows["coza_domain"] == $domain && $filename) {
                        $query = update_query("mod_domaincloudregistrar", $values, array("domainid" => $domainid));
                    } else {
                        $values['domainid'] = $domainid;
                        $values['domain_registration_date'] = $rows['registrationdate'];
                        $values['domain_status'] = "2";
                        $query = insert_query("mod_domaincloudregistrar", $values);
                    }
                    $query = update_query("tbldomains", array("registrar" => "domainku"), array("id" => $domainid));
                    redir("module=domaincloud");
                }
            }
        }
        if (strpos($action, 'upload') !== false) {
            echo $section->outputUploadSection($domain, $action);
        } elseif (strpos($action, 'dl') !== false) {
            $file = $upload_path . $document_name;
            if (file_exists($file)) {
                header('Content-Description: File Transfer');
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename=' . basename($file));
                header('Content-Transfer-Encoding: binary');
                header('Expires: 0');
                header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                header('Pragma: public');
                header('Content-Length: ' . filesize($file));
                ob_clean();
                flush();
                readfile($file);
                exit;
            }
        } elseif (strpos($action, 'download') !== false) {
            echo $section->outputDownloadSection($domain, $domainid, $uid, $document_name, $action, $domain_status);
            $file = $upload_path . $document_name;
            if ($rows["coza_domain"] == $domain && $domain_status != "") {
                $mvalues = array("domain_status" => $domain_status);
                $params = array();
                $params['userid'] = $uid;
                $params['domainid'] = $domainid;
                $domainparts = explode(".", $domain, 2);
                $params['sld'] = $domainparts[0];
                $params['tld'] = $domainparts[1];
                $params['regperiod'] = $rows['registrationperiod'];
                $params['registrar'] = $rows['registrar'];
                $params['regtype'] = $rows['type'];
                if ($domain_status == 3) {
                    if ($rows['type'] == 'Register') {
                        $result_epp = RegRegisterDomain($params);
                    } elseif ($rows['type'] == 'Transfer') {
                        $params['transfersecret'] = $rows['transfersecret'];
                        $result_epp = RegTransferDomain($params);
                    }
                    if (!$result_epp['error']) {
                        $mvalues['domain_approval_date'] = $current_date;
                        echo "\n                        <div class=\"infobox\">\n                            <strong><span class=\"title\">Registrar Status</span></strong><br />" . $result_epp['status'] . "\n                        </div>\n                        ";
                    } else {
                        $mvalues['domain_status'] = $rows['domain_status'];
                        echo "\n        \t\t\t\t<div class=\"infobox\">\n        \t\t\t\t\t<strong><span class=\"title\">Registrar Error</span></strong><br>" . $result_epp['error'] . "\n        \t\t\t\t</div>\n        \t\t\t\t";
                    }
                }
                $query = update_query("mod_domaincloudregistrar", $mvalues, array("domainid" => $domainid));
            }
        } elseif (strpos($action, 'transfer') !== false) {
            echo "\n            <form method=\"post\">\n                EPP Code: <input type=\"textbox\" name=\"transfersecret\" id=\"transfersecret\" value=\"\">\n                <input type=\"submit\" value=\"Submit Domain Renewal via Transfer\">\n            </form>";
            if (!empty($transfersecret)) {
                $params = array();
                $params['userid'] = $uid;
                $params['domainid'] = $rows['id'];
                $domainparts = explode(".", $domain, 2);
                $params['sld'] = $domainparts[0];
                $params['tld'] = $domainparts[1];
                $params['regperiod'] = $rows['registrationperiod'];
                $params['registrar'] = $rows['registrar'];
                $params['regtype'] = 'transfer';
                $params['transfersecret'] = $transfersecret;
                $result_epp = RegTransferDomain($params);
                if (!$result_epp['error']) {
                    # Set domain approval to 'Approved'.
                    $query = update_query("mod_domaincloudregistrar", array("domain_approval_date" => $current_date, "domain_status" => 3), array("domainid" => $rows['id']));
                    # Check domain status, if 'Pending Transfer' set it to 'Active'.
                    $query = update_query("tbldomains", array("status" => "Active"), array("domainid" => $rows['id'], "status" => "Pending Transfer"));
                    echo "\n                    <div class=\"infobox\">\n                        <strong><span class=\"title\">Registrar Status</span></strong><br />Command completed successfully.\n                    </div>\n                    ";
                } else {
                    echo "\n    \t\t\t\t<div class=\"infobox\">\n    \t\t\t\t\t<strong><span class=\"title\">Registrar Error</span></strong><br>" . $result_epp['error'] . "\n    \t\t\t\t</div>\n    \t\t\t\t";
                }
            }
        }
    }
}
Ejemplo n.º 5
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;
}