Fixed: Using incorrect table name format for addons
Changed: Addons no longer store the Enterprise Server credentials Fixed: Error codes not resolving to the correct response text
This commit is contained in:
parent
bdd51f2151
commit
a2c0a6b6eb
5 changed files with 89 additions and 23 deletions
|
@ -46,15 +46,17 @@ function websitepanel_addons_AddonActivation($params)
|
||||||
{
|
{
|
||||||
// Sanity check to make sure the associated service is WebsitePanel based product
|
// Sanity check to make sure the associated service is WebsitePanel based product
|
||||||
// And that the addon purchased has an associated WebsitePanel addon
|
// And that the addon purchased has an associated WebsitePanel addon
|
||||||
$results = full_query("SELECT h.id AS `id` FROM `tblhosting` AS h, `tblwspaddons` AS w, `tblservers` AS s WHERE h.id = {$params['serviceid']} AND h.server = s.id AND s.type = 'websitepanel' AND w.whmcs_id = {$params['addonid']}");
|
$results = full_query("SELECT h.id AS `id` FROM `tblhosting` AS h, `mod_wspaddons` AS w, `tblservers` AS s WHERE h.id = {$params['serviceid']} AND h.server = s.id AND s.type = 'websitepanel' AND w.whmcs_id = {$params['addonid']}");
|
||||||
if (mysql_num_rows($results) > 0)
|
if (mysql_num_rows($results) > 0)
|
||||||
{
|
{
|
||||||
// Include the WebsitePanel ES Class
|
// Include the WebsitePanel ES Class
|
||||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php');
|
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php');
|
||||||
|
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php');
|
||||||
|
|
||||||
// Retrieve the WebsitePanel Addons module settings
|
// Retrieve the WebsitePanel Addons module settings
|
||||||
$modSettings = websitepanel_addons_GetSettings();
|
$modSettings = websitepanel_addons_GetSettings();
|
||||||
if (empty($modSettings['username']) || empty($modSettings['password']) || empty($modSettings['serverhost']) || empty($modSettings['serverport']))
|
$srvSettings = websitepanel_GetServerSettings();
|
||||||
|
if (empty($modSettings['serverhost']) || empty($modSettings['serverport']) || empty($srvSettings['username']) || empty($srvSettings['password']))
|
||||||
{
|
{
|
||||||
// The module is disabled or has not yet been configured - stop
|
// The module is disabled or has not yet been configured - stop
|
||||||
return;
|
return;
|
||||||
|
@ -71,7 +73,7 @@ function websitepanel_addons_AddonActivation($params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the WebsitePanel object instance
|
// Create the WebsitePanel object instance
|
||||||
$wsp = new WebsitePanel($modSettings['username'], $modSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE));
|
$wsp = new WebsitePanel($srvSettings['username'], $srvSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE));
|
||||||
|
|
||||||
// Grab the user's details from WebsitePanel in order to get the user's id
|
// Grab the user's details from WebsitePanel in order to get the user's id
|
||||||
$user = $wsp->get_user_by_username($username);
|
$user = $wsp->get_user_by_username($username);
|
||||||
|
@ -89,7 +91,7 @@ function websitepanel_addons_AddonActivation($params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the associated WebsitePanel addon id
|
// Get the associated WebsitePanel addon id
|
||||||
$results = select_query('tblwspaddons', 'wsp_id,is_ipaddress', array('whmcs_id' => $params['addonid']));
|
$results = select_query('mod_wspaddons', 'wsp_id,is_ipaddress', array('whmcs_id' => $params['addonid']));
|
||||||
$addon = mysql_fetch_array($results);
|
$addon = mysql_fetch_array($results);
|
||||||
$addonPlanId = $addon['wsp_id'];
|
$addonPlanId = $addon['wsp_id'];
|
||||||
$addonIsIpAddress = $addon['is_ipaddress'];
|
$addonIsIpAddress = $addon['is_ipaddress'];
|
||||||
|
@ -129,7 +131,7 @@ function websitepanel_addons_GetSettings()
|
||||||
$results = select_query('tbladdonmodules', 'setting,value', array('module' => 'websitepanel_addons'));
|
$results = select_query('tbladdonmodules', 'setting,value', array('module' => 'websitepanel_addons'));
|
||||||
while (($row = mysql_fetch_array($results)) != false)
|
while (($row = mysql_fetch_array($results)) != false)
|
||||||
{
|
{
|
||||||
$settings[$row['setting']] = $row['value'];
|
$settings[$row[0]] = $row[1];
|
||||||
}
|
}
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
|
@ -50,17 +50,19 @@ function websitepanel_sync_ClientEdit($params)
|
||||||
{
|
{
|
||||||
// Include the WebsitePanel ES Class
|
// Include the WebsitePanel ES Class
|
||||||
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php');
|
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php');
|
||||||
|
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php');
|
||||||
|
|
||||||
// Retrieve the WebsitePanel Addons module settings
|
// Retrieve the WebsitePanel Addons module settings
|
||||||
$modSettings = websitepanel_sync_GetSettings();
|
$modSettings = websitepanel_sync_GetSettings();
|
||||||
if (empty($modSettings['username']) || empty($modSettings['password']) || empty($modSettings['serverhost']) || empty($modSettings['serverport']))
|
$srvSettings = websitepanel_GetServerSettings();
|
||||||
|
if (empty($modSettings['serverhost']) || empty($modSettings['serverport']) || empty($srvSettings['username']) || empty($srvSettings['password']))
|
||||||
{
|
{
|
||||||
// The module is disabled or has not yet been configured - stop
|
// The module is disabled or has not yet been configured - stop
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the WebsitePanel object instance
|
// Create the WebsitePanel object instance
|
||||||
$wsp = new WebsitePanel($modSettings['username'], $modSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE));
|
$wsp = new WebsitePanel($srvSettings['username'], $srvSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE));
|
||||||
|
|
||||||
// Get all WSP users with the old email
|
// Get all WSP users with the old email
|
||||||
$items = (array)$wsp->get_users_paged_recursive(1, 'Email', $params['olddata']['email'], 0, 0, '');
|
$items = (array)$wsp->get_users_paged_recursive(1, 'Email', $params['olddata']['email'], 0, 0, '');
|
||||||
|
|
|
@ -46,13 +46,11 @@ function websitepanel_addons_config()
|
||||||
{
|
{
|
||||||
$configarray = array('name' => 'WebsitePanel Addons Automation',
|
$configarray = array('name' => 'WebsitePanel Addons Automation',
|
||||||
'description' => 'Automates WHMCS product addons with WebsitePanel',
|
'description' => 'Automates WHMCS product addons with WebsitePanel',
|
||||||
'version' => '1.0',
|
'version' => '1.2',
|
||||||
'author' => 'Christopher York',
|
'author' => 'Christopher York',
|
||||||
'fields' => array('serverhost' => array('FriendlyName', 'Enterprise Server Host', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server hostname / IP address', 'Default' => '127.0.0.1'),
|
'fields' => array('serverhost' => array('FriendlyName', 'Enterprise Server Host', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server hostname / IP address', 'Default' => '127.0.0.1'),
|
||||||
'serverport' => array('FriendlyName', 'Enterprise Server Port', 'Type' => 'text', 'Size' => 4, 'Description' => 'Enterprise Server port', 'Default' => 9002),
|
'serverport' => array('FriendlyName', 'Enterprise Server Port', 'Type' => 'text', 'Size' => 4, 'Description' => 'Enterprise Server port', 'Default' => 9002),
|
||||||
'serversecured' => array('FriendlyName', 'Use Secured Connection', 'Type' => 'yesno', 'Description' => 'Tick to use SSL secured connection'),
|
'serversecured' => array('FriendlyName', 'Use Secured Connection', 'Type' => 'yesno', 'Description' => 'Tick to use SSL secured connection'),
|
||||||
'username' => array('FriendlyName', 'Username', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server username', 'Default' => 'serveradmin'),
|
|
||||||
'password' => array('FriendlyName', 'Password', 'Type' => 'password', 'Size' => 25, 'Description' => 'Enterprise Server password')
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return $configarray;
|
return $configarray;
|
||||||
|
@ -67,7 +65,7 @@ function websitepanel_addons_config()
|
||||||
function websitepanel_addons_activate()
|
function websitepanel_addons_activate()
|
||||||
{
|
{
|
||||||
// Create the WebsitePanel Addons table
|
// Create the WebsitePanel Addons table
|
||||||
$query = "CREATE TABLE `tblwspaddons` (
|
$query = "CREATE TABLE `mod_wspaddons` (
|
||||||
`whmcs_id` int(11) NOT NULL,
|
`whmcs_id` int(11) NOT NULL,
|
||||||
`wsp_id` int(11) NOT NULL,
|
`wsp_id` int(11) NOT NULL,
|
||||||
`is_ipaddress` bit(1) NOT NULL DEFAULT b'0',
|
`is_ipaddress` bit(1) NOT NULL DEFAULT b'0',
|
||||||
|
@ -94,9 +92,8 @@ function websitepanel_addons_activate()
|
||||||
*/
|
*/
|
||||||
function websitepanel_addons_deactivate()
|
function websitepanel_addons_deactivate()
|
||||||
{
|
{
|
||||||
// Create the WebsitePanel Addons table
|
// Drop the WebsitePanel Addons table
|
||||||
$query = 'DROP TABLE `tblwspaddons`';
|
$result = full_query('DROP TABLE `mod_wspaddons`');
|
||||||
$result = full_query($query);
|
|
||||||
|
|
||||||
// Check the results to verify that the table has been created properly
|
// Check the results to verify that the table has been created properly
|
||||||
if (!$result)
|
if (!$result)
|
||||||
|
@ -109,6 +106,27 @@ function websitepanel_addons_deactivate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* websitepanel_addons_upgrade
|
||||||
|
*
|
||||||
|
* @param $vars array
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function websitepanel_addons_upgrade($vars)
|
||||||
|
{
|
||||||
|
|
||||||
|
$version = $vars['version'];
|
||||||
|
|
||||||
|
// Adjust the table name and remove the WebsitePanel credentials
|
||||||
|
if ($version < 1.2)
|
||||||
|
{
|
||||||
|
full_query('RENAME TABLE `tblwspaddons` TO `mod_wspaddons`');
|
||||||
|
full_query("DELETE FROM `tbladdonmodules` WHERE `module` = 'websitepanel_addons' AND `setting` = 'username'");
|
||||||
|
full_query("DELETE FROM `tbladdonmodules` WHERE `module` = 'websitepanel_addons' AND `setting` = 'password'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* websitepanel_addons_output
|
* websitepanel_addons_output
|
||||||
*
|
*
|
||||||
|
@ -120,24 +138,24 @@ function websitepanel_addons_output($params)
|
||||||
// Delete the requested WebsitePanel addon
|
// Delete the requested WebsitePanel addon
|
||||||
if (isset($_GET['action']) && $_GET['action'] == 'delete')
|
if (isset($_GET['action']) && $_GET['action'] == 'delete')
|
||||||
{
|
{
|
||||||
delete_query('tblwspaddons', array('whmcs_id' => $_GET['id']));
|
delete_query('mod_wspaddons', array('whmcs_id' => $_GET['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the requested WebsitePanel addon
|
// Add the requested WebsitePanel addon
|
||||||
if ($_POST && isset($_POST['action']) && $_POST['action'] == 'add')
|
if ($_POST && isset($_POST['action']) && $_POST['action'] == 'add')
|
||||||
{
|
{
|
||||||
// Sanity check to make sure the WHMCS addon ID exists
|
// Sanity check to make sure the WHMCS addon ID exists
|
||||||
$results = select_query('tbladdons', 'id', array('id' => $_POST['whmcs_id']));
|
$results = select_query('mod_wspaddons', 'id', array('id' => $_POST['whmcs_id']));
|
||||||
if (mysql_num_rows($results) > 0)
|
if (mysql_num_rows($results) > 0)
|
||||||
{
|
{
|
||||||
$results = select_query('tblwspaddons', 'whmcs_id', array('whmcs_id' => $_POST['whmcs_id']));
|
$results = select_query('mod_wspaddons', 'whmcs_id', array('whmcs_id' => $_POST['whmcs_id']));
|
||||||
if (mysql_num_rows($results) > 0)
|
if (mysql_num_rows($results) > 0)
|
||||||
{
|
{
|
||||||
echo '<p><div style="margin:0 0 -5px 0;padding: 10px;background-color: #FBEEEB;border: 1px dashed #cc0000;font-weight: bold;color: #cc0000;font-size:14px;text-align: center;-moz-border-radius: 10px;-webkit-border-radius: 10px;-o-border-radius: 10px;border-radius: 10px;">Duplicate WHMCS Addon ID. The WHMCS Addon ID Is Assigned To Another WebsitePanel Addon.</div></p>';
|
echo '<p><div style="margin:0 0 -5px 0;padding: 10px;background-color: #FBEEEB;border: 1px dashed #cc0000;font-weight: bold;color: #cc0000;font-size:14px;text-align: center;-moz-border-radius: 10px;-webkit-border-radius: 10px;-o-border-radius: 10px;border-radius: 10px;">Duplicate WHMCS Addon ID. The WHMCS Addon ID Is Assigned To Another WebsitePanel Addon.</div></p>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
insert_query('tblwspaddons', array('whmcs_id' => $_POST['whmcs_id'], 'wsp_id' => $_POST['wsp_id'], 'is_ipaddress' => $_POST['is_ipaddress']));
|
insert_query('mod_wspaddons', array('whmcs_id' => $_POST['whmcs_id'], 'wsp_id' => $_POST['wsp_id'], 'is_ipaddress' => $_POST['is_ipaddress']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -147,7 +165,7 @@ function websitepanel_addons_output($params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the assigned addons and display them to the user
|
// Get all the assigned addons and display them to the user
|
||||||
$results = full_query('SELECT a.name AS `name`, a.id AS `whmcs_id`, w.wsp_id AS `wsp_id` FROM `tbladdons` AS a, `tblwspaddons` AS w WHERE w.whmcs_id = a.id');
|
$results = full_query('SELECT a.name AS `name`, a.id AS `whmcs_id`, w.wsp_id AS `wsp_id` FROM `tbladdons` AS a, `mod_wspaddons` AS w WHERE w.whmcs_id = a.id');
|
||||||
|
|
||||||
// Build the table / data grid
|
// Build the table / data grid
|
||||||
echo '<div class="tablebg">';
|
echo '<div class="tablebg">';
|
||||||
|
|
|
@ -46,14 +46,32 @@ function websitepanel_sync_config()
|
||||||
{
|
{
|
||||||
$configarray = array('name' => 'WebsitePanel Sync Automation',
|
$configarray = array('name' => 'WebsitePanel Sync Automation',
|
||||||
'description' => 'Syncs WHMCS client details / contact changes with WebsitePanel',
|
'description' => 'Syncs WHMCS client details / contact changes with WebsitePanel',
|
||||||
'version' => '1.0',
|
'version' => '1.2',
|
||||||
'author' => 'Christopher York',
|
'author' => 'Christopher York',
|
||||||
'fields' => array('serverhost' => array('FriendlyName', 'Enterprise Server Host', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server hostname / IP address', 'Default' => '127.0.0.1'),
|
'fields' => array('serverhost' => array('FriendlyName', 'Enterprise Server Host', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server hostname / IP address', 'Default' => '127.0.0.1'),
|
||||||
'serverport' => array('FriendlyName', 'Enterprise Server Port', 'Type' => 'text', 'Size' => 4, 'Description' => 'Enterprise Server port', 'Default' => 9002),
|
'serverport' => array('FriendlyName', 'Enterprise Server Port', 'Type' => 'text', 'Size' => 4, 'Description' => 'Enterprise Server port', 'Default' => 9002),
|
||||||
'serversecured' => array('FriendlyName', 'Use Secured Connection', 'Type' => 'yesno', 'Description' => 'Tick to use SSL secured connection'),
|
'serversecured' => array('FriendlyName', 'Use Secured Connection', 'Type' => 'yesno', 'Description' => 'Tick to use SSL secured connection'),
|
||||||
'username' => array('FriendlyName', 'Username', 'Type' => 'text', 'Size' => 25, 'Description' => 'Enterprise Server username', 'Default' => 'serveradmin'),
|
|
||||||
'password' => array('FriendlyName', 'Password', 'Type' => 'password', 'Size' => 25, 'Description' => 'Enterprise Server password')
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return $configarray;
|
return $configarray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* websitepanel_addons_upgrade
|
||||||
|
*
|
||||||
|
* @param $vars array
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function websitepanel_sync_upgrade($vars)
|
||||||
|
{
|
||||||
|
|
||||||
|
$version = $vars['version'];
|
||||||
|
|
||||||
|
// Remove the WebsitePanel credentials
|
||||||
|
if ($version < 1.2)
|
||||||
|
{
|
||||||
|
full_query("DELETE FROM `tbladdonmodules` WHERE `module` = 'websitepanel_sync' AND `setting` = 'username'");
|
||||||
|
full_query("DELETE FROM `tbladdonmodules` WHERE `module` = 'websitepanel_sync' AND `setting` = 'password'");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -45,8 +45,13 @@
|
||||||
*/
|
*/
|
||||||
function websitepanel_GetErrorMessage($code)
|
function websitepanel_GetErrorMessage($code)
|
||||||
{
|
{
|
||||||
global $esErrorCodes;
|
// Error codes
|
||||||
|
$esErrorCodes = array();
|
||||||
|
|
||||||
|
// Include the common / known error codes
|
||||||
|
require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.errorcodes.php');
|
||||||
|
|
||||||
|
// Check if the error code exists, if not return the code
|
||||||
if (array_key_exists($code, $esErrorCodes))
|
if (array_key_exists($code, $esErrorCodes))
|
||||||
{
|
{
|
||||||
return $esErrorCodes[$code];
|
return $esErrorCodes[$code];
|
||||||
|
@ -167,4 +172,25 @@ function websitepanel_CalculateUsage($result, $usageType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $total;
|
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;
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue