Skip to content

Commit 142e00a

Browse files
committed
formatting updates
1 parent b78f605 commit 142e00a

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

src/Plugin.php

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*
1010
* @package Detain\MyAdminWebhostingIp
1111
*/
12-
class Plugin {
13-
12+
class Plugin
13+
{
1414
public static $name = 'Dedicated IP Webhosting Addon';
1515
public static $description = 'Allows selling of Dedicated IP Addon for Webhosting.';
1616
public static $help = '';
@@ -20,13 +20,15 @@ class Plugin {
2020
/**
2121
* Plugin constructor.
2222
*/
23-
public function __construct() {
23+
public function __construct()
24+
{
2425
}
2526

2627
/**
2728
* @return array<string,string[]>
2829
*/
29-
public static function getHooks() {
30+
public static function getHooks()
31+
{
3032
return [
3133
self::$module.'.load_addons' => [__CLASS__, 'getAddon'],
3234
self::$module.'.settings' => [__CLASS__, 'getSettings']
@@ -36,7 +38,8 @@ public static function getHooks() {
3638
/**
3739
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
3840
*/
39-
public static function getAddon(GenericEvent $event) {
41+
public static function getAddon(GenericEvent $event)
42+
{
4043
/**
4144
* @var \ServiceHandler $service
4245
*/
@@ -59,10 +62,11 @@ function_requirements('class.AddonHandler');
5962
* @param bool $regexMatch
6063
* @throws \Exception
6164
*/
62-
public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = FALSE) {
65+
public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
66+
{
6367
$serviceInfo = $serviceOrder->getServiceInfo();
6468
$settings = get_module_settings(self::$module);
65-
if ($regexMatch === FALSE) {
69+
if ($regexMatch === false) {
6670
function_requirements('get_service_master');
6771
$serverdata = get_service_master($serviceInfo[$settings['PREFIX'].'_server'], self::$module);
6872
$hash = $serverdata[$settings['PREFIX'].'_key'];
@@ -76,16 +80,19 @@ function_requirements('whm_api');
7680
$whm->set_auth_type('hash');
7781
$whm->set_user($user);
7882
$whm->set_hash($hash);
79-
$accts = json_decode($whm->listips(), TRUE);
83+
$accts = json_decode($whm->listips(), true);
8084
$freeips = [];
8185
$sharedIps = [];
8286
foreach (array_values($accts['result']) as $ipData) {
83-
if ($ipData['mainaddr'] == '1')
87+
if ($ipData['mainaddr'] == '1') {
8488
$mainIp = $ipData['ip'];
85-
if ($ipData['used'] == 0 && $ipData['active'] == 1 && $ipData['dedicated'] == 1)
89+
}
90+
if ($ipData['used'] == 0 && $ipData['active'] == 1 && $ipData['dedicated'] == 1) {
8691
$freeips[] = $ipData['ip'];
87-
if ($ipData['dedicated'] == 0)
92+
}
93+
if ($ipData['dedicated'] == 0) {
8894
$sharedIps[] = $ipData['ip'];
95+
}
8996
}
9097
// check if ip is main or additional/dedicated. if ip is main, get a new one
9198
if (in_array($serviceInfo[$settings['PREFIX'].'_ip'], $sharedIps)) {
@@ -108,11 +115,11 @@ function_requirements('whm_api');
108115
$headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL;
109116
$headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.PHP_EOL;
110117
$subject = 'Error Setting IP '.$serviceInfo[$settings['PREFIX'].'_ip'].' on '.$settings['TBLNAME'].' '.$serviceInfo[$settings['TITLE_FIELD']];
111-
admin_mail($subject, $subject, $headers, FALSE, 'admin/website_no_ips.tpl');
118+
admin_mail($subject, $subject, $headers, false, 'admin/website_no_ips.tpl');
112119
}
113120
} else {
114121
$subject = "0 Free IPs On {$settings['TBLNAME']} Server {$serverdata[$settings['PREFIX'].'_name']}";
115-
admin_mail($subject, "webserver {$serviceInfo[$settings['PREFIX'].'_id']} Has Pending IPS<br>\n".$subject, FALSE, FALSE, 'admin/website_no_ips.tpl');
122+
admin_mail($subject, "webserver {$serviceInfo[$settings['PREFIX'].'_id']} Has Pending IPS<br>\n".$subject, false, false, 'admin/website_no_ips.tpl');
116123
myadmin_log(self::$module, 'info', $subject, __LINE__, __FILE__);
117124
}
118125
} else {
@@ -130,7 +137,8 @@ function_requirements('whm_api');
130137
* @param bool $regexMatch
131138
* @throws \Exception
132139
*/
133-
public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = FALSE) {
140+
public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
141+
{
134142
$serviceInfo = $serviceOrder->getServiceInfo();
135143
$settings = get_module_settings(self::$module);
136144
$db = get_module_db(self::$module);
@@ -151,12 +159,15 @@ function_requirements('whm_api');
151159
$sharedIps = [];
152160
$values = array_values($accts['result']);
153161
foreach ($values as $ipData) {
154-
if ($ipData['mainaddr'] == 1)
162+
if ($ipData['mainaddr'] == 1) {
155163
$mainIp = $ipData['ip'];
156-
if ($ipData['used'] == 0 && $ipData['active'] == 1)
164+
}
165+
if ($ipData['used'] == 0 && $ipData['active'] == 1) {
157166
$freeips[] = $ipData['ip'];
158-
if ($ipData['dedicated'] == 0)
167+
}
168+
if ($ipData['dedicated'] == 0) {
159169
$sharedIps[] = $ipData['ip'];
170+
}
160171
}
161172
// check if ip is main or additional/dedicated. if ip is main, get a new one
162173
if (!in_array($serviceInfo[$settings['PREFIX'].'_ip'], $sharedIps)) {
@@ -176,7 +187,7 @@ function_requirements('whm_api');
176187
$headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL;
177188
$headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.PHP_EOL;
178189
$subject = 'Error Reverting To Main IP '.$serviceInfo[$settings['PREFIX'].'_ip'].' on '.$settings['TBLNAME'].' '.$serviceInfo[$settings['TITLE_FIELD']];
179-
admin_mail($subject, $subject, $headers, FALSE, 'admin/website_no_ips.tpl');
190+
admin_mail($subject, $subject, $headers, false, 'admin/website_no_ips.tpl');
180191
}
181192
} else {
182193
myadmin_log(self::$module, 'info', "ip {$serviceInfo[$settings['PREFIX'].'_ip']} (Shared IP) Main IP {$mainIp}, no Change Needed", __LINE__, __FILE__);
@@ -188,13 +199,14 @@ function_requirements('whm_api');
188199
$headers .= 'MIME-Version: 1.0'.PHP_EOL;
189200
$headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL;
190201
$headers .= 'From: '.$settings['TITLE'].' <'.$settings['EMAIL_FROM'].'>'.PHP_EOL;
191-
admin_mail($subject, $email, $headers, FALSE, 'admin/website_ip_canceled.tpl');
202+
admin_mail($subject, $email, $headers, false, 'admin/website_ip_canceled.tpl');
192203
}
193204

194205
/**
195206
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
196207
*/
197-
public static function getSettings(GenericEvent $event) {
208+
public static function getSettings(GenericEvent $event)
209+
{
198210
$settings = $event->getSubject();
199211
$settings->add_text_setting(self::$module, 'Costs & Limits', 'website_ip_cost', 'Dedicated IP Cost:', 'This is the cost for purchasing an additional IP on top of a Website.', (defined(WEBSITE_IP_COST) ? WEBSITE_IP_COST : 3));
200212
}

0 commit comments

Comments
 (0)