Skip to content

Commit 5932039

Browse files
committed
updates migrating off global tf handler to the MyAdminApp class handler
1 parent deb48fb commit 5932039

10 files changed

Lines changed: 39 additions & 39 deletions

bin/activate_cpanel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<?php
33

44
require_once __DIR__.'/../../../../include/functions.inc.php';
5-
$GLOBALS['tf']->session->create(160308, 'services');
6-
$GLOBALS['tf']->session->verify();
5+
\MyAdmin\App::session()->create(160308, 'services');
6+
\MyAdmin\App::session()->verify();
77

88
activate_cpanel('66.45.228.100', 401);
99
deactivate_cpanel('66.45.228.100');
1010

11-
$GLOBALS['tf']->session->destroy();
11+
\MyAdmin\App::session()->destroy();

bin/find_unbilled_cpanel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
$dbVps2 = get_module_db('vps');
1515
$dbInnertell = get_module_db('innertell');
1616
$dbCms = get_module_db('mb');
17-
$GLOBALS['tf']->session->create(160308, 'services');
18-
$GLOBALS['tf']->session->verify();
17+
\MyAdmin\App::session()->create(160308, 'services');
18+
\MyAdmin\App::session()->verify();
1919
$whitelist = explode("\n", trim(`export PATH="\$PATH:/bin:/usr/bin:/sbin:/usr/sbin"; cat /home/interser/public_html/misha/cpanel_whitelist.txt`));
2020
$licenses = [];
2121
$tocheck = [];
2222
$goodIps = [];
2323
$ipOutput = [];
24-
$session_id = $GLOBALS['tf']->session->sessionid;
24+
$session_id = \MyAdmin\App::session()->sessionid;
2525
$serviceTypes = get_license_types();
2626
$cpl = new \Detain\Cpanel\Cpanel(CPANEL_LICENSING_USERNAME, CPANEL_LICENSING_PASSWORD);
2727
$status = $cpl->fetchLicenses();
@@ -158,4 +158,4 @@
158158
}
159159
}
160160
echo $errors.'/'.count($licenses).' Licenses have matching problems'.PHP_EOL;
161-
$GLOBALS['tf']->session->destroy();
161+
\MyAdmin\App::session()->destroy();

