wsp-10081 Added WHMCS Module to Source
This commit is contained in:
parent
8bb83305f2
commit
5d1c59c9fd
4 changed files with 932 additions and 0 deletions
332
WebsitePanel.WHMCSModule/websitepanel.class.php
Normal file
332
WebsitePanel.WHMCSModule/websitepanel.class.php
Normal file
|
@ -0,0 +1,332 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* WebsitePanel account states
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
const USERSTATUS_ACTIVE = 'Active';
|
||||
const USERSTATUS_SUSPENDED = 'Suspended';
|
||||
const USERSTATUS_CANCELLED = 'Cancelled';
|
||||
const USERSTATUS_PENDING = 'Pending';
|
||||
|
||||
/**
|
||||
* WebsitePanel usage calculation
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
const USAGE_DISKSPACE = 0;
|
||||
const USAGE_BANDWIDTH = 1;
|
||||
|
||||
/**
|
||||
* 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 create_user_wizard($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->execute_server_method(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 update_user_details($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 $name => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$name] = $value;
|
||||
}
|
||||
return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'UpdateUser', array('user' => $params))->UpdateUserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::DeleteUser()
|
||||
*
|
||||
* @access public
|
||||
* @param int $userid User id
|
||||
* @return int
|
||||
*/
|
||||
public function delete_user($userId)
|
||||
{
|
||||
return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'DeleteUser', array('userId' => $userId))->DeleteUserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetUserByUsername()
|
||||
*
|
||||
* @access public
|
||||
* @param string $username Username
|
||||
* @return array
|
||||
*/
|
||||
public function get_user_by_username($username)
|
||||
{
|
||||
return (array)$this->execute_server_method(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 change_user_status($userId, $status)
|
||||
{
|
||||
return $this->execute_server_method(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 change_user_password($userId, $password)
|
||||
{
|
||||
return $this->execute_server_method(WebsitePanel::SERVICEFILE_USERS, 'ChangeUserPassword', array('userId' => $userId, 'password' => $password))->ChangeUserPasswordResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetUserPackages()
|
||||
*
|
||||
* @access public
|
||||
* @param int $userid User id
|
||||
* @return array
|
||||
*/
|
||||
public function get_user_packages($userid)
|
||||
{
|
||||
return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'GetMyPackages', array('userId' => $userid))->GetMyPackagesResult->PackageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 update_package_literal($packageId, $statusId, $planId, $purchaseDate, $packageName, $packageComments)
|
||||
{
|
||||
$params = array();
|
||||
foreach (get_defined_vars() as $name => $value)
|
||||
{
|
||||
if ($key == 'params')
|
||||
continue;
|
||||
|
||||
$params[$name] = $value;
|
||||
}
|
||||
return (array)$this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'UpdatePackageLiteral', $params)->UpdatePackageLiteralResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebsitePanel::GetSpaceBandwidthUsage()
|
||||
*
|
||||
* @access public
|
||||
* @param int $packageId Package id
|
||||
* @param string $startDate Start date
|
||||
* @param string $endDate Ending date
|
||||
* @return object
|
||||
*/
|
||||
public function get_space_bandwidth_usage($packageId, $startDate, $endDate)
|
||||
{
|
||||
return $this->execute_server_method(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 get_space_diskspace_usage($packageId)
|
||||
{
|
||||
return $this->execute_server_method(WebsitePanel::SERVICEFILE_PACKAGES, 'GetPackageDiskspace', array('packageId' => $packageId))->GetPackageDiskspaceResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request 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 execute_server_method($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
|
||||
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP
|
||||
);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
25
WebsitePanel.WHMCSModule/websitepanel.errorcodes.php
Normal file
25
WebsitePanel.WHMCSModule/websitepanel.errorcodes.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
$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');
|
142
WebsitePanel.WHMCSModule/websitepanel.functions.php
Normal file
142
WebsitePanel.WHMCSModule/websitepanel.functions.php
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
global $esErrorCodes;
|
||||
|
||||
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->get_space_bandwidth_usage($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->get_space_diskspace_usage($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;
|
||||
}
|
433
WebsitePanel.WHMCSModule/websitepanel.php
Normal file
433
WebsitePanel.WHMCSModule/websitepanel.php
Normal file
|
@ -0,0 +1,433 @@
|
|||
<?php if (!defined('WHMCS')) exit('ACCESS DENIED');
|
||||
/**
|
||||
* WHMCS WebsitePanel Server Module
|
||||
*
|
||||
* Tested with WHMCS v5.1.3 - however this should work for all v5 releases.
|
||||
* DO NOT contact WHMCS for support with this module, they will not provide
|
||||
* you any support for this. This should replace the default WHMCS WebsitePanel
|
||||
* server module, however I HIGHLY RECOMMEND that you backup the stock WebsitePanel
|
||||
* server module.
|
||||
*
|
||||
* THIS IS PROVIDED AS IS AND WITHOUT WARRANTY! I TAKE NO RESPOSIBILITY FOR
|
||||
* ERRORS, MISUSE, EXCEPTIONS, LOSS OF DATA, LOSS OF LIFE, PLANETS NOT ALIGNING
|
||||
* PROPERLY, ALIEN ABDUCTIONS AND ANYTHING ELSE THAT CAN OR MAY HAPPEN FROM
|
||||
* USING THIS! BY INSTALLING AND USING THIS YOU AGREE TO TAKE FULL RESPOSNBILITY
|
||||
* FOR ANY AND ALL THINGS!
|
||||
*
|
||||
* @author Christopher York
|
||||
* @package WHMCS Server Module
|
||||
* @version v1.0
|
||||
* @link http://www.websitepanel.net/
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
// WebsitePanel WHMCS Server Module Configuration / Commands
|
||||
/****************************************************************************/
|
||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php');
|
||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.errorcodes.php');
|
||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php');
|
||||
|
||||
/**
|
||||
* websitepanel_ConfigOptions()
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function websitepanel_ConfigOptions()
|
||||
{
|
||||
$configarray = array('Package Name' => array( 'Type' => 'text', 'Size' => 25, 'Description' => 'Package Name'),
|
||||
'Web Space Quota' => array( 'Type' => 'text', 'Size' => 5, 'Description' => 'MB'),
|
||||
'Bandwidth Limit' => array( 'Type' => 'text', 'Size' => 5, 'Description' => 'MB'),
|
||||
'Plan ID' => array( 'Type' => 'text', 'Size' => 4, 'Description' => 'WebsitePanel hosting plan id'),
|
||||
'Parent Space ID' => array( 'Type' => 'text', 'Size' => 3, 'Description' => '* SpaceID that all accounts are created under', 'Default' => 1),
|
||||
'Enterprise Server Port' => array( 'Type' => 'text', 'Size' => 5, 'Description' => '* Required', 'Default' => 9002),
|
||||
'Different Potal URL' => array( 'Type' => 'yesno', 'Description' => 'Tick if portal address is different to server address'),
|
||||
'Portal URL' => array( 'Type' => 'text', 'Size' => 25, 'Description' => 'Portal URL, with http://, no trailing slash' ),
|
||||
'Send Account Summary Email' => array( 'Type' => 'yesno', 'Description' => 'Tick to send the "Account Summary" letter' ),
|
||||
'Send Hosting Space Summary Email' => array( 'Type' => 'yesno', 'Description' => 'Tick to send the "Hosting Space Summary" letter'),
|
||||
'Create Mail Account' => array( 'Type' => 'yesno', 'Description' => 'Tick to create mail account' ),
|
||||
'Create FTP Account' => array( 'Type' => 'yesno', 'Description' => 'Tick to create FTP account' ),
|
||||
'Create Temporary Domain' => array( 'Type' => 'yesno', 'Description' => 'Tick to create a temporary domain' ),
|
||||
'Send HTML Email' => array( 'Type' => 'yesno', 'Description' => 'Tick enable HTML email from WebsitePanel' ),
|
||||
'Create Website' => array( 'Type' => 'yesno', 'Description' => 'Tick to create Website' ),
|
||||
'Count Bandwidth / Diskspace' => array( 'Type' => 'yesno', 'Description' => 'Tick to update diskpace / bandwidth in WHMCS'),
|
||||
'Default Pointer' => array( 'Type' => 'text', 'Size' => 25, 'Description' => 'The default pointer (hostname) to use when creating a Website' ),
|
||||
'Create DNS Zone' => array( 'Type' => 'yesno', 'Description' => 'Tick to create domain DNS zone' )
|
||||
);
|
||||
return $configarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_CreateAccount()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_CreateAccount($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
$password = $params['password'];
|
||||
$accountid = $params['accountid'];
|
||||
$packageid = $params['packageid'];
|
||||
$domain = $params['domain'];
|
||||
$packagetype = $params['type'];
|
||||
$clientsdetails = $params['clientsdetails'];
|
||||
|
||||
// WebsitePanel API parameters
|
||||
$planId = $params['configoption4'];
|
||||
$parentPackageId = $params['configoption5'];
|
||||
$roleId = ($packagetype == 'reselleraccount') ? 2 : 3;
|
||||
$htmlMail = ($params['configoption14'] == 'on') ? TRUE : FALSE;
|
||||
$sendAccountLetter = ($params['configoption9'] == 'on') ? TRUE : FALSE;
|
||||
$sendPackageLetter = ($params['configoption10'] == 'on') ? TRUE : FALSE;
|
||||
$createMailAccount = ($params['configoption11'] == 'on') ? TRUE : FALSE;
|
||||
$createTempDomain = ($params['configoption13'] == 'on') ? TRUE : FALSE;
|
||||
$createFtpAccount = ($params['configoption12'] == 'on') ? TRUE : FALSE;
|
||||
$createWebsite = ($params['configoption15'] == 'on') ? TRUE : FALSE;
|
||||
$websitePointerName = $params['configoption17'];
|
||||
$createZoneRecord = ($params['configoption18'] == 'on') ? TRUE : FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
// Attempt to create the WSP user account and his / her package / hosting space
|
||||
$result = $wsp->create_user_wizard($username, $password, $roleId, $clientsdetails['firstname'], $clientsdetails['lastname'], $clientsdetails['email'], $planId, $parentPackageId, $domain, $websitePointerName, $htmlMail, $sendAccountLetter, $sendPackageLetter, TRUE, $createTempDomain, $createWebsite, $createFtpAccount, $username, $createMailAccount, $createZoneRecord);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Grab the user's details from WebsitePanel
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
|
||||
// Update the user's account with his / her WHMCS contact details
|
||||
$wsp->update_user_details($user['RoleId'], $user['Role'], $user['StatusId'], $user['Status'], $user['LoginStatusId'], $user['LoginStatus'], $user['FailedLogins'], $user['UserId'], $user['OwnerId'], $user['Created'], $user['Changed'], $user['IsDemo'], $user['IsPeer'], $user['Comments'], $username, $password, $clientsdetails['firstname'], $clientsdetails['lastname'], $clientsdetails['email'], $clientsdetails['phonenumber'], $clientsdetails['postcode'], '', '', '', '', $clientsdetails['country'], $clientsdetails['address1'], $clientsdetails['city'], $clientsdetails['state'], $htmlMail, $clientsdetails['companyname'], (($roleId == 2) ? TRUE : FALSE));
|
||||
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_TerminateAccount()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_TerminateAccount($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
|
||||
try
|
||||
{
|
||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
if (empty($user))
|
||||
{
|
||||
return "The specified user {$username} does not exist";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to delete the users account and package / hosting space
|
||||
$result = $wsp->delete_user($user['UserId']);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_SuspendAccount()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_SuspendAccount($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
|
||||
try
|
||||
{
|
||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
if (empty($user))
|
||||
{
|
||||
return "The specified user {$username} does not exist";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to suspend the users account and package / hosting space
|
||||
$result = $wsp->change_user_status($user['UserId'], WebsitePanel::USERSTATUS_SUSPENDED);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_UnsuspendAccount()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_UnsuspendAccount($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
|
||||
try
|
||||
{
|
||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
if (empty($user))
|
||||
{
|
||||
return "The specified user {$username} does not exist";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to activate the users account and package / hosting space
|
||||
$result = $wsp->change_user_status($user['UserId'], WebsitePanel::USERSTATUS_ACTIVE);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_ChangePassword()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return int
|
||||
*/
|
||||
function websitepanel_ChangePassword($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
$password = $params['password'];
|
||||
|
||||
try
|
||||
{
|
||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
if (empty($user))
|
||||
{
|
||||
return "The specified user {$username} does not exist";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to change the user's account password
|
||||
$result = $wsp->change_user_password($user['UserId'], $password);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_ChangePackage()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_ChangePackage($params)
|
||||
{
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// WHMCS server parameters & package parameters
|
||||
$username = $params['username'];
|
||||
|
||||
// WebsitePanel API parameters
|
||||
$planId = $params['configoption4'];
|
||||
$packageName = $params['configoption1'];
|
||||
|
||||
try
|
||||
{
|
||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
if (empty($user))
|
||||
{
|
||||
return "The specified user {$username} does not exist";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the user's current WebsitePanel hosting space Id (Hosting Plan)
|
||||
$package = $wsp->get_user_packages($user['UserId']);
|
||||
$packageId = $package['PackageId'];
|
||||
|
||||
// Update the user's package
|
||||
$result = $wsp->update_package_literal($packageId, $package['StatusId'], $planId, $package['PurchaseDate'], $packageName, '');
|
||||
$result = $result['Result'];
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Success - Alert WHMCS
|
||||
return 'success';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed - Alert WHMCS of the returned Enterprise Server error code
|
||||
return websitepanel_GetErrorMessage($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_LoginLink()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_LoginLink($params)
|
||||
{
|
||||
echo "<a href='{$params['configoption8']}/default.aspx?pid=Login&user={$params['username']}&password={$params['password']}' title='Control Panel Login' style='color:#cc0000;' target='_blank'>Login to Control Panel (One-Click Login)</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_ClientArea()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
function websitepanel_ClientArea($params)
|
||||
{
|
||||
return "<a href='{$params['configoption8']}/default.aspx?pid=Login&user={$params['username']}&password={$params['password']}' title='Control Panel Login' style='color:#cc0000;' target='_blank'>Login to Control Panel (One-Click Login)</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* websitepanel_UsageUpdate()
|
||||
*
|
||||
* @access public
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
function websitepanel_UsageUpdate($params)
|
||||
{
|
||||
// WHMCS server parameters & package parameters
|
||||
$serverid = $params['serverid'];
|
||||
$serverip = $params['serverip'];
|
||||
|
||||
// Query for all active or suspended users under the specified server
|
||||
$query = full_query("SELECT `username`, `packageid`, `regdate` FROM `tblhosting` WHERE `server` = {$serverid} AND `domainstatus` IN ('Active', 'Suspended') AND `username` <> ''");
|
||||
while (($row = mysql_fetch_array($query)) != false)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Start processing the specified users usage
|
||||
$username = $row['username'];
|
||||
$packageId = $row['packageid'];
|
||||
|
||||
// Get the packages ConfigOptions
|
||||
$packageQuery = select_query('tblproducts', 'configoption2,configoption3,configoption6,configoption16', array('id' => $packageId, 'configoption16' => 'on'));
|
||||
$cfgOptions = mysql_fetch_array($packageQuery);
|
||||
$params['configoption6'] = $cfgOptions['configoption6'];
|
||||
|
||||
// Diskspace and Bandwidth limits for this package
|
||||
$diskLimit = $cfgOptions['configoption2'];
|
||||
$bwidthLimit = $cfgOptions['configoption3'];
|
||||
|
||||
// Create the WebsitePanel object instance
|
||||
$wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $serverip, $params['configoption6'], $params['serversecure']);
|
||||
|
||||
// Get the specified user details
|
||||
// Get the Package id of the user's package
|
||||
$user = $wsp->get_user_by_username($username);
|
||||
$package = $wsp->get_user_packages($user['UserId']);
|
||||
|
||||
// Gather the bandwidth / diskspace usage stats
|
||||
$bandwidthUsage = websitepanel_CalculateBandwidthUsage($params, $package['PackageId'], websitepanel_CreateBandwidthDate($row['regdate']));
|
||||
$diskSpaceUsage = websitepanel_CalculateDiskspaceUsage($params, $package['PackageId']);
|
||||
|
||||
// Update the package details
|
||||
update_query('tblhosting', array('diskusage' => $diskSpaceUsage, 'disklimit' => $diskLimit, 'bwusage' => $bandwidthUsage, 'bwlimit' => $bwidthLimit, 'lastupdate' => date('Y-m-d H:i:s')), array('username' => $username, 'server' => $serverid));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue