protected function execute($postParams, $existingSession = true) { if ($existingSession) { if (self::$sessionId === false) { $api = new TPPW_AuthAPI($this->params); $acountId = $this->params['AccountNo']; $userId = $this->params['Login']; $password = $this->params['Password']; $results = $api->authenticate($acountId, $userId, $password); if (!$results->isSuccess()) { return $results; } self::$sessionId = $results->getResponse(); } $postParams['SessionID'] = self::$sessionId; } $postParams = array_merge(TPPW_APIUtils::$API_COMMON_PARAMS, $postParams); $postFields = ''; foreach ($postParams as $key => $values) { if (is_array($values)) { foreach ($values as $value) { $postFields .= $key . '=' . urlencode($value) . '&'; } } else { $postFields .= $key . '=' . urlencode($values) . '&'; } } $conn = curl_init(); curl_setopt($conn, CURLOPT_URL, $this->url); curl_setopt($conn, CURLOPT_POST, 1); curl_setopt($conn, CURLOPT_POSTFIELDS, $postFields); curl_setopt($conn, CURLOPT_HEADER, false); curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($conn, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($conn); $error = curl_error($conn); $errorNum = curl_errno($conn); $stats = curl_getinfo($conn); curl_close($conn); $message = "<p><strong>API Query:</strong> <pre>{$this->url}?{$postFields}</pre></p>"; $message .= "<p><strong>Response:</strong> <pre>{$response}</pre></p>"; $message .= "<p><strong>Stats:</strong> <pre>" . print_r($stats, true) . "</pre></p>"; if (function_exists('logModuleCall')) { logModuleCall(TPPW_APIUtils::$MODULE_NAME, $this->url, $postFields, $response); } if ($this->params['Debug']) { logactivity($message); } if ($errorNum) { return new TPPW_APIResult("ERR-CURL: {$errorNum}, {$error}"); } return new TPPW_APIResult($response); }
/** * Handles updating WebsitePanel account details when a client or administrator updates a client's details * * @access public * @param array $params WHMCS parameters * @throws Exception */ function websitepanel_sync_ClientEdit($params) { // WHMCS server parameters & package parameters $userId = $params['userid']; $serviceId = 0; // Query for the users WebsitePanel accounts - If they do not have any, just ignore the request $result = full_query("SELECT h.username AS username, s.ipaddress AS serverip, s.hostname AS serverhostname, s.secure AS serversecure, s.username AS serverusername, s.password AS serverpassword, p.configoption6 AS configoption6, h.id AS serviceid FROM `tblhosting` AS h, `tblservers` AS s, `tblproducts` AS p WHERE h.userid = {$userId} AND h.packageid = p.id AND h.server = s.id AND s.type = 'websitepanel' AND h.domainstatus IN ('Active', 'Suspended')"); while (($row = mysql_fetch_array($result)) != false) { // Start updating the users account details $serviceId = $row['serviceid']; $username = $row['username']; $serverUsername = $row['serverusername']; $serverPassword = decrypt($row['serverpassword']); $serverPort = $row['configoption6']; $serverHost = empty($row['serverhostname']) ? $row['serverip'] : $row['serverhostname']; $serverSecure = $row['serversecure'] == 'on' ? TRUE : FALSE; $clientsDetails = $params; try { // Create the WebsitePanel Enterprise Server Client object instance $wsp = new websitepanel_EnterpriseServer($serverUsername, $serverPassword, $serverHost, $serverPort, $serverSecure); // Get the user's details from WebsitePanel - We need the username $user = $wsp->getUserByUsername($username); if (empty($user)) { throw new Exception("User {$username} does not exist - Cannot update account details for unknown user"); } // Update the user's account details using the previous details + WHMCS's details (address, city, state etc.) $userParams = array('RoleId' => $user['RoleId'], 'Role' => $user['Role'], 'StatusId' => $user['StatusId'], 'Status' => $user['Status'], 'LoginStatusId' => $user['LoginStatusId'], 'LoginStatus' => $user['LoginStatus'], 'FailedLogins' => $user['FailedLogins'], 'UserId' => $user['UserId'], 'OwnerId' => $user['OwnerId'], 'IsPeer' => $user['IsPeer'], 'Created' => $user['Created'], 'Changed' => $user['Changed'], 'IsDemo' => $user['IsDemo'], 'Comments' => $user['Comments'], 'LastName' => $clientsDetails['lastname'], 'Username' => $user['Username'], 'Password' => $user['Password'], 'FirstName' => $clientsDetails['firstname'], 'Email' => $clientsDetails['email'], 'PrimaryPhone' => $clientsDetails['phonenumber'], 'Zip' => $clientsDetails['postcode'], 'InstantMessenger' => '', 'Fax' => '', 'SecondaryPhone' => '', 'SecondaryEmail' => '', 'Country' => $clientsDetails['country'], 'Address' => $clientsDetails['address1'], 'City' => $clientsDetails['city'], 'State' => $clientsDetails['state'], 'HtmlMail' => $user['HtmlMail'], 'CompanyName' => $clientsDetails['companyname'], 'EcommerceEnabled' => $user['EcommerceEnabled'], 'SubscriberNumber' => ''); // Execute the UpdateUserDetails method $wsp->updateUserDetails($userParams); // Add log entry to client log logactivity("WebsitePanel Sync - Account {$username} contact details updated successfully", $userId); } catch (Exception $e) { // Error message to log / return $errorMessage = "websitepanel_sync_ClientEdit Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}, Service ID: {$serviceId})"; // Log to WHMCS logactivity($errorMessage, $userId); } } }
<?php # process SQL logactivity('OnApp Elastic User Module: process SQL file.'); $sql = file_get_contents(__DIR__ . '/module.sql'); $sql = explode(PHP_EOL . PHP_EOL, $sql); $tmpSQLConfig = $CONFIG['SQLErrorReporting']; $CONFIG['SQLErrorReporting'] = ''; foreach ($sql as $qry) { full_query($qry); } $CONFIG['SQLErrorReporting'] = $tmpSQLConfig; unset($tmpSQLConfig); # process mail templates todo uncomment require __DIR__ . '/module.mail.php'; # store module version $whmcs->set_config('OnAppElasticUsersVersion', OnAppElasticUsersModule::MODULE_VERSION);
private function checkSQL() { // todo rewrite if (file_exists($file = dirname(__DIR__) . '/module.sql')) { logactivity('OnApp User Module: process SQL file, called from cronjob.'); $sql = file_get_contents($file); $sql = explode(PHP_EOL . PHP_EOL, $sql); foreach ($sql as $qry) { full_query($qry); } unlink($file); } }
function InvoicePaidHook_OnAppElasticUsers($vars) { $invoiceID = $vars['invoiceid']; $qry = 'SELECT OnAppElasticUsers.`WHMCSUserID`, OnAppElasticUsers.`serverID`, OnAppElasticUsers.`OnAppUserID`, tblhosting.`id` AS service_id, tblinvoices.`subtotal` AS subtotal, tblinvoices.`total` AS total, tblproducts.`configoption1` AS settings, tblhosting.`domainstatus` AS status FROM tblinvoices LEFT JOIN OnAppElasticUsers ON tblinvoices.`userid` = OnAppElasticUsers.`WHMCSUserID` LEFT JOIN tblhosting ON tblhosting.`userid` = OnAppElasticUsers.`WHMCSUserID` AND tblhosting.`server` = OnAppElasticUsers.`serverID` RIGHT JOIN tblinvoiceitems ON tblinvoiceitems.`invoiceid` = tblinvoices.`id` AND tblinvoiceitems.`relid` = tblhosting.`id` LEFT JOIN tblproducts ON tblproducts.`id` = tblhosting.`packageid` WHERE tblinvoices.`id` = @invoiceID AND tblinvoices.`status` = "Paid" AND tblproducts.`servertype` = "OnAppElasticUsers" AND tblinvoiceitems.`type` = "OnAppElasticUsers" GROUP BY tblinvoices.`id`'; $qry = str_replace('@invoiceID', $invoiceID, $qry); $result = full_query($qry); if (mysql_num_rows($result) == 0) { return; } $data = mysql_fetch_assoc($result); if ($data['status'] == 'Suspended') { # check for other unpaid invoices for this service $qry = 'SELECT tblinvoices.`id` FROM tblinvoices RIGHT JOIN tblinvoiceitems ON tblinvoiceitems.`invoiceid` = tblinvoices.`id` AND tblinvoiceitems.`relid` = :serviceID WHERE tblinvoices.`status` = "Unpaid" GROUP BY tblinvoices.`id`'; $qry = str_replace(':serviceID', $data['service_id'], $qry); $result = full_query($qry); if (mysql_num_rows($result) == 0) { if (!function_exists('serverunsuspendaccount')) { $path = dirname(dirname(dirname(__DIR__))) . '/includes/'; require_once $path . 'modulefunctions.php'; } serverunsuspendaccount($data['service_id']); } } if (!defined('ONAPP_WRAPPER_INIT')) { define('ONAPP_WRAPPER_INIT', $path . 'wrapper/OnAppInit.php'); require_once ONAPP_WRAPPER_INIT; } $qry = 'SELECT `secure`, `username`, `hostname`, `password`, `ipaddress` FROM tblservers WHERE `type` = "OnAppElasticUsers" AND `id` = :serverID'; $qry = str_replace(':serverID', $data['server_id'], $qry); $result = full_query($qry); $server = mysql_fetch_assoc($result); $server['password'] = decrypt($server['password']); if ($server['secure']) { $server['address'] = 'https://'; } else { $server['address'] = 'http://'; } if (empty($server['ipaddress'])) { $server['address'] .= $server['hostname']; } else { $server['address'] .= $server['ipaddress']; } unset($server['ipaddress'], $server['hostname'], $server['secure']); # get OnApp amount $result = select_query('OnAppElasticUsers_Cache', 'data', ['itemID' => 123, 'type' => 'invoiceData']); $amount = mysql_fetch_object($result)->data; if ($amount) { $payment = new OnApp_Payment(); $payment->auth($server['address'], $server['username'], $server['password']); $payment->_user_id = $data['onapp_user_id']; $payment->_amount = $amount; $payment->_invoice_number = $invoiceID; $payment->save(); $error = $payment->getErrorsAsString(); if (empty($error)) { $msg = 'OnApp payment was sent. Service ID #' . $data['service_id'] . ', amount: ' . $amount; # delete invoice data $where = ['itemID' => $invoiceID, 'type' => 'invoiceData']; delete_query('OnAppElasticUsers_Cache', $where); } else { $msg = 'ERROR with OnApp payment for service ID #' . $data['service_id'] . ': ' . $error; } } else { $msg = 'ERROR with OnApp payment for service ID #' . $data['service_id'] . ': Cannot find OnApp amount'; } logactivity($msg); }
$expirydate = date("Y-m-d", strtotime($domains[$row['domain']]['Expires'])); if (!$expirydate) { $report .= "Getting expirydate for domain " . $row['domain'] . " failed\n"; } else { if ($expirydate != $row['expirydate']) { $update = array('expirydate' => $expirydate, 'nextduedate' => $expirydate); update_query("tbldomains", $update, array('id' => $row['id'])); $report .= "Domain " . $row['domain'] . " expirydate and nextduedate updated\n"; } } $count++; } } if (0 == $count) { $report .= "There were no domains to process\n"; } } } } $report .= "\n-----------------------------------------------------------------------------------------------------\n" . "End of report\n"; logactivity("Namecheap Domain Sync Run"); sendadminnotification("system", "WHMCS Namecheap Domain Synchronization Report", nl2br($report)); function namecheap_parseResult($transfers, $domainNameKey = "DomainName") { $result = array(); foreach ($transfers as $t) { $attr = $t['@attributes']; $result[strtolower($attr[$domainNameKey])] = $attr; } return $result; }
function disableuser($uid, $admlvl, $admgrp, $admid) { if (file_exists("config.php")) { require "config.php"; } else { require "../config.php"; } if (isset($admlvl)) { $admlvl = $admlvl; } else { $admlvl = $_SESSION[$secretkey . "userlvl"]; } if (isset($admgrp)) { $admgrp = $admgrp; } else { $admgrp = $_SESSION[$secretkey . "usergrp"]; } $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); $sql = $mysqli->query("SELECT usrgroup FROM users WHERE id='" . $uid . "'"); $delres = $sql->fetch_array(); if ($admlvl == "2" && $admgrp != $delres["usrgroup"]) { $status = "1"; } else { $mysqli->query("UPDATE users SET enabled='0',changed='" . date('Y-m-d H:i:s') . "',changedby='" . $admid . "' WHERE id='" . $uid . "'"); if (checksetting("logactivity") == "1") { logactivity("5", $admid, $admlvl, $uid, idtouser($uid)); } $status = "0"; } mysqli_close($mysqli); return $status; }
<?php use Illuminate\Database\Capsule\Manager as Capsule; # process SQL logactivity(OnAppvCDModule::MODULE_NAME . ' Module: process SQL file.'); $sql = file_get_contents(__DIR__ . '/module.sql'); $sql = explode(';', $sql); $tmpSQLConfig = $CONFIG['SQLErrorReporting']; $CONFIG['SQLErrorReporting'] = ''; foreach ($sql as $qry) { $qry = trim($qry); if (!$qry) { continue; } $qry = str_replace('{moduleName}', OnAppvCDModule::MODULE_NAME, $qry); try { Capsule::connection()->statement($qry); } catch (\Exception $e) { logactivity('SQL ERROR: ' . $e->getMessage()); } } $CONFIG['SQLErrorReporting'] = $tmpSQLConfig; unset($tmpSQLConfig); # process mail templates require __DIR__ . '/module.mail.php'; # store module version $whmcs->set_config(OnAppvCDModule::MODULE_NAME . 'Version', OnAppvCDModule::MODULE_VERSION);
<?php if (!defined('ONAPP_WRAPPER_INIT')) { define('ONAPP_WRAPPER_INIT', ROOTDIR . '/includes/wrapper/OnAppInit.php'); } if (file_exists(ONAPP_WRAPPER_INIT)) { require_once ONAPP_WRAPPER_INIT; } loadLang(); if (file_exists($file = __DIR__ . '/module.sql')) { logactivity('OnApp User Module: process SQL file, called from module.'); $sql = file_get_contents($file); $sql = explode(PHP_EOL . PHP_EOL, $sql); foreach ($sql as $qry) { full_query($qry); } unlink($file); // Add e-mail templates require_once __DIR__ . '/module.mail.php'; } function onappusers_ConfigOptions() { global $_LANG; if (!file_exists(ONAPP_WRAPPER_INIT)) { $configArray = array($_LANG['onappwrappernotfound'] . realpath(ROOTDIR) . '/includes/wrapper' => array()); return $configArray; } $js = '<script type="text/javascript" src="../modules/servers/onappusers/includes/js/onappusers.js"></script>'; $js .= '<script type="text/javascript" src="../modules/servers/onappusers/includes/js/tz.js"></script>'; $serverGroup = isset($_GET['servergroup']) ? $_GET['servergroup'] : (int) $GLOBALS['servergroup']; $sql = 'SELECT
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 fbpromo_message($message, $type = 'debug') { global $barEcho; if (is_array($message)) { $message = print_r($message, true); } $output = $message; if (!isset($barEcho) || $barEcho) { echo '<br />' . $output, '<br />'; } logactivity($output); }
function hook_onappusers_InvoicePaid($vars) { $invoice_id = $vars['invoiceid']; $qry = 'SELECT tblonappusers.`client_id`, tblonappusers.`server_id`, tblonappusers.`onapp_user_id`, tblhosting.`id` AS service_id, tblinvoices.`subtotal` AS subtotal, tblinvoices.`total` AS total, tblproducts.`configoption1` AS settings, tblhosting.`domainstatus` AS status FROM tblinvoices LEFT JOIN tblonappusers ON tblinvoices.`userid` = tblonappusers.`client_id` LEFT JOIN tblhosting ON tblhosting.`userid` = tblonappusers.`client_id` AND tblhosting.`server` = tblonappusers.`server_id` RIGHT JOIN tblinvoiceitems ON tblinvoiceitems.`invoiceid` = tblinvoices.`id` AND tblinvoiceitems.`relid` = tblhosting.`id` LEFT JOIN tblproducts ON tblproducts.`id` = tblhosting.`packageid` WHERE tblinvoices.`id` = :invoiceID AND tblinvoices.`status` = "Paid" AND tblproducts.`servertype` = "onappusers" AND tblinvoiceitems.`type` = "onappusers" GROUP BY tblinvoices.`id`'; $qry = str_replace(':invoiceID', $invoice_id, $qry); $result = full_query($qry); if (mysql_num_rows($result) == 0) { return; } $data = mysql_fetch_assoc($result); $path = dirname(dirname(dirname(__DIR__))) . '/includes/'; if ($data['status'] == 'Suspended') { // check for other unpaid invoices for this service $qry = 'SELECT tblinvoices.`id` FROM tblinvoices RIGHT JOIN tblinvoiceitems ON tblinvoiceitems.`invoiceid` = tblinvoices.`id` AND tblinvoiceitems.`relid` = :serviceID WHERE tblinvoices.`status` = "Unpaid" GROUP BY tblinvoices.`id`'; $qry = str_replace(':serviceID', $data['service_id'], $qry); $result = full_query($qry); if (mysql_num_rows($result) == 0) { if (!function_exists('serverunsuspendaccount')) { require_once $path . 'modulefunctions.php'; } serverunsuspendaccount($data['service_id']); } } if (!defined('ONAPP_WRAPPER_INIT')) { define('ONAPP_WRAPPER_INIT', $path . 'wrapper/OnAppInit.php'); require_once ONAPP_WRAPPER_INIT; } $qry = 'SELECT `secure`, `username`, `hostname`, `password`, `ipaddress` FROM tblservers WHERE `type` = "onappusers" AND `id` = :serverID'; $qry = str_replace(':serverID', $data['server_id'], $qry); $result = full_query($qry); $server = mysql_fetch_assoc($result); $server['password'] = decrypt($server['password']); if ($server['secure']) { $server['address'] = 'https://'; } else { $server['address'] = 'http://'; } if (empty($server['ipaddress'])) { $server['address'] .= $server['hostname']; } else { $server['address'] .= $server['ipaddress']; } unset($server['ipaddress'], $server['hostname'], $server['secure']); # get OnApp amount $qry = 'SELECT `amount` FROM `tblonappusers_invoices` LIMIT 1'; $res = mysql_query($qry); $amount = mysql_result($res, 0); $payment = new OnApp_Payment(); $payment->auth($server['address'], $server['username'], $server['password']); $payment->_user_id = $data['onapp_user_id']; $payment->_amount = $amount; $payment->_invoice_number = $invoice_id; $payment->save(); $where = array('id' => $invoice_id); delete_query('tblonappusers_invoices', $where); $error = $payment->getErrorsAsString(); if (empty($error)) { logactivity('OnApp payment was sent. Service ID #' . $data['service_id'] . ', amount: ' . $amount); } else { logactivity('ERROR with OnApp payment for service ID #' . $data['service_id'] . ': ' . $error); } }
function bar_message($message, $type = 'debug') { global $barEcho; if (is_array($message)) { $message = print_r($message, true); } $output = 'Backup & Restore: ' . $message; //if (!$barNlc || isset($_SERVER['HTTP_USER_AGENT'])) echo '<br />'.$output,'<br />'; if (!isset($barEcho) || $barEcho) { echo '<br />' . $output, '<br />'; } logactivity($output); }
function bar_processtest($vars) { logactivity('testing hook'); }
<?php logactivity('OnApp User Module: process mail templates file, called from module.'); // create account template $where = array(); $where['type'] = 'product'; $where['name'] = 'OnApp account has been created'; if (!mysql_num_rows(select_query('tblemailtemplates', 'id', $where))) { $fields = array(); $fields['type'] = 'product'; $fields['name'] = $fields['subject'] = $where['name']; $fields['message'] = '<p>Dear {$client_name},</p> <p>Your OnApp account has been created:<br /> login: {$service_username}<br /> password: {$service_password}</p> <p></p> To login, visit http://{$service_server_ip}'; $fields['plaintext'] = 0; insert_query('tblemailtemplates', $fields); } // suspend account template $where = array(); $where['type'] = 'product'; $where['name'] = 'OnApp account has been suspended'; if (!mysql_num_rows(select_query('tblemailtemplates', 'id', $where))) { $fields = array(); $fields['type'] = 'product'; $fields['name'] = $fields['subject'] = $where['name']; $fields['message'] = '<p>Dear {$client_name},</p> <p>Your OnApp account has been suspended.</p>'; $fields['plaintext'] = 0; insert_query('tblemailtemplates', $fields);
if (!$result) { $cronreport .= "Error connecting to API:<br>" . nl2br($data) . "<br>"; } else { $queryresult = select_query("tbldomains", "domain", "registrar='internetbs' AND (status='Pending Transfer' OR status='Active')"); while ($data = mysql_fetch_array($queryresult)) { $domainname = trim(strtolower($data['domain'])); if (isset($result[$domainname])) { if (!is_null($result[$domainname]["expiry"])) { $expirydate = date("Y-m-d", $result[$domainname]["expiry"]); } else { $expirydate = false; } $status = $result[$domainname]["status"]; if ($status == 'ok') { update_query("tbldomains", array("status" => "Active"), array("domain" => $domainname)); } if ($expirydate) { update_query("tbldomains", array("expirydate" => $expirydate), array("domain" => $domainname)); if ($SyncNextDueDate) { update_query("tbldomains", array("nextduedate" => $expirydate), array("domain" => $domainname)); } $cronreport .= '' . 'Updated ' . $domainname . ' expiry to ' . frommysqldate($expirydate) . '<br>'; } } else { $cronreport .= '' . 'ERROR: ' . $domainname . ' - Domain does not appear in the account at Internet.bs.<br>'; } } } } logactivity('Internet.bs Domain Sync Run'); sendadminnotification('system', 'WHMCS Internet.bs Domain Syncronisation Report', $cronreport);
/** * Handles activating and adding client addons to WebsitePanel * * @access public * @param array $params WHMCS parameters * @throws Exception */ function websitepanel_addons_AddonActivation($params) { // WHMCS server parameters & package parameters $userId = $params['userid']; $serviceId = $params['serviceid']; $addonId = $params['addonid']; $result = full_query("SELECT h.username AS username, s.ipaddress AS serverip, s.hostname AS serverhostname, s.secure AS serversecure, s.username AS serverusername, s.password AS serverpassword, p.configoption6 AS configoption6, h.id AS serviceid FROM `tblhosting` AS h, `tblservers` AS s, `tblproducts` AS p, `mod_wspaddons` AS w WHERE h.packageid = p.id AND w.whmcs_id = {$addonId} AND h.id = {$serviceId} AND h.server = s.id AND s.type = 'websitepanel'"); if (mysql_num_rows($result) > 0) { // Get the results of the query $row = mysql_fetch_assoc($result); // Start processing the users addon $username = $row['username']; $serverUsername = $row['serverusername']; $serverPassword = decrypt($row['serverpassword']); $serverPort = $row['configoption6']; $serverHost = empty($row['serverhostname']) ? $row['serverip'] : $row['serverhostname']; $serverSecure = $row['serversecure'] == 'on' ? TRUE : FALSE; try { // Create the WebsitePanel Enterprise Server Client object instance $wsp = new websitepanel_EnterpriseServer($serverUsername, $serverPassword, $serverHost, $serverPort, $serverSecure); // Get the user's details from WebsitePanel - We need the UserId $user = $wsp->getUserByUsername($username); if (empty($user)) { throw new Exception("User {$username} does not exist - Cannot allocate addon for unknown user"); } // Get the user's package details from WebsitePanel - We need the PackageId $package = $wsp->getUserPackages($user['UserId']); $packageId = $package['PackageId']; // Get the associated WebsitePanel addon id $results = select_query('mod_wspaddons', 'wsp_id,is_ipaddress', array('whmcs_id' => $addonId)); $addon = mysql_fetch_array($results); $addonPlanId = $addon['wsp_id']; $addonIsIpAddress = $addon['is_ipaddress']; // Add the Addon Plan to the customer's WebsitePanel package / hosting space $results = $wsp->addPackageAddonById($packageId, $addonPlanId); // Check the results to verify that the addon has been successfully allocated if ($results['Result'] > 0) { // If this addon is an IP address addon - attempt to randomly allocate an IP address to the customer's hosting space if ($addonIsIpAddress) { $wsp->allocatePackageIPAddresses($packageId); } // Add log entry to client log logactivity("WebsitePanel Addon - Account {$username} addon successfully completed - Addon ID: {$addonId}", $userId); } else { // Add log entry to client log throw new Exception("Unknown", $results['Result']); } } catch (Exception $e) { // Error message to log / return $errorMessage = "websitepanel_addons_AddonActivation Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}, Service ID: {$serviceId})"; // Log to WHMCS logactivity($errorMessage, $userId); } } }
/** * Returns the WebsitePanel one-click login link * * @param array $params WHMCS parameters * @throws Exception * @return string */ function websitepanel_LoginLink($params) { // WHMCS does not return the full hosting account details, we will query for what we need $result = select_query('tblhosting', 'domainstatus', array('id' => $params['serviceid'])); $results = mysql_fetch_array($result); $params['domainstatus'] = $results['domainstatus']; // Display the link only if the account is Active or Suspended if (in_array($params['domainstatus'], array('Active', 'Suspended'))) { // WHMCS server parameters & package parameters $serverUsername = $params['serverusername']; $serverPassword = $params['serverpassword']; $serverPort = $params['configoption6']; $serverHost = empty($params['serverhostname']) ? $params['serverip'] : $params['serverhostname']; $serverSecure = $params['serversecure']; $username = $params['username']; $serviceId = $params['serviceid']; $clientsDetails = $params['clientsdetails']; $userId = $clientsDetails['userid']; try { // Create the WebsitePanel Enterprise Server Client object instance $wsp = new websitepanel_EnterpriseServer($serverUsername, $serverPassword, $serverHost, $serverPort, $serverSecure); // Get the user's details from WebsitePanel - We need the userid $user = $wsp->getUserByUsername($username); if (empty($user)) { throw new Exception("User {$username} does not exist - Cannot display account link for unknown user"); } // Load the client area language file $LANG = websitepanel_LoadClientLanguage(); // Print the link echo "<a href=\"{$params['configoption8']}/Default.aspx?pid=Home&UserID={$user['UserId']}\" target=\"_blank\" title=\"{$LANG['websitepanel_adminarea_gotowebsitepanelaccount']}\">{$LANG['websitepanel_adminarea_gotowebsitepanelaccount']}</a><br />"; // Log the module call websitepanel_logModuleCall(__FUNCTION__, $params, $user); } catch (Exception $e) { // Error message to log / return $errorMessage = "LoginLink Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}, Service ID: {$serviceId})"; // Log to WHMCS logactivity($errorMessage, $userId); // Log the module call websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage()); } } }
/** * @param $vars * * @return bool */ function ProductEditHook_OnAppvCD($vars) { if ($_POST['servertype'] === ($moduleName = OnAppvCDModule::MODULE_NAME)) { $serverID = $_POST[$moduleName . '_Server'] ?: $_POST['packageconfigoption'][1]; if (empty($_POST[$moduleName . '_Skip']) && isset($_POST[$moduleName . '_Server'])) { if (!empty($_POST[$moduleName . '_Prev'])) { $settings = json_decode(html_entity_decode($_POST[$moduleName . '_Prev'])); } else { $settings = new stdClass(); } $settings->{$serverID} = $_POST[$moduleName]; # store product settings Capsule::table('tblproducts')->where('id', $vars['pid'])->update(['configoption2' => $_POST[$moduleName]['BillingType'], 'configoption3' => $_POST[$moduleName]['SuspendDays'], 'configoption5' => $_POST[$moduleName]['DueDays'], 'configoption6' => $_POST[$moduleName]['TerminateDays'], 'configoption7' => $_POST[$moduleName]['OrganizationType'], 'configoption24' => json_encode($settings)]); } # reset server cache if (!empty($_POST[$moduleName . '_ResetServerCache'])) { try { Capsule::table($moduleName . '_Cache')->where('type', 'serverData')->where('itemID', $serverID)->delete(); } catch (\Exception $e) { logactivity('SQL ERROR: ' . $e->getMessage()); } } # create custom field if ($_POST[$moduleName]['OrganizationType'] == 2) { $exist = Capsule::table('tblcustomfields')->where('type', 'product')->where('fieldname', 'Organization Name')->where('relid', $vars['pid'])->first(); if (!$exist) { Capsule::table('tblcustomfields')->insert(['type' => 'product', 'fieldtype' => 'text', 'required' => 'on', 'showorder' => 'on', 'fieldname' => 'Organization Name', 'relid' => $vars['pid']]); } } } return true; }
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)) { $clientAmount = $this->getAmount($client); if (!$clientAmount) { continue; } if ($clientAmount->total_cost > 0) { $client['dueDate'] = htmlspecialchars_decode($client['dueDate']); $client['dueDate'] = json_decode($client['dueDate']); $client['dueDate'] = $client['dueDate']->DueDateCurrent->{$client}['server_id']; $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` = "onappusers" WHERE `invoiceid` = :invoiceID'; $qry = str_replace(':WHMCSServiceID', $client['service_id'], $qry); $qry = str_replace(':invoiceID', $result['invoiceid'], $qry); full_query($qry); $table = 'tblonappusers_invoices'; $values = array('id' => $result['invoiceid'], 'amount' => $this->dataTMP->total_cost); insert_query($table, $values); } } } }