bin/unbilled_cpanel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
function_requirements('unbilled_cpanel');
27-
$GLOBALS['tf']->ima = 'admin';
27+
\MyAdmin\App::tf()->ima = 'admin';
2828
unbilled_cpanel();
2929
if ($webpage == true) {
3030
add_output('</body></html>');

bin/update_cpanel_data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
define('VERBOSE_MODE', false);
1515
$show_help = false;
1616
$endprog = false;
17-
$GLOBALS['tf']->session->create(160307, 'services');
18-
$GLOBALS['tf']->session->verify();
17+
\MyAdmin\App::session()->create(160307, 'services');
18+
\MyAdmin\App::session()->verify();
1919
$module = 'licenses';
2020
$db = get_module_db($module);
2121
$settings = get_module_settings($module);
@@ -258,4 +258,4 @@
258258
$smarty->assign('out', $out);
259259
(new \MyAdmin\Mail())->adminMail('CPanel License Updates', $smarty->fetch('email/admin/cpanel_updates.tpl'), 'my@interserver.net', 'admin/cpanel_updates.tpl');
260260
echo "\n";
261-
$GLOBALS['tf']->session->destroy();
261+
\MyAdmin\App::session()->destroy();

src/Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function_requirements('activate_cpanel');
109109
myadmin_log(self::$module, 'info', 'IP Change - (OLD:'.$serviceClass->getIp().") (NEW:{$event['newip']})", __LINE__, __FILE__, self::$module, $serviceClass->getId());
110110
if (deactivate_cpanel($serviceClass->getIp()) == true) {
111111
activate_cpanel($event['newip'], $event['field1']);
112-
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_ip', $event['newip'], $serviceClass->getId(), $serviceClass->getCustid());
112+
\MyAdmin\App::history()->add($settings['TABLE'], 'change_ip', $event['newip'], $serviceClass->getId(), $serviceClass->getCustid());
113113
$serviceClass->set_ip($event['newip'])->save();
114114
$event['status'] = 'ok';
115115
$event['status_text'] = 'The IP Address has been changed.';
@@ -127,7 +127,7 @@ function_requirements('activate_cpanel');
127127
public static function getMenu(GenericEvent $event)
128128
{
129129
$menu = $event->getSubject();
130-
if ($GLOBALS['tf']->ima == 'admin') {
130+
if (\MyAdmin\App::ima() == 'admin') {
131131
$menu->add_link(self::$module, 'choice=none.unbilled_cpanel', '/images/myadmin/payment-history.png', _('Unbilled cPanel'));
132132
$menu->add_link(self::$module.'api', 'choice=none.cpanel_list', '/images/myadmin/list.png', _('List all cPanel Licenses'));
133133
}

src/cpanel.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function activate_cpanel($ipAddress, $package)
3333
'reactivateok' => 1
3434
];
3535
$response = $cpl->activateLicense($request);
36-
request_log($module, $GLOBALS['tf']->session->account_id, __FUNCTION__, 'cpanel', 'activateLicense', $request, $response);
36+
request_log($module, \MyAdmin\App::session()->account_id, __FUNCTION__, 'cpanel', 'activateLicense', $request, $response);
3737
myadmin_log('licenses', 'info', json_encode($response['attr']), __LINE__, __FILE__);
3838
return $response['attr'];
3939
}
@@ -46,8 +46,8 @@ function activate_cpanel($ipAddress, $package)
4646
*/
4747
function deactivate_cpanel($ipAddress = false)
4848
{
49-
if ($GLOBALS['tf']->ima == 'admin' && $ipAddress === false && isset($GLOBALS['tf']->variables->request['ip'])) {
50-
$ipAddress = $GLOBALS['tf']->variables->request['ip'];
49+
if (\MyAdmin\App::ima() == 'admin' && $ipAddress === false && isset(\MyAdmin\App::variables()->request['ip'])) {
50+
$ipAddress = \MyAdmin\App::variables()->request['ip'];
5151
}
5252
if (trim($ipAddress) == '') {
5353
return true;

src/cpanel_kcare_addon.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ function cpanel_kcare_addon()
1919
page_title('CPanel KCare Addon');
2020
$settings = \get_module_settings('licenses');
2121
$db = get_module_db('licenses');
22-
$id = (int) $GLOBALS['tf']->variables->request['id'];
22+
$id = (int) \MyAdmin\App::variables()->request['id'];
2323
$servicesCpanelType = get_service_define('CPANEL');
24-
if ($GLOBALS['tf']->ima == 'admin') {
24+
if (\MyAdmin\App::ima() == 'admin') {
2525
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType})", __LINE__, __FILE__);
2626
} else {
27-
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType}) and {$settings['PREFIX']}_custid='".get_custid($GLOBALS['tf']->session->account_id, 'licenses')."'", __LINE__, __FILE__);
27+
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType}) and {$settings['PREFIX']}_custid='".get_custid(\MyAdmin\App::session()->account_id, 'licenses')."'", __LINE__, __FILE__);
2828
}
2929
if ($db->num_rows() > 0) {
3030
$db->next_record(MYSQL_ASSOC);
@@ -34,7 +34,7 @@ function cpanel_kcare_addon()
3434
add_output('Only Active '.$settings['TBLNAME']);
3535
return;
3636
}
37-
if (!isset($GLOBALS['tf']->variables->request['submitbutton'])) {
37+
if (!isset(\MyAdmin\App::variables()->request['submitbutton'])) {
3838
$table = new \TFTable();
3939
$table->add_hidden('choice', 'none.cpanel_kcare_addon');
4040
$table->add_hidden('id', $id);

src/cpanel_ksplice_addon.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function cpanel_ksplice_addon()
1818
page_title('CPanel KSplice Addon');
1919
$settings = \get_module_settings('licenses');
2020
$db = get_module_db('licenses');
21-
$id = (int) $GLOBALS['tf']->variables->request['id'];
21+
$id = (int) \MyAdmin\App::variables()->request['id'];
2222
$servicesCpanelType = get_service_define('CPANEL');
23-
if ($GLOBALS['tf']->ima == 'admin') {
23+
if (\MyAdmin\App::ima() == 'admin') {
2424
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType})", __LINE__, __FILE__);
2525
} else {
26-
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType}) and {$settings['PREFIX']}_custid='".get_custid($GLOBALS['tf']->session->account_id, 'licenses')."'", __LINE__, __FILE__);
26+
$db->query("select * from {$settings['TABLE']} where {$settings['PREFIX']}_id='{$id}' and {$settings['PREFIX']}_type in (select services_id from services where services_type={$servicesCpanelType}) and {$settings['PREFIX']}_custid='".get_custid(\MyAdmin\App::session()->account_id, 'licenses')."'", __LINE__, __FILE__);
2727
}
2828
if ($db->num_rows() > 0) {
2929
$db->next_record(MYSQL_ASSOC);
@@ -32,7 +32,7 @@ function cpanel_ksplice_addon()
3232
add_output('Only Active '.$settings['TBLNAME']);
3333
return;
3434
}
35-
if (!isset($GLOBALS['tf']->variables->request['submitbutton'])) {
35+
if (!isset(\MyAdmin\App::variables()->request['submitbutton'])) {
3636
$table = new \TFTable();
3737
$table->add_hidden('choice', 'none.cpanel_ksplice_addon');
3838
$table->add_hidden('id', $id);

src/cpanel_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
function cpanel_list()
1111
{
1212
page_title('CPanel License List');
13-
if ($GLOBALS['tf']->ima == 'admin') {
13+
if (\MyAdmin\App::ima() == 'admin') {
1414
$table = new \TFTable();
1515
$table->set_title('CPanel License List');
1616
$header = false;

src/unbilled_cpanel.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
function unbilled_cpanel()
1717
{
1818
function_requirements('has_acl');
19-
if ($GLOBALS['tf']->ima != 'admin' || !has_acl('view_service')) {
19+
if (\MyAdmin\App::ima() != 'admin' || !has_acl('view_service')) {
2020
dialog('Not admin', 'Not Admin or you lack the permissions to view this page.');
2121
return false;
2222
}
@@ -95,14 +95,14 @@ function_requirements('has_acl');
9595
if ($db->Record['license_status'] == 'active' && $db->Record['services_field1'] == $license['package']) {
9696
$goodIps[] = $license['ip'];
9797
} elseif ($db->Record['license_status'] != 'active' && $db->Record['services_field1'] == $license['package']) {
98-
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'];
98+
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'];
9999
// $db->query("update licenses set license_type=$license_type where license_id='{$db->Record['license_id']}'");
100100
} elseif ($db->Record['license_status'] == 'active' && $db->Record['services_field1'] != $license['package']) {
101-
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but type is '.str_replace('INTERSERVER-', '', $db->Record['services_name']).' instead of '.str_replace('INTERSERVER-', '', $services[$license['package']]);
101+
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but type is '.str_replace('INTERSERVER-', '', $db->Record['services_name']).' instead of '.str_replace('INTERSERVER-', '', $services[$license['package']]);
102102
} elseif (!isset($services[$license['package']])) {
103-
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'].' and type is '.$db->Record['services_name'].' with no local package matching the '.$license['package'].' type';
103+
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'].' and type is '.$db->Record['services_name'].' with no local package matching the '.$license['package'].' type';
104104
} else {
105-
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'].' and type is '.str_replace('INTERSERVER-', '', $db->Record['services_name']).' instead of '.str_replace('INTERSERVER-', '', $services[$license['package']]);
105+
$ipOutput[$license['ip']][] = 'CPanelDirect License '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_license&id='.$db->Record['license_id']).'" target=_blank>'.$db->Record['license_id'].'</a>'.' Found but status is '.$db->Record['license_status'].' and type is '.str_replace('INTERSERVER-', '', $db->Record['services_name']).' instead of '.str_replace('INTERSERVER-', '', $services[$license['package']]);
106106
}
107107
}
108108
}
@@ -120,14 +120,14 @@ function_requirements('has_acl');
120120
if ($dbVps2->num_rows() > 0) {
121121
$goodIps[] = $license['ip'];
122122
} else {
123-
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Has Cpanel But Has not Paid In 2+ Months';
123+
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Has Cpanel But Has not Paid In 2+ Months';
124124
}
125125
} elseif ($vps['vps_status'] == 'active' && $vps['repeat_invoices_id'] == null) {
126-
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found but no CPanel';
126+
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found but no CPanel';
127127
} elseif ($vps['vps_status'] != 'active' && $vps['repeat_invoices_id'] != null) {
128-
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found with CPanel but VPS status is '.$vps['vps_status'];
128+
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found with CPanel but VPS status is '.$vps['vps_status'];
129129
} else {
130-
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found But Status '.$vps['vps_status'].' and no CPanel';
130+
$ipOutput[$license['ip']][] = 'VPS '.'<a href="'.\MyAdmin\App::link('index.php', 'choice=none.view_vps&id='.$vps['vps_id']).'" target=_blank>'.$vps['vps_id'].'</a>'.' Found But Status '.$vps['vps_status'].' and no CPanel';
131131
}
132132
}
133133
}
@@ -151,13 +151,13 @@ function_requirements('has_acl');
151151
if ((count($dedicatedTag) > 8 && ($dedicatedTag[7] == 1 || $dedicatedTag[7] == 6)) || $db->Record['server_dedicated_cp'] == 1 || $db->Record['server_dedicated_cp'] == 6) {
152152
$goodIps[] = $license['ip'];
153153
} else {
154-
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.$GLOBALS['tf']->link('view_server_order', 'id='.$db->Record['server_id']).'">'.$db->Record['server_id'].'</a>'.' found but no CPanel';
154+
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.\MyAdmin\App::link('view_server_order', 'id='.$db->Record['server_id']).'">'.$db->Record['server_id'].'</a>'.' found but no CPanel';
155155
}
156156
} else {
157157
if ((count($dedicatedTag) > 8 && ($dedicatedTag[7] == 1 || $dedicatedTag[7] == 6)) || $db->Record['server_dedicated_cp'] == 1 || $db->Record['server_dedicated_cp'] == 6) {
158-
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.$GLOBALS['tf']->link('view_server_order', 'id='.$db->Record['server_id']).'" target=_blank>'.$db->Record['server_id'].'</a>'.' found but status '.$db->Record['server_status'];
158+
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.\MyAdmin\App::link('view_server_order', 'id='.$db->Record['server_id']).'" target=_blank>'.$db->Record['server_id'].'</a>'.' found but status '.$db->Record['server_status'];
159159
} else {
160-
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.$GLOBALS['tf']->link('view_server_order', 'id='.$db->Record['server_id']).'" target=_blank>'.$db->Record['server_id'].'</a>'.' found but status '.$db->Record['server_status'].' and no CPanel';
160+
$ipOutput[$license['ip']][] = 'Innertell Order '.'<a href="'.\MyAdmin\App::link('view_server_order', 'id='.$db->Record['server_id']).'" target=_blank>'.$db->Record['server_id'].'</a>'.' found but status '.$db->Record['server_status'].' and no CPanel';
161161
}
162162
}
163163
} else {
@@ -181,12 +181,12 @@ function_requirements('has_acl');
181181
add_output(
182182
'<tr style="vertical-align: top;"><td>
183183
<a href="search?comments=no&search='.$ipAddress.'&expand=1" target=_blank>'.$ipAddress.'</a>
184-
(<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.deactivate_cpanel&ip='.$ipAddress).'" target=_blank>cancel</a>)</td>
184+
(<a href="'.\MyAdmin\App::link('index.php', 'choice=none.deactivate_cpanel&ip='.$ipAddress).'" target=_blank>cancel</a>)</td>
185185
<td>'.$license['hostname'].'</td><td>'.str_replace(['INTERSERVER-', ' License'], ['', ''], $services[$license['package']]).'</td><td>'
186186
);
187187
} elseif ($outType == 'tftable') {
188188
$table->set_col_options('style="width: 210px;"');
189-
$table->add_field('<a href="search?comments=no&search='.$ipAddress.'&expand=1" target=_blank>'.$ipAddress.'</a> (<a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.deactivate_cpanel&ip='.$ipAddress).'" target=_blank>cancel</a>)', 'r');
189+
$table->add_field('<a href="search?comments=no&search='.$ipAddress.'&expand=1" target=_blank>'.$ipAddress.'</a> (<a href="'.\MyAdmin\App::link('index.php', 'choice=none.deactivate_cpanel&ip='.$ipAddress).'" target=_blank>cancel</a>)', 'r');
190190
$table->set_col_options('');
191191
// $table->set_col_options('style="width: 225px;"');
192192
$table->add_field($license['hostname'], 'r');

0 commit comments

Comments
 (0)