Example #1
0
function doUpgrade($upgradeid)
{
    $result = select_query("tblupgrades", "", array("id" => $upgradeid));
    $data = mysql_fetch_array($result);
    $orderid = $data['orderid'];
    $type = $data['type'];
    $relid = $data['relid'];
    $originalvalue = $data['originalvalue'];
    $newvalue = $data['newvalue'];
    $upgradeamount = $data['amount'];
    $recurringchange = $data['recurringchange'];
    $result = select_query("tblorders", "promocode", array("id" => $orderid));
    $data = mysql_fetch_array($result);
    $promocode = $data['promocode'];
    if ($type == "package") {
        $newvalue = explode(",", $newvalue);
        $newpackageid = $newvalue[0];
        $newbillingcycle = $newvalue[1];
        $changevalue = "amount";
        if ($newbillingcycle == "free") {
            $newbillingcycle = "Free Account";
        } else {
            if ($newbillingcycle == "onetime") {
                $newbillingcycle = "One Time";
                $changevalue = "firstpaymentamount";
                $recurringchange = $upgradeamount;
            } else {
                if ($newbillingcycle == "monthly") {
                    $newbillingcycle = "Monthly";
                } else {
                    if ($newbillingcycle == "quarterly") {
                        $newbillingcycle = "Quarterly";
                    } else {
                        if ($newbillingcycle == "semiannually") {
                            $newbillingcycle = "Semi-Annually";
                        } else {
                            if ($newbillingcycle == "annually") {
                                $newbillingcycle = "Annually";
                            } else {
                                if ($newbillingcycle == "biennially") {
                                    $newbillingcycle = "Biennially";
                                } else {
                                    if ($newbillingcycle == "triennially") {
                                        $newbillingcycle = "Triennially";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $result = select_query("tblhosting", "billingcycle", array("id" => $relid));
        $data = mysql_fetch_array($result);
        $billingcycle = $data['billingcycle'];
        if ($billingcycle == "Free Account") {
            $newnextdue = getInvoicePayUntilDate(date("Y-m-d"), $newbillingcycle, true);
            update_query("tblhosting", array("nextduedate" => $newnextdue, "nextinvoicedate" => $newnextdue), array("id" => $relid));
        }
        if (!function_exists("migrateCustomFieldsBetweenProducts")) {
            require ROOTDIR . "/includes/customfieldfunctions.php";
        }
        migrateCustomFieldsBetweenProducts($relid, $newpackageid);
        update_query("tblhosting", array("packageid" => $newpackageid, "billingcycle" => $newbillingcycle, "" . $changevalue => "+=" . $recurringchange), array("id" => $relid));
        $result = full_query("SELECT tblinvoiceitems.id,tblinvoiceitems.invoiceid FROM tblinvoices INNER JOIN tblinvoiceitems ON tblinvoiceitems.invoiceid=tblinvoices.id INNER JOIN tblhosting ON tblhosting.id=tblinvoiceitems.relid WHERE tblinvoices.status='Unpaid' AND tblinvoiceitems.type='Hosting' AND tblhosting.id=" . (int) $relid . " ORDER BY tblinvoiceitems.duedate DESC");
        $data = mysql_fetch_array($result);
        $invitemid = $data['id'];
        $inviteminvoiceid = $data['invoiceid'];
        if ($invitemid) {
            update_query("tblinvoices", array("status" => "Cancelled"), array("id" => $inviteminvoiceid));
            update_query("tblinvoiceitems", array("duedate" => "0000-00-00"), array("id" => $invitemid));
            full_query("UPDATE tblhosting SET nextinvoicedate=nextduedate WHERE id=" . (int) $relid);
        }
        if (!function_exists("getCartConfigOptions")) {
            require ROOTDIR . "/includes/configoptionsfunctions.php";
        }
        $configoptions = getCartConfigOptions($newpackageid, "", $newbillingcycle);
        foreach ($configoptions as $configoption) {
            $result = select_query("tblhostingconfigoptions", "COUNT(*)", array("relid" => $relid, "configid" => $configoption['id']));
            $data = mysql_fetch_array($result);
            if (!$data[0]) {
                insert_query("tblhostingconfigoptions", array("relid" => $relid, "configid" => $configoption['id'], "optionid" => $configoption['selectedvalue']));
                continue;
            }
        }
        run_hook("AfterProductUpgrade", array("upgradeid" => $upgradeid));
    } else {
        if ($type == "configoptions") {
            $tempvalue = explode("=>", $originalvalue);
            $configid = $tempvalue[0];
            $result = select_query("tblproductconfigoptions", "", array("id" => $configid));
            $data = mysql_fetch_array($result);
            $optiontype = $data['optiontype'];
            $result = select_query("tblhostingconfigoptions", "COUNT(*)", array("relid" => $relid, "configid" => $configid));
            $data = mysql_fetch_array($result);
            if (!$data[0]) {
                insert_query("tblhostingconfigoptions", array("relid" => $relid, "configid" => $configid));
            }
            if ($optiontype == 1 || $optiontype == 2) {
                update_query("tblhostingconfigoptions", array("optionid" => $newvalue), array("relid" => $relid, "configid" => $configid));
            } else {
                if ($optiontype == 3 || $optiontype == 4) {
                    update_query("tblhostingconfigoptions", array("qty" => $newvalue), array("relid" => $relid, "configid" => $configid));
                }
            }
            update_query("tblhosting", array("amount" => "+=" . $recurringchange), array("id" => $relid));
            run_hook("AfterConfigOptionsUpgrade", array("upgradeid" => $upgradeid));
        }
    }
    if ($promocode) {
        $result = select_query("tblpromotions", "id,type,recurring,value", array("code" => $promocode));
        $data = mysql_fetch_array($result);
        $promoid = $data[0];
        $promotype = $data[1];
        $promorecurring = $data[2];
        $promovalue = $data[3];
        if ($promorecurring) {
            $recurringamount = recalcRecurringProductPrice($relid);
            if ($promotype == "Percentage") {
                $discount = $recurringamount * ($promovalue / 100);
                $recurringamount = $recurringamount - $discount;
            } else {
                $recurringamount = $recurringamount < $promovalue ? "0" : $recurringamount - $promovalue;
            }
            update_query("tblhosting", array("amount" => $recurringamount, "promoid" => $promoid), array("id" => $relid));
        } else {
            update_query("tblhosting", array("promoid" => "0"), array("id" => $relid));
        }
    } else {
        update_query("tblhosting", array("promoid" => "0"), array("id" => $relid));
    }
    if ($type == "package" || $type == "configoptions") {
        $data = get_query_vals("tblhosting", "userid,packageid", array("id" => $relid));
        $userid = $data['userid'];
        $pid = $data['packageid'];
        $result = select_query("tblproducts", "servertype,upgradeemail", array("id" => $pid));
        $data = mysql_fetch_array($result);
        $servertype = $data['servertype'];
        $upgradeemail = $data['upgradeemail'];
        if ($servertype) {
            if (!function_exists("getModuleType")) {
                require dirname(__FILE__) . "/modulefunctions.php";
            }
            $result = ServerChangePackage($relid);
            if ($result != "success") {
                logActivity("Automatic Product/Service Upgrade Failed - Service ID: " . $relid, $userid);
            } else {
                logActivity("Automatic Product/Service Upgrade Successful - Service ID: " . $relid, $userid);
                if ($upgradeemail) {
                    $result = select_query("tblemailtemplates", "name", array("id" => $upgradeemail));
                    $data = mysql_fetch_array($result);
                    $emailtplname = $data[0];
                    sendMessage($emailtplname, $relid);
                }
            }
        } else {
            insert_query("tbltodolist", array("date" => "now()", "title" => "Manual Upgrade Required", "description" => "Manual Upgrade Required for Service ID: " . $relid, "admin" => "", "status" => "Pending", "duedate" => date("Y-m-d")));
        }
    }
    update_query("tblupgrades", array("status" => "Completed"), array("id" => $upgradeid));
}
Example #2
0
}
if ($modop == "unsuspend") {
    check_token("WHMCS.admin.default");
    $result = ServerUnsuspendAccount($id);
    wSetCookie("ModCmdResult", $result);
    redir("userid=" . $userid . "&id=" . $id . "&act=unsuspend&ajaxupdate=1");
}
if ($modop == "terminate") {
    check_token("WHMCS.admin.default");
    $result = ServerTerminateAccount($id);
    wSetCookie("ModCmdResult", $result);
    redir("userid=" . $userid . "&id=" . $id . "&act=terminate&ajaxupdate=1");
}
if ($modop == "changepackage") {
    check_token("WHMCS.admin.default");
    $result = ServerChangePackage($id);
    wSetCookie("ModCmdResult", $result);
    redir("userid=" . $userid . "&id=" . $id . "&act=updown&ajaxupdate=1");
}
if ($modop == "changepw") {
    check_token("WHMCS.admin.default");
    $result = ServerChangePassword($id);
    wSetCookie("ModCmdResult", $result);
    redir("userid=" . $userid . "&id=" . $id . "&act=pwchange&ajaxupdate=1");
}
if ($modop == "custom") {
    check_token("WHMCS.admin.default");
    $result = ServerCustomFunction($id, $ac);
    if (substr($result, 0, 9) == "redirect|") {
        exit($result);
    }
Example #3
0
 }
 if ($massterminate) {
     checkPermission("Perform Server Operations");
     foreach ($selproducts as $serviceid) {
         $modresult = ServerTerminateAccount($serviceid);
         if ($modresult != "success") {
             $moduleresults[] = "Service ID " . $serviceid . ": " . $modresult;
             continue;
         }
         $moduleresults[] = "Service ID " . $serviceid . ": " . $aInt->lang("services", "terminatesuccess");
     }
 }
 if ($masschangepackage) {
     checkPermission("Perform Server Operations");
     foreach ($selproducts as $serviceid) {
         $modresult = ServerChangePackage($serviceid);
         if ($modresult != "success") {
             $moduleresults[] = "Service ID " . $serviceid . ": " . $modresult;
             continue;
         }
         $moduleresults[] = "Service ID " . $serviceid . ": " . $aInt->lang("services", "updownsuccess");
     }
 }
 if ($masschangepw) {
     checkPermission("Perform Server Operations");
     foreach ($selproducts as $serviceid) {
         $modresult = ServerChangePassword($serviceid);
         if ($modresult != "success") {
             $moduleresults[] = "Service ID " . $serviceid . ": " . $modresult;
             continue;
         }