Skip to content

Commit 3ef361c

Browse files
committed
updates migrating off global tf handler to the MyAdminApp class handler
1 parent 4773c1b commit 3ef361c

2 files changed

Lines changed: 36 additions & 36 deletions

File tree

src/Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static function loadProcessing(GenericEvent $event)
111111
$settings = get_module_settings(self::$module);
112112
$db = get_module_db(self::$module);
113113
$db->query("update {$settings['TABLE']} set {$settings['PREFIX']}_status='active' where {$settings['PREFIX']}_id='{$serviceInfo[$settings['PREFIX'].'_id']}'", __LINE__, __FILE__);
114-
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_status', 'active', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_custid']);
114+
\MyAdmin\App::history()->add($settings['TABLE'], 'change_status', 'active', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_custid']);
115115
$smarty = new \TFSmarty();
116116
$smarty->assign('license_ip', $serviceInfo[$settings['PREFIX'].'_ip']);
117117
$smarty->assign('service_name', $serviceTypes[$serviceInfo[$settings['PREFIX'].'_type']]['services_name']);
@@ -125,7 +125,7 @@ public static function loadProcessing(GenericEvent $event)
125125
$settings = get_module_settings(self::$module);
126126
$db = get_module_db(self::$module);
127127
$db->query("update {$settings['TABLE']} set {$settings['PREFIX']}_status='active' where {$settings['PREFIX']}_id='{$serviceInfo[$settings['PREFIX'].'_id']}'", __LINE__, __FILE__);
128-
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_status', 'active', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_custid']);
128+
\MyAdmin\App::history()->add($settings['TABLE'], 'change_status', 'active', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_custid']);
129129
$smarty = new \TFSmarty();
130130
$smarty->assign('license_ip', $serviceInfo[$settings['PREFIX'].'_ip']);
131131
$smarty->assign('service_name', $serviceTypes[$serviceInfo[$settings['PREFIX'].'_type']]['services_name']);

src/api.php

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ function api_cancel_license_ip($sid, $ip, $service_type)
4646
$return = [];
4747
$return['status'] = '';
4848
$return['status_text'] = '';
49-
$GLOBALS['tf']->session->sessionid = $sid;
50-
if ($GLOBALS['tf']->session->verify()) {
49+
\MyAdmin\App::session()->sessionid = $sid;
50+
if (\MyAdmin\App::session()->verify()) {
5151
// Read there account data
52-
$custid = get_custid($GLOBALS['tf']->session->account_id, $module);
53-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($custid);
54-
$GLOBALS['tf']->ima = $GLOBALS['tf']->session->appsession('ima');
55-
$GLOBALS['tf']->session->update_dla();
52+
$custid = get_custid(\MyAdmin\App::session()->account_id, $module);
53+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read($custid);
54+
\MyAdmin\App::tf()->ima = \MyAdmin\App::session()->appsession('ima');
55+
\MyAdmin\App::session()->update_dla();
5656
} else {
5757
$return['status'] = 'error';
5858
$return['status_text'] = 'Invalid Session ID';
@@ -114,13 +114,13 @@ function api_cancel_license($sid, $id)
114114
$return = [];
115115
$return['status'] = '';
116116
$return['status_text'] = '';
117-
$GLOBALS['tf']->session->sessionid = $sid;
118-
if ($GLOBALS['tf']->session->verify()) {
117+
\MyAdmin\App::session()->sessionid = $sid;
118+
if (\MyAdmin\App::session()->verify()) {
119119
// Read there account data
120-
$custid = get_custid($GLOBALS['tf']->session->account_id, $module);
121-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($custid);
122-
$GLOBALS['tf']->ima = $GLOBALS['tf']->session->appsession('ima');
123-
$GLOBALS['tf']->session->update_dla();
120+
$custid = get_custid(\MyAdmin\App::session()->account_id, $module);
121+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read($custid);
122+
\MyAdmin\App::tf()->ima = \MyAdmin\App::session()->appsession('ima');
123+
\MyAdmin\App::session()->update_dla();
124124
} else {
125125
$return['status'] = 'error';
126126
$return['status_text'] = 'Invalid Session ID';
@@ -202,20 +202,20 @@ function api_buy_license($sid, $ip, $service_type, $coupon = '', $use_prepay = n
202202
5002 => 5009,
203203
10683 => 10682
204204
];
205-
$GLOBALS['tf']->session->sessionid = $sid;
206-
if ($GLOBALS['tf']->session->verify()) {
205+
\MyAdmin\App::session()->sessionid = $sid;
206+
if (\MyAdmin\App::session()->verify()) {
207207
// Read there account data
208-
$custid = convert_custid($GLOBALS['tf']->session->account_id, $module);
209-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($custid);
210-
$GLOBALS['tf']->ima = $GLOBALS['tf']->session->appsession('ima');
211-
$GLOBALS['tf']->session->update_dla();
208+
$custid = convert_custid(\MyAdmin\App::session()->account_id, $module);
209+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read($custid);
210+
\MyAdmin\App::tf()->ima = \MyAdmin\App::session()->appsession('ima');
211+
\MyAdmin\App::session()->update_dla();
212212
} else {
213213
$return['status'] = 'error';
214214
$return['status_text'] = 'Invalid Session ID';
215215
return $return;
216216
}
217217
update_session_log(__FUNCTION__);
218-
$data = $GLOBALS['tf']->accounts->read($custid);
218+
$data = \MyAdmin\App::accounts()->read($custid);
219219
$continue = true;
220220
$ip_owner = get_ip_owner($ip);
221221
if (!validIp($ip, false)) {
@@ -266,7 +266,7 @@ function api_buy_license($sid, $ip, $service_type, $coupon = '', $use_prepay = n
266266
$service_cost = $coupon_info['amount'];
267267
break;
268268
}
269-
$GLOBALS['tf']->history->add('apply_coupon', $ip, $service_cost, $tcost, $custid);
269+
\MyAdmin\App::history()->add('apply_coupon', $ip, $service_cost, $tcost, $custid);
270270
}
271271
}
272272
if ($use_prepay == true) {
@@ -405,16 +405,16 @@ function_requirements('get_paypal_link');
405405
*/
406406
function api_change_license_ip($sid, $oldip, $newip)
407407
{
408-
$GLOBALS['tf']->session->sessionid = $sid;
408+
\MyAdmin\App::session()->sessionid = $sid;
409409
$module = 'licenses';
410410
$settings = get_module_settings($module);
411411
$db = get_module_db($module);
412412
$oldip = $db->real_escape($oldip);
413-
if ($GLOBALS['tf']->session->verify()) {
414-
$custid = $GLOBALS['tf']->session->account_id;
415-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($custid);
416-
$GLOBALS['tf']->ima = $GLOBALS['tf']->session->appsession('ima');
417-
$GLOBALS['tf']->session->update_dla();
413+
if (\MyAdmin\App::session()->verify()) {
414+
$custid = \MyAdmin\App::session()->account_id;
415+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read($custid);
416+
\MyAdmin\App::tf()->ima = \MyAdmin\App::session()->appsession('ima');
417+
\MyAdmin\App::session()->update_dla();
418418
if (!check_auth_limits(false)) {
419419
myadmin_log('api', 'info', 'This account is currently locked or does not meet the requirements to login.', __LINE__, __FILE__);
420420
return false;
@@ -425,7 +425,7 @@ function api_change_license_ip($sid, $oldip, $newip)
425425
return $return;
426426
}
427427
update_session_log(__FUNCTION__);
428-
$data = $GLOBALS['tf']->accounts->read($custid);
428+
$data = \MyAdmin\App::accounts()->read($custid);
429429
if ($data['status'] == 'locked') {
430430
$return['status'] = 'error';
431431
$return['status_text'] .= "Locked Account.\n";
@@ -463,15 +463,15 @@ function api_change_license_ip($sid, $oldip, $newip)
463463
function api_change_license_ip_by_id($sid, $id, $newip)
464464
{
465465
$id = (int)$id;
466-
$GLOBALS['tf']->session->sessionid = $sid;
466+
\MyAdmin\App::session()->sessionid = $sid;
467467
$module = 'licenses';
468468
$settings = get_module_settings($module);
469469
$db = get_module_db($module);
470-
if ($GLOBALS['tf']->session->verify()) {
471-
$custid = $GLOBALS['tf']->session->account_id;
472-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($custid);
473-
$GLOBALS['tf']->ima = $GLOBALS['tf']->session->appsession('ima');
474-
$GLOBALS['tf']->session->update_dla();
470+
if (\MyAdmin\App::session()->verify()) {
471+
$custid = \MyAdmin\App::session()->account_id;
472+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read($custid);
473+
\MyAdmin\App::tf()->ima = \MyAdmin\App::session()->appsession('ima');
474+
\MyAdmin\App::session()->update_dla();
475475
if (!check_auth_limits(false)) {
476476
myadmin_log('api', 'info', 'This account is currently locked or does not meet the requirements to login.', __LINE__, __FILE__, $module);
477477
return false;
@@ -482,7 +482,7 @@ function api_change_license_ip_by_id($sid, $id, $newip)
482482
return $return;
483483
}
484484
update_session_log(__FUNCTION__);
485-
$data = $GLOBALS['tf']->accounts->read($custid);
485+
$data = \MyAdmin\App::accounts()->read($custid);
486486
if ($data['status'] == 'locked') {
487487
$return['status'] = 'error';
488488
$return['status_text'] .= "Locked Account.\n";

0 commit comments

Comments
 (0)