'WebsitePanel Addons Automation', 'description' => 'Automates WHMCS product addons with WebsitePanel', 'version' => '1.2', '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'), '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'), ) ); return $configarray; } /** * websitepanel_addons_activate * * @access public * @return array */ function websitepanel_addons_activate() { // Create the WebsitePanel Addons table $query = "CREATE TABLE `mod_wspaddons` ( `whmcs_id` int(11) NOT NULL, `wsp_id` int(11) NOT NULL, `is_ipaddress` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`whmcs_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; $result = full_query($query); // Check the results to verify that the table has been created properly if (!$result) { return array('status' => 'error', 'description' => 'There was an error while activating the module'); } else { return array('status' => 'success', 'description' => 'The module has been activated successfully'); } } /** * websitepanel_addons_deactivate * * @access public * @return array */ function websitepanel_addons_deactivate() { // Drop the WebsitePanel Addons table $result = full_query('DROP TABLE `mod_wspaddons`'); // Check the results to verify that the table has been created properly if (!$result) { return array('status' => 'error', 'description' => 'There was an error while deactiviting the module'); } else { return array('status' => 'success', 'description' => 'The module has been deactivated successfully'); } } /** * 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 * * @access public * @return mixed */ function websitepanel_addons_output($params) { // Delete the requested WebsitePanel addon if (isset($_GET['action']) && $_GET['action'] == 'delete') { delete_query('mod_wspaddons', array('whmcs_id' => $_GET['id'])); } // Add the requested WebsitePanel addon if ($_POST && isset($_POST['action']) && $_POST['action'] == 'add') { // Sanity check to make sure the WHMCS addon ID exists $results = select_query('mod_wspaddons', 'id', array('id' => $_POST['whmcs_id'])); if (mysql_num_rows($results) > 0) { $results = select_query('mod_wspaddons', 'whmcs_id', array('whmcs_id' => $_POST['whmcs_id'])); if (mysql_num_rows($results) > 0) { echo '
Addon Name | WHMCS ID | WebsitePanel ID | |
---|---|---|---|
{$row['name']} | {$row['whmcs_id']} | {$row['wsp_id']} | Delete |
No Addon Data Found |
Add WebsitePanel Addon
'; echo "