0) { // Include the WebsitePanel ES Class require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php'); require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php'); // Retrieve the WebsitePanel Addons module settings $modSettings = websitepanel_addons_GetSettings(); $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 return; } // Get the associated WebsitePanel username from WHMCS $results = select_query('tblhosting', 'username', array('id' => $params['serviceid'])); $username = mysql_fetch_array($results); $username = $username['username']; if (empty($username)) { // The username is required - if missing we cannot continue return; } // Create the WebsitePanel object instance $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 $user = $wsp->getUserByUsername($username); if (empty($user)) { return; } // Get the user's current WebsitePanel hosting space Id (Hosting Plan) $package = $wsp->getUserPackages($user['UserId']); $packageId = $package['PackageId']; if (empty($packageId)) { return; } // Get the associated WebsitePanel addon id $results = select_query('mod_wspaddons', 'wsp_id,is_ipaddress', array('whmcs_id' => $params['addonid'])); $addon = mysql_fetch_array($results); $addonPlanId = $addon['wsp_id']; $addonIsIpAddress = $addon['is_ipaddress']; // Add the Addon Plan to the customer's WebsitePanel package / hosting space $results = $wsp->addPackageAddonById($packageId, $addonPlanId); // Check the results to verify that the addon has been successfully allocated if ($results['Result'] > 0) { // If this addon is an IP address addon - attempt to randomly allocate an IP address to the customer's hosting space if ($addonIsIpAddress) { $wsp->packageAllocateIpAddress($packageId); } } } } /* Addon Activation - WebsitePanel */ add_hook('AddonActivation', 1, 'websitepanel_addons_AddonActivation'); /* Addon Activation - WebsitePanel */ add_hook('AddonActivated', 1, 'websitepanel_addons_AddonActivation'); /** * websitepanel_addons_GetSettings * * @access public * @return array */ function websitepanel_addons_GetSettings() { $settings = array(); // Retrieve the settings from the modules configuration table $results = select_query('tbladdonmodules', 'setting,value', array('module' => 'websitepanel_addons')); while (($row = mysql_fetch_array($results)) != false) { $settings[$row[0]] = $row[1]; } return $settings; }