Pushing the new v3.x.x series WHMCS WebsitePanel module
This commit is contained in:
parent
bb873be496
commit
a9263bc903
17 changed files with 1895 additions and 1707 deletions
|
@ -0,0 +1,2 @@
|
|||
<br />
|
||||
<form action="{$websitepanel_url}/default.aspx?pid=Login" method="POST" target="_blank"><input type="hidden" value="{$username}" name="user"><input type="hidden" value="{$password}" name="password"><input type="submit" value="{$LANG.websitepanel_clientarea_oneclicklogin}"></form>
|
|
@ -0,0 +1,502 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* WebsitePanel Enterprise Server Client
|
||||
* For the ASPnix WebsitePanel system only - Only tested against the ASPnix WebsitePanel system
|
||||
*
|
||||
* @author Christopher York
|
||||
* @link http://www.websitepanel.net/
|
||||
* @access public
|
||||
* @name websitepanel_EnterpriseServer
|
||||
* @version 3.0.2
|
||||
* @package WHMCS
|
||||
* @final
|
||||
*/
|
||||
final class websitepanel_EnterpriseServer
|
||||
{
|
||||
/**
|
||||
* WebsitePanel user account statuses / states
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
const USERSTATUS_ACTIVE = 'Active';
|
||||
const USERSTATUS_SUSPENDED = 'Suspended';
|
||||
const USERSTATUS_CANCELLED = 'Cancelled';
|
||||
const USERSTATUS_PENDING = 'Pending';
|
||||
|
||||
/**
|
||||
* WebsitePanel usage calculation types
|
||||
*
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
const USAGE_DISKSPACE = 0;
|
||||
const USAGE_BANDWIDTH = 1;
|
||||
|
||||
/**
|
||||
* Enterprise Server username
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_username;
|
||||
|
||||
/**
|
||||
* Enterprise Server password
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_password;
|
||||
|
||||
/**
|
||||
* Enterprise Server URL / address (without the port)
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_host;
|
||||
|
||||
/**
|
||||
* Enterprise Server TCP port
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_port;
|
||||
|
||||
/**
|
||||
* Use SSL (HTTPS) for Enterprise Server communications
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $_secured;
|
||||
|
||||
/**
|
||||
* SoapClient WSDL caching
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $_caching;
|
||||
|
||||
/**
|
||||
* SoapClient HTTP compression
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $_compression;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param boolean $secured
|
||||
* @param boolean $caching
|
||||
* @param boolean $compression
|
||||
*/
|
||||
function __construct($username, $password, $host, $port = 9002, $secured = FALSE, $caching = FALSE, $compression = TRUE)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
$this->_host = $host;
|
||||
$this->_port = $port;
|
||||
$this->_secured = $secured;
|
||||
$this->_caching = $caching;
|
||||
$this->_compression = $compression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "CreateUserWizard" method
|
||||
*
|
||||
* @param array $params CreateUserWizard method parameters
|
||||
* @throws Exception
|
||||
* @return int
|
||||
*/
|
||||
public function createUserWizard($params)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->execute('esPackages.asmx', 'CreateUserWizard', $params)->CreateUserWizardResult;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("ChangeUserStatus Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "UpdateUser" method
|
||||
*
|
||||
* @access private
|
||||
* @param array $params
|
||||
* @throws Exception
|
||||
* @return int
|
||||
*/
|
||||
public function updateUserDetails($params)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->execute('esUsers.asmx', 'UpdateUser', array('user' => $params))->UpdateUserResult;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("UpdateUser Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "DeleteUser" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $userId User's WebsitePanel userId
|
||||
* @throws Exception
|
||||
* @return int
|
||||
*/
|
||||
public function deleteUser($userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->execute('esUsers.asmx', 'DeleteUser', array('userId' => $userId))->DeleteUserResult;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("ChangeUserStatus Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "GetUserByUsername" method
|
||||
*
|
||||
* @access public
|
||||
* @param string $username Websitepanel username
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function getUserByUsername($username)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->convertArray($this->execute('esUsers.asmx', 'GetUserByUsername', array('username' => $username))->GetUserByUsernameResult);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("GetUserByUsername Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()})", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "ChangeUserStatus" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $userId User's WebsitePanel userId
|
||||
* @param string $status Account status (Active, Suspended, Cancelled, Pending)
|
||||
* @throws Exception
|
||||
* @return int
|
||||
*/
|
||||
public function changeUserStatus($userId, $status)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->execute('esUsers.asmx', 'ChangeUserStatus', array('userId' => $userId, 'status' => $status))->ChangeUserStatusResult;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("ChangeUserStatus Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "ChangeUserPassword" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $userId User's WebsitePanel userId
|
||||
* @param string $password User's new password
|
||||
* @throws Exception
|
||||
* @return int
|
||||
*/
|
||||
public function changeUserPassword($userId, $password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->execute('esUsers.asmx', 'ChangeUserPassword', array('userId' => $userId, 'password' => $password))->ChangeUserPasswordResult;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("ChangeUserPassword Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "GetMyPackages" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $userId User's WebsitePanel userId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function getUserPackages($userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->convertArray($this->execute('esPackages.asmx', 'GetMyPackages', array('userId' => $userId))->GetMyPackagesResult->PackageInfo);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("GetMyPackages Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "GetUsersPagedRecursive" method
|
||||
*
|
||||
* @access public
|
||||
* @param unknown $userId Users's WebsitePanel userId
|
||||
* @param unknown $filterColumn Column value to filter against
|
||||
* @param unknown $filterValue Filter value
|
||||
* @param unknown $statusId Users's account status id
|
||||
* @param unknown $roleId User's account role id
|
||||
* @param unknown $sortColumn Column value to sort against
|
||||
* @param number $startRow Start value
|
||||
* @param string $maximumRows Maximum rows to return
|
||||
* @throws Exception
|
||||
* @return object
|
||||
*/
|
||||
public function getUsersPagedRecursive($userId, $filterColumn, $filterValue, $statusId, $roleId, $sortColumn, $startRow = 0, $maximumRows = PHP_INT_MAX)
|
||||
{
|
||||
try
|
||||
{
|
||||
$result = (array)$this->execute('esUsers.asmx', 'GetUsersPagedRecursive', array('userId' => $userId, 'filterColumn' => $filterColumn, 'filterValue' => $filterValue, 'statusId' => $statusId, 'roleId' => $roleId, 'sortColumn' => $sortColumn, 'startRow' => $startRow, 'maximumRows' => $maximumRows))->GetUsersPagedRecursiveResult;
|
||||
return $this->convertArray($result['any'], TRUE);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("GetUsersPagedRecursive Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "UpdatePackageLiteral" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $packageId Package's WebsitePanel packageId
|
||||
* @param int $statusId Package's status id
|
||||
* @param int $planId Package's WebsitePanel planid
|
||||
* @param string $purchaseDate Package's purchase date
|
||||
* @param string $packageName Package's name
|
||||
* @param string $packageComments Package's comments
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function updatePackageLiteral($packageId, $statusId, $planId, $purchaseDate, $packageName, $packageComments)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->convertArray($this->execute('esPackages.asmx', 'UpdatePackageLiteral', array('packageId' => $packageId, 'statusId' => $statusId, 'planId' => $planId, 'purchaseDate' => $purchaseDate, 'packageName' => $packageName, 'packageComments' => $packageComments))->UpdatePackageLiteralResult);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("UpdatePackageLiteral Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "AddPackageAddonById" method
|
||||
*
|
||||
* @access public
|
||||
* @param unknown $packageId WebsitePanel package Id
|
||||
* @param unknown $addonPlanId WebsitePanel addon id
|
||||
* @param number $quantity Number of addons to add :)
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function addPackageAddonById($packageId, $addonPlanId, $quantity = 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->convertArray($this->execute('esPackages.asmx', 'AddPackageAddonById', array('packageId' => $packageId, 'addonPlanId' => $addonPlanId, 'quantity' => $quantity))->AddPackageAddonByIdResult);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("AddPackageAddonById Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "GetPackageBandwidth" method
|
||||
*
|
||||
* @access public
|
||||
* @param unknown $packageId WebsitePanel package id
|
||||
* @param unknown $startDate Calculation start date
|
||||
* @param unknown $endDate Calculation end date
|
||||
* @throws Exception
|
||||
* @return object
|
||||
*/
|
||||
public function getPackageBandwidthUsage($packageId, $startDate, $endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
$result = (array)$this->execute('esPackages.asmx', 'GetPackageBandwidth', array('packageId' => $packageId, 'startDate' => $startDate, 'endDate' => $endDate))->GetPackageBandwidthResult;
|
||||
return $this->convertArray($result['any'], TRUE);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("GetPackageBandwidth Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "GetPackageDiskspace" method
|
||||
*
|
||||
* @access public
|
||||
* @param unknown $packageId WebsitePanel package id
|
||||
* @throws Exception
|
||||
* @return object
|
||||
*/
|
||||
public function getPackageDiskspaceUsage($packageId)
|
||||
{
|
||||
try
|
||||
{
|
||||
$result = (array)$this->execute('esPackages.asmx', 'GetPackageDiskspace', array('packageId' => $packageId))->GetPackageDiskspaceResult;
|
||||
return $this->convertArray($result['any'], TRUE);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("GetPackageDiskspace Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the "AllocatePackageIPAddresses" method
|
||||
*
|
||||
* @access public
|
||||
* @param int $packageId WebsitePanel package id
|
||||
* @param string $groupName WebsitePanel IP address group name
|
||||
* @param string $pool WebsitePanel IP address pool
|
||||
* @param int $addressesNumber Number of IP addresses to allocate
|
||||
* @param string $allocateRandom Allocate randomly
|
||||
* @throws Exception
|
||||
* @return object
|
||||
*/
|
||||
public function allocatePackageIPAddresses($packageId, $groupName = 'Web', $pool = 'WebSites', $addressesNumber = 1, $allocateRandom = TRUE)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->convertArray($this->execute('esServers.asmx', 'AllocatePackageIPAddresses', array('packageId' => $packageId, 'groupName' => $groupName, 'pool' => $pool, 'addressesNumber' => $addressesNumber, 'allocateRandom' => $allocateRandom))->AllocatePackageIPAddressesResult);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("AllocatePackageIPAddresses Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}", $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the WebsitePanel error code to a friendly human-readable message
|
||||
*
|
||||
* @access public
|
||||
* @param int $code WebsitePanel error code
|
||||
* @return string
|
||||
*/
|
||||
public static function getFriendlyError($code)
|
||||
{
|
||||
$errors = array(-100 => 'Username not available, already in use',
|
||||
-101 => 'Username not found, invalid username',
|
||||
-102 => 'User\'s account has child accounts',
|
||||
-300 => 'Hosting package could not be found',
|
||||
-301 => 'Hosting package has child hosting spaces',
|
||||
-501 => 'The sub-domain belongs to an existing hosting space that does not allow sub-domains to be created',
|
||||
-502 => 'The domain or sub-domain exists in another hosting space / user account',
|
||||
-511 => 'Instant alias is enabled, but not configured',
|
||||
-601 => 'The website already exists on the target hosting space or server',
|
||||
-700 => 'The email domain already exists on the target hosting space or server',
|
||||
-1100 => 'User already exists');
|
||||
|
||||
// Find the error and return it, else a general error will do!
|
||||
if (array_key_exists($code, $errors))
|
||||
{
|
||||
return $errors[$code];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "An unknown error occured (Code: {$code}). Please reference WebsitePanel BusinessErrorCodes for further information";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request on the Enterprise Server and returns the results
|
||||
*
|
||||
* @param unknown $service
|
||||
* @param unknown $method
|
||||
* @param unknown $params
|
||||
* @throws Exception
|
||||
*/
|
||||
private function execute($service, $method, $params)
|
||||
{
|
||||
// Set the Enterprise Server full URL
|
||||
$host = (($this->_secured) ? 'https' : 'http') . "://{$this->_host}:{$this->_port}/{$service}?WSDL";
|
||||
try
|
||||
{
|
||||
// Create the SoapClient
|
||||
$client = new SoapClient($host, array('login' => $this->_username, 'password' => $this->_password, 'compression' => (($this->_compression) ? (SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP) : ''), 'cache_wsdl' => ($this->_caching) ? 1 : 0));
|
||||
|
||||
// Execute the request and process the results
|
||||
return call_user_func(array($client, $method), $params);
|
||||
}
|
||||
catch (SoapFault $e)
|
||||
{
|
||||
throw new Exception("SOAP Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()})");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception("General Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()})");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an object or an XML string to an array
|
||||
*
|
||||
* @access private
|
||||
* @param mixed $value Object or an XML string
|
||||
* @param boolean $loadXml Loads the string into the SimpleXML object
|
||||
* @return array
|
||||
*/
|
||||
private function convertArray($value, $loadXml = FALSE)
|
||||
{
|
||||
// This is silly, but it works, and it works very well for what we are doing :)
|
||||
return json_decode(json_encode(($loadXml ? simplexml_load_string($value) : $value)), TRUE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* WebsitePanel WHMCS Server Module Shared Funcitons
|
||||
*
|
||||
* @author Christopher York
|
||||
* @link http://www.websitepanel.net/
|
||||
* @access public
|
||||
* @name websitepanel
|
||||
* @version 3.0.2
|
||||
* @package WHMCS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculate the bandwidth calculation starting date based on when the customer signed up
|
||||
*
|
||||
* @access public
|
||||
* @param string $startDate Customer registration date (starting date)
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_CreateBandwidthDate($startDate)
|
||||
{
|
||||
$dateExploded = explode('-', $startDate);
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
$newDate = "{$currentYear}-{$currentMonth}-{$dateExploded[2]}";
|
||||
|
||||
$dateDiff = time() - strtotime('+1 hour', strtotime($newDate));
|
||||
$fullDays = floor($dateDiff / (60 * 60 * 24));
|
||||
if ($fullDays < 0)
|
||||
{
|
||||
return date('Y-m-d', strtotime('-1 month', strtotime($newDate)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return $newDate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the total usage of the provided WebsitePanel usage tables
|
||||
* Each websitepanel provider / service calculates its own disk and bandwidth usage, total all provided tables and return
|
||||
*
|
||||
* @access public
|
||||
* @param array $usageTables Usage tables (each service provides its own usage breakdown)
|
||||
* @param int $usageType WebsitePanel usage type (websitepanel_EnterpriseServer::USAGE_*)
|
||||
* @return int
|
||||
*/
|
||||
function websitepanel_CalculateUsage($usageTables, $usageType)
|
||||
{
|
||||
$totalUsage = 0;
|
||||
foreach ($usageTables['NewDataSet']['Table'] as $table)
|
||||
{
|
||||
switch ($usageType)
|
||||
{
|
||||
case websitepanel_EnterpriseServer::USAGE_BANDWIDTH:
|
||||
$totalUsage += $table['MegaBytesTotal'];
|
||||
break;
|
||||
|
||||
case websitepanel_EnterpriseServer::USAGE_DISKSPACE:
|
||||
$totalUsage += $table['Diskspace'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $totalUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the WebsitePanel language file
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function websitepanel_LoadClientLanguage()
|
||||
{
|
||||
global $CONFIG, $_LANG, $smarty;
|
||||
|
||||
// Attempt to load the client's language
|
||||
$selectedLanguage = !empty($_SESSION['Language']) ? $_SESSION['Language'] : $CONFIG['Language'];
|
||||
|
||||
// For the admin area
|
||||
if (defined('ADMINAREA'))
|
||||
{
|
||||
$result = select_query('tbladmins', 'language', array('id' => (int)$_SESSION['adminid']));
|
||||
$results = mysql_fetch_assoc($result);
|
||||
$selectedLanguage = !empty($results['language']) ? $results['language'] : 'english';
|
||||
}
|
||||
|
||||
// Load the language file
|
||||
$languageFile = dirname(__FILE__) . "/lang/{$selectedLanguage}.php";
|
||||
if (file_exists($languageFile))
|
||||
{
|
||||
require_once($languageFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the default (English) language file
|
||||
require_once(dirname(__FILE__) . '/lang/english.php');
|
||||
}
|
||||
|
||||
// Process the module language entries
|
||||
if (is_array($_MOD_LANG))
|
||||
{
|
||||
foreach ($_MOD_LANG as $key => $value)
|
||||
{
|
||||
if (empty($_LANG[$key]))
|
||||
{
|
||||
$_LANG[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the template
|
||||
if (isset($smarty))
|
||||
{
|
||||
$smarty->assign('LANG', $_LANG);
|
||||
}
|
||||
|
||||
return $_MOD_LANG;
|
||||
}
|
|
@ -1,60 +1,42 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* WebsitePanel Server Module - WebsitePanel Business Error Codes
|
||||
*
|
||||
* @author Christopher York
|
||||
* @package WebsitePanel Server Module - WebsitePanel Business Error Codes
|
||||
* @version v1.0
|
||||
* @link http://www.websitepanel.net/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common error codes encountered while using the WebsitePanel Server Module
|
||||
* These are not all the Enterprise Server error codes, only the ones I have encountered using the API
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function websitepanel_GetEnterpriseServerErrors()
|
||||
{
|
||||
$esErrorCodes = array(-100 => 'User already exists',
|
||||
-101 => 'User not found',
|
||||
-102 => 'User has child user accounts',
|
||||
-300 => 'Hosting package could not be found',
|
||||
-301 => 'Hosting package has child hosting spaces',
|
||||
-501 => 'The sub-domain belongs to an existing hosting space that does not allow sub-domains to be created',
|
||||
-502 => 'The domain or sub-domain exists within another hosting space',
|
||||
-511 => 'Instant alias is enabled, but not configured',
|
||||
-601 => 'The website already exists on the target hosting space',
|
||||
-700 => 'The email domain already exists on the target hosting space',
|
||||
-1100 => 'User already exists');
|
||||
return $esErrorCodes;
|
||||
}
|
||||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
/**
|
||||
* WebsitePanel WHMCS Server Module Client Area Language
|
||||
*
|
||||
* @author Christopher York
|
||||
* @link http://www.websitepanel.net/
|
||||
* @access public
|
||||
* @name websitepanel
|
||||
* @version 3.0.0
|
||||
* @package WHMCS
|
||||
*/
|
||||
$_MOD_LANG['websitepanel_clientarea_oneclicklogin'] = 'Login to Control Panel (One-Click Login)';
|
||||
$_MOD_LANG['websitepanel_adminarea_gotowebsitepanelaccount'] = 'View Account in WebsitePanel';
|
|
@ -1,438 +0,0 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* WebsitePanel Server Module - Enterprise Server Wrapper
|
||||
*
|
||||
* @author Christopher York
|
||||
* @package WebsitePanel Server Module - WebsitePanel Enterprise Server Wrapper
|
||||
* @version v1.0
|
||||
* @link http://www.websitepanel.net/
|
||||
*/
|
||||
|
||||
class WebsitePanel
|
||||
{
|
||||
/**
|
||||
* WebsitePanel Enteprise Server service file names
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
const SERVICEFILE_PACKAGES = 'esPackages.asmx';
|
||||
const SERVICEFILE_USERS = 'esUsers.asmx';
|
||||
const SERVICEFILE_SERVERS = 'esServers.asmx';
|
||||
|
||||
/**
|
||||
* WebsitePanel account states
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
const USERSTATUS_ACTIVE = 'Active';
|
||||
const USERSTATUS_SUSPENDED = 'Suspended';
|
||||
const USERSTATUS_CANCELLED = 'Cancelled';
|
||||
const USERSTATUS_PENDING = 'Pending';
|
||||
|
||||
/**
|
||||
* WebsitePanel usage calculation
|
||||
*
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
const USAGE_DISKSPACE = 0;
|
||||
const USAGE_BANDWIDTH = 1;
|
||||
|
||||
/**
|
||||
* WebsitePanel IP address pools
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
const IPADDRESS_POOL_WEB = 'Web';
|
||||
|
||||
/**
|
||||
* WebsitePanel IP address groups
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
const IPADDRESS_GROUP_WEBSITES = 'WebSites';
|
||||
|
||||
/**
|
||||
* Enterprise Server username
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_esUsername = 'serveradmin';
|
||||
|
||||
/**
|
||||
* Enterprise Server password
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_esPassword;
|
||||
|
||||
/**
|
||||
* Enterprise Server URL / address (without the port)
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_esServerUrl;
|
||||
|
||||
/**
|
||||
* Enterprise Server TCP port
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_esServerPort = 9002;
|
||||
|
||||
/**
|
||||
* Use SSL (HTTPS) for Enterprise Server communications
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $_esUseSsl = false;
|
||||
|
||||
/**
|
||||
* WebsitePanel class constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string $esUsername Enterprise Server username
|
||||
* @param string $esPassword Enterprise Server password
|
||||
* @param string $esServerUrl Enterprise Server URL / address (without the port)
|
||||
* @param int $esServerPort Enterprise Server TCP port
|
||||
* @param boolean $useSsl Use SSL (HTTPS) for Enterprise Server communications
|
||||
*/
|
||||
public function __construct($esUsername, $esPassword, $esServerUrl, $esServerPort = 9002, $useSsl = FALSE)
|
||||
{
|
||||
$this->_esUsername = $esUsername;
|
||||
$this->_esPassword = $esPassword;
|
||||
$this->_esServerUrl = $esServerUrl;
|
||||
$this->_esServerPort = $esServerPort;
|
||||
$this->_esUseSsl = $useSsl;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::CreateAccount()
|
||||
*
|
||||
* @param string $username Account username
|
||||
* @param string $password Account password
|
||||
* @param string $roleId Account role id
|
||||
* @param string $firstName Account holders firstname
|
||||
* @param string $lastName Account holders lastname
|
||||
* @param string $email Account holders email address
|
||||
* @param string $planId WebsitePanel plan id
|
||||
* @param integer $parentPackageId Parent space / package id
|
||||
* @param string $domainName Account domain name
|
||||
* @param string $hostName Website hostname (if createWebsite is TRUE)
|
||||
* @param bool $htmlMail Send HTML email
|
||||
* @param bool $sendAccountLetter Send WebsitePanel "Account Summary" letter
|
||||
* @param bool $sendPackageLetter Send WebsitePanel "Hosting Space Summary" letter
|
||||
* @param bool $createPackage Create hostingspace / package on user creation
|
||||
* @param bool $tempDomain Create temporary domain on hostingspace / package creation
|
||||
* @param bool $createWebSite Create Website on hostingspace / package creation
|
||||
* @param bool $createFtpAccount Create FTP account on hostingspace / package creation
|
||||
* @param string $ftpAcountName FTP account name to create (if createFtpAccount is TRUE)
|
||||
* @param bool $createMailAccount Create default mail account on hostingspace / package creation
|
||||
* @param bool $createZoneRecord Create domain DNS zone record (if createMailAccount OR createWebSite are TRUE)
|
||||
* @return int
|
||||
*/
|
||||
public function createUserWizard($username, $password, $roleId, $firstName, $lastName, $email, $planId, $parentPackageId, $domainName, $hostName, $htmlMail = TRUE, $sendAccountLetter = TRUE, $sendPackageLetter = TRUE, $createPackage = TRUE, $tempDomain = FALSE, $createWebSite = FALSE, $createFtpAccount = FALSE, $ftpAcountName = '', $createMailAccount = FALSE, $createZoneRecord = FALSE)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $key => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$key] = $value;
|
||||
}
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'CreateUserWizard', $params)->CreateUserWizardResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::UpdateUserDetails()
|
||||
*
|
||||
* @access public
|
||||
* @param int $RoleId Account role id
|
||||
* @param string $Role Account role
|
||||
* @param int $StatusId Account status id
|
||||
* @param string $Status Account status
|
||||
* @param int $UserId Account user id
|
||||
* @param int $OwnerId Account owner id
|
||||
* @param string $Created Account creation date
|
||||
* @param string $Changed Account changed date
|
||||
* @param bool $IsDemo Demo account
|
||||
* @param bool $IsPeer Peer account
|
||||
* @param string $Comments Account comments
|
||||
* @param string $Username Account username
|
||||
* @param string $Password Account password
|
||||
* @param string $FirstName Account holders firstname
|
||||
* @param string $LastName Account holders lastname
|
||||
* @param string $Email Account holders email address
|
||||
* @param string $PrimaryPhone Account holders phone number
|
||||
* @param string $Zip Account holders postal code
|
||||
* @param string $InstantMessenger Account holders IM
|
||||
* @param string $Fax Account holders fax number
|
||||
* @param string $SecondaryPhone Account holders secondary phone number
|
||||
* @param string $SecondaryEmail Account holders secondary email
|
||||
* @param string $Country Account holders country
|
||||
* @param string $Address Account holders physical address
|
||||
* @param string $City Account holders city
|
||||
* @param string $State Account holders state
|
||||
* @param bool $HtmlMail Send HTML email
|
||||
* @param string $CompanyName Account holders Company name
|
||||
* @param bool $EcommerceEnabled Ecommerce enabled
|
||||
* @return void
|
||||
*/
|
||||
public function updateUserDetails($RoleId, $Role, $StatusId, $Status, $LoginStatusId, $LoginStatus, $FailedLogins, $UserId, $OwnerId, $Created, $Changed, $IsDemo, $IsPeer, $Comments, $Username, $Password, $FirstName, $LastName, $Email, $PrimaryPhone, $Zip, $InstantMessenger, $Fax, $SecondaryPhone, $SecondaryEmail, $Country, $Address, $City, $State, $HtmlMail, $CompanyName, $EcommerceEnabled)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $key => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$key] = $value;
|
||||
}
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'UpdateUser', array('user' => $params))->UpdateUserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::DeleteUser()
|
||||
*
|
||||
* @access public
|
||||
* @param int $userid User id
|
||||
* @return int
|
||||
*/
|
||||
public function deleteUser($userId)
|
||||
{
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'DeleteUser', array('userId' => $userId))->DeleteUserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetUserByUsername()
|
||||
*
|
||||
* @access public
|
||||
* @param string $username Username
|
||||
* @return array
|
||||
*/
|
||||
public function getUserByUsername($username)
|
||||
{
|
||||
return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'GetUserByUsername', array('username' => $username))->GetUserByUsernameResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::ChangeUserStatus()
|
||||
*
|
||||
* @param int $userId User id
|
||||
* @param string $status Account status (Active, Suspended, Cancelled, Pending)
|
||||
* @return int
|
||||
*/
|
||||
public function changeUserStatus($userId, $status)
|
||||
{
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserStatus', array('userId' => $userId, 'status' => $status))->ChangeUserStatusResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::ChangeUserPassword()
|
||||
*
|
||||
* @access public
|
||||
* @param int $userId User id
|
||||
* @param string $password New password
|
||||
* @return int
|
||||
*/
|
||||
public function changeUserPassword($userId, $password)
|
||||
{
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserPassword', array('userId' => $userId, 'password' => $password))->ChangeUserPasswordResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetUserPackages()
|
||||
*
|
||||
* @access public
|
||||
* @param int $userid User id
|
||||
* @return array
|
||||
*/
|
||||
public function getUserPackages($userid)
|
||||
{
|
||||
return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetMyPackages', array('userId' => $userid))->GetMyPackagesResult->PackageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::getUsersPagedRecursive()
|
||||
*
|
||||
* @param int $userId User id
|
||||
* @param string $filterColumn Column name to filter on
|
||||
* @param string $filterValue Filter value
|
||||
* @param int $statusId Status id
|
||||
* @param int $roleId Role id
|
||||
* @param string $sortColumn Column name to sort on
|
||||
* @param int $startRow Row to start at
|
||||
* @param int $maximumRows Maximum rows to return
|
||||
*/
|
||||
public function getUsersPagedRecursive($userId, $filterColumn, $filterValue, $statusId, $roleId, $sortColumn, $startRow = 0, $maximumRows = 999)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $key => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$key] = $value;
|
||||
}
|
||||
return $this->executeServerMethod(WebSitePanel::SERVICEFILE_USERS, 'GetUsersPagedRecursive', $params)->GetUsersPagedRecursiveResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::UpdatePackageLiteral()
|
||||
*
|
||||
* @access public
|
||||
* @param int $packageId Package id
|
||||
* @param int $statusId Status id
|
||||
* @param int $planId Plan id
|
||||
* @param string $purchaseDate Purchase date
|
||||
* @param string $packageName Package name
|
||||
* @param string $packageComments Package comments
|
||||
* @return array
|
||||
*/
|
||||
public function updatePackageLiteral($packageId, $statusId, $planId, $purchaseDate, $packageName, $packageComments)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $key => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$key] = $value;
|
||||
}
|
||||
return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'UpdatePackageLiteral', $params)->UpdatePackageLiteralResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::addPackageAddonById()
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $packageId Package id
|
||||
* @param mixed $addonPlanId Addon plan od
|
||||
* @param integer $quantity Quantity
|
||||
* @return array
|
||||
*/
|
||||
public function addPackageAddonById($packageId, $addonPlanId, $quantity = 1)
|
||||
{
|
||||
return (array)$this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'AddPackageAddonById', array('packageId' => $packageId, 'addonPlanId' => $addonPlanId, 'quantity' => $quantity))->AddPackageAddonByIdResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetSpaceBandwidthUsage()
|
||||
*
|
||||
* @access public
|
||||
* @param int $packageId Package id
|
||||
* @param string $startDate Start date
|
||||
* @param string $endDate Ending date
|
||||
* @return object
|
||||
*/
|
||||
public function getSpaceBandwidthUsage($packageId, $startDate, $endDate)
|
||||
{
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageBandwidth', array('packageId' => $packageId, 'startDate' => $startDate, 'endDate' => $endDate))->GetPackageBandwidthResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetSpaceDiskspaceUsage()
|
||||
*
|
||||
* @access private
|
||||
* @param int $packageId Package Id
|
||||
* @return object
|
||||
*/
|
||||
public function getSpaceDiskspaceUsage($packageId)
|
||||
{
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageDiskspace', array('packageId' => $packageId))->GetPackageDiskspaceResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::packageAllocateIpAddress()
|
||||
*
|
||||
* @param mixed $packageId Package id
|
||||
* @param mixed $groupName Group name
|
||||
* @param mixed $pool Address pool
|
||||
* @param integer $addressesNumber Number of IP addresses
|
||||
* @param bool $allocateRandom Allocate IP addresses randomly
|
||||
* @return object
|
||||
*/
|
||||
public function packageAllocateIpAddress($packageId, $groupName = WebsitePanel::IPADDRESS_POOL_WEB, $pool = WebsitePanel::IPADDRESS_GROUP_WEBSITES, $addressesNumber = 1, $allocateRandom = TRUE)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $key => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$key] = $value;
|
||||
}
|
||||
return $this->executeServerMethod(WebsitePanel::SERVICEFILE_SERVERS, 'AllocatePackageIPAddresses', $params)->AllocatePackageIPAddressesResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the requested Enterprise Server method / parameters and returns the results
|
||||
*
|
||||
* @access private
|
||||
* @param string $serviceFile Enterprise Server service filename
|
||||
* @param string $serviceMethod Enterprise Server service method name
|
||||
* @param array $methodParameters Method parameters
|
||||
* @throws Exception
|
||||
* @return object
|
||||
*/
|
||||
private function executeServerMethod($serviceFile, $serviceMethod, $methodParameters = array())
|
||||
{
|
||||
$esUrl = (($this->_esUseSsl ? "https" : "http") . "://{$this->_esServerUrl}:{$this->_esServerPort}/{$serviceFile}?WSDL");
|
||||
$soapParams = array('login' => $this->_esUsername,
|
||||
'password' => $this->_esPassword,
|
||||
'cache_wsdl' => WSDL_CACHE_NONE // WSDL caching is an annoying nightmare - we will disable it
|
||||
);
|
||||
try
|
||||
{
|
||||
$client = new SoapClient($esUrl, $soapParams);
|
||||
$result = $client->$serviceMethod($methodParameters);
|
||||
if (is_soap_fault($result))
|
||||
{
|
||||
throw new Exception($result->faultstring);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* websitepanel Server Module - websitepanel Helper Functions
|
||||
*
|
||||
* @author Christopher York
|
||||
* @package websitepanel Server Module - websitepanel Helper Functions
|
||||
* @version v1.0
|
||||
* @link http://www.websitepanel.net/
|
||||
*/
|
||||
|
||||
/**
|
||||
* websitepanel_GetErrorMessage()
|
||||
*
|
||||
* @access public
|
||||
* @param int $code
|
||||
* @return mixed
|
||||
*/
|
||||
function websitepanel_GetErrorMessage($code)
|
||||
{
|
||||
// Error codes
|
||||
$esErrorCodes = array();
|
||||
|
||||
// Include the common / known error codes
|
||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.errorcodes.php');
|
||||
$esErrorCodes = websitepanel_GetEnterpriseServerErrors();
|
||||
|
||||
// Check if the error code exists, if not return the code
|
||||
if (array_key_exists($code, $esErrorCodes))
|
||||
{
|
||||
return $esErrorCodes[$code];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_CreateBandwidthDate()
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $date
|
||||
* @return date
|
||||
*/
|
||||
function websitepanel_CreateBandwidthDate($date)
|
||||
{
|
||||
$dateExploded = explode('-', $date);
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
$newDate = "{$currentYear}-{$currentMonth}-{$dateExploded[2]}";
|
||||
|
||||
$dateDiff = time() - strtotime('+1 hour', strtotime($newDate));
|
||||
$fullDays = floor($dateDiff / (60 * 60 * 24));
|
||||
if ($fullDays < 0)
|
||||
{
|
||||
return date('Y-m-d', strtotime('-1 month', strtotime($newDate)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return $newDate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_CalculateBandwidthUsage()
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $params
|
||||
* @param mixed $packageId
|
||||
* @param mixed $startDate
|
||||
* @return int
|
||||
*/
|
||||
function websitepanel_CalculateBandwidthUsage($params, $packageId, $startDate)
|
||||
{
|
||||
// Create the ASPnix websitepanel_EnterpriseServer class object
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $wsp->getSpaceBandwidthUsage($packageId, $startDate, date('Y-m-d', time()));
|
||||
return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_BANDWIDTH);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// Do nothing, just catch the Exception to keep PHP from exploding :)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_CalculateDiskspaceUsage()
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $params
|
||||
* @param mixed $packageId
|
||||
* @return int
|
||||
*/
|
||||
function websitepanel_CalculateDiskspaceUsage($params, $packageId)
|
||||
{
|
||||
// Create the ASPnix websitepanel_EnterpriseServer class object
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $wsp->getSpaceDiskspaceUsage($packageId);
|
||||
return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_DISKSPACE);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// Do nothing, just catch the Exception to keep PHP from exploding :)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_CalculateUsage()
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $result
|
||||
* @param int $usageType
|
||||
* @return int
|
||||
*/
|
||||
function websitepanel_CalculateUsage($result, $usageType)
|
||||
{
|
||||
// Process results
|
||||
$xml = simplexml_load_string($result->any);
|
||||
$total = 0;
|
||||
if (count($xml->NewDataSet->Table) > 0)
|
||||
{
|
||||
foreach ($xml->NewDataSet->Table as $table)
|
||||
{
|
||||
switch ($usageType)
|
||||
{
|
||||
case WebsitePanel::USAGE_BANDWIDTH:
|
||||
$total = $total + $table[0]->MegaBytesTotal;
|
||||
break;
|
||||
|
||||
case WebsitePanel::USAGE_DISKSPACE:
|
||||
$total = $total + $table[0]->Diskspace;
|
||||
break;
|
||||
|
||||
default:
|
||||
$total = $total + $table[0]->MegaBytesTotal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_GetServerSettings
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function websitepanel_GetServerSettings()
|
||||
{
|
||||
$settings = array('username' => '', 'password' => '');
|
||||
|
||||
// Retrieve the settings from the modules configuration table
|
||||
$results = select_query('tblservers', 'username,password', array('type' => 'websitepanel'));
|
||||
if (mysql_num_rows($results) != 0)
|
||||
{
|
||||
$row = mysql_fetch_array($results, MYSQL_ASSOC);
|
||||
$settings['username'] = $row['username'];
|
||||
$settings['password'] = decrypt($row['password']);
|
||||
}
|
||||
return $settings;
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue