/**
 * Smarty {oms_credit_time} function plugin
 *
 * Type:     function<br>
 * Name:     oms_credit_time<br>
 * Date:     April 12, 2013<br>
 * Purpose:  Providing buyer with the info about how long will a certain credit have him running for the defined bundles.
 * @version  1.0
 * @param array
 * @param Smarty
 * @return Integer logged in user credit amount
 */
function smarty_function_oms_credit_time($params, &$smarty)
{
    $eurPerHour = empty($params['eurPerHour']) ? 0 : $params['eurPerHour'];
    $credit = empty($params['credit']) ? null : $params['credit'];
    $digits = empty($params['digits']) ? 1 : $params['digits'];
    if ($credit) {
        return round($credit / $eurPerHour, $digits);
    } else {
        if ($_SESSION['uid']) {
            $clientCredit = 0;
            $command = "getcredits";
            $adminuser = "******";
            $values["clientid"] = $_SESSION['uid'];
            $clientData = localAPI($command, $values, $adminuser);
            if ($clientData['result'] == "success") {
                foreach ($clientData['credits'] as $creditArr) {
                    foreach ($creditArr as $credit) {
                        $clientCredit += $credit['amount'];
                    }
                }
            }
            return round($clientCredit / $eurPerHour, $digits);
        }
    }
    return 0;
}
Example #2
0
function get_client_name($clientid)
{
    $client = "";
    $command = "getclientsdetails";
    $adminuser = "******";
    $values["clientid"] = $clientid;
    $values["pid"] = $pid;
    $results = localAPI($command, $values, $adminuser);
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $results, $values, $tags);
    xml_parser_free($parser);
    $data = array();
    if ($results["result"] == "success") {
        $client = $results["firstname"] . " " . $results["lastname"];
        $client = trim($client);
        $company = $results["companyname"];
        if ($company != "") {
            $client .= " (" . $company . ")";
        }
    } else {
        $client = "Error";
    }
    return $client;
}
 /**
  * @param \Exception $e
  */
 public function handle(\Exception $e)
 {
     $admin = Admin::firstOrNew(array('roleid' => 1));
     if ($admin->exists) {
         localAPI('logactivity', array('description' => $e->getMessage()), $admin->username);
     }
 }
function purchaseorder_accept_order($orderid)
{
    $command = "acceptorder";
    $values["orderid"] = $orderid;
    $values["autosetup"] = TRUE;
    $values["sendregistrar"] = TRUE;
    $values["sendemail"] = TRUE;
    $results = localAPI($command, $values);
    logModuleCall('purchaseorder', 'activate', $values, $results);
}
function send_unsuspension_email($var)
{
    $server = $var["params"]["domain"];
    lg_info("Sent unsuspension mail to " . $var["params"]["clientsdetails"]);
    $command = "sendemail";
    $adminuser = "******";
    $values["customtype"] = "product";
    $values["customsubject"] = "Service reactivated successfully";
    $values["custommessage"] = "Dear Customer,\n\nyour server {$server} has just been reactivated successfully.\n\nRegards,\nYour Support Team";
    $values["id"] = $var["params"]["serviceid"];
    $results = localAPI($command, $values, $adminuser);
}
function get_ticket_info($id)
{
    $command = 'getticket';
    $values = array('ticketid' => $id);
    $results = localAPI($command, $values, get_options()['admin_user']);
    if ($results['result'] != 'success') {
        write_log('An Error Occurred: ' . $results['message']);
        return false;
    } else {
        return $results;
    }
}
function getCreditForUserId($userId)
{
    $clientCredit = 0;
    $command = "getcredits";
    $adminuser = "******";
    $values["clientid"] = $userId;
    $clientData = localAPI($command, $values, $adminuser);
    if ($clientData['result'] == "success") {
        foreach ($clientData['credits'] as $creditArr) {
            foreach ($creditArr as $credit) {
                $clientCredit += $credit['amount'];
            }
        }
    }
    return $clientCredit;
}
function add_oms_user_promotion($vars)
{
    global $whmcs_admin_user;
    // Get promo code (this is just very wrong on all levels)
    $sql = "SELECT id FROM tblcustomfields WHERE fieldname='promotion'";
    $result = mysql_query($sql);
    if (!$result) {
        logActivity("Error: failed to retrieve promotion field index from database (user ID: {$vars['userid']}), MySQL error: " . mysql_error());
        return;
    }
    $resultArr = mysql_fetch_assoc($result);
    $promotionFieldIndex = (int) $resultArr['id'];
    $promoCode = $_POST['customfield'][$promotionFieldIndex];
    if (!$promoCode) {
        logActivity("No promo code provided (user ID: {$vars['userid']}, promotion field ID: {$promotionFieldIndex})...");
        return;
    }
    // Get promotion
    $values = array('code' => $promoCode);
    $result = localAPI("getpromotions", $values, $whmcs_admin_user);
    if ($result['result'] != "success") {
        logActivity("Failed to retrieve promotions (user ID: {$vars['userid']}), API call result: " . print_r($result, true));
        return;
    }
    if ($result['totalresults'] < 1) {
        logActivity("No promotions found (user ID: {$vars['userid']})");
        return;
    }
    $promotion = $result['promotions']['promotion'][0];
    // TODO: What if multiple promotions are found for one code?
    if (!$promotion) {
        logActivity("API error: promotion count > 1 reported but no promotions returned (user ID: {$vars['userid']})");
        return;
    }
    logActivity("Promotion found (user ID: {$vars['userid']}, promo code: {$promoCode})");
    // TODO: check $promotion['uses'] < $promotion['maxuses']
    // TODO: check time() < strtotime($promotion['expirationdate'])
    // Add credit to client
    $values = array('amount' => $promotion['value'], 'clientid' => $vars['userid'], 'description' => "Promotion code: {$promoCode}");
    $result = localAPI("addcredit", $values, $whmcs_admin_user);
    if ($result['result'] != "success") {
        logActivity("Failed to add credit from promotion (user ID: {$vars['userid']}, promo code: {$promoCode}), API call result: " . print_r($result, true));
        return;
    }
}
/**
 * GoCardless WHMCS module HOOKS - aka GoCardless Direct Debit Helper
 *
 * This file needs to be moved to the /includes/hooks directory within
 * the WHMCS install. This file works around the limitation in WHMCS
 * to request Direct Debit payments in time and stop sending payment
 * failure emails.
 *
 * @author: York UK Hosting <*****@*****.**>
 * @version: 1.1.0-YUH
 * @github: http://github.com/yorkukhosting/gocardless-whmcs/
 *
 */
function GoCardlessCaptureCron()
{
    /*
     * Triggers the capture of the Debit Card payment X days before the
     * due to date. Modify the +X days and adminuser paramters as
     * necessary
     */
    $duedate = date('Y-m-d', strtotime("+10 days"));
    $result = full_query("Select id,duedate,paymentmethod,status FROM tblinvoices WHERE duedate <= '" . $duedate . "' AND status='Unpaid' and paymentmethod='gocardless'");
    while ($data = mysql_fetch_array($result)) {
        $invoiceid = $data['id'];
        $result_gocardless = select_query("mod_gocardless", "invoiceid", array("invoiceid" => $invoiceid));
        $result_data = mysql_fetch_array($result_gocardless);
        if ($result_data['invoiceid'] != $invoiceid) {
            $command = "capturepayment";
            $adminuser = "******";
            $values["invoiceid"] = $invoiceid;
            $capture_results = localAPI($command, $values, $adminuser);
        }
    }
}
Example #10
0
 public function allProducts()
 {
     $command = "getproducts";
     $adminuser = MonitisHelper::getAdminName();
     $values = array();
     $results = localAPI($command, $values, $adminuser);
     if ($results && $results['result'] == "success") {
         $products = $results['products']['product'];
         $otherProducts = array();
         if ($products) {
             $activeProducts = $this->monitisProducts();
             for ($i = 0; $i < count($products); $i++) {
                 if (strtolower($products[$i]['type']) == 'other') {
                     $product = $products[$i];
                     $fields = $this->getCustomfields($product['customfields']['customfield']);
                     $isMonitisProduct = false;
                     if ($fields) {
                         $isMonitisProduct = true;
                         $website_id = $fields['website']['id'];
                         $monType_id = $fields['monitortype']['id'];
                         $monTypes = $this->getFieldById($monType_id);
                         $types = $monTypes['fieldoptions'];
                         $monitisProduct = MonitisHelper::in_array($activeProducts, 'product_id', $product['pid']);
                         $settings = null;
                         if ($monitisProduct && $monitisProduct['settings']) {
                             $settings = $monitisProduct['settings'];
                         }
                         $product['monitisProduct'] = array('product_id' => $product['pid'], 'website_id' => $fields['website']['id'], 'monType_id' => $fields['monitortype']['id'], 'types' => $types, 'settings' => $settings);
                     }
                     $otherProducts[] = $product;
                 }
             }
         }
         return $otherProducts;
     }
     return null;
 }
