This commit is contained in:
Christopher York 2014-04-23 23:21:29 -05:00
parent 9a3fc09abc
commit 3d1bb47f35
8 changed files with 92 additions and 16 deletions

View file

@ -9,6 +9,14 @@
<h1>WHMCS WebsitePanel Server Module</h1>
<p style="color: #FF0000">DO NOT CONTACT WHMCS FOR SUPPORT WITH THIS MODULE</p>
<h3>Changelog / Updates</h3>
<p>2-24-2014 (v3.0.3)</p>
<ul>
<li>Added: WHMCS module log debug calls.
<ul>
<li>See <a href="http://docs.whmcs.com/Troubleshooting_Module_Problems" target="new">http://docs.whmcs.com/Troubleshooting_Module_Problems</a></li>
</ul>
</li>
</ul>
<p>2-23-2014 (v3.0.2)</p>
<ul>
<li>HTTP communications now support GZIP compression (enabled by default)</li>

View file

@ -37,7 +37,7 @@ require_once(ROOTDIR. '/modules/servers/websitepanel/enterpriseserver.php');
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel_EnterpriseServer
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
* @final
*/

View file

@ -35,7 +35,7 @@
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel_EnterpriseServer
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
* @final
*/
@ -50,7 +50,7 @@ function websitepanel_addons_config()
{
return array('name' => 'WebsitePanel Addons Automation',
'description' => 'Automates WHMCS product addons with WebsitePanel Addons',
'version' => '3.0.2',
'version' => '3.0.3',
'author' => 'Christopher York');
}

View file

@ -37,7 +37,7 @@ require_once(ROOTDIR. '/modules/servers/websitepanel/enterpriseserver.php');
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
*/

View file

@ -34,7 +34,7 @@
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
*/
@ -48,7 +48,7 @@ function websitepanel_sync_config()
{
return array('name' => 'WebsitePanel Sync Automation',
'description' => 'Syncs WHMCS client details / contact changes with WebsitePanel accounts',
'version' => '3.0.2',
'version' => '3.0.3',
'author' => 'Christopher York');
}

View file

@ -35,7 +35,7 @@
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel_EnterpriseServer
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
* @final
*/

View file

@ -34,7 +34,7 @@
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
*/

View file

@ -38,7 +38,7 @@ require_once(ROOTDIR. '/modules/servers/websitepanel/functions.php');
* @link http://www.websitepanel.net/
* @access public
* @name websitepanel
* @version 3.0.2
* @version 3.0.3
* @package WHMCS
*/
@ -143,6 +143,9 @@ function websitepanel_CreateAccount($params)
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Get the newly created user's details from WebsitePanel so we can update the account details completely
$user = $wsp->getUserByUsername($username);
@ -195,6 +198,9 @@ function websitepanel_CreateAccount($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
}
@ -240,6 +246,9 @@ function websitepanel_TerminateAccount($params)
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Notify success
return 'success';
}
@ -251,6 +260,9 @@ function websitepanel_TerminateAccount($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
}
@ -296,6 +308,9 @@ function websitepanel_SuspendAccount($params)
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Notify success
return 'success';
}
@ -307,6 +322,9 @@ function websitepanel_SuspendAccount($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
}
@ -351,6 +369,9 @@ function websitepanel_UnsuspendAccount($params)
// Something went wrong
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Notify success
return 'success';
@ -362,6 +383,9 @@ function websitepanel_UnsuspendAccount($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
@ -408,6 +432,9 @@ function websitepanel_ChangePassword($params)
// Something went wrong
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Notify success
return 'success';
@ -419,6 +446,9 @@ function websitepanel_ChangePassword($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
@ -472,6 +502,9 @@ function websitepanel_ChangePackage($params)
throw new Exception('Fault: ' . websitepanel_EnterpriseServer::getFriendlyError($result), $result);
}
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $result);
// Notify success
return 'success';
}
@ -482,6 +515,9 @@ function websitepanel_ChangePackage($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Notify failure - Houston we have a problem!
return $errorMessage;
@ -507,7 +543,7 @@ function websitepanel_UsageUpdate($params)
// Query for WebsitePanel user accounts assigned to this server
// Only services that have packages that have "Tick to update diskpace / bandwidth in WHMCS" enabled
$result = full_query("SELECT h.id AS serviceid, h.userid AS userid, h.username AS username, h.regdate AS regdate, p.configoption2 AS configoption2, p.configoption3 AS configoption3, p.configoption6 AS configoption6 FROM `tblhosting` AS h, `tblproducts` AS p WHERE h.server = {$serverId} AND h.packageid = p.id AND p.configoption16 = 'on' AND h.domainstatus IN ('Active', 'Suspended')");
$result = full_query("SELECT h.id AS serviceid, h.userid AS userid, h.username AS username, h.regdate AS regdate, p.configoption2 AS configoption2, p.configoption3 AS configoption3, p.configoption6 AS configoption6 FROM `tblhosting` AS h, `tblproducts` AS p WHERE h.server = 17 AND h.packageid = p.id AND p.configoption16 = 'on' AND h.domainstatus IN ('Active', 'Suspended')");
while (($row = mysql_fetch_array($result)) != false)
{
// Start processing the users usage
@ -541,12 +577,18 @@ function websitepanel_UsageUpdate($params)
// Update WHMCS's service details
update_query('tblhosting', array('diskusage' => $diskUsage, 'disklimit' => $diskLimit, 'bwusage' => $bwidthUsage, 'bwlimit' => $bwidthLimit, 'lastupdate' => 'now()'), array('id' => $serviceId));
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $package);
}
catch (Exception $e)
{
// Error message to log / return
$errorMessage = "UsageUpdate Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}, Service ID: {$serviceId})";
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
// Log to WHMCS
logactivity($errorMessage, $userId);
}
@ -565,9 +607,10 @@ 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($results['domainstatus'], array('Active', 'Suspended')))
if (in_array($params['domainstatus'], array('Active', 'Suspended')))
{
// WHMCS server parameters & package parameters
$serverUsername = $params['serverusername'];
@ -589,7 +632,7 @@ function websitepanel_LoginLink($params)
$user = $wsp->getUserByUsername($username);
if (empty($user))
{
throw new Exception("User {$username} does not exist - Cannot display LoginLink for non-existing user");
throw new Exception("User {$username} does not exist - Cannot display account link for unknown user");
}
// Load the client area language file
@ -597,6 +640,9 @@ function websitepanel_LoginLink($params)
// 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)
{
@ -605,9 +651,9 @@ function websitepanel_LoginLink($params)
// Log to WHMCS
logactivity($errorMessage, $userId);
// Notify failure - Houston we have a problem!
return $errorMessage;
// Log the module call
websitepanel_logModuleCall(__FUNCTION__, $params, $e->getMessage());
}
}
}
@ -631,4 +677,26 @@ function websitepanel_ClientArea($params)
// Return template information
return array('templatefile' => 'clientarea', 'vars' => array('websitepanel_url' => $params['configoption8'], 'username' => $username, 'password' => $password));
}
/**
* Logs all module calls to the WHMCS module debug logger
*
* @access public
* @param string $function
* @param mixed $params
* @param mixed $response
*/
function websitepanel_logModuleCall($function, $params, $response)
{
// Get the module name
$callerData = explode('_', $function);
$module = $callerData[0];
$action = $callerData[1];
// Replacement variables
$replacementVars = array('');
// Log the call with WHMCS
logModuleCall($module, $action, $params, $response, '', $replacementVars);
}