예제 #1
0
파일: hooks.php 프로젝트: OnApp/WHMCS-vCD
function AutoTerminateHook_OnAppvCD()
{
    if ($GLOBALS['CONFIG']['AutoTermination'] != 'on') {
        return;
    }
    /**
     * @var WHMCS_CRON $cron
     */
    global $cron;
    $moduleName = OnAppvCDModule::MODULE_NAME;
    /*
    Capsule::table( 'tblinvoices' )
       ->leftJoin( 'tblinvoiceitems', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' )
       ->leftJoin( 'tblhosting', 'tblhosting.id', '=', 'tblinvoiceitems.relid' )
       ->leftJoin( 'tblproducts', 'tblproducts.id', '=', 'tblhosting.packageid' )
       ->where( 'tblinvoices.status', 'Unpaid' )
       ->where( 'tblinvoiceitems.type', OnAppUsersNGModule::MODULE_NAME )
       ->where( 'tblhosting.domainstatus', 'Suspended' )
       ->whereRaw( 'NOW() > DATE_ADD( `tblinvoices`.`duedate`, INTERVAL `tblproducts`.`configoption6` DAY )' )
       ->select( 'tblhosting.id', 'tblhosting.userid' )
    	->groupBy( 'tblhosting.id' )
    	->get()
    ;
    */
    $qry = 'SELECT
				tblhosting.`id`,
				tblhosting.`userid`
			FROM
				tblinvoices
			LEFT JOIN tblinvoiceitems ON
				tblinvoiceitems.`invoiceid` = tblinvoices.`id`
			LEFT JOIN tblhosting ON
				tblhosting.`id` = tblinvoiceitems.`relid`
			LEFT JOIN tblproducts ON
				tblproducts.`id` = tblhosting.`packageid`
			WHERE
				tblinvoices.`status` = "Unpaid"
				AND tblinvoiceitems.`type` = "@moduleName"
				AND tblhosting.`domainstatus` = "Suspended"
				AND NOW() > DATE_ADD( tblinvoices.`duedate`, INTERVAL tblproducts.`configoption6` DAY )
			GROUP BY
				tblhosting.`id`';
    // todo check
    $qry = str_replace('@moduleName', $moduleName, $qry);
    $result = full_query($qry);
    if (!function_exists('serverterminateaccount')) {
        $path = dirname(dirname(dirname(__DIR__))) . '/includes/';
        require_once $path . 'modulefunctions.php';
    }
    $cnt = 0;
    echo 'Starting Processing ' . $moduleName . ' Terminations', PHP_EOL;
    while ($data = mysql_fetch_assoc($result)) {
        ServerTerminateAccount($data['id']);
        echo ' - terminate service ID ', $data['id'], ', user ID ', $data['userid'], PHP_EOL;
        ++$cnt;
    }
    echo ' - Processed ', $cnt, ' Terminations', PHP_EOL;
    $cron->emailLog($cnt . ' ' . $moduleName . ' Services Terminated');
}
예제 #2
0
                $companyname = $data['companyname'];
                $module = $data['servertype'];
                $client = $firstname . " " . $lastname;
                if ($companyname) {
                    $client .= " (" . $companyname . ")";
                }
                if ($module) {
                    if (!isValidforPath($module)) {
                        exit("Invalid Server Module Name");
                    }
                    $modulepath = ROOTDIR . "/modules/servers/" . $module . "/" . $module . ".php";
                    if (file_exists($modulepath)) {
                        require_once $modulepath;
                    }
                }
                $result = ServerTerminateAccount($serviceid);
                if ($result != "success") {
                    $result = "Failed: " . $result;
                } else {
                    $result = "Successful!";
                }
                echo "<li>" . $client . " - " . $package . " (" . $domain . ") - " . $result . "</li>";
            }
            echo "\n</ul>\n<p><b>" . $aInt->lang("utilitiesresolvercheck", "terminatingacctsdone") . "</b><br />" . $aInt->lang("utilitiesresolvercheck", "terminatingacctsdonedesc") . "</p>";
        }
    }
}
$content = ob_get_contents();
ob_end_clean();
$aInt->content = $content;
$aInt->jquerycode = $jquerycode;
예제 #3
0
    $result = ServerSuspendAccount($id, $suspreason);
    wSetCookie("ModCmdResult", $result);
    if ($result == "success" && $suspemail == "true") {
        sendMessage("Service Suspension Notification", $id);
    }
    redir("userid=" . $userid . "&id=" . $id . "&act=suspend&ajaxupdate=1");
}
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");
}
예제 #4
0
function AutoTerminateHook_OnAppElasticUsers()
{
    global $CONFIG, $cron;
    if ($CONFIG['AutoTermination'] != 'on') {
        return;
    }
    $qry = 'SELECT
				tblhosting.`id`,
				tblhosting.`userid`
			FROM
				tblinvoices
			LEFT JOIN tblinvoiceitems ON
				tblinvoiceitems.`invoiceid` = tblinvoices.`id`
			LEFT JOIN tblhosting ON
				tblhosting.`id` = tblinvoiceitems.`relid`
			WHERE
				tblinvoices.`status` = "Unpaid"
				AND tblinvoiceitems.`type` = "OnAppElasticUsers"
				AND tblhosting.`domainstatus` = "Suspended"
				AND NOW() > DATE_ADD( tblinvoices.`duedate`, INTERVAL :days DAY )
			GROUP BY
				tblhosting.`id`';
    $qry = str_replace(':days', $CONFIG['AutoTerminationDays'], $qry);
    $result = full_query($qry);
    if (!function_exists('serverterminateaccount')) {
        $path = dirname(dirname(dirname(__DIR__))) . '/includes/';
        require_once $path . 'modulefunctions.php';
    }
    $cnt = 0;
    echo 'Starting Processing OnApp OnAppElasticUsers Terminations', PHP_EOL;
    while ($data = mysql_fetch_assoc($result)) {
        ServerTerminateAccount($data['id']);
        echo ' - terminate service ID ', $data['id'], ', user ID ', $data['userid'], PHP_EOL;
        ++$cnt;
    }
    echo ' - Processed ', $cnt, ' Terminations', PHP_EOL;
    $cron->emailLog($cnt . ' OnApp OnAppElasticUsers Services Terminated');
}
예제 #5
0
<?php