/**
Open Ticket on ordering selected products for WHMCS
Version 1.0 by TinyTunnel_Tom (ThomasGlassUK.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
function productOpenTicket($vars)
{
    //Configuration
    $products = array('1', '3');
    //Array of product IDs for this hook
    $adminuser = '******';
    //Set admin user to preform action (required for internal WHMCS API)
    $departmentid = '1';
    //Set support department to open ticket
    $subject = "Ticket Subject";
    //Subject for ticket
    $message = "Ticket Message";
    //Message in ticket
    $priority = "LOW";
    //Priority for ticket
    //The rest is magic
    $orderid = $vars['orderid'];
    //Get OrderID from WHMCS
    $result = select_query('tblhosting', '', array("orderid" => $orderid));
    //Find the product from the order
    $data = mysql_fetch_assoc($result);
    foreach ($products as $pid) {
        if ($data['packageid'] == $pid) {
            $command = "openticket";
            //WHMCS Internal API command
            $values = array('clientid' => $data['userid'], 'deptid' => $departmentid, 'subject' => $subject, 'message' => $message, 'priority' => $priority, 'admin' => '1');
            //WHMCS Internal API values
            $results = localAPI($command, $values, $adminuser);
            //Run command to open ticket
            if ($results['result'] != "success") {
                logActivity('An Error Occurred: ' . $results['message']);
                //Something went wrong check WHMCS logs
            }
        }
    }
}
Example #12
0
function feathur_CreateAccount($sData)
{
    $sConfig = feathur_GeneralConfig();
    $sPost = array("email" => $sConfig["email"], "password" => $sConfig["password"], "action" => "createvps", "useremail" => $sData["clientsdetails"]["email"], "username" => $sData["clientsdetails"]["firstname"], "server" => $sData["configoption1"], "ram" => $sData["configoption2"], "swap" => $sData["configoption3"], "disk" => $sData["configoption4"], "cpuunits" => $sData["configoption5"], "cpulimit" => $sData["configoption6"], "bandwidthlimit" => $sData["configoption7"], "inodes" => $sData["configoption8"], "numproc" => $sData["configoption9"], "numiptent" => $sData["configoption10"], "ipaddresses" => $sData["configoption11"], "nameserver" => $sData["configoption12"], "hostname" => preg_replace('/[^A-Za-z0-9-.]/', '', $sData["domain"]));
    $sSetupVPS = feathur_RemoteConnect($sPost, $sConfig["master"]);
    if ($sSetupVPS["type"] == 'success') {
        $sCustomField = mysql_fetch_array(mysql_query("SELECT * FROM tblcustomfields WHERE relid='{$sData["pid"]}' && fieldname='feathurvpsid'"));
        $sCommand = "updateclientproduct";
        $sPostFields["serviceid"] = $sData["serviceid"];
        $sPostFields["serviceusername"] = $sData["clientsdetails"]["email"];
        $sPostFields["servicepassword"] = "";
        $sCustomFields = array($sCustomField["id"] => $sSetupVPS["vps"]);
        $sPostFields["customfields"] = base64_encode(serialize($sCustomFields));
        $sAPIPost = localAPI($sCommand, $sPostFields, $sConfig["whmcs_admin_user"]);
        if ($sAPIPost["result"] == success) {
            $sResult = "success";
        } else {
            $sResult = $sAPIPost["message"];
        }
    } else {
        $sResult = $sSetupVPS["result"];
    }
    return $sResult;
}
function getUsersOrders($userId)
{
    $command = "getorders";
    $adminuser = "******";
    $values["userid"] = $userId;
    // without this all record are returned
    $results = localAPI($command, $values, $adminuser);
    if ($results['result'] == "success") {
        if ($results['orders']['order']) {
            return $results['orders']['order'];
        }
    } else {
        if ($results['result'] == "error") {
            logActivity("Error getting orders for userId:" . $userId . ". Error:" . $clientData['message']);
        } else {
            logActivity("getUsersOrders: no success or error.");
        }
    }
    return null;
}
Example #14
0
 static function userProducts($userid)
 {
     $products = null;
     $adminuser = MonitisHelper::getAdminName();
     $values = array("clientid" => $userid);
     $prdcts = localAPI("getclientsproducts", $values, $adminuser);
     if ($prdcts && $prdcts['result'] == 'success' && $prdcts['products']['product']) {
         $products = $prdcts['products']['product'];
     }
     return $products;
 }
Example #15
0
<?php

# require whmcs functions
require "../../../dbconnect.php";
require "../../../includes/functions.php";
# find first administrator
$administrator = select_query('tbladmins');
$administrator = mysql_fetch_array($administrator, MYSQL_ASSOC);
# try and process the login
$login = localAPI('validatelogin', array('email' => $_REQUEST['username'], 'password2' => $_REQUEST['password']), $administrator['id']);
# couldn't process the login, so forbid access
if ($login['result'] != 'success') {
    header('HTTP/1.0 403 Forbidden');
    return;
}
# check to see if login was a client or a contact
if ($login['contactid']) {
    $user = full_query("SELECT CONCAT(`firstname`, ' ', `lastname`), `permissions`, `email`  FROM `tblcontacts` WHERE `id` = '" . $login['contactid'] . "'");
    $user = mysql_fetch_array($user, MYSQL_BOTH);
    $permissions = explode(',', $user['permissions']);
    if (!in_array('tickets', $permissions)) {
        header('HTTP/1.0 403 Forbidden');
        return;
    }
} else {
    $user = full_query("SELECT CONCAT(`firstname`, ' ', `lastname`), `email` FROM `tblclients` WHERE `id` = '" . $login['userid'] . "'");
    $user = mysql_fetch_array($user, MYSQL_BOTH);
}
# output the JSON
echo json_encode(array('name' => $user['0'], 'email' => $user['email'], 'reference' => $user['email']));
Example #16
0
        $client = select_query('tblclients', 'id', array('email' => $split['1']));
        if (mysql_num_rows($client)) {
            break;
        }
    }
}
if (mysql_num_rows($client)) {
    $client = mysql_fetch_array($client, MYSQL_ASSOC);
} else {
    die('No such user');
}
## To access the internal API we still stupidly require an administrators id so let's fetch one.
$administrator = mysql_fetch_array(full_query("SELECT `id` FROM `tbladmins` LIMIT 0, 1"), MYSQL_ASSOC);
## Client Details
$results = localAPI('getclientsdetails', array('clientid' => $client['id'], 'stats' => true), $administrator['id']);
foreach ($results as $key => $value) {
    $vars[$key] = $value;
}
## Client Products
$client_products = localAPI('getclientsproducts', array('clientid' => $client['id']), $administrator['id']);
foreach ($client_products['products'] as $key => $value) {
    $vars['products'] = $value;
}
## Client Domains
$client_domains = localAPI('getclientsdomains', array('clientid' => $client['id']), $administrator['id']);
foreach ($client_domains['domains'] as $key => $value) {
    $vars['domains'] = $value;
}
$ca = new WHMCS_ClientArea();
$ca->initPage();
echo $ca->getSingleTPLOutput("/templates/sirportly/frame.tpl", $vars);
    private function process()
    {
        # get admin
        $qry = 'SELECT
					`username`
				FROM
					`tbladmins`
				LIMIT 1';
        $res = mysql_query($qry);
        $admin = mysql_result($res, 0);
        # calculate invoice due date
        $this->dueDate = date('Ymd');
        while ($client = mysql_fetch_assoc($this->clients)) {
            if ($client['billingType'] != 'postpaid') {
                continue;
            }
            $clientAmount = $this->getAmount($client);
            if (!$clientAmount) {
                continue;
            }
            if ($clientAmount->total_cost > 0) {
                $data = $this->generateInvoiceData($clientAmount, $client);
                if ($data == false) {
                    continue;
                }
                if ($this->logEnabled) {
                    $this->log[] = $data;
                }
                $result = localAPI('CreateInvoice', $data, $admin);
                if ($result['result'] != 'success') {
                    if ($this->printEnabled) {
                        echo 'An Error occurred trying to create a invoice: ', $result['result'], PHP_EOL;
                        print_r($result, true);
                    }
                    if ($this->logEnabled) {
                        $this->log[] = 'An Error occurred trying to create a invoice: ' . $result['result'];
                        $this->log[] = print_r($result, true);
                    }
                    logactivity('An Error occurred trying to create a invoice: ' . $result['result']);
                } else {
                    if ($this->printEnabled) {
                        print_r($result);
                        echo PHP_EOL, PHP_EOL;
                    }
                    if ($this->logEnabled) {
                        $this->log[] = print_r($result, true);
                        $this->log[] = '========== SPLIT =============';
                    }
                    $qry = 'UPDATE
								`tblinvoiceitems`
							SET
								`relid` = :WHMCSServiceID,
								`type` = "OnAppElasticUsers"
							WHERE
								`invoiceid` = :invoiceID';
                    $qry = str_replace(':WHMCSServiceID', $client['service_id'], $qry);
                    $qry = str_replace(':invoiceID', $result['invoiceid'], $qry);
                    full_query($qry);
                    # save OnApp amount
                    $table = 'OnAppElasticUsers_Cache';
                    $values = ['itemID' => $result['invoiceid'], 'type' => 'invoiceData', 'data' => $this->dataTMP->total_cost];
                    insert_query($table, $values);
                }
            }
        }
    }
function opensrspro_viewdomainnotes($params)
{
    global $osrsError;
    global $osrsLogError;
    $domain = $params['sld'] . '.' . $params['tld'];
    $params = array_merge($params, getConfigurationParamsData());
    $command = 'getadmindetails';
    $adminuser = '';
    $values = '';
    $results = localAPI($command, $values, $adminuser);
    $callArray = array('func' => 'viewDomainNotes', 'data' => array('domain' => $domain), 'connect' => generateConnectData($params));
    $result = "";
    $openSRSHandler = processOpenSRS("array", $callArray);
    $result = '<table cellspacing="1" cellpadding="3" width="100%" border="0" class="datatable"><tbody>';
    $result .= '<th>Notes</th>';
    $result .= '<th>Date</th>';
    foreach ($openSRSHandler->resultFullRaw['attributes']['notes'] as $notesData) {
        $result .= '<tr>';
        $result .= '<td>' . $notesData['note'] . '</td>';
        $result .= '<td width=18%>' . $notesData['timestamp'] . '</td>';
        $result .= '</tr>';
    }
    $result .= '</tbody><table>';
    echo $result;
    exit;
}
Example #19
0
function onapp_UsageUpdate($params)
{
    global $_LANG, $CONFIG;
    error_reporting(E_ERROR);
    ini_set("display_errors", 1);
    //    date_default_timezone_set('UTC');
    $serverid = $params['serverid'];
    $query = "\n        SELECT\n            tblservers.id,\n            tblservers.password,\n            tblservers.hostname,\n            tblservers.ipaddress,\n            tblservers.username,\n            tblhosting.regdate,\n            tblhosting.id as hosting_id,\n            tblhosting.bwusage,\n            tblhosting.domain,\n            tblhosting.bwlimit,\n            tblproducts.servertype,\n            tblhosting.lastupdate,\n            tblhosting.nextinvoicedate,\n            tblhosting.paymentmethod,\n            tblonappservices.vm_id,\n            tblproducts.overagesbwlimit as bwlimit,\n            tblproducts.overagesdisklimit as disklimit,\n            tblproducts.overagesenabled as enabled,\n            tblproducts.configoption10 as configoption10,\n            tblproducts.configoption22 as bandwidthconfigoption,\n            tblproducts.name as packagename,\n            tblproducts.overagesbwprice,\n            tblproducts.tax,\n            tblhostingconfigoptions.optionid,\n            tblupgrades.status as upgrade_status,\n            tblupgrades.paid as upgrade_paid,\n            tblupgrades.id as upgrade_id,\n            tblproductconfigoptionssub.sortorder as additional_bandwidth,\n            tblclients.id as clientid,\n            tblclients.taxexempt,\n            tblclients.state,\n            tblclients.country,\n            tblcurrencies.prefix,\n            tblcurrencies.code,\n            tblcurrencies.rate,\n            tblonappcronhostingdates.account_date\n        FROM\n            tblservers\n    \n        LEFT JOIN\n            tblhosting ON tblhosting.server = tblservers.id\n        LEFT JOIN\n            tblproducts ON tblhosting.packageid = tblproducts.id\n        LEFT JOIN\n            tblonappservices ON tblhosting.id = tblonappservices.service_id\n        LEFT JOIN\n            tblhostingconfigoptions\n            ON tblhostingconfigoptions.relid = tblhosting.id\n            AND tblhostingconfigoptions.configid = tblproducts.configoption22\n        LEFT JOIN\n            tblproductconfigoptionssub\n            ON\n            tblhostingconfigoptions.optionid = tblproductconfigoptionssub.id\n        LEFT JOIN\n            tblupgrades\n            ON tblupgrades.newvalue = tblhostingconfigoptions.optionid\n            AND tblupgrades.id = (SELECT MAX( id ) FROM tblupgrades WHERE\n            newvalue = tblhostingconfigoptions.optionid )\n        LEFT JOIN \n            tblclients ON tblhosting.userid = tblclients.id\n        LEFT JOIN\n            tblcurrencies ON tblcurrencies.id = tblclients.currency\n        LEFT JOIN\n            tblonappcronhostingdates ON tblonappcronhostingdates.hosting_id = tblhosting.id\n\n        WHERE\n           tblservers.id = {$serverid} AND\n           tblproducts.servertype = 'onapp' AND\n           tblproducts.overagesenabled = 1 AND\n           tblonappservices.vm_id != ''\n    ";
    $result = full_query($query);
    if (!$result || mysql_num_rows($result) < 1) {
        return;
    }
    $duedate = date('Ymd', time() + $GLOBALS['CONFIG']['CreateInvoiceDaysBefore'] * 86400);
    $today = date('Y-m-d H:i:s');
    $enddate = $today;
    $i = 0;
    while ($products = mysql_fetch_assoc($result)) {
        if ($products['account_date']) {
            $invoicedate = date('Y-m-d', strtotime($products['account_date']) + 31 * 24 * 60 * 60);
            $startdate = $products['account_date'];
        } else {
            $invoicedate = getAccountDate($products['regdate']);
            $time = strtotime($invoicedate) - 2678400;
            $startdate = date('Y-m-d H:00:00', $time);
        }
        $onapp = new OnApp_Factory($products['hostname'] ? $products['hostname'] : $products['ipaddress'], $products['username'], decrypt($products['password']));
        if ($onapp->getErrorsAsArray()) {
            // Debug
            echo '<b>Get OnApp Version Permission Error: </b>' . implode(PHP_EOL, $onapp->getErrorsAsArray()) . '. Skipping' . PHP_EOL;
            continue;
        }
        $network_interface = $onapp->factory('VirtualMachine_NetworkInterface');
        if (!$products['vm_id']) {
            // Debug
            echo 'virtual_machine_id is empty. Skipping' . PHP_EOL;
            continue;
        }
        $network_interfaces = $network_interface->getList($products['vm_id']);
        if ($network_interface->getErrorsAsArray()) {
            // Debug
            echo '<b>Network Interface Get List Error : </b>' . implode(PHP_EOL, $network_interface->getErrorsAsArray()) . '. Skipping' . PHP_EOL;
            continue;
        }
        $usage = $onapp->factory('VirtualMachine_NetworkInterface_Usage', true);
        $url_args = array('period[startdate]' => $startdate, 'period[enddate]' => $enddate);
        foreach ($network_interfaces as $interface) {
            $usage_stats[$i][$interface->_id] = $usage->getList($interface->_virtual_machine_id, $interface->_id, $url_args);
        }
        $traffic = 0;
        foreach ($usage_stats[$i] as $interface) {
            foreach ($interface as $bandwidth) {
                $traffic += $bandwidth->_data_sent;
                $traffic += $bandwidth->_data_received;
            }
        }
        $traffic = $traffic / 1024;
        // Count bandwidth limit + upgrades if needed
        $bandwidth_limit = $products['optionid'] && $products['additional_bandwidth'] && $products['upgrade_status'] == 'Completed' && $products['upgrade_paid'] == 'Y' ? $products['bwlimit'] + $products['additional_bandwidth'] : $products['bwlimit'];
        if (date('Y-m-d') == $invoicedate) {
            // debug
            echo 'Payment Day' . PHP_EOL;
            if ($traffic > $bandwidth_limit && !$params['extracall']) {
                // debug
                echo 'Called by the main cron' . PHP_EOL;
                echo 'Update cron dates' . PHP_EOL;
                $query = "REPLACE INTO\n                              tblonappcronhostingdates\n                              ( hosting_id, account_date )\n                          VALUES ( {$products['hosting_id']}, '" . $enddate . "'  )\n                ";
                $result = full_query($query);
                if (!$result) {
                    // debug
                    echo 'cron date REPLACE error ' . mysql_error() . PHP_EOL;
                }
                /// Generating Invoice ///
                /////////////////////////
                // debug
                echo 'Generating Invoice' . PHP_EOL;
                $sql = 'SELECT username FROM tbladmins LIMIT 1';
                $res = full_query($sql);
                $admin = mysql_fetch_assoc($res);
                $taxed = empty($products['taxexempt']) && $CONFIG['TaxEnabled'];
                if ($taxed) {
                    // debug
                    echo 'taxed invoice' . PHP_EOL;
                    $taxrate = getTaxRate(1, $products['state'], $products['country']);
                    $taxrate = $taxrate['rate'];
                } else {
                    $taxrate = '';
                }
                $amount = round(($traffic - $bandwidth_limit) * $products['overagesbwprice'] * $products['rate'], 2);
                $description = $products['packagename'] . ' - ' . $products['domain'] . ' ( ' . $startdate . ' / ' . $enddate . ' )' . PHP_EOL . $_LANG['onappbwusage'] . ' - ' . $traffic . ' MB' . PHP_EOL . $_LANG['onappbwlimit'] . ' - ' . $bandwidth_limit . ' MB' . PHP_EOL . $_LANG['onappbwoverages'] . ' - ' . ($traffic - $bandwidth_limit) . ' MB' . PHP_EOL . $_LANG['onapppriceformbbwoverages'] . ' - ' . $products['prefix'] . round($products['rate'] * $products['overagesbwprice'], 2) . ' ' . $products['code'] . PHP_EOL;
                $data = array('userid' => $products['clientid'], 'date' => $today, 'duedate' => $duedate, 'paymentmethod' => $products['paymentmethod'], 'taxrate' => $taxrate, 'sendinvoice' => true, 'itemdescription1' => $description, 'itemamount1' => $amount, 'itemtaxed1' => $taxed);
                // debug
                print '<pre>';
                print_r($data);
                echo PHP_EOL;
                $result = localAPI('CreateInvoice', $data, $admin);
                if ($result['result'] != 'success') {
                    // debug
                    echo 'Following error occurred: ' . $result['result'] . PHP_EOL;
                }
                // Generating Invoice End //
                ///////////////////////////
            }
            if (!$params['extracall']) {
                // debug
                echo 'Reset bwusage to 0' . PHP_EOL;
                $traffic = 0;
            }
        }
        $results[] = array('bwusage' => $traffic, 'disklimit' => $products['disklimit'], 'bwlimit' => $bandwidth_limit, 'domain' => $products['domain']);
        /// Debug block ///
        //////////////////
        print '<pre>';
        print_r($products);
        echo PHP_EOL;
        echo 'today  => ' . $today . PHP_EOL;
        echo 'regdate  => ' . $products['regdate'] . PHP_EOL;
        echo 'invoicedate  => ' . $invoicedate . PHP_EOL;
        echo 'startdate  => ' . $startdate . PHP_EOL;
        echo 'enddate  => ' . $enddate . PHP_EOL;
        echo 'bwlimit  (' . $products['bwlimit'] . ') + ';
        echo 'additional bwlimit (' . $products['additional_bandwidth'] . ') = ';
        echo $bandwidth_limit . PHP_EOL . PHP_EOL;
        echo 'Updating bwusage => ' . PHP_EOL;
        print '<pre>';
        print_r($results);
        echo '************************************************' . PHP_EOL . PHP_EOL;
        /// Debug block END ///
        //////////////////////
        $i++;
    }
    // Updating Usage Overages
    foreach ($results as $domain => $values) {
        update_query("tblhosting", array("disklimit" => $values['disklimit'], "bwusage" => $values['bwusage'], "bwlimit" => $values['bwlimit'], "lastupdate" => $today), array("server" => $serverid, "domain" => $values['domain']));
    }
}
*/
if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}
if (!isset($_POST['reason']) || !isset($_POST['vserverid'])) {
    die('Invalid Request');
}
$vserverid = intval($_POST['vserverid']);
$reason = mysql_real_escape_string($_POST['reason']);
// This query SHOULD only get 1 server product
$hosting_query = mysql_query('
SELECT *, h.id AS hostingID
FROM tblcustomfieldsvalues v 
        LEFT JOIN tblcustomfields f ON f.id=v.fieldid
        LEFT JOIN tblhosting h ON h.id=v.relid 
WHERE 
        f.fieldname = "vserverid" AND v.value = ' . $vserverid . '
LIMIT 1');
if (mysql_num_rows($hosting_query) == 0) {
    die('Invalid vserverid');
}
$account = mysql_fetch_assoc($hosting_query);
$values['accountid'] = $account['hostingID'];
$values['suspendreason'] = $reason;
$results = localAPI("modulesuspend", $values);
$results['service_id'] = $account['hostingID'];
if ($results['result'] != "success") {
    echo json_encode($results);
} else {
    echo json_encode($results);
}
function LiveHelperChatJS($vars)
{
    $q = @mysql_query("SELECT * FROM tbladdonmodules WHERE module = 'livehelperchat'");
    while ($arr = mysql_fetch_array($q)) {
        $settings[$arr['setting']] = html_entity_decode($arr['value']);
    }
    if ($_SESSION['uid'] == null && $settings['show_for_logged'] == 'on') {
        return;
    }
    $url = '';
    if ($settings['widget_click']) {
        $url .= '(click)/internal/';
    }
    if ($settings['hide_offline']) {
        $url .= "(hide_offline)/true/";
    }
    if ($settings['widget_click']) {
        $url .= "(check_operator_messages)/true/";
    }
    if ($settings['leaveamessage']) {
        $url .= "(leaveamessage)/true/";
    }
    if ($settings['disable_pro_active']) {
        $url .= "(disable_pro_active)/true/";
    }
    if ($settings['noresponse']) {
        $url .= "(noresponse)/true/";
    }
    if ($settings['position'] == 'Native placement - it will be shown where the html is embedded') {
        $url .= '(position)/original/';
    } elseif ($settings['position'] == 'Bottom left corner of the screen') {
        $url .= '(position)/bottom_left/';
    } elseif ($settings['position'] == 'Bottom right corner of the screen') {
        $url .= '(position)/bottom_right/';
    } elseif ($settings['position'] == 'Middle right side of the screen') {
        $url .= '(position)/middle_right/';
    } elseif ($settings['position'] == 'Middle left side of the screen') {
        $url .= '(position)/middle_left/';
    }
    if ($settings['enabled']) {
        $script = "<script type=\"text/javascript\">\r\n\t\tvar LHCChatOptions = {};</script>";
        if ($_SESSION['uid']) {
            $userid = $_SESSION['uid'];
            $command = "getclientsdomains";
            $adminuser = "******";
            $values["clientid"] = $userid;
            $results = localAPI($command, $values, $adminuser);
            $command = "getclientsproducts";
            $products_results = localAPI($command, $values, $adminuser);
            $command = "getinvoices";
            $values_unpaid["userid"] = $userid;
            $values_unpaid["status"] = "Unpaid";
            $unpaidinvoices = localAPI($command, $values_unpaid, $adminuser);
            $firstname = $vars['clientsdetails']['firstname'];
            $lastname = $vars['clientsdetails']['lastname'];
            $email = $vars['clientsdetails']["email"];
            $companyname = $vars['clientsdetails']['companyname'];
            $credit = $vars['clientsdetails']['credit'];
            $script .= "<script type=\"text/javascript\">\r\n\t\t    \tLHCChatOptions.attr = new Array();\r\n\t\t\t\tLHCChatOptions.attr.push({'name':'First name','value':'{$firstname}','type':'hidden','size':6,'req':false});\r\n\t\t\t\tLHCChatOptions.attr.push({'name':'Last name','value':'{$lastname}','type':'hidden','size':6,'req':false});\r\n\t\t\t\tLHCChatOptions.attr.push({'name':'Email','value':'{$email}','type':'hidden','size':6,'req':false});\r\n\t\t\t\tLHCChatOptions.attr.push({'name':'Company name','value':'{$companyname}','type':'hidden','size':6,'req':false});\r\n\t\t\t\tLHCChatOptions.attr.push({'name':'Credit','value':'{$credit}','type':'hidden','size':6,'req':false});";
            if (count($results['domains']['domain'])) {
                foreach ($results['domains']['domain'] as $domain) {
                    $domainname = $domain['domainname'];
                    $script .= "LHCChatOptions.attr.push({'name':'Domain name','value':'{$domainname}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$domain['domainname']} expiry date','value':'{$domain['expirydate']}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$domain['domainname']} registrar','value':'{$domain['registrar']}','type':'hidden','size':6,'req':false});";
                }
            }
            if (count($unpaidinvoices['invoices']['invoice'])) {
                foreach ($unpaidinvoices['invoices']['invoice'] as $invoice) {
                    $invoicenumber = $invoice['invoicenum'];
                    $invoiceid = $invoice['id'];
                    $inv = $invoicenumber . '(ID:' . $invoiceid . ')';
                    $script .= "LHCChatOptions.attr.push({'name':'Unpaid invoice','value':'{$inv}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$inv} duedate','value':'{$invoice['duedate']}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$inv} subtotal','value':'{$invoice['subtotal']}','type':'hidden','size':6,'req':false});";
                }
            }
            if (count($products_results['products']['product'])) {
                foreach ($results['products']['product'] as $products) {
                    $script .= "LHCChatOptions.attr.push({'name':'Service name','value':'{$products['name']}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$products['name']} server ip','value':'{$products['serverip']}','type':'hidden','size':6,'req':false});";
                    $script .= "LHCChatOptions.attr.push({'name':'{$products['name']} next due date','value':'{$products['nextduedate']}','type':'hidden','size':6,'req':false});";
                }
            }
            $script .= "</script>";
        }
        $script .= "<script type=\"text/javascript\">\nLHCChatOptions.opt = {widget_height:" . $settings['widget_height'] . ",widget_width:" . $settings['widget_height'] . ",popup_height:" . $settings['popup_height'] . ",popup_width:" . $settings['popup_width'] . "};\r\n\t\t(function() {\r\n\t\tvar po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;\r\n\t\tvar refferer = (document.referrer) ? encodeURIComponent(document.referrer.substr(document.referrer.indexOf('://')+1)) : '';\r\n\t\tvar location  = (document.location) ? encodeURIComponent(window.location.href.substring(window.location.protocol.length)) : '';\r\n\t\tpo.src = '{$settings['widget_domain']}/chat/getstatus/(top)/{$settings['pos_top']}/(units)/{$settings['unit']}/{$url}?r='+refferer+'&l='+location;\r\n\t\tvar s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);\r\n\t\t})();\r\n\t\t</script>";
        return $script;
    }
}
Example #22
0
function autorelease_Renew($params)
{
    if ($params['configoption5'] == "Add To-Do List Item") {
        $todoarray['title'] = "Service Renewal";
        $todoarray['description'] = "Service ID # " . $params['serviceid'] . " was just renewed";
        $todoarray['status'] = "Pending";
        $todoarray['date'] = $todoarray['duedate'] = date("Y-m-d");
        insert_query("tbltodolist", $todoarray);
    } else {
        if ($params['configoption5'] == "Create Support Ticket") {
            $postfields['action'] = "openticket";
            $postfields['clientid'] = $params['clientsdetails']['userid'];
            $postfields['deptid'] = $params['configoption6'] ? $params['configoption6'] : "1";
            $postfields['subject'] = "Service Renewal";
            $postfields['message'] = "Service ID # " . $params['serviceid'] . " was just renewed";
            $postfields['priority'] = "Low";
            localAPI($postfields['action'], $postfields, 1);
        }
    }
    return "success";
}
Example #23
0
function tunai_link($params)
{
    # Gateway Specific Variables
    $merchantid = $params['merchantid'];
    $accesskey = $params['accesskey'];
    $secretkey = $params['secretkey'];
    # Invoice Variables
    $invoiceid = $params['invoiceid'];
    $description = $params["description"];
    $amount = $params['amount'];
    # Format: ##.##
    $currency = $params['currency'];
    # Currency Code
    # Client Variables
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];
    # System Variables
    $companyname = $params['companyname'];
    $systemurl = $params['systemurl'];
    $currency = $params['currency'];
    $log_enable = $params['log_enable'];
    # Invoice Items
    $command = "getinvoice";
    $adminuser = $params['api_username'];
    $values["invoiceid"] = $invoiceid;
    $results = localAPI($command, $values, $adminuser);
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $results, $values, $tags);
    xml_parser_free($parser);
    if ($log_enable == true) {
        logModuleCall('tunai', 'getinvoice', $values, $results, $ressultarray, '');
    }
    $item_details = array();
    $itemid = 0;
    if ($results["result"] == "success") {
        $invoiceitems = $results['items']['item'];
        for ($i = 0; $i < count($invoiceitems); $i++) {
            $invoiceitem = $invoiceitems[$i];
            $itemdescription = $invoiceitem['description'];
            $itemdescription = preg_replace("/\r|\n/", ",", $itemdescription);
            if (strlen($itemdescription) > 50) {
                $itemdescription = substr($itemdescription, 0, 50);
            }
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $invoiceitem['amount'], 'quantity' => 1, 'description' => $itemdescription);
            $item_details[] = $data;
        }
        # PPn
        $tax = $results['tax'];
        if ($tax > 0) {
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $tax, 'quantity' => 1, 'description' => 'Pajak');
            $item_details[] = $data;
        }
        # credit
        $credit = $results['credit'];
        if ($credit > 0) {
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $credit * -1, 'quantity' => 1, 'description' => 'Saldo');
            $item_details[] = $data;
        }
    }
    if ($log_enable == true) {
        logModuleCall('tunai', 'itemdetails', $values, $results, $item_details, '');
    }
    $customer = array("name" => $firstname . " " . $lastname, "address" => $address1 . "\r\n" . $address2, "phone" => $phone, "city" => $city, "province" => $state, "zipcode" => $postcode, "country" => $country, "mobilephone" => "", "identity" => "");
    $data = array("refId" => strval($invoiceid), "expired" => (string) time() + 24 * 60 * 60 . '000', "amount" => $amount, "customer" => $customer, "items" => $item_details);
    $invoice = new Invoice($accesskey, $secretkey);
    $response = $invoice->getByRefOrCreate($data);
    $json = $response->getBody();
    if ($log_enable == true) {
        logModuleCall('tunai', 'getByRefOrCreate', $data, $json, $ressultarray, '');
    }
    $statusCode = $response->getStatusCode();
    $obj = json_decode($json);
    if ($statusCode == 200) {
        $code = '<img src="//files.tunai.id/images/tunai-button-white.png" alt="tunai" /><p>Kode Pembayaran: <strong>' . $obj->token . '</strong><br />Total: Rp ' . $obj->amount . ' </p><form method="post" action="https://pay.tunai.id/' . $obj->token . '"><input type="submit" value="Bayar ke Agen" /></form>';
        return $code;
    }
    return '<b>' . $obj->message . '</b>';
}
Example #24
0
function shadowsocks_CreateAccount($params)
{
    $serviceid = $params["serviceid"];
    # Unique ID of the product/service in the WHMCS Database
    $pid = $params["pid"];
    # Product/Service ID
    $producttype = $params["producttype"];
    # Product Type: hostingaccount, reselleraccount, server or other
    $domain = $params["domain"];
    $username = $params["username"];
    $password = $params["password"];
    $clientsdetails = $params["clientsdetails"];
    # Array of clients details - firstname, lastname, email, country, etc...
    $customfields = $params["customfields"];
    # Array of custom field values for the product
    $configoptions = $params["configoptions"];
    # Array of configurable option values for the product
    # Product module option settings from ConfigOptions array above
    $configoption1 = $params["configoption1"];
    $configoption2 = $params["configoption2"];
    # Additional variables if the product/service is linked to a server
    $server = $params["server"];
    # True if linked to a server
    $serverid = $params["serverid"];
    $serverip = $params["serverip"];
    $serverusername = $params["serverusername"];
    $serverpassword = $params["serverpassword"];
    $serveraccesshash = $params["serveraccesshash"];
    $serversecure = $params["serversecure"];
    # If set, SSL Mode is enabled in the server config
    $adminusername = mysql_fetch_array(mysql_query("SELECT username FROM `tbladmins`"));
    $mysql = mysql_connect($params['serverip'], $params['serverusername'], $params['serverpassword']);
    $port = shadowsocks_CreateNewPort($params);
    if (!$mysql) {
        $result = "Can not connect to MySQL Server" . mysql_error();
    } else {
        mysql_select_db($params['configoption1'], $mysql);
        $select = mysql_query("SELECT pid FROM user WHERE pid='" . $serviceid . "'", $mysql);
        $select = mysql_fetch_array($select);
        if (!empty($select['pid'])) {
            $result = "Service already exists.";
        } else {
            if (isset($params['customfields']['password'])) {
                $command = "encryptpassword";
                $adminuser = $adminusername['username'];
                $values["password2"] = $params["customfields"]['password'];
                $results = localAPI($command, $values, $adminuser);
                $table = "tblhosting";
                $update = array("password" => $results['password']);
                $where = array("id" => $params["serviceid"]);
                update_query($table, $update, $where);
                #mysql_query("UPDATE `tblhosting` set password='******'password']."' where id='".$params["serviceid"]."'");
                $password = $params["customfields"]['password'];
            }
            //Create Account
            if (isset($params['configoptions']['traffic'])) {
                $traffic = $params['configoptions']['traffic'] * 1024 * 1048576;
                $query = mysql_query("INSERT INTO user(pid,passwd,port,transfer_enable) VALUES ('" . $params['serviceid'] . "','" . $password . "','" . $port . "','" . $traffic . "')", $mysql);
                if ($query) {
                    $result = 'success';
                } else {
                    // $result = 'Error.Cloud not create a new user.';
                    $result = mysql_error();
                }
            } else {
                if (!empty($params['configoption5'])) {
                    $max = $params['configoption5'];
                }
                if (isset($max)) {
                    $traffic = $max * 1024 * 1048576;
                } else {
                    $traffic = 1099511627776;
                }
                $query = mysql_query("INSERT INTO user(pid,passwd,port,transfer_enable) VALUES ('" . $params['serviceid'] . "','" . $password . "','" . $port . "','" . $traffic . "')", $mysql);
                if ($query) {
                    $result = 'success';
                } else {
                    $result = 'Error.Cloud not create a new user.' . mysql_error();
                }
            }
        }
    }
    return $result;
}
Example #25
0
function lvmcloud_CreateAccount($params)
{
    //Definimos variables de API
    $url = "https://api.lvmcloud.com/api/instance";
    $method = "POST";
    # ** The variables listed below are passed into all module functions **
    $serviceid = $params["serviceid"];
    # Unique ID of the product/service in the WHMCS Database
    $pid = $params["pid"];
    # Product/Service ID
    $producttype = $params["producttype"];
    # Product Type: hostingaccount, reselleraccount, server or other
    $domain = $params["domain"];
    $username = $params["username"];
    $password = $params["password"];
    $clientsdetails = $params["clientsdetails"];
    # Array of clients details - firstname, lastname, email, country, etc...
    $customfields = $params["customfields"];
    # Array of custom field values for the product
    $configoptions = $params["configoptions"];
    # Array of configurable option values for the product
    # Product module option settings from ConfigOptions array above
    $configoption1 = $params["configoption1"];
    $configoption2 = $params["configoption2"];
    $configoption3 = $params["configoption3"];
    $configoption4 = $params["configoption4"];
    # Additional variables if the product/service is linked to a server
    $server = $params["server"];
    # True if linked to a server
    $serverid = $params["serverid"];
    $serverip = $params["serverip"];
    $serverusername = $params["serverusername"];
    $serverpassword = $params["serverpassword"];
    $serveraccesshash = $params["serveraccesshash"];
    $serversecure = $params["serversecure"];
    # If set, SSL Mode is enabled in the server config
    $plan = $configoption1;
    $template = $params["customfields"]["Sistema Operativo"];
    $localization = $params["customfields"]["Localizacion"];
    $data = array("localization_id" => $localization, "plan_id" => $plan, "template_id" => $template, "extra_ram" => 0, "extra_cpu" => 0);
    $result = apiCall($url, $data, $method, $serverusername, $serverpassword);
    if ($result['instance']['status'] == "CREATING") {
        $vmid = $result['instance']['id'];
        $ipaddr = $result['instance']['ips']['0']['ip'];
        $vmpasswd = $result['instance']['password'];
        //Get admin list
        $AdminsQuery = mysql_query("SELECT * FROM tbladmins WHERE roleid='1'");
        $Admin = mysql_fetch_object($AdminsQuery);
        $command = "modulechangepw";
        $adminuser = $Admin->username;
        $values["serviceid"] = $serviceid;
        $values["servicepassword"] = $vmpasswd;
        $results = localAPI($command, $values, $adminuser);
        if ($results['result'] != "success") {
            return "Error writing password:  "******"tblhosting";
        $array = array("dedicatedip" => $ipaddr, "domain" => $result['instance']['name']);
        $where = array("id" => $serviceid);
        update_query($table, $array, $where);
        $SQL = mysql_query("SELECT * FROM tblcustomfields WHERE relid='" . $pid . "'");
        //Ahora buscamos los optionalfields de este pid
        while ($fields = mysql_fetch_object($SQL)) {
            if ($fields->fieldname == "VmId") {
                $vmid_field = $fields->id;
            }
        }
        $result = "success";
        //Insertamos la VmId en la MySQL
        if (mysql_num_rows(mysql_query("SELECT * FROM tblcustomfieldsvalues WHERE fieldid='{$vmid_field}' and relid='{$serviceid}'")) == 0) {
            $vmidQ = mysql_query("INSERT into tblcustomfieldsvalues (fieldid, relid, value) VALUES('{$vmid_field}','{$serviceid}','{$vmid}')");
        } else {
            $vmidQ = mysql_query("UPDATE tblcustomfieldsvalues SET fieldid='{$vmid_field}', relid='{$serviceid}', value='{$vmid}'  WHERE fieldid='{$vmid_field}' and relid='{$serviceid}'");
        }
    } else {
        if ($result['code'] != null) {
            $result = $result['code'] . ": " . $result['message'];
        }
    }
    return $result;
}
Example #26
0
        $var .= $value;
    }
}
$genstamp = md5($var . $gateway["md5key"]);
//Check hash
if ($genstamp != $_GET["hash"]) {
    logTransaction($gateway["name"], $_GET, "Unsuccessful");
} else {
    //Hash OK
    //Add fee to invoice
    if ($fee > 0) {
        $fee_values["invoiceid"] = $invoiceid;
        $fee_values["newitemdescription"] = array("Payment Fee");
        $fee_values["newitemamount"] = array($fee);
        $fee_values["newitemtaxed"] = array("0");
        $fee_result = localAPI("updateinvoice", $fee_values, null);
    }
    //Add payment to invoice
    addInvoicePayment($invoiceid, $transid, $amount + $fee, $fee, "epay");
    logTransaction($gateway["name"], $_GET, "Successful");
    //Save subscription information
    if ($_GET["subscriptionid"]) {
        //Get client
        $client_query = mysql_query("SELECT gatewayid FROM tblclients WHERE id = " . $invoice_result['userid']);
        $client_result = mysql_fetch_array($client_query);
        //Set subscription ID
        $subscriptionid = $client_result['gatewayid'];
        //Get expire date
        $soap = new SoapClient("https://ssl.ditonlinebetalingssystem.dk/remote/subscription.asmx?wsdl");
        $soap_subscription_result = $soap->getsubscriptions(array("merchantnumber" => $gateway["merchantnumber"], "subscriptionid" => $_GET["subscriptionid"], "epayresponse" => -1));
        if ($soap_subscription_result->getsubscriptionsResult == true) {
 function _get_order_details($user_id, $service_id, $domain, $product_id)
 {
     $local_api_values = array('clientid' => $user_id, 'serviceid' => $service_id, 'domain' => $domain, 'pid' => $product_id);
     $client_order_details = localAPI('getclientsproducts', $local_api_values);
     return $client_order_details;
 }
function hook_opensrspro_ActivateTemplatesChangesHeadOutput($vars)
{
    $pre_script = '';
    $script = '';
    /* Tld AU start */
    if ($vars['filename'] == "ordersadd" || $vars['filename'] == "clientsdomains") {
        $script .= '
            <script type="text/javascript">
            //<![CDATA[
             var all_prerequisites_exist = 0;
                       var js_e_type_ids = {"Trademark Owner":[{"value":"TM","name":"Trademark"}],"Registered Business":[{"value":"OTHER","name":"Australian Registered Body Number"}],"Partnership":[{"value":"ABN","name":"Australian Business Number"}],"Sole Trader":[{"value":"ABN","name":"Australian Business Number"}],"Pending TM Owner":[{"value":"TM","name":"Trademark"}],"Company":[{"value":"ACN","name":"Australian Company Number"}],"Trade Union":[{"value":"OTHER","name":"Organisation Number"}],"Charity":[{"value":"ABN","name":"Australian Business Number"}],"Incorporated Association":[{"value":"ACT BN","name":"Australian Capital Territory Business Number"},{"value":"NSW BN","name":"New South Wales Business Number"},{"value":"NT BN","name":"Northern Territory Business Number"},{"value":"QLD BN","name":"Queensland Business Number"},{"value":"SA BN","name":"South Australia Business Number"},{"value":"TAS BN","name":"Tasmania Business Number"},{"value":"VIC BN","name":"Victoria Business Number"},{"value":"WA BN","name":"Western Australia Business Number"}],"Club":[{"value":"ABN","name":"Australian Business Number"}],"Non-profit Organisation":[{"value":"ABN","name":"Australian Business Number"},{"value":"ACT BN","name":"Australian Capital Territory Business Number"},{"value":"ACN","name":"Australian Company Number"},{"value":"OTHER","name":"Australian Registered Body Number"},{"value":"NSW BN","name":"New South Wales Business Number"},{"value":"NT BN","name":"Northern Territory Business Number"},{"value":"QLD BN","name":"Queensland Business Number"},{"value":"SA BN","name":"South Australia Business Number"},{"value":"TAS BN","name":"Tasmania Business Number"},{"value":"VIC BN","name":"Victoria Business Number"},{"value":"WA BN","name":"Western Australia Business Number"}],"Citizen/Resident":[{"value":"ABN","name":"Australian Business Number"},{"value":"ACN","name":"Australian Company Number"},{"value":"ACT BN","name":"Australian Capital Territory Business Number"},{"value":"NSW BN","name":"New South Wales Business Number"},{"value":"OTHER","name":"Other"},{"value":"NT BN","name":"Northern Territory Business Number"},{"value":"QLD BN","name":"Queensland Business Number"},{"value":"SA BN","name":"South Australia Business Number"},{"value":"TAS BN","name":"Tasmania Business Number"},{"value":"TM","name":"Trademark"},{"value":"VIC BN","name":"Victoria Business Number"},{"value":"WA BN","name":"Western Australia Business Number"}]};
                       
                        function prerequisites_exist() {
                            // Defensive.. test all ids exist before we enable the functionality
                            var ids = [ \'id_au_eligibility_type\', \'id_au_eligibility_id_type\' ];
                            for (var i = 0; i < ids.length; ++i ) {
         
                            if ( ! $(\'#"+ids[i]\') )  {
                                return false;
                            }
                            }
                            all_prerequisites_exist = 1;
                            return true;
                        }
                        function on_change_entity_type(entity_type) { 
                            if ( ( ! all_prerequisites_exist ) || entity_type == undefined || ! js_e_type_ids[entity_type] ) {
                                return false;
                            }
                            
                            var select_e_id_type = $("#id_au_eligibility_id_type");
                            select_e_id_type.empty();
            
                            for (var i = 0; i < js_e_type_ids[entity_type].length; i++) {
                                var o = document.createElement("option");
                                o.value = js_e_type_ids[entity_type][i].value;
                                o.text =  js_e_type_ids[entity_type][i].name;
                                select_e_id_type.append(o);
                            }
                            return false;
                        }
                        function update_ui_on_load(){ 
                            if ( ! prerequisites_exist() ) { return false; }
                            on_change_entity_type( $("#id_au_eligibility_type").val());
                        }
                        
                         //]]>
            // Chnaged by BC : To resolved issue of WHMCS Logo Overlaps Links on Domains Tab
                
                //</script>"
                </script>
            
            // End : To resolved issue of WHMCS Logo Overlaps Links on Domains Tab
                        ';
    }
    /* Tld AU End */
    $script .= '
        <script type="text/javascript">
        //<![CDATA[
            jQuery(document).ready(function(){
    ';
    /* Added by BC : NG : 8-10-2014 : To display domain notes */
    if ($vars['filename'] == "clientsdomains") {
        $command = 'getadmindetails';
        $adminuser = '';
        $values = '';
        $resultData = localAPI($command, $values, $adminuser);
        $adminDetails = mysql_fetch_assoc(mysql_query("SELECT * FROM tbladmins WHERE id='" . mysql_real_escape_string($resultData['adminid']) . "'"));
        $resQuery = mysql_query("SELECT permid FROM tbladminperms WHERE roleid='" . $adminDetails['roleid'] . "'");
        $rowData = mysql_num_rows($resQuery);
        $permIds = array();
        if ($rowData > 0) {
            while ($resData = mysql_fetch_array($resQuery)) {
                array_push($permIds, $resData['permid']);
            }
        }
        if (in_array(9999, $permIds)) {
            $script .= "\n                    jQuery('table.form tr:last').append('<div id=\\'dialog\\' title=\\'Domain Notes\\' scrolling=\\'auto\\'></div>');\n                    if(jQuery('input[value=\\'View Domain Notes\\']').val())\n                    {\n                        jQuery('input[value=\\'View Domain Notes\\']').after('&nbsp;<div id=\\'dialogloader\\' style=\\'display:none\\'><img src=\\'/whmcs/images/loadingsml.gif\\' /></div>')\n                        var tokenurl = jQuery('input[value=\\'View Domain Notes\\']').attr('onclick').split('&token=');\n                        var rplurl = tokenurl[1].replace(\"'\",'');\n                        var DomainId = jQuery('select[name=\\'id\\'] option:selected').val();\n                        jQuery('input[value=\\'View Domain Notes\\']').attr('onclick', '');\n                        jQuery('input[value=\\'View Domain Notes\\']').click(function(event){\n                            jQuery('#dialogloader').css('display', 'inline'); \n                            var url = '?userid=" . $_REQUEST['userid'] . "&id='+DomainId+'&regaction=custom&ac=viewdomainnotes&token='+rplurl;\n                            jQuery.ajax({url:url,success:function(result){\n                              jQuery('#dialog').html(result);\n                              if(result)\n                              {\n                                jQuery('#dialogloader').css('display', 'none');\n                                jQuery('#dialog').dialog({\n                                    autoOpen: true,\n                                    resizable: false,\n                                    width: 800,\n                                    height: 500,\n                                    modal: true,\n                                    position: 'center', \n                                    open: function (event, ui) {\n                                      jQuery('#dialog').css('overflow', 'auto'); \n                                    }\n                                });\n                              }\n                            }});\n                        });\n                    }\n                    \n\n                ";
        }
        /* Added by BC : dd : 16-07-2014 :  Disallow Registrar permissions (Using Role Permission) */
        if (in_array(8888, $permIds)) {
            $script .= "\n                  jQuery('input[value=\\'Register\\']').attr('disabled','disabled');\n                  jQuery('input[value=\\'Register\\']').addClass('btn disabled');\n                  \n                  jQuery('input[value=\\'Renew\\']').attr('disabled','disabled');\n                  jQuery('input[value=\\'Renew\\']').addClass('btn disabled');\n                ";
        }
        /* END */
    }
    /* End : To display domain notes */
    /* Tld AU start */
    if ($vars['filename'] == "ordersadd" || $vars['filename'] == "clientsdomains") {
        if ($vars['filename'] == "ordersadd") {
            $script .= 'var orderFlag = 1';
        } else {
            if ($_REQUEST['domainid']) {
                $domainId = $_REQUEST['domainid'];
            } else {
                $domainId = $_REQUEST['id'];
            }
            $resQuery = mysql_query("SELECT name,value FROM tbldomainsadditionalfields WHERE domainid='" . $domainId . "' AND name = 'Eligibility ID Type'");
            $rowData = mysql_fetch_assoc($resQuery);
            if ($rowData > 0) {
                $eligibilityIDType = $rowData['value'];
            }
            $resQuery1 = mysql_query("SELECT name,value FROM tbldomainsadditionalfields WHERE domainid='" . $domainId . "' AND name = 'Eligibility Type'");
            $rowData1 = mysql_fetch_assoc($resQuery1);
            if ($rowData1 > 0) {
                $eligibilityType = $rowData1['value'];
            }
            $script .= 'var orderFlag = 0';
        }
        $script .= '
            
            function autldfield()
            {   
                $(".fieldlabel").each(function(e){
                    if(this.innerHTML == "Eligibility Type")
                    {
                       if(orderFlag == 1)
                       {
                            var domain = $("#regdomain0").val();
                       }
                       else
                       {
                            var domain = $("input:text[name=domain]").val()
                       }
                       var domainArr = domain.split(".");
                       var domainTld = domainArr.splice(-2,2)
                       var tld = domainTld[0] + "." + domainTld[1]; 
                       if(tld == "com.au" || tld == "net.au")
                       {      
                           $("select[name=\'domainfield[0][5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[0][6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"}); 
                           $("select[name=\'domainfield[5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"});
                             
                           var newOptions = {"Company": "Company",  "Partnership": "Partnership",  "Pending TM Owner": "Pending TM Owner", "Registered Business" : "Registered Business", "Sole Trader" : "Sole Trader",  "Trademark Owner" : "Trademark Owner"};

                           var $el = $("#id_au_eligibility_type");
                           $el.empty();
                           $.each(newOptions, function(value,key) {
                           $el.append($("<option></option>")
                             .attr("value", value).text(key));
                           });  
                           if(orderFlag == 0)
                           {
                             $el.val("' . $eligibilityType . '"); 
                           }
                           update_ui_on_load();
                           if(orderFlag == 0)
                           {
                             $("#id_au_eligibility_id_type").val("' . $eligibilityIDType . '");
                           }

                       }
                       if(tld == "org.au" || tld == "asn.au")
                       {      
                           $("select[name=\'domainfield[0][5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[0][6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"}); 
                           $("select[name=\'domainfield[5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"}); 
                           var newOptions2 = {"Charity": "Charity",  "Club": "Club",  "Incorporated Association": "Incorporated Association", "Non-profit Organisation" : "Non-profit Organisation", "Trade Union" : "Trade Union"};

                           var $el = $("#id_au_eligibility_type");
                           $el.empty();
                           $.each(newOptions2, function(value,key) {
                           $el.append($("<option></option>")
                             .attr("value", value).text(key));
                           });
                           if(orderFlag == 0)
                           {
                             $el.val("' . $eligibilityType . '"); 
                           }
                           update_ui_on_load();
                           if(orderFlag == 0)
                           {
                             $("#id_au_eligibility_id_type").val("' . $eligibilityIDType . '");
                           }
                           
                       }
                       if(tld == "id.au")
                       {      
                           $("select[name=\'domainfield[0][5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[0][6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"}); 
                           $("select[name=\'domainfield[5]\']").attr({id: "id_au_eligibility_id_type"});
                           $("select[name=\'domainfield[6]\']").attr({id: "id_au_eligibility_type", onchange : "return on_change_entity_type(this.value)"});
                           
                           var newOptions3 = {"Citizen/Resident" : "Citizen/Resident"};
                           var $el = $("#id_au_eligibility_type");
                           $el.empty();
                           $.each(newOptions3, function(value,key) {
                           $el.append($("<option></option>")
                             .attr("value", value).text(key));
                           });
                           if(orderFlag == 0)
                           {
                             $el.val("' . $eligibilityType . '");
                           }
                           update_ui_on_load();
                           if(orderFlag == 0)
                           {
                             $("#id_au_eligibility_id_type").val("' . $eligibilityIDType . '");
                           }
                       }
                    }
                });
            }
            
            
            $("#domain0").blur(function(ele){
                autldfield();
            });
            
            $("#regdomain0").blur(function(ele){
                autldfield();
            });
            
             $("#domreg0").click(function(ele){
                    setTimeout(function() {
                          autldfield();
                    }, 1000);
            });
            
            ';
        if ($vars['filename'] == "clientsdomains") {
            $script .= 'autldfield();';
        }
    }
    /* Tld AU End */
    if (($vars['filename'] == 'clientarea' || $vars['filename'] == 'register' || $vars['filename'] == 'cart' || $vars['filename'] == 'clientsdomaincontacts' || $vars['filename'] == 'clientscontacts' || $vars['filename'] == 'clientsprofile' || $vars['filename'] == 'clientsadd') && opensrspro_getSetting('DisableTemplatesChanges') != 'on') {
        /*$pre_script.='
              <script type="text/javascript" src="includes/jscript/validate.js"></script>
          ';*/
        /* Added by BC : NG : 9-8-2014 : To Add validations for phone and email to contact forms  */
        $script .= '
            jQuery("input[name=\'phonenumber\']").blur(function(){
                if(!this.value.match(/^(\\+?[0-9]{1,3})\\.[0-9]+x?[0-9]*$/))
                {
                    if(!jQuery("#msg").length)
                    {
                        jQuery("input[name=\'phonenumber\']").after("<div id=\'msg\'></div>");
                    }
                    jQuery("#msg").html("<span style=\'color:#DF0101\'>Invalid Phone Number Format (ex. +1.4163334444 or 1.4163334444)</span>");
                     jQuery(".btn-primary").prop("disabled", true);
                }
                else
                {
                    jQuery("#msg").html("");
                    jQuery(".btn-primary").prop("disabled", false);
                }
            })
        ';
        $script .= '
            jQuery("input[name=\'email\']").blur(function(){
                if(!this.value.match(/^(("[\\w-\\s]+")|([\\w-]+(?:\\.[\\w-]+)*)|("[\\w-\\s]+")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/))
                {
                    if(!jQuery("#msgemail").length)
                    {
                        jQuery("input[name=\'email\']").after("<div id=\'msgemail\'></div>");
                    }
                    jQuery("#msgemail").html("<span style=\'color:#DF0101\'>Invalid Email Format (ex. johndoe@domain.com)</span>");
                     jQuery(".btn-primary").prop("disabled", true);
                }
                else
                {
                    jQuery("#msgemail").html("");
                    jQuery(".btn-primary").prop("disabled", false);
                }
            })
        ';
        $script .= '
            var phoneArray = ["contactdetails[Registrant][Phone]","contactdetails[Billing][Phone]","contactdetails[Admin][Phone]","contactdetails[Tech][Phone]"];
            jQuery("input[name^=\'contactdetails\']").each(function(e){    
                  if(jQuery.inArray(this.name,phoneArray) >= 0)
                  {
                      var phoneVal = "";
                      jQuery("input[name=\'"+this.name+"\']").blur(function(){
                            var divId = this.name.replace("contactdetails[","").replace("][Phone]","");
                            var phoneVal = this.value;
                            if(!phoneVal.match(/^(\\+?[0-9]{1,3})\\.[0-9]+x?[0-9]*$/))
                            {
                                if(!jQuery("#msg"+divId).length)
                                {
                                    jQuery("input[name=\'"+this.name+"\']").after("<div id=\'msg"+divId+"\'></div>");
                                }
                                jQuery("#msg"+divId).html("<span style=\'color:#DF0101\'>Invalid Phone Number Format (ex. +1.4163334444 or 1.4163334444)</span>");
                                jQuery(".btn-primary").prop("disabled", true);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", true);
                            }
                            else
                            {
                                jQuery("#msg"+divId).html("");
                                jQuery(".btn-primary").prop("disabled", false);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", false);
                            }
                      })
                     
                  }
                
            });
            
        ';
        $script .= '
            var emailArray = ["contactdetails[Registrant][Email]","contactdetails[Billing][Email]","contactdetails[Admin][Email]","contactdetails[Tech][Email]"];
            jQuery("input[name^=\'contactdetails\']").each(function(e){    
                  if(jQuery.inArray(this.name,emailArray) >= 0)
                  {
                      var emailVal = "";
                      jQuery("input[name=\'"+this.name+"\']").blur(function(){
                            var divIdEmail = this.name.replace("contactdetails[","").replace("]","").replace("[","").replace("]","");
                            var emailVal = this.value;
                            if(!emailVal.match(/^(("[\\w-\\s]+")|([\\w-]+(?:\\.[\\w-]+)*)|("[\\w-\\s]+")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/))
                            {
                                if(!jQuery("#msg"+divIdEmail).length)
                                {
                                    jQuery("input[name=\'"+this.name+"\']").after("<div id=\'msg"+divIdEmail+"\'></div>");
                                }
                                jQuery("#msg"+divIdEmail).html("<span style=\'color:#DF0101\'>Invalid Email Format (ex. johndoe@domain.com)</span>");
                                jQuery(".btn-primary").prop("disabled", true);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", true);
                            }
                            else
                            {
                                jQuery("#msg"+divIdEmail).html("");
                                jQuery(".btn-primary").prop("disabled", false);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", false);
                            }
                      })
                     
                  }
                
            });
            
        ';
        $script .= '
            var faxArray = ["contactdetails[Registrant][Fax]","contactdetails[Billing][Fax]","contactdetails[Admin][Fax]","contactdetails[Tech][Fax]"];
            jQuery("input[name^=\'contactdetails\']").each(function(e){    
                  if(jQuery.inArray(this.name,faxArray) >= 0)
                  {
                      var faxVal = "";
                      jQuery("input[name=\'"+this.name+"\']").blur(function(){
                            var divIdFax = this.name.replace("contactdetails[","").replace("]","").replace("[","").replace("]","");
                            var faxVal = this.value;
                            if(!faxVal.match(/^(\\+?[0-9]{1,3})\\.[0-9]+x?[0-9]*$/))
                            {
                                if(!jQuery("#msg"+divIdFax).length)
                                {
                                    jQuery("input[name=\'"+this.name+"\']").after("<div id=\'msg"+divIdFax+"\'></div>");
                                }
                                jQuery("#msg"+divIdFax).html("<span style=\'color:#DF0101\'>Invalid Fax Format (ex. +1.4163334444 or 1.4163334444)</span>");
                                jQuery(".btn-primary").prop("disabled", true);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", true)
                            }
                            else
                            {
                                jQuery("#msg"+divIdFax).html("");
                                jQuery(".btn-primary").prop("disabled", false);
                                jQuery("input[value=\'Save Changes\']").prop("disabled", false)
                            }
                      })
                     
                  }
                
            });
            
        ';
        /* End : To Add validations for phone and email to contact forms  */
        /* Added by BC : NG : 11-9-2014 : To Add JS validation at review & checkout page for Domain Registration  */
        $script .= '
            jQuery("input[name=\'domaincontactphonenumber\']").blur(function(){
                if(!this.value.match(/^(\\+?[0-9]{1,3})\\.[0-9]+x?[0-9]*$/))
                {
                    if(!jQuery("#msgdomaincontactphonenumber").length)
                    {
                        jQuery("input[name=\'domaincontactphonenumber\']").after("<div id=\'msgdomaincontactphonenumber\'></div>");
                    }
                    jQuery("#msgdomaincontactphonenumber").html("<span style=\'color:#DF0101\'>Invalid Phone Number Format (ex. +1.4163334444 or 1.4163334444)</span>");
                     jQuery(".ordernow").prop("disabled", true);
                }
                else
                {
                    jQuery("#msgdomaincontactphonenumber").html("");
                    jQuery(".ordernow").prop("disabled", false);
                }
            })
        ';
        $script .= '
            jQuery("input[name=\'domaincontactemail\']").blur(function(){
                if(!this.value.match(/^(("[\\w-\\s]+")|([\\w-]+(?:\\.[\\w-]+)*)|("[\\w-\\s]+")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/))
                {
                    if(!jQuery("#msgdomaincontactemail").length)
                    {
                        jQuery("input[name=\'domaincontactemail\']").after("<div id=\'msgdomaincontactemail\'></div>");
                    }
                    jQuery("#msgdomaincontactemail").html("<span style=\'color:#DF0101\'>Invalid Email Format (ex. johndoe@domain.com)</span>");
                    jQuery(".ordernow").prop("disabled", true);
                }
                else
                {
                    jQuery("#msgdomaincontactemail").html("");
                    jQuery(".ordernow").prop("disabled", false);
                }
            })
        ';
        /* END : To Add JS validation at review & checkout page for Domain Registration  */
    }
    /* Added by BC : NG : 21-8-2014 : To set role perimission for hide Registrant Verification Status (Using Role Permission) */
    if ($vars['filename'] == 'configadminroles' && opensrspro_getSetting('DisableTemplatesChanges') != 'on') {
        $command = 'getadmindetails';
        $adminuser = '';
        $values = '';
        $results = localAPI($command, $values, $adminuser);
        $admin_details = mysql_fetch_assoc(mysql_query("SELECT * FROM tbladmins WHERE id='" . mysql_real_escape_string($results['adminid']) . "'"));
        $query = mysql_query("SELECT permid FROM tbladminperms WHERE roleid='" . $admin_details['roleid'] . "'");
        $row = mysql_num_rows($query);
        $permId = array();
        if ($row > 0) {
            while ($res = mysql_fetch_array($query)) {
                array_push($permId, $res['permid']);
            }
        }
        if (in_array(999, $permId)) {
            $script .= '
                  
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent();
             firstTD.append("<input id=\'adminperms999\' checked=\'checked\' type=\'checkbox\' name=\'adminperms[999]\'><label for=\'adminperms999\'>Registrant Verification Status</label><br>");
        ';
        } else {
            $script .= '
                  
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent();
             firstTD.append("<input id=\'adminperms999\' type=\'checkbox\' name=\'adminperms[999]\'><label for=\'adminperms999\'>Registrant Verification Status</label><br>");
        ';
        }
        /* END : To set role perimission for hide Registrant Verification Status (Using Role Permission) */
        /* Added by BC : NG : 8-10-2014 : To set role perimission for hide View Domain Notes (Using Role Permission) */
        if (in_array(9999, $permId)) {
            $script .= '
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent().next();
             firstTD.append("<input id=\'adminperms9999\' checked=\'checked\' type=\'checkbox\' name=\'adminperms[9999]\'><label for=\'adminperms9999\'>&nbsp;View Domain Notes</label><br>");
             ';
        } else {
            $script .= '
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent().next();
             firstTD.append("<input id=\'adminperms9999\' type=\'checkbox\' name=\'adminperms[9999]\'><label for=\'adminperms9999\'>&nbsp;View Domain Notes</label><br>");
        ';
        }
        /* End : To set role perimission for hide View Domain Notes (Using Role Permission) */
        /* Added by BC : dd : 16-07-2014 :  Disallow Registrar permissions (Using Role Permission) */
        if (in_array(8888, $permId)) {
            $script .= '
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent().next().next();
             firstTD.append("<input id=\'adminperms8888\' checked=\'checked\' type=\'checkbox\' name=\'adminperms[8888]\'><label for=\'adminperms8888\'>&nbsp;Disallow Registrar Operations</label><br>");
             ';
        } else {
            $script .= '
             var firstTD = jQuery("input[name^=\'adminperms\']:first").parent().next().next();
             firstTD.append("<input id=\'adminperms8888\' type=\'checkbox\' name=\'adminperms[8888]\'><label for=\'adminperms8888\'>&nbsp;Disallow Registrar Operations</label><br>");
        ';
        }
        /* END*/
    }
    $script .= "\n        });\n        //]]>\n        </script>";
    return $pre_script . $script;
}
    # http://docs.whmcs.com/API:Update_Invoice - add BTC currency conversion in invoice notes
    $command = "updateinvoice";
    $values["invoiceid"] = $invoice_id;
    #changeme
    $values["notes"] = "BTC:{$total_btc_cents};USD:{$total_native_cents};";
    #changeme
    $results = localAPI($command, $values, $adminuser);
    //addInvoicePayment($invoice_id,$trans_id,$amount,$fee,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
    $command = "addinvoicepayment";
    $values["invoiceid"] = $invoice_id;
    $values["transid"] = $trans_id;
    $values["amount"] = $amount;
    $values["fee"] = $fee;
    $values["gateway"] = $GATEWAY['name'];
    $results = localAPI($command, $values, $adminuser);
    logTransaction($GATEWAY["name"], $json, "Successful");
    # Save to Gateway Log: name, data array, status
} elseif ($status == "canceled") {
    # Canceled
    $command = "updateinvoice";
    $values["invoiceid"] = $invoice_id;
    #changeme
    $values["status"] = "Unpaid";
    $results = localAPI($command, $values, $adminuser);
    logTransaction($GATEWAY["name"], $json, "Canceled");
    # Save to Gateway Log: name, data array, status
} else {
    # Unsuccessful
    logTransaction($GATEWAY["name"], $json, "Unsuccessful");
    # Save to Gateway Log: name, data array, status
}
Example #30
0
function ODR_RequestDelete($params)
{
    $module = ODR_Config($params);
    $login = ODR_Login($module);
    if ($login != "OK") {
        $values["error"] = $login;
        return $values;
    }
    $raw = $module->custom('/domain/renew-off/' . $params["domainname"] . '/', Api_Odr::METHOD_PUT);
    $result = $raw->getResult();
    logModuleCall("ODR", "RequestDelete | Cancel domain in ODR", $params["domainname"], $result, "", "");
    if ($result['status'] !== Api_Odr::STATUS_SUCCESS) {
        $values["error"] = 'Following error occurred: ' . $result['response']['message'];
        return $values;
    }
    $values["domainid"] = $params["domainid"];
    $values["status"] = "Cancelled";
    $result = localAPI("updateclientdomain", $values, $params['Adminuser']);
    logModuleCall("ODR", "RequestDelete | Cancel domain in WHMCS", $values, $result, "", "");
    return $values;
}