本文整理汇总了PHP中localAPI函数的典型用法代码示例。如果您正苦于以下问题:PHP localAPI函数的具体用法?PHP localAPI怎么用?PHP localAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了localAPI函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: smarty_function_oms_credit_time
/**
* 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 = "admin";
$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;
}
开发者ID:carriercomm,项目名称:opennode-whmcs,代码行数:38,代码来源:function.oms_credit_time.php
示例2: get_client_name
function get_client_name($clientid)
{
$client = "";
$command = "getclientsdetails";
$adminuser = "ilham";
$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;
}
开发者ID:hxinen,项目名称:whmcs-hook-slack,代码行数:26,代码来源:slack.php
示例3: handle
/**
* @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);
}
}
开发者ID:4ernovm,项目名称:whmcs-foundation,代码行数:10,代码来源:ExceptionHandler.php
示例4: purchaseorder_accept_order
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);
}
开发者ID:carriercomm,项目名称:whmcs-purchaseorder,代码行数:10,代码来源:purchaseorder.php
示例5: send_unsuspension_email
function send_unsuspension_email($var)
{
$server = $var["params"]["domain"];
lg_info("Sent unsuspension mail to " . $var["params"]["clientsdetails"]);
$command = "sendemail";
$adminuser = "admin";
$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);
}
开发者ID:carriercomm,项目名称:whmcs-customizations,代码行数:12,代码来源:send_unsuspension_mail.php
示例6: get_ticket_info
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;
}
}
开发者ID:vitaliy-orlov,项目名称:whmcs-slack-notif,代码行数:12,代码来源:tickets_hook.php
示例7: getCreditForUserId
function getCreditForUserId($userId)
{
$clientCredit = 0;
$command = "getcredits";
$adminuser = "admin";
$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;
}
开发者ID:carriercomm,项目名称:opennode-whmcs,代码行数:16,代码来源:hook_oms_dailycronjob.php
示例8: add_oms_user_promotion
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;
}
}
开发者ID:carriercomm,项目名称:opennode-whmcs,代码行数:45,代码来源:hook_oms_userpromotion.php
示例9: GoCardlessCaptureCron
/**
* 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 <[email protected]>
* @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 = "admin";
$values["invoiceid"] = $invoiceid;
$capture_results = localAPI($command, $values, $adminuser);
}
}
}
开发者ID:stehardy,项目名称:gocardless-whmcs,代码行数:34,代码来源:gocardless_hook.php
示例10: allProducts
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;
}
开发者ID:carriercomm,项目名称:WHMCS,代码行数:37,代码来源:products.php
示例11: TinyTunnel_Tom
/**
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 = 'admin';
//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
}
}
}
}
开发者ID:ThomasGlass,项目名称:productOpenTicket,代码行数:43,代码来源:productOpenTicket.php
示例12: feathur_CreateAccount
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;
}
开发者ID:AstroProfundis,项目名称:Feathur,代码行数:24,代码来源:feathur.php
示例13: getUsersOrders
function getUsersOrders($userId)
{
$command = "getorders";
$adminuser = "admin";
$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;
}
开发者ID:carriercomm,项目名称:opennode-whmcs,代码行数:20,代码来源:hook_oms_newvm.php
示例14: userProducts
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;
}
开发者ID:carriercomm,项目名称:WHMCS,代码行数:11,代码来源:clientservices.php
示例15: select_query
<?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']));
开发者ID:markbakeruk,项目名称:sirportly-whmcs,代码行数:30,代码来源:sso.php
示例16: select_query
$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);
开发者ID:markbakeruk,项目名称:sirportly-whmcs,代码行数:31,代码来源:frame.php
示例17: process
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);
}
}
}
}
开发者ID:Lev-Bartashevsky,项目名称:ElasticUsers,代码行数:66,代码来源:generate-invoices.php
示例18: opensrspro_viewdomainnotes
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;
}
开发者ID:carriercomm,项目名称:WHMCS-OpenSRSPro-Module,代码行数:26,代码来源:opensrspro.php
示例19: onapp_UsageUpdate
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 //
//.........这里部分代码省略.........
开发者ID:jessejusoli,项目名称:OnApp-WHMCS-Module,代码行数:101,代码来源:onapp.php
示例20: die
*/
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);
}
开发者ID:HostGuard,项目名称:whmcs-module,代码行数:31,代码来源:hostguardsuspend.php
注:本文中的localAPI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论