Beispiel #1
0
     }
 }
 $tplvars['tickets'] = $tickets;
 $invoiceids = explode(",", $invoiceids);
 foreach ($invoiceids as $k => $invoiceid) {
     if (!$invoiceid) {
         unset($invoiceids[$k]);
         continue;
     }
 }
 if (!function_exists("getGatewaysArray")) {
     require ROOTDIR . "/includes/gatewayfunctions.php";
 }
 $gateways = getGatewaysArray();
 $ticketinvoicesquery = !empty($ticketinvoicelinks) ? "(" . implode(" OR ", $ticketinvoicelinks) . ") OR " : "";
 $result = select_query("tblinvoices", "", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "')) OR id IN (" . db_build_in_array(db_escape_numarray($invoiceids)) . ")", "id", "ASC");
 while ($data = mysql_fetch_array($result)) {
     $invoices[] = array("id" => $data['id'], "date" => fromMySQLDate($data['date'], 0, 1), "duedate" => fromMySQLDate($data['duedate'], 0, 1), "datepaid" => fromMySQLDate($data['datepaid'], 0, 1), "total" => formatCurrency($data['total']), "paymentmethod" => $gateways[$data['paymentmethod']], "status" => $data['status'], "rawstatus" => strtolower($data['status']));
 }
 $tplvars['invoices'] = $invoices;
 $attachments = explode(",", $attachments);
 foreach ($attachments as $i => $attachment) {
     $attachment = substr($attachment, 7);
     if ($attachment) {
         $attachmentsarray[$i] = array("filename" => $attachment);
         continue;
     }
 }
 $tplvars['attachments'] = $attachmentsarray;
 $totaltimecount = 0;
 $i = 1;