/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ 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("ServerTerminateAccount")) {
    require ROOTDIR . "/includes/modulefunctions.php";
}
$result = select_query("tblhosting", "packageid", array("id" => $_POST['accountid']));
$data = mysql_fetch_array($result);
$packageid = $data['packageid'];
$result = ServerTerminateAccount($_POST['accountid']);
if ($result == "success") {
    $apiresults = array("result" => "success");
    return 1;
}
$apiresults = array("result" => "error", "message" => $result);
예제 #6
0
function changeOrderStatus($orderid, $status)
{
    if (!$orderid) {
        return false;
    }
    $orderid = (int) $orderid;
    if ($status == "Cancelled") {
        run_hook("CancelOrder", array("orderid" => $orderid));
    } else {
        if ($status == "Fraud") {
            run_hook("FraudOrder", array("orderid" => $orderid));
        } else {
            if ($status == "Pending") {
                run_hook("PendingOrder", array("orderid" => $orderid));
            }
        }
    }
    update_query("tblorders", array("status" => $status), array("id" => $orderid));
    if ($status == "Cancelled" || $status == "Fraud") {
        $result = select_query("tblhosting", "tblhosting.id,tblhosting.domainstatus,tblproducts.servertype,tblhosting.packageid,tblproducts.stockcontrol,tblproducts.qty", array("orderid" => $orderid), "", "", "", "tblproducts ON tblproducts.id=tblhosting.packageid");
        while ($data = mysql_fetch_array($result)) {
            $productid = $data['id'];
            $prodstatus = $data['domainstatus'];
            $module = $data['servertype'];
            $packageid = $data['packageid'];
            $stockcontrol = $data['stockcontrol'];
            $qty = $data['qty'];
            if ($module && ($prodstatus == "Active" || $prodstatus == "Suspended")) {
                logActivity("Running Module Terminate on Order Cancel");
                if (!isValidforPath($module)) {
                    exit("Invalid Server Module Name");
                }
                require_once ROOTDIR . ("/modules/servers/" . $module . "/" . $module . ".php");
                $moduleresult = ServerTerminateAccount($productid);
                if ($moduleresult == "success") {
                    update_query("tblhosting", array("domainstatus" => $status), array("id" => $productid));
                    if ($stockcontrol == "on") {
                        update_query("tblproducts", array("qty" => "+1"), array("id" => $packageid));
                    }
                }
            }
            update_query("tblhosting", array("domainstatus" => $status), array("id" => $productid));
            if ($stockcontrol == "on") {
                update_query("tblproducts", array("qty" => "+1"), array("id" => $packageid));
            }
        }
    } else {
        update_query("tblhosting", array("domainstatus" => $status), array("orderid" => $orderid));
    }
    update_query("tblhostingaddons", array("status" => $status), array("orderid" => $orderid));
    if ($status == "Pending") {
        $result = select_query("tbldomains", "id,type", array("orderid" => $orderid));
        while ($data = mysql_fetch_assoc($result)) {
            if ($data['type'] == "Transfer") {
                $status = "Pending Transfer";
            } else {
                $status = "Pending";
            }
            update_query("tbldomains", array("status" => $status), array("id" => $data['id']));
        }
    } else {
        update_query("tbldomains", array("status" => $status), array("orderid" => $orderid));
    }
    $result = select_query("tblorders", "userid,invoiceid", array("id" => $orderid));
    $data = mysql_fetch_array($result);
    $userid = $data['userid'];
    $invoiceid = $data['invoiceid'];
    if ($status == "Pending") {
        update_query("tblinvoices", array("status" => "Unpaid"), array("id" => $invoiceid, "status" => "Cancelled"));
    } else {
        update_query("tblinvoices", array("status" => "Cancelled"), array("id" => $invoiceid, "status" => "Unpaid"));
        run_hook("InvoiceCancelled", array("invoiceid" => $invoiceid));
    }
    logActivity("Order Status set to " . $status . " - Order ID: " . $orderid, $userid);
}