Skip to content

Commit a91538a

Browse files
committed
updates migrating off global tf handler to the MyAdminApp class handler
1 parent 27db6db commit a91538a

5 files changed

Lines changed: 42 additions & 42 deletions

File tree

bin/abuse_imap_downloader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
include_once __DIR__.'/../../../../include/functions.inc.php';
1515
include_once __DIR__.'/../src/ImapAbuseCheck.php';
16-
$GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
17-
$db = $GLOBALS['tf']->db;
16+
\MyAdmin\App::session()->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
17+
$db = \MyAdmin\App::db();
1818
$db->query('select abuse_ip,count(abuse_lid) as count from abuse where Year(abuse_time)=Year(now()) and Month(abuse_time)=Month(now()) and Day(abuse_time)=Day(now()) group by abuse_ip');
1919
$abuse_ips = [];
2020
$total_sent = 0;

src/ImapAbuseCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function process($type = 'spam', $limit = false)
283283
$db->query("select * from mail where mail_username='{$mbUser}'");
284284
if ($db->num_rows() > 0) {
285285
$db->next_record(MYSQL_ASSOC);
286-
$data = $GLOBALS['tf']->accounts->read($db->Record['mail_custid']);
286+
$data = \MyAdmin\App::accounts()->read($db->Record['mail_custid']);
287287
$email = (!isset($data['email_abuse']) || trim($data['email_abuse']) == '') ? $data['account_lid'] : $data['email_abuse'];
288288
$server_data = [
289289
'email' => $email,

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function getHooks()
4141
public static function getMenu(GenericEvent $event)
4242
{
4343
$menu = $event->getSubject();
44-
if ($GLOBALS['tf']->ima == 'admin') {
44+
if (\MyAdmin\App::ima() == 'admin') {
4545
function_requirements('has_acl');
4646
if (has_acl('client_billing')) {
4747
$menu->add_link('admin', 'choice=none.abuse_admin', '/images/myadmin/spam-can.png', _('Abuse'));

src/abuse.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ function abuse()
2626
)
2727
ENGINE = INNODB
2828
*/
29-
//$customer = $GLOBALS['tf']->variables->request['customer'];
29+
//$customer = \MyAdmin\App::variables()->request['customer'];
3030
function_requirements('get_server_from_ip');
3131
$module = get_module_name('default');
3232
$db = get_module_db($module);
3333
$logged_in = false;
3434
$continue = false;
35-
if (isset($GLOBALS['tf']->variables->request['key']) && isset($GLOBALS['tf']->variables->request['id'])) {
36-
$key = $GLOBALS['tf']->variables->request['key'];
37-
$id = (int)$GLOBALS['tf']->variables->request['id'];
35+
if (isset(\MyAdmin\App::variables()->request['key']) && isset(\MyAdmin\App::variables()->request['id'])) {
36+
$key = \MyAdmin\App::variables()->request['key'];
37+
$id = (int)\MyAdmin\App::variables()->request['id'];
3838
$db->query("select md5(concat(abuse_id,abuse_ip,abuse_type)) as abuse_key from abuse where abuse_id=$id");
3939
if ($db->num_rows() == 1) {
4040
$db->next_record(MYSQL_ASSOC);
@@ -43,18 +43,18 @@ function_requirements('get_server_from_ip');
4343
}
4444
}
4545
}
46-
if (!$continue && $GLOBALS['tf']->session->verify()) {
46+
if (!$continue && \MyAdmin\App::session()->verify()) {
4747
$logged_in = true;
4848
$continue = true;
49-
$GLOBALS['tf']->accounts->data = $GLOBALS['tf']->accounts->read($GLOBALS['tf']->session->account_id);
50-
$GLOBALS['tf']->ima = $GLOBALS['tf']->accounts->data['ima'];
49+
\MyAdmin\App::accounts()->data = \MyAdmin\App::accounts()->read(\MyAdmin\App::session()->account_id);
50+
\MyAdmin\App::tf()->ima = \MyAdmin\App::accounts()->data['ima'];
5151
}
5252
if ($continue !== true) {
5353
add_output('Invalid Authentication, Please Login first or use the URL given in the email.');
5454
return false;
5555
}
5656
unset($continue);
57-
if ($GLOBALS['tf']->ima == 'admin' && !isset($GLOBALS['tf']->variables->request['id'])) {
57+
if (\MyAdmin\App::ima() == 'admin' && !isset(\MyAdmin\App::variables()->request['id'])) {
5858
function_requirements('abuse_admin');
5959
abuse_admin();
6060
add_output('<script type="text/javascript">
@@ -66,8 +66,8 @@ function_requirements('abuse_admin');
6666
} else {
6767
$smarty = new TFSmarty();
6868
page_title('Manage Abuse Complaints');
69-
if (isset($GLOBALS['tf']->variables->request['id'])) {
70-
$id = (int)$GLOBALS['tf']->variables->request['id'];
69+
if (isset(\MyAdmin\App::variables()->request['id'])) {
70+
$id = (int)\MyAdmin\App::variables()->request['id'];
7171
$db->query("select * from abuse left join abuse_data using (abuse_id) where abuse_id={$id}");
7272
if ($db->num_rows() > 0) {
7373
$db->next_record(MYSQL_ASSOC);
@@ -90,17 +90,17 @@ function_requirements('abuse_admin');
9090
}
9191
$ip = $db->Record['abuse_ip'];
9292
$server_data = get_server_from_ip($ip);
93-
if (($logged_in && $GLOBALS['tf']->accounts->data['account_lid'] == $server_data['email']) || ($logged_in && $GLOBALS['tf']->accounts->data['account_lid'] == $db->Record['abuse_lid']) || ($logged_in == false) || ($GLOBALS['tf']->ima == 'admin')) {
94-
if (isset($GLOBALS['tf']->variables->request['response'])) {
95-
$db->query("update abuse set abuse_status='" . $db->real_escape($GLOBALS['tf']->variables->request['response_status']) . "' where abuse_id={$id}", __LINE__, __FILE__);
96-
$db->query("update abuse_data set abuse_response='" . $db->real_escape($GLOBALS['tf']->variables->request['response']) . "' where abuse_id={$id}", __LINE__, __FILE__);
93+
if (($logged_in && \MyAdmin\App::accounts()->data['account_lid'] == $server_data['email']) || ($logged_in && \MyAdmin\App::accounts()->data['account_lid'] == $db->Record['abuse_lid']) || ($logged_in == false) || (\MyAdmin\App::ima() == 'admin')) {
94+
if (isset(\MyAdmin\App::variables()->request['response'])) {
95+
$db->query("update abuse set abuse_status='" . $db->real_escape(\MyAdmin\App::variables()->request['response_status']) . "' where abuse_id={$id}", __LINE__, __FILE__);
96+
$db->query("update abuse_data set abuse_response='" . $db->real_escape(\MyAdmin\App::variables()->request['response']) . "' where abuse_id={$id}", __LINE__, __FILE__);
9797
$db->query("select * from abuse left join abuse_data using (abuse_id) where abuse_id={$id}");
9898
$db->next_record(MYSQL_ASSOC);
9999
if (!is_null($db->Record['abuse_attachments'])) {
100100
$decoded = json_decode($db->Record['abuse_attachments'], true);
101101
$db->Record['abuse_attachments'] = is_array($decoded) ? array_values(array_filter($decoded, 'is_array')) : null;
102102
}
103-
add_output('Abuse Entry Updated <a href="'.$GLOBALS['tf']->link('index.php', 'choice=none.abuse').'">View Pending Abuse Complaints</a>');
103+
add_output('Abuse Entry Updated <a href="'.\MyAdmin\App::link('index.php', 'choice=none.abuse').'">View Pending Abuse Complaints</a>');
104104
}
105105
$smarty->assign($db->Record);
106106
$smarty->assign('post_location', 'abuse.php?id='.$id . ($logged_in === true || !isset($key) ? '' : '&key='.$key));
@@ -113,7 +113,7 @@ function_requirements('abuse_admin');
113113
$anonemail .= '*';
114114
}
115115
$anonemail .= $eparts[1];
116-
add_output('Your account '.$GLOBALS['tf']->accounts->data['account_lid']. ' does not match the owner of this complaint '.$anonemail);
116+
add_output('Your account '.\MyAdmin\App::accounts()->data['account_lid']. ' does not match the owner of this complaint '.$anonemail);
117117
}
118118
} else {
119119
add_output('Invalid complaint');

src/abuse_admin.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function_requirements('class.ImapAbuseCheck');
2323
$maxmailed = 5;
2424
$limit = 'limit 20';
2525
function_requirements('has_acl');
26-
if ($GLOBALS['tf']->ima != 'admin' || !has_acl('client_billing')) {
26+
if (\MyAdmin\App::ima() != 'admin' || !has_acl('client_billing')) {
2727
myadmin_log('myadmin', 'debug', 'Not Admin', __LINE__, __FILE__);
2828
dialog('Not admin', 'Not Admin or you lack the permissions to view this page.');
2929
return false;
@@ -40,9 +40,9 @@ function_requirements('has_acl');
4040
$table2->hide_title();
4141
$table2->hide_table();
4242
$table2->hide_form();
43-
if (isset($GLOBALS['tf']->variables->request['lid'])) {
44-
$lid = $db->real_escape($GLOBALS['tf']->variables->request['lid']);
45-
$lid_data = $GLOBALS['tf']->accounts->read($GLOBALS['tf']->accounts->cross_reference($lid));
43+
if (isset(\MyAdmin\App::variables()->request['lid'])) {
44+
$lid = $db->real_escape(\MyAdmin\App::variables()->request['lid']);
45+
$lid_data = \MyAdmin\App::accounts()->read(\MyAdmin\App::accounts()->cross_reference($lid));
4646
$table = new \TFTable();
4747
$table->set_col_options('style="vertical-align: middle; padding-top: 1px; padding-right: 3px;"');
4848
if (isset($lid_data['picture']) && null !== $lid_data['picture'] && $lid_data['picture'] != '') {
@@ -94,8 +94,8 @@ function_requirements('has_acl');
9494
function_requirements('crud_abuse');
9595
crud_abuse();
9696
}
97-
if (isset($GLOBALS['tf']->variables->request['headers']) && verify_csrf('abuse_admin')) {
98-
$ip = $GLOBALS['tf']->variables->request['ip'];
97+
if (isset(\MyAdmin\App::variables()->request['headers']) && verify_csrf('abuse_admin')) {
98+
$ip = \MyAdmin\App::variables()->request['ip'];
9999
if (validIp($ip, false)) {
100100
$server_data = get_server_from_ip($ip);
101101
if (isset($server_data['email']) && $server_data['email'] != '') {
@@ -104,20 +104,20 @@ function_requirements('crud_abuse');
104104
'abuse_id' => null,
105105
'abuse_time' => mysql_now(),
106106
'abuse_ip' => $ip,
107-
'abuse_type' => $GLOBALS['tf']->variables->request['type'],
108-
'abuse_amount' => $GLOBALS['tf']->variables->request['amount'],
107+
'abuse_type' => \MyAdmin\App::variables()->request['type'],
108+
'abuse_amount' => \MyAdmin\App::variables()->request['amount'],
109109
'abuse_lid' => $email,
110110
'abuse_status' => 'pending'
111111
]), __LINE__, __FILE__);
112112
$id = $db->getLastInsertId('abuse', 'abuse_id');
113113
$db->query(make_insert_query('abuse_data', [
114114
'abuse_id' => $id,
115-
'abuse_headers' => ImapAbuseCheck::fix_headers($GLOBALS['tf']->variables->request['headers']),
115+
'abuse_headers' => ImapAbuseCheck::fix_headers(\MyAdmin\App::variables()->request['headers']),
116116
]), __LINE__, __FILE__);
117117
$subject = 'InterServer Abuse Report for '.$ip;
118118
$message = str_replace(
119119
['{$email}', '{$ip}', '{$type}', '{$count}', '{$id}', '{$key}'],
120-
[$server_data['email_abuse'], $ip, $GLOBALS['tf']->variables->request['type'], $GLOBALS['tf']->variables->request['amount'], $id, md5($id . $ip . $GLOBALS['tf']->variables->request['type'])],
120+
[$server_data['email_abuse'], $ip, \MyAdmin\App::variables()->request['type'], \MyAdmin\App::variables()->request['amount'], $id, md5($id . $ip . \MyAdmin\App::variables()->request['type'])],
121121
$email_template
122122
);
123123
(new \MyAdmin\Mail())->clientMail($subject, $message, $server_data['email_abuse'], 'client/abuse.tpl');
@@ -133,8 +133,8 @@ function_requirements('crud_abuse');
133133
}
134134
}
135135
}
136-
if (isset($GLOBALS['tf']->variables->request['evidence']) && verify_csrf('abuse_admin_multiple')) {
137-
$ips = explode("\n", trim($GLOBALS['tf']->variables->request['ips']));
136+
if (isset(\MyAdmin\App::variables()->request['evidence']) && verify_csrf('abuse_admin_multiple')) {
137+
$ips = explode("\n", trim(\MyAdmin\App::variables()->request['ips']));
138138
foreach ($ips as $ip) {
139139
$ip = trim($ip);
140140
if (validIp($ip, false)) {
@@ -145,20 +145,20 @@ function_requirements('crud_abuse');
145145
'abuse_id' => null,
146146
'abuse_time' => mysql_now(),
147147
'abuse_ip' => $ip,
148-
'abuse_type' => $GLOBALS['tf']->variables->request['type'],
148+
'abuse_type' => \MyAdmin\App::variables()->request['type'],
149149
'abuse_amount' => 1,
150150
'abuse_lid' => $email,
151151
'abuse_status' => 'pending'
152152
]), __LINE__, __FILE__);
153153
$id = $db->getLastInsertId('abuse', 'abuse_id');
154154
$db->query(make_insert_query('abuse_data', [
155155
'abuse_id' => $id,
156-
'abuse_headers' => ImapAbuseCheck::fix_headers($GLOBALS['tf']->variables->request['headers']),
156+
'abuse_headers' => ImapAbuseCheck::fix_headers(\MyAdmin\App::variables()->request['headers']),
157157
]), __LINE__, __FILE__);
158158
$subject = 'InterServer Abuse Report for '.$ip;
159159
$message = str_replace(
160160
['{$email}', '{$ip}', '{$type}', '{$count}', '{$id}', '{$key}'],
161-
[$server_data['email_abuse'], $ip, $GLOBALS['tf']->variables->request['type'], 1, $id, md5($id . $ip . $GLOBALS['tf']->variables->request['type'])],
161+
[$server_data['email_abuse'], $ip, \MyAdmin\App::variables()->request['type'], 1, $id, md5($id . $ip . \MyAdmin\App::variables()->request['type'])],
162162
$email_template
163163
);
164164
(new \MyAdmin\Mail())->clientMail($subject, $message, $server_data['email_abuse'], 'client/abuse.tpl');
@@ -187,8 +187,8 @@ function_requirements('crud_abuse');
187187
$parts = explode(',', $lines[$x]);
188188
$ip = $parts[0];
189189
$date = new \DateTime(is_numeric($parts[1]) && mb_strlen($parts[1]) == 10 ? date(MYSQL_DATE_FORMAT, $parts[1]) : $parts[1]);
190-
if (isset($GLOBALS['tf']->variables->request['dates']) && $GLOBALS['tf']->variables->request['dates'] != 'all' && is_numeric($GLOBALS['tf']->variables->request['dates'])) {
191-
$limit_date = new \DateTime(date(MYSQL_DATE_FORMAT, time() - $GLOBALS['tf']->variables->request['dates']));
190+
if (isset(\MyAdmin\App::variables()->request['dates']) && \MyAdmin\App::variables()->request['dates'] != 'all' && is_numeric(\MyAdmin\App::variables()->request['dates'])) {
191+
$limit_date = new \DateTime(date(MYSQL_DATE_FORMAT, time() - \MyAdmin\App::variables()->request['dates']));
192192
if ($date < $limit_date) {
193193
continue;
194194
}
@@ -232,9 +232,9 @@ function_requirements('crud_abuse');
232232
add_output('<pre style="text-align: left;">$_FILES = '.var_export($_FILES, true).';</pre>');
233233
}
234234
}
235-
if (isset($GLOBALS['tf']->variables->request['csvtext']) && $GLOBALS['tf']->variables->request['csvtext'] != '' && verify_csrf('abuse_admin_uce')) {
235+
if (isset(\MyAdmin\App::variables()->request['csvtext']) && \MyAdmin\App::variables()->request['csvtext'] != '' && verify_csrf('abuse_admin_uce')) {
236236
add_output('Importing CSV Text<br>');
237-
$lines = explode("\n", $GLOBALS['tf']->variables->request['csvtext']);
237+
$lines = explode("\n", \MyAdmin\App::variables()->request['csvtext']);
238238
for ($x = 0, $x_max = count($lines); $x < $x_max; $x++) {
239239
if (mb_strpos($lines[$x], ',') !== false && is_numeric(mb_substr($lines[$x], 0, 1))) {
240240
$parts = explode(',', $lines[$x]);
@@ -277,9 +277,9 @@ function_requirements('crud_abuse');
277277
}
278278
// display the current abuse entries
279279
//uceprotect links to - http://www.uceprotect.net/en/rblcheck.php?ipr=$ip
280-
if (isset($GLOBALS['tf']->variables->request['tmcsvtext']) && $GLOBALS['tf']->variables->request['tmcsvtext'] != '' && verify_csrf('abuse_admin_trend')) {
280+
if (isset(\MyAdmin\App::variables()->request['tmcsvtext']) && \MyAdmin\App::variables()->request['tmcsvtext'] != '' && verify_csrf('abuse_admin_trend')) {
281281
add_output('Importing TrendMicro CSV Text<br>');
282-
$lines = explode("\n", $GLOBALS['tf']->variables->request['tmcsvtext']);
282+
$lines = explode("\n", \MyAdmin\App::variables()->request['tmcsvtext']);
283283
for ($x = 0, $x_max = count($lines); $x < $x_max; $x++) {
284284
if (is_numeric(mb_substr($lines[$x], 0, 1))) {
285285
$ip = $lines[$x];
@@ -299,7 +299,7 @@ function_requirements('crud_abuse');
299299
$id = $db->getLastInsertId('abuse', 'abuse_id');
300300
$db->query(make_insert_query('abuse_data', [
301301
'abuse_id' => $id,
302-
'abuse_headers' => ImapAbuseCheck::fix_headers($GLOBALS['tf']->variables->request['headers']),
302+
'abuse_headers' => ImapAbuseCheck::fix_headers(\MyAdmin\App::variables()->request['headers']),
303303
]), __LINE__, __FILE__);
304304
$subject = 'InterServer Abuse Report for '.$ip;
305305
$message = str_replace(

0 commit comments

Comments
 (0)