Beispiel #2
0
function createUpgradeOrder($id, $ordernotes, $promocode, $paymentmethod)
{
    global $CONFIG;
    global $remote_ip;
    global $orderdescription;
    global $orderamount;
    if ($promocode && !$GLOBALS['qualifies']) {
        $promocode = "";
    }
    if ($promocode) {
        $result = select_query("tblpromotions", "upgradeconfig", array("code" => $promocode));
        $data = mysql_fetch_array($result);
        $upgradeconfig = $data['upgradeconfig'];
        $upgradeconfig = unserialize($upgradeconfig);
        $promo_type = $upgradeconfig['discounttype'];
        $promo_value = $upgradeconfig['value'];
        update_query("tblpromotions", array("uses" => "+1"), array("code" => $promocode));
    }
    $order_number = generateUniqueID();
    $orderid = insert_query("tblorders", array("ordernum" => $order_number, "userid" => $_SESSION['uid'], "date" => "now()", status => "Pending", "promocode" => $promocode, "promotype" => $promo_type, "promovalue" => $promo_value, "paymentmethod" => $paymentmethod, "ipaddress" => $remote_ip, "amount" => $orderamount, "notes" => $ordernotes));
    foreach ($_SESSION['upgradeids'] as $upgradeid) {
        update_query("tblupgrades", array("orderid" => $orderid), array("id" => $upgradeid));
    }
    sendMessage("Order Confirmation", $_SESSION['uid'], array("order_id" => $orderid, "order_number" => $order_number, "order_details" => $orderdescription));
    logActivity("Upgrade Order Placed - Order ID: " . $orderid);
    if (!function_exists("createInvoices")) {
        include ROOTDIR . "/includes/processinvoices.php";
    }
    $invoiceid = 0;
    $invoiceid = createInvoices($_SESSION['uid'], true);
    if ($invoiceid) {
        $result = select_query("tblinvoiceitems", "invoiceid", "type='Upgrade' AND relid IN (" . db_build_in_array(db_escape_numarray($_SESSION['upgradeids'])) . ")", "invoiceid", "DESC");
        $data = mysql_fetch_array($result);
        $invoiceid = $data['invoiceid'];
    }
    if ($CONFIG['OrderDaysGrace']) {
        $new_time = mktime(0, 0, 0, date("m"), date("d") + $CONFIG['OrderDaysGrace'], date("Y"));
        $duedate = date("Y-m-d", $new_time);
        update_query("tblinvoices", array("duedate" => $duedate), array("id" => $invoiceid));
    }
    if (!$CONFIG['NoInvoiceEmailOnOrder']) {
        sendMessage("Invoice Created", $invoiceid);
    }
    update_query("tblorders", array("invoiceid" => $invoiceid), array("id" => $orderid));
    $result = select_query("tblclients", "firstname, lastname, companyname, email, address1, address2, city, state, postcode, country, phonenumber, ip, host", array("id" => $_SESSION['uid']));
    $data = mysql_fetch_array($result);
    list($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, $ip, $host) = $data;
    $nicegatewayname = get_query_val("tblpaymentgateways", "value", array("gateway" => $paymentmethod, "setting" => "Name"));
    $ordertotal = get_query_val("tblinvoices", "total", array("id" => $invoiceid));
    $adminemailitems = "";
    if ($invoiceid) {
        $result = select_query("tblinvoiceitems", "description", "type='Upgrade' AND relid IN (" . db_build_in_array(db_escape_numarray($_SESSION['upgradeids'])) . ")", "invoiceid", "DESC");
        while ($invoicedata = mysql_fetch_assoc($result)) {
            $adminemailitems .= $invoicedata['description'] . "<br />";
        }
    } else {
        $adminemailitems .= "Upgrade/Downgrade";
    }
    sendAdminMessage("New Order Notification", array("order_id" => $orderid, "order_number" => $order_number, "order_date" => date("d/m/Y H:i:s"), "invoice_id" => $invoiceid, "order_payment_method" => $nicegatewayname, "order_total" => formatCurrency($ordertotal), "client_id" => $_SESSION['uid'], "client_first_name" => $firstname, "client_last_name" => $lastname, "client_email" => $email, "client_company_name" => $companyname, "client_address1" => $address1, "client_address2" => $address2, "client_city" => $city, "client_state" => $state, "client_postcode" => $postcode, "client_country" => $country, "client_phonenumber" => $phonenumber, "order_items" => $adminemailitems, "order_notes" => "", "client_ip" => $ip, "client_hostname" => $host), "account");
    return array("id" => $id, "orderid" => $orderid, "order_number" => $order_number, "invoiceid" => $invoiceid);
}
Beispiel #3
0
    }
    if ($page) {
        $userid .= "&page=" . $page;
    }
    redir("userid=" . $userid . "&filter=1");
}
if ($merge) {
    check_token("WHMCS.admin.default");
    if (count($selectedinvoices) < 2) {
        if ($page) {
            $userid .= "&page=" . $page;
        }
        redir("userid=" . $userid . "&mergeerr=1");
        exit;
    }
    $selectedinvoices = db_escape_numarray($selectedinvoices);
    sort($selectedinvoices);
    $endinvoiceid = end($selectedinvoices);
    update_query("tblinvoiceitems", array("invoiceid" => $endinvoiceid), "invoiceid IN (" . db_build_in_array($selectedinvoices) . ")");
    update_query("tblaccounts", array("invoiceid" => $endinvoiceid), "invoiceid IN (" . db_build_in_array($selectedinvoices) . ")");
    update_query("tblorders", array("invoiceid" => $endinvoiceid), "invoiceid IN (" . db_build_in_array($selectedinvoices) . ")");
    $result = select_query("tblinvoices", "SUM(credit)", "id IN (" . db_build_in_array($selectedinvoices) . ")");
    $data = mysql_fetch_array($result);
    $totalcredit = $data[0];
    update_query("tblinvoices", array("credit" => $totalcredit), array("id" => $endinvoiceid));
    unset($selectedinvoices[count($selectedinvoices) - 1]);
    delete_query("tblinvoices", "id IN (" . db_build_in_array($selectedinvoices) . ")");
    updateInvoiceTotal($endinvoiceid);
    logActivity("Merged Invoice IDs " . db_build_in_array($selectedinvoices) . (" to Invoice ID: " . $endinvoiceid), $userid);
    if ($page) {
        $userid .= "&page=" . $page;
Beispiel #4
0
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
define("CLIENTAREA", true);
require "init.php";
$pagetitle = $_LANG['bannedtitle'];
$breadcrumbnav = "<a href=\"index.php\">" . $_LANG['globalsystemname'] . "</a> > <a href=\"banned.php\">" . $_LANG['bannedtitle'] . "</a>";
$pageicon = "";
initialiseClientArea($pagetitle, $pageicon, $breadcrumbnav);
$remote_ip = $whmcs->get_user_ip();
$ip = explode(".", $remote_ip);
$ip = db_escape_numarray($ip);
$remote_ip1 = $ip[0] . "." . $ip[1] . "." . $ip[2] . ".*";
$remote_ip2 = $ip[0] . "." . $ip[1] . ".*.*";
$data = get_query_vals("tblbannedips", "", "ip='" . db_escape_string($remote_ip) . "' OR ip='" . db_escape_string($remote_ip1) . "' OR ip='" . db_escape_string($remote_ip2) . "'", "id", "DESC");
$id = $data['id'];
$reason = $data['reason'];
$expires = fromMySQLDate($data['expires'], true, true);
if (!$id) {
    redir("", "index.php");
}
$smartyvalues['ip'] = htmlspecialchars($remote_ip);
$smartyvalues['reason'] = $reason;
$smartyvalues['expires'] = $expires;
$templatefile = "banned";
outputClientArea($templatefile);
Beispiel #5
0
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
if (!defined("WHMCS")) {
    exit("This file cannot be accessed directly");
}
global $currency;
$currency = getCurrency();
$where = array();
if ($serviceid) {
    if (is_numeric($serviceid)) {
        $where[] = "hostingid=" . (int) $serviceid;
    } else {
        $serviceids = explode(",", $serviceid);
        $serviceids = db_build_in_array(db_escape_numarray($serviceids));
        if ($serviceids) {
            $where[] = "hostingid IN (" . $serviceids . ")";
        }
    }
}
if ($clientid) {
    $result = select_query("tblhosting", "", array("userid" => $clientid));
    $hostingids = array();
    while ($data = mysql_fetch_array($result)) {
        $hostingids[] = (int) $data['id'];
    }
    $where[] = "hostingid IN (" . db_build_in_array($hostingids) . ")";
}
if ($addonid) {
    $where[] = "addonid=" . (int) $addonid;
Beispiel #6
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
function createInvoices($func_userid = "", $noemails = "", $nocredit = "", $specificitems = "")
{
    global $whmcs;
    global $cron;
    global $CONFIG;
    global $_LANG;
    global $invoicecount;
    global $invoiceid;
    global $continuous_invoicing_active_only;
    $continvoicegen = $whmcs->get_config("ContinuousInvoiceGeneration");
    $invoicedate = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBefore'], date("Y")));
    $invoicedatemonthly = $CONFIG['CreateInvoiceDaysBeforeMonthly'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeMonthly'], date("Y"))) : $invoicedate;
    $invoicedatequarterly = $CONFIG['CreateInvoiceDaysBeforeQuarterly'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeQuarterly'], date("Y"))) : $invoicedate;
    $invoicedatesemiannually = $CONFIG['CreateInvoiceDaysBeforeSemiAnnually'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeSemiAnnually'], date("Y"))) : $invoicedate;
    $invoicedateannually = $CONFIG['CreateInvoiceDaysBeforeAnnually'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeAnnually'], date("Y"))) : $invoicedate;
    $invoicedatebiennially = $CONFIG['CreateInvoiceDaysBeforeBiennially'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeBiennially'], date("Y"))) : $invoicedate;
    $invoicedatetriennially = $CONFIG['CreateInvoiceDaysBeforeTriennially'] ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateInvoiceDaysBeforeTriennially'], date("Y"))) : $invoicedate;
    $domaininvoicedate = 0 < $whmcs->get_config("CreateDomainInvoiceDaysBefore") ? date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['CreateDomainInvoiceDaysBefore'], date("Y"))) : $invoicedate;
    $matchfield = $continvoicegen ? "nextinvoicedate" : "nextduedate";
    $statusfilter = "'Pending','Active'";
    if (!$continuous_invoicing_active_only) {
        $statusfilter .= ",'Suspended'";
    }
    $hostingquery = "paymentmethod!='' AND domainstatus IN (" . $statusfilter . ") AND billingcycle!='Free' AND billingcycle!='Free Account' AND nextduedate!='00000000' AND nextinvoicedate!='00000000' AND ((billingcycle='Monthly' AND " . $matchfield . "<='" . $invoicedatemonthly . ("') OR (billingcycle='Quarterly' AND " . $matchfield . "<='") . $invoicedatequarterly . ("') OR (billingcycle='Semi-Annually' AND " . $matchfield . "<='") . $invoicedatesemiannually . ("') OR (billingcycle='Annually' AND " . $matchfield . "<='") . $invoicedateannually . ("') OR (billingcycle='Biennially' AND " . $matchfield . "<='") . $invoicedatebiennially . ("') OR (billingcycle='Triennially' AND " . $matchfield . "<='") . $invoicedatetriennially . "') OR (billingcycle='One Time'))";
    $domainquery = "paymentmethod!='' AND (donotrenew='' OR `status`='Pending') AND `status` IN (" . $statusfilter . ") AND " . $matchfield . "<='" . $domaininvoicedate . "'";
    $hostingaddonsquery = "tblhostingaddons.paymentmethod!='' AND tblhostingaddons.billingcycle!='Free' AND tblhostingaddons.billingcycle!='Free Account' AND tblhostingaddons.status IN (" . $statusfilter . ") AND tblhostingaddons.nextduedate!='00000000' AND tblhostingaddons.nextinvoicedate!='00000000' AND ((tblhostingaddons.billingcycle='Monthly' AND tblhostingaddons." . $matchfield . "<='" . $invoicedatemonthly . ("') OR (tblhostingaddons.billingcycle='Quarterly' AND tblhostingaddons." . $matchfield . "<='") . $invoicedatequarterly . ("') OR (tblhostingaddons.billingcycle='Semi-Annually' AND tblhostingaddons." . $matchfield . "<='") . $invoicedatesemiannually . ("') OR (tblhostingaddons.billingcycle='Annually' AND tblhostingaddons." . $matchfield . "<='") . $invoicedateannually . ("') OR (tblhostingaddons.billingcycle='Biennially' AND tblhostingaddons." . $matchfield . "<='") . $invoicedatebiennially . ("') OR (tblhostingaddons.billingcycle='Triennially' AND tblhostingaddons." . $matchfield . "<='") . $invoicedatetriennially . "') OR (tblhostingaddons.billingcycle='One Time'))";
    $i = 0;
    $billableitemqry = "";
    if ($func_userid != "") {
        $hostingquery .= " AND userid=" . (int) $func_userid;
        $domainquery .= " AND userid=" . (int) $func_userid;
        $hostingaddonsquery .= " AND tblhosting.userid=" . (int) $func_userid;
        $billableitemqry = " AND userid=" . (int) $func_userid;
    }
    if (is_array($specificitems)) {
        $hostingquery = $domainquery = $hostingaddonsquery = "";
        if ($specificitems['products']) {
            $hostingquery .= "(id IN (" . db_build_in_array(db_escape_numarray($specificitems['products'])) . ") AND billingcycle!='Free' AND billingcycle!='Free Account')";
        }
        if ($specificitems['addons']) {
            $hostingaddonsquery .= "tblhostingaddons.id IN (" . db_build_in_array(db_escape_numarray($specificitems['addons'])) . ") AND tblhostingaddons.billingcycle!='Free' AND tblhostingaddons.billingcycle!='Free Account'";
        }
        if ($specificitems['domains']) {
            $domainquery .= "id IN (" . db_build_in_array(db_escape_numarray($specificitems['domains'])) . ")";
        }
    }
    $AddonsArray = $AddonSpecificIDs = array();
    if ($hostingquery) {
        $servicecount = 0;
        $cancellationreqids = array();
        $result = select_query("tblcancelrequests", "DISTINCT relid", "");
        while ($data = mysql_fetch_array($result)) {
            $cancellationreqids[] = $data[0];
        }
        $result = select_query("tblhosting", "tblhosting.id,tblhosting.userid,tblhosting.nextduedate,tblhosting.nextinvoicedate,tblhosting.billingcycle,tblhosting.regdate,tblhosting.firstpaymentamount,tblhosting.amount,tblhosting.domain,tblhosting.paymentmethod,tblhosting.packageid,tblhosting.promoid,tblhosting.domainstatus", $hostingquery, "domain", "ASC");
        $totalservicerows = mysql_num_rows($result);
        while ($data = mysql_fetch_array($result)) {
            $id = $serviceid = $data['id'];
            if (!in_array($serviceid, $cancellationreqids)) {
                $userid = $data['userid'];
                $nextduedate = $data[$matchfield];
                $billingcycle = $data['billingcycle'];
                $status = $data['domainstatus'];
                $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Hosting", "relid" => $serviceid, "duedate" => $nextduedate));
                $contblock = false;
                if (!$num_rows && $continvoicegen && $status == "Pending") {
                    $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Hosting", "relid" => $serviceid));
                    $contblock = true;
                }
                if ($num_rows == 0) {
                    $regdate = $data['regdate'];
                    $amount = $regdate == $nextduedate ? $data['firstpaymentamount'] : $data['amount'];
                    $domain = $data['domain'];
                    $paymentmethod = $data['paymentmethod'];
                    $pid = $data['packageid'];
                    $promoid = $data['promoid'];
                    $productdetails = getInvoiceProductDetails($id, $pid, $regdate, $nextduedate, $billingcycle, $domain);
                    $description = $productdetails['description'];
                    $tax = $productdetails['tax'];
                    $recurringcycles = $productdetails['recurringcycles'];
                    $recurringfinished = false;
                    if ($recurringcycles) {
                        $num_rows3 = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Hosting", "relid" => $id));
                        if ($recurringcycles <= $num_rows3) {
                            update_query("tblhosting", array("domainstatus" => "Completed"), array("id" => $id));
                            run_hook("ServiceRecurringCompleted", array("serviceid" => $id, "recurringinvoices" => $num_rows3));
                            $recurringfinished = true;
                        }
                    }
                    if (!$recurringfinished) {
                        $promovals = getInvoiceProductPromo($amount, $promoid, $userid, $id);
                        if (isset($promovals['description'])) {
                            $amount -= $promovals['amount'];
                        }
                        insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "Hosting", "relid" => $id, "description" => $description, "amount" => $amount, "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                        if (isset($promovals['description'])) {
                            insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "PromoHosting", "relid" => $id, "description" => $promovals['description'], "amount" => $promovals['amount'], "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                        }
                    }
                } else {
                    if (!$contblock && $continvoicegen && $billingcycle != "One Time") {
                        update_query("tblhosting", array("nextinvoicedate" => getInvoicePayUntilDate($nextduedate, $billingcycle, true)), array("id" => $id));
                    }
                }
            }
            if ($hostingaddonsquery) {
                $result3 = select_query("tblhostingaddons", "tblhostingaddons.*,tblhostingaddons.regdate AS addonregdate,tblhosting.userid,tblhosting.domain", $hostingaddonsquery . (" AND tblhostingaddons.hostingid='" . $id . "'"), "tblhostingaddons`.`name", "ASC", "", "tblhosting ON tblhosting.id=tblhostingaddons.hostingid");
                while ($data = mysql_fetch_array($result3)) {
                    $id = $data['id'];
                    $userid = $data['userid'];
                    $nextduedate = $data[$matchfield];
                    $status = $data['status'];
                    $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Addon", "relid" => $id, "duedate" => $nextduedate));
                    $contblock = false;
                    if (!$num_rows && $continvoicegen && $status == "Pending") {
                        $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Addon", "relid" => $id));
                        $contblock = true;
                    }
                    if ($num_rows == 0) {
                        $hostingid = $serviceid = $data['hostingid'];
                        $addonid = $data['addonid'];
                        $domain = $data['domain'];
                        $regdate = $data['addonregdate'];
                        $name = $data['name'];
                        $setupfee = $data['setupfee'];
                        $amount = $data['recurring'];
                        $paymentmethod = $data['paymentmethod'];
                        $billingcycle = $data['billingcycle'];
                        $tax = $data['tax'];
                        if (!$name) {
                            if (isset($AddonsArray[$addonid])) {
                                $name = $AddonsArray[$addonid];
                            } else {
                                $AddonsArray[$addonid] = $name = get_query_val("tbladdons", "name", array("id" => $addonid));
                            }
                        }
                        $tax = $CONFIG['TaxEnabled'] && $tax ? "1" : "0";
                        $invoicepayuntildate = getInvoicePayUntilDate($nextduedate, $billingcycle);
                        $paydates = "";
                        if ($billingcycle != "One Time") {
                            $paydates = "(" . fromMySQLDate($nextduedate) . " - " . fromMySQLDate($invoicepayuntildate) . ")";
                        }
                        $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Addon", "relid" => $id, "duedate" => $nextduedate));
                        if ($num_rows == 0) {
                            if (!in_array($serviceid, $cancellationreqids)) {
                                if ($regdate == $nextduedate) {
                                    $amount = $amount + $setupfee;
                                }
                                if ($domain) {
                                    $domain = "(" . $domain . ") ";
                                }
                                $description = $_LANG['orderaddon'] . (" " . $domain . "- " . $name . " " . $paydates);
                                insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "Addon", "relid" => $id, "description" => $description, "amount" => $amount, "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                                $AddonSpecificIDs[] = $id;
                            }
                        }
                        if (!$contblock && $continvoicegen) {
                            update_query("tblhostingaddons", array("nextinvoicedate" => getInvoicePayUntilDate($nextduedate, $billingcycle, true)), array("id" => $id));
                        }
                    }
                }
            }
            ++$servicecount;
            if (is_object($cron)) {
                $cron->logActivityDebug("Invoicing Loop Service ID " . $serviceid . " - " . $servicecount . " of " . $totalservicerows);
            }
        }
    }
    if ($hostingaddonsquery) {
        $addoncount = 0;
        if (count($AddonSpecificIDs)) {
            $hostingaddonsquery .= " AND tblhostingaddons.id NOT IN (" . db_build_in_array(db_escape_numarray($AddonSpecificIDs)) . ")";
        }
        $result = select_query("tblhostingaddons", "tblhostingaddons.*,tblhostingaddons.regdate AS addonregdate,tblhosting.userid,tblhosting.domain", $hostingaddonsquery, "tblhostingaddons`.`name", "ASC", "", "tblhosting ON tblhosting.id=tblhostingaddons.hostingid");
        $totaladdonrows = mysql_num_rows($result);
        while ($data = mysql_fetch_array($result)) {
            $id = $data['id'];
            $userid = $data['userid'];
            $nextduedate = $data[$matchfield];
            $status = $data['status'];
            $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Addon", "relid" => $id, "duedate" => $nextduedate));
            $contblock = false;
            if (!$num_rows && $continvoicegen && $status == "Pending") {
                $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("userid" => $userid, "type" => "Addon", "relid" => $id));
                $contblock = true;
            }
            if ($num_rows == 0) {
                $hostingid = $serviceid = $data['hostingid'];
                $addonid = $data['addonid'];
                $domain = $data['domain'];
                $regdate = $data['addonregdate'];
                $name = $data['name'];
                $setupfee = $data['setupfee'];
                $amount = $data['recurring'];
                $paymentmethod = $data['paymentmethod'];
                $billingcycle = $data['billingcycle'];
                $tax = $data['tax'];
                if (!$name) {
                    if ($AddonsArray[$addonid]) {
                        $name = $AddonsArray[$addonid];
                    } else {
                        $AddonsArray[$addonid] = $name = get_query_val("tbladdons", "name", array("id" => $addonid));
                    }
                }
                $tax = $CONFIG['TaxEnabled'] && $tax ? "1" : "0";
                $invoicepayuntildate = getInvoicePayUntilDate($nextduedate, $billingcycle);
                $paydates = "";
                if ($billingcycle != "One Time") {
                    $paydates = "(" . fromMySQLDate($nextduedate) . " - " . fromMySQLDate($invoicepayuntildate) . ")";
                }
                if (!in_array($serviceid, $cancellationreqids)) {
                    if ($regdate == $nextduedate) {
                        $amount = $amount + $setupfee;
                    }
                    if ($domain) {
                        $domain = "(" . $domain . ") ";
                    }
                    $description = $_LANG['orderaddon'] . (" " . $domain . "- " . $name . " " . $paydates);
                    insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "Addon", "relid" => $id, "description" => $description, "amount" => $amount, "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                }
            } else {
                if (!$contblock && $continvoicegen) {
                    update_query("tblhostingaddons", array("nextinvoicedate" => getInvoicePayUntilDate($nextduedate, $billingcycle, true)), array("id" => $id));
                }
            }
            ++$addoncount;
            if (is_object($cron)) {
                $cron->logActivityDebug("Invoicing Loop Addon ID " . $id . " - " . $addoncount . " of " . $totaladdonrows);
            }
        }
    }
    if ($domainquery) {
        $domaincount = 0;
        $result = select_query("tbldomains", "", $domainquery, "domain", "ASC");
        $totaldomainrows = mysql_num_rows($result);
        while ($data = mysql_fetch_array($result)) {
            $id = $data['id'];
            $userid = $data['userid'];
            $nextduedate = $data[$matchfield];
            $status = $data['status'];
            $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", "userid='" . $userid . "' AND type IN ('Domain','DomainRegister','DomainTransfer') AND relid='" . $id . "' AND duedate='" . $nextduedate . "'");
            $contblock = false;
            if (!$num_rows && $continvoicegen && $status == "Pending") {
                $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", "userid='" . $userid . "' AND type IN ('Domain','DomainRegister','DomainTransfer') AND relid='" . $id . "'");
                $contblock = true;
            }
            if ($num_rows == 0) {
                $type = $data['type'];
                $domain = $data['domain'];
                $registrationperiod = $data['registrationperiod'];
                $regdate = $data['registrationdate'];
                $expirydate = $data['expirydate'];
                $paymentmethod = $data['paymentmethod'];
                $dnsmanagement = $data['dnsmanagement'];
                $emailforwarding = $data['emailforwarding'];
                $idprotection = $data['idprotection'];
                $promoid = $data['promoid'];
                getUsersLang($userid);
                if ($expirydate == "0000-00-00") {
                    $expirydate = $nextduedate;
                }
                if ($regdate == $nextduedate) {
                    $amount = $data['firstpaymentamount'];
                    if ($type == "Transfer") {
                        $domaindesc = $_LANG['domaintransfer'];
                    } else {
                        $domaindesc = $_LANG['domainregistration'];
                        $type = "Register";
                    }
                } else {
                    $amount = $data['recurringamount'];
                    $domaindesc = $_LANG['domainrenewal'];
                    $type = "";
                }
                $tax = $CONFIG['TaxEnabled'] && $CONFIG['TaxDomains'] ? "1" : "0";
                $domaindesc .= " - " . $domain . " - " . $registrationperiod . " " . $_LANG['orderyears'];
                if ($type != "Transfer") {
                    $domaindesc .= " (" . fromMySQLDate($expirydate) . " - " . fromMySQLDate(getInvoicePayUntilDate($expirydate, $registrationperiod)) . ")";
                }
                if ($dnsmanagement) {
                    $domaindesc .= "\r\n + " . $_LANG['domaindnsmanagement'];
                }
                if ($emailforwarding) {
                    $domaindesc .= "\r\n + " . $_LANG['domainemailforwarding'];
                }
                if ($idprotection) {
                    $domaindesc .= "\r\n + " . $_LANG['domainidprotection'];
                }
                $promo_description = $promo_amount = 0;
                if ($promoid) {
                    $data = get_query_vals("tblpromotions", "", array("id" => $promoid));
                    $promo_id = $data['id'];
                    if ($promo_id) {
                        $promo_code = $data['code'];
                        $promo_type = $data['type'];
                        $promo_recurring = $data['recurring'];
                        $promo_value = $data['value'];
                        if ($promo_recurring || !$promo_recurring && $regdate == $nextduedate) {
                            if ($promo_type == "Percentage") {
                                $promo_amount = round($amount / (1 - $promo_value / 100), 2) - $amount;
                                $promo_value .= "%";
                            } else {
                                if ($promo_type == "Fixed Amount") {
                                    $promo_amount = $promo_value;
                                    $currency = getCurrency($userid);
                                    $promo_value = formatCurrency($promo_value);
                                }
                            }
                            $amount += $promo_amount;
                            $promo_recurring = $promo_recurring ? $_LANG['recurring'] : $_LANG['orderpaymenttermonetime'];
                            $promo_description = $_LANG['orderpromotioncode'] . (": " . $promo_code . " - " . $promo_value . " " . $promo_recurring . " ") . $_LANG['orderdiscount'];
                            $promo_amount *= 0 - 1;
                        }
                    }
                }
                insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "Domain" . $type, "relid" => $id, "description" => $domaindesc, "amount" => $amount, "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                if ($promo_description) {
                    insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "PromoDomain", "relid" => $id, "description" => $promo_description, "amount" => $promo_amount, "taxed" => $tax, "duedate" => $nextduedate, "paymentmethod" => $paymentmethod));
                }
            } else {
                if (!$contblock && $continvoicegen) {
                    $year = substr($nextduedate, 0, 4);
                    $month = substr($nextduedate, 5, 2);
                    $day = substr($nextduedate, 8, 2);
                    $new_time = mktime(0, 0, 0, $month, $day, $year + $registrationperiod);
                    $nextinvoicedate = date("Ymd", $new_time);
                    update_query("tbldomains", array("nextinvoicedate" => $nextinvoicedate), array("id" => $id));
                }
            }
            getUsersLang(0);
            ++$domaincount;
            if (is_object($cron)) {
                $cron->logActivityDebug("Invoicing Loop Domain ID " . $id . " - " . $domaincount . " of " . $totaldomainrows);
            }
        }
    }
    if (!is_array($specificitems)) {
        $billableitemstax = $CONFIG['TaxEnabled'] && $CONFIG['TaxBillableItems'] ? "1" : "0";
        $result = select_query("tblbillableitems", "", "((invoiceaction='1' AND invoicecount='0') OR (invoiceaction='3' AND invoicecount='0' AND duedate<='" . $invoicedate . "') OR (invoiceaction='4' AND duedate<='" . $invoicedate . "' AND (recurfor='0' OR invoicecount<recurfor)))" . $billableitemqry);
        while ($data = mysql_fetch_array($result)) {
            $paymentmethod = getClientsPaymentMethod($data['userid']);
            if ($data['invoiceaction'] != "4") {
                insert_query("tblinvoiceitems", array("userid" => $data['userid'], "type" => "Item", "relid" => $data['id'], "description" => $data['description'], "amount" => $data['amount'], "taxed" => $billableitemstax, "duedate" => $data['duedate'], "paymentmethod" => $paymentmethod));
            }
            $updatearray = array("invoicecount" => "+1");
            if ($data['invoiceaction'] == "4") {
                $num_rows = get_query_val("tblinvoiceitems", "COUNT(id)", array("type" => "Item", "relid" => $data['id'], "duedate" => $data['duedate']));
                if ($num_rows == 0) {
                    insert_query("tblinvoiceitems", array("userid" => $data['userid'], "type" => "Item", "relid" => $data['id'], "description" => $data['description'], "amount" => $data['amount'], "taxed" => $billableitemstax, "duedate" => $data['duedate'], "paymentmethod" => $paymentmethod));
                }
                $adddays = $addmonths = $addyears = 0;
                if ($data['recurcycle'] == "Days") {
                    $adddays = $data['recur'];
                } else {
                    if ($data['recurcycle'] == "Weeks") {
                        $adddays = $data['recur'] * 7;
                    } else {
                        if ($data['recurcycle'] == "Months") {
                            $addmonths = $data['recur'];
                        } else {
                            if ($data['recurcycle'] == "Years") {
                                $addyears = $data['recur'];
                            }
                        }
                    }
                }
                $year = substr($data['duedate'], 0, 4);
                $month = substr($data['duedate'], 5, 2);
                $day = substr($data['duedate'], 8, 2);
                $updatearray['duedate'] = date("Ymd", mktime(0, 0, 0, $month + $addmonths, $day + $adddays, $year + $addyears));
            }
            update_query("tblbillableitems", $updatearray, array("id" => $data['id']));
        }
    }
    $invoicecount = $invoiceid = 0;
    $where = array();
    $where[] = "invoiceid=0";
    if ($func_userid) {
        $where[] = "userid=" . (int) $func_userid;
    }
    if (!is_array($specificitems)) {
        $where[] = "tblclients.separateinvoices=''";
        $where[] = "(tblclientgroups.separateinvoices='' OR tblclientgroups.separateinvoices is null)";
    }
    $result = select_query("tblinvoiceitems", "DISTINCT tblinvoiceitems.userid,tblinvoiceitems.duedate,tblinvoiceitems.paymentmethod", implode(" AND ", $where), "duedate", "ASC", "", "tblclients ON tblclients.id=tblinvoiceitems.userid LEFT JOIN tblclientgroups ON tblclientgroups.id=tblclients.groupid");
    while ($data = mysql_fetch_array($result)) {
        createInvoicesProcess($data, $noemails, $nocredit);
    }
    if (!is_array($specificitems)) {
        $where = array();
        $where[] = "invoiceid=0";
        if ($func_userid) {
            $where[] = "userid=" . (int) $func_userid;
        }
        $where[] = "(tblclients.separateinvoices='on' OR tblclientgroups.separateinvoices='on')";
        $result = select_query("tblinvoiceitems", "tblinvoiceitems.id,tblinvoiceitems.userid,tblinvoiceitems.type,tblinvoiceitems.relid,tblinvoiceitems.duedate,tblinvoiceitems.paymentmethod", implode(" AND ", $where), "duedate", "ASC", "", "tblclients ON tblclients.id=tblinvoiceitems.userid LEFT JOIN tblclientgroups ON tblclientgroups.id=tblclients.groupid");
        while ($data = mysql_fetch_array($result)) {
            createInvoicesProcess($data, $noemails, $nocredit);
        }
    }
    if (is_object($cron)) {
        $cron->logActivity("" . $invoicecount . " Invoices Created", true);
        $cron->emailLog($invoicecount . " Invoices Created");
    }
    if ($func_userid) {
        return $invoiceid;
    }
}
Beispiel #7
0
    $filters[] = "title LIKE '%" . mysql_real_escape_string($subject) . "%'";
}
if (!$ignore_dept_assignments) {
    $result = select_query("tbladmins", "supportdepts", array("id" => $_SESSION['adminid']));
    $data = mysql_fetch_array($result);
    $supportdepts = $data[0];
    $supportdepts = explode(",", $supportdepts);
    $deptids = array();
    foreach ($supportdepts as $id) {
        if (trim($id)) {
            $deptids[] = trim($id);
            continue;
        }
    }
    if (count($deptids)) {
        $filters[] = "did IN (" . db_build_in_array(db_escape_numarray($deptids)) . ")";
    }
}
$where = implode(" AND ", $filters);
$result = select_query("tbltickets", "COUNT(id)", $where);
$data = mysql_fetch_array($result);
$totalresults = $data[0];
$apiresults = array("result" => "success", "totalresults" => $totalresults, "startnumber" => $limitstart);
$result = select_query("tbltickets", "", $where, "lastreply", "DESC", "" . $limitstart . "," . $limitnum);
$apiresults['numreturned'] = mysql_num_rows($result);
while ($data = mysql_fetch_array($result)) {
    $id = $data['id'];
    $tid = $data['tid'];
    $deptid = $data['did'];
    $userid = $data['userid'];
    $name = $data['name'];
Beispiel #8
0
    if ($deptfilter) {
        $filters[] = "did IN (" . db_build_in_array(getAdminDepartmentAssignments()) . ")";
    }
    $query .= implode(" AND ", $filters) . (" ORDER BY tbltickets." . $orderby . " " . $order);
    $numresultsquery = "SELECT COUNT(tbltickets.id)" . $query;
    $result = full_query($numresultsquery);
    $data = mysql_fetch_array($result);
    $numrows = $data[0];
    $query = "SELECT tbltickets.*,tblclients.firstname,tblclients.lastname,tblclients.companyname,tblclients.groupid" . $query . " LIMIT " . (int) $page * $limit . "," . (int) $limit;
    $result = full_query($query);
    buildAdminTicketListArray($result);
    echo $aInt->sortableTable(array("checkall", "", $aInt->lang("support", "department"), array("title", $aInt->lang("fields", "subject")), $aInt->lang("support", "submitter"), array("status", $aInt->lang("fields", "status")), array("lastreply", $aInt->lang("support", "lastreply"))), $tabledata, $tableformurl, $tableformbuttons, true);
    $smartyvalues['tagcloud'] = $tickets->buildTagCloud();
}
if ($action == "search") {
    $where = "tid='" . db_escape_string($ticketid) . "' AND did IN (" . db_build_in_array(db_escape_numarray(getAdminDepartmentAssignments())) . ")";
    $result = select_query("tbltickets", "", $where);
    $data = mysql_fetch_array($result);
    $id = $data['id'];
    if (!$id) {
        echo "<p>" . $aInt->lang("support", "ticketnotfound") . "  <a href=\"javascript:history.go(-1)\">" . $aInt->lang("support", "pleasetryagain") . "</a>.</p>";
    } else {
        $action = "viewticket";
    }
}
if ($action == "viewticket") {
    releaseSession();
    $aInt->template = "viewticket";
    $smartyvalues['inticket'] = true;
    $ticket = new WHMCS_Tickets();
    $ticket->setID($id);
Beispiel #9
0
 }
 if ($all) {
     $invoiceids = array();
     $result = select_query("tblinvoices", "id", array("userid" => $client->getID(), "status" => "Unpaid", "(select count(id) from tblinvoiceitems where invoiceid=tblinvoices.id and type='Invoice')" => array("sqltype" => "<=", "value" => 0)), "id", "DESC");
     while ($data = mysql_fetch_array($result)) {
         $invoiceids[] = $data['id'];
     }
 } else {
     if (count($invoiceids) == 0) {
         redir();
         exit;
     } else {
         if (count($invoiceids) == 1) {
             redir("id=" . (int) $invoiceids[0], "viewinvoice.php");
         } else {
             $tmp_invoiceids = db_escape_numarray($invoiceids);
             $invoiceids = array();
             $result = select_query("tblinvoices", "id", array("userid" => $client->getID(), "status" => "Unpaid", "id" => array("sqltype" => "IN", "values" => $tmp_invoiceids)), "id", "DESC");
             while ($data = mysql_fetch_array($result)) {
                 $invoiceids[] = $data['id'];
             }
         }
     }
 }
 $xmasspays = array();
 $result = select_query("tblinvoiceitems", "invoiceid,relid", array("tblinvoiceitems.userid" => $client->getID(), "tblinvoiceitems.type" => "Invoice", "tblinvoices.status" => "Unpaid"), "", "", "", "tblinvoices ON tblinvoices.id=tblinvoiceitems.invoiceid");
 while ($data = mysql_fetch_array($result)) {
     $xmasspays[$data[0]][$data[1]] = 1;
 }
 if (count($xmasspays)) {
     $numsel = count($invoiceids);
Beispiel #10
0
 public function getUpgradePIDs()
 {
     return db_escape_numarray($this->getProductInfo("upgradepackages"));
 }
Beispiel #11
0
 public function getAssociatedDownloads()
 {
     if (!count($this->associated_download_ids)) {
         return array();
     }
     $downloadsarray = array();
     $result = select_query("tbldownloads", "", "id IN (" . db_build_in_array(db_escape_numarray($this->associated_download_ids)) . ")", "id", "DESC");
     while ($data = mysql_fetch_array($result)) {
         $dlid = $data['id'];
         $category = $data['category'];
         $type = $data['type'];
         $title = $data['title'];
         $description = $data['description'];
         $downloads = $data['downloads'];
         $location = $data['location'];
         $fileext = explode(".", $location);
         $fileext = end($fileext);
         $type = "zip";
         if ($fileext == "doc") {
             $type = "doc";
         }
         if ($fileext == "gif" || $fileext == "jpg" || $fileext == "jpeg" || $fileext == "png") {
             $type = "picture";
         }
         if ($fileext == "txt") {
             $type = "txt";
         }
         $type = "<img src=\"images/" . $type . ".png\" align=\"absmiddle\" alt=\"\" />";
         $downloadsarray[] = array("id" => $dlid, "catid" => $category, "type" => $type, "title" => $title, "description" => $description, "downloads" => $downloads, "link" => "dl.php?type=d&id=" . $dlid . "&serviceid=" . $this->getID());
     }
     return $downloadsarray;
 }
Beispiel #12
0
function doFraudCheck($params, $checkonly = false)
{
    global $_LANG;
    global $cc_encryption_hash;
    $availablelanguages = array("English", "Arabic", "Cantonese", "Croatian", "Czech", "Danish", "Dutch", "Estonian", "Finnish", "French", "German", "Greek", "Hebrew", "Hindi", "Hungarian", "Italian", "Japanese", "Korean", "Mandarin", "Norwegian", "Polish", "Portuguese", "Portugueseeu", "Romanian", "Russian", "Slovakian", "Spanish", "Swedish", "Thai", "Turkish", "Ukrainian", "Vietnamese");
    if (in_array($_SESSION['Language'], $availablelanguages)) {
        $params['Language'] = $_SESSION['Language'];
    }
    if ($params['Language'] == "Portuguese-br") {
        $params['Language'] = "PT_BR";
    }
    if ($params['Language'] == "Portuguese-pt") {
        $params['Language'] = "PT_PT";
    }
    $phonecc = $params['clientsdetails']['countrycode'];
    $phonenumber = $params['clientsdetails']['phonenumber'];
    if ($phonecc == "44" && substr($phonenumber, 0, 1) == "0") {
        $phonenumber = substr($phonenumber, 1);
    }
    $phonecclen = strlen($phonecc);
    if (substr($phonenumber, 0, $phonecclen) == $phonecc) {
        $phonenumber = "+" . $phonenumber;
    } else {
        $phonenumber = "+" . $phonecc . $phonenumber;
    }
    $emaildomain = explode("@", $params['clientsdetails']['email'], 2);
    $emaildomain = $emaildomain[1];
    $cchash = md5($cc_encryption_hash . $params['clientsdetails']['userid']);
    $cardnum = get_query_val("tblclients", "AES_DECRYPT(cardnum,'" . $cchash . "') as cardnum", array("id" => $params['clientsdetails']['userid']));
    $url = "http://minfraud3.maxmind.com/app/ccv2r";
    $postfields = array();
    $postfields['license_key'] = $params["MaxMind License Key"];
    $postfields['requested_type'] = isset($params["Service Type"]) && $params["Service Type"] == "Premium" ? "premium" : "standard";
    $postfields['i'] = $params['ip'];
    $postfields['EmailMD5'] = md5($params['clientsdetails']['email']);
    $postfields['PasswordMD5'] = md5($params['clientsdetails']['password']);
    $postfields['city'] = $params['clientsdetails']['city'];
    $postfields['region'] = $params['clientsdetails']['state'];
    $postfields['postal'] = $params['clientsdetails']['postcode'];
    $postfields['country'] = $params['clientsdetails']['country'];
    $postfields['domain'] = $emaildomain;
    $postfields['custPhone'] = $phonenumber;
    if ($cardnum) {
        $postfields['bin'] = substr($cardnum, 0, 6);
    }
    $postfields['shipAddr'] = $params['clientsdetails']['address1'];
    $postfields['shipCity'] = $params['clientsdetails']['city'];
    $postfields['shipRegion'] = $params['clientsdetails']['state'];
    $postfields['shipPostal'] = $params['clientsdetails']['postcode'];
    $postfields['shipCountry'] = $params['clientsdetails']['country'];
    $postfields['txnID'] = $_SESSION['orderdetails']['OrderID'];
    $postfields['sessionID'] = session_id();
    $postfields['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $postfields['accept_language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
        $postfields['forwardedIP'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    $content = curlCall($url, $postfields);
    if (substr($content, 0, 10) == "CURL Error") {
        $results['err'] = $content;
    } else {
        if (!$content) {
            $results['err'] = "No Response Received";
        } else {
            $results = array();
            $keyvaluepairs = explode(";", $content);
            foreach ($keyvaluepairs as $v) {
                $v = explode("=", $v);
                $results[$v[0]] = $v[1];
            }
        }
    }
    if ($checkonly) {
        return $results;
    }
    if ($params["Reject Free Email Service"] == "on" && $results['freeMail'] == "Yes") {
        $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_error'];
        $results['error']['description'] = $_LANG['maxmind_rejectemail'];
    }
    if ($params["Reject Country Mismatch"] == "on" && $results['countryMatch'] == "No") {
        $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_error'];
        $results['error']['description'] = $_LANG['maxmind_countrymismatch'];
    }
    if ($params["Reject Anonymous Proxy"] == "on" && $results['anonymousProxy'] == "Yes") {
        $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_error'];
        $results['error']['description'] = $_LANG['maxmind_anonproxy'];
    }
    if ($params["Reject High Risk Country"] == "on" && $results['highRiskCountry'] == "Yes") {
        $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_error'];
        $results['error']['description'] = $_LANG['maxmind_highriskcountry'];
    }
    $score = $params["Use New Risk Score"] ? $results['riskScore'] : $results['score'];
    if ($params["MaxMind Fraud Risk Score"] != "" && $params["MaxMind Fraud Risk Score"] < $score) {
        $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_error'];
        $results['error']['description'] = $_LANG['maxmind_highfraudriskscore'];
    }
    $forcephoneverify = false;
    $forcepids = $params["Force Phone Verify Products"];
    if ($forcepids) {
        $forcepids = explode(",", $forcepids);
        foreach ($forcepids as $k => $v) {
            $forcepids[$k] = trim($v);
        }
        $result = select_query("tblhosting", "COUNT(id)", "orderid=" . (int) $_SESSION['orderdetails']['OrderID'] . " AND packageid IN (" . db_build_in_array(db_escape_numarray($forcepids)) . ")");
        $data = mysql_fetch_array($result);
        if ($data[0]) {
            $forcephoneverify = true;
        }
    }
    if (!$params['error']['title'] && $params["Perform Telephone Verification"] && ($params["Telephone Fraud Score"] <= $score || $forcephoneverify)) {
        if ($_POST['pin']) {
            if ($_POST['pin'] != $_SESSION['maxmindpin']) {
                $results['error']['title'] = $_LANG['maxmind_title'] . " " . $_LANG['maxmind_incorrectcode'];
                $results['error']['description'] = "<p>" . $_LANG['maxmind_faileddescription'] . "</p>";
                $results['code'] = $_SESSION['maxmindpin'];
                $results['message'] = "Pin Code Verification Failed";
            }
        } else {
            $pin = "";
            $i = 0;
            while ($i < 4) {
                $pin .= mt_rand(1, 9);
                ++$i;
            }
            $_SESSION['maxmindpin'] = $pin;
            $url = "https://www.maxmind.com/app/telephone_http";
            $postfields = array();
            $postfields['l'] = $params["MaxMind License Key"];
            $postfields['phone'] = $phonenumber;
            $postfields['verify_code'] = $pin;
            if ($params['Language'] != "English") {
                $postfields['language'] = $params['Language'];
            }
            $content = curlCall($url, $postfields);
            if (substr($content, 0, 10) == "CURL Error") {
                $results['err'] = $content;
            } else {
                if (!$content) {
                    $results['err'] = "No Response Received";
                } else {
                    $keyvaluepairs = explode(";", $content);
                    foreach ($keyvaluepairs as $v) {
                        $v = explode("=", $v);
                        $results[$v[0]] = $v[1];
                    }
                }
            }
            $results['userinput'] = "true";
            $results['title'] = $_LANG['maxmind_title'];
            $results['description'] = "<p>" . $_LANG['maxmind_callingnow'] . "</p>\n<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?step=fraudcheck\">\n<center><div id=\"pinnumber\" align=\"center\">" . $_LANG['maxmind_pincode'] . ": <input type=\"text\" name=\"pin\" size=\"10\"></div></center>\n<p align=\"center\"><input type=\"submit\" value=\"" . $_LANG['ordercontinuebutton'] . "\"></p>\n</form>";
        }
    }
    return $results;
}