Skip to content

Commit e87910b

Browse files
committed
Various minor performance improvements.
1 parent 502403b commit e87910b

3 files changed

Lines changed: 34 additions & 34 deletions

File tree

modules/modules.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PHPMailer:
3333
Checksum: "f7c8210e4047871f9f0b0639d7387d5574738fb9984f744d58d85378da77c68e:53628"
3434
events/phpmailer.php:
3535
From: "https://raw.githubusercontent.com/CIDRAM/CIDRAM-Extras/master/modules/phpmailer.php"
36-
Checksum: "10bd631ddc5525787ab7411c030f5c6dd9e0e196a83d3e230cc1fd9a36a3cf80:7487"
36+
Checksum: "8e676250e93246046c6ead204ec7e536ec13a3559d1c924149ee53a0c6252a3e:7499"
3737
Used with: "events"
3838
imports/phpmailer.yml:
3939
From: "https://raw.githubusercontent.com/CIDRAM/CIDRAM-Extras/master/modules/phpmailer.yml"
@@ -42,11 +42,11 @@ PHPMailer:
4242
Referrer spam module:
4343
Name: "Referrer spam module"
4444
False Positive Risk: "Medium"
45-
Version: "2026.13.0"
45+
Version: "2026.76.0"
4646
Dependencies:
4747
intl: "*"
4848
Files:
4949
modules/refspam.php:
5050
From: "https://raw.githubusercontent.com/CIDRAM/CIDRAM-Extras/master/modules/refspam.php"
51-
Checksum: "437fccf22ec70923cc6439e7f74a1b5b5babee858634cc936126dfce3d55b54f:12478"
51+
Checksum: "fcd2a6afffa780194f8f02326be936f165aa7287cca0b26c92ea5cbdf6df7ace:12499"
5252
Used with: "modules"

modules/phpmailer.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: PHPMailer event handlers (last modified: 2024.09.22).
11+
* This file: PHPMailer event handlers (last modified: 2026.03.18).
1212
*/
1313

1414
/**
@@ -27,13 +27,13 @@
2727
}
2828

2929
$Truncate = $this->readBytes($this->Configuration['logging']['truncate']);
30-
$WriteMode = (!file_exists($EventLog) || $Truncate > 0 && filesize($EventLog) >= $Truncate) ? 'wb' : 'ab';
31-
if (!is_resource($Handle = fopen($EventLog, $WriteMode))) {
32-
trigger_error('The "writeToPHPMailerEventLog" event failed to open "' . $EventLog . '" for writing.');
30+
$WriteMode = (!\file_exists($EventLog) || $Truncate > 0 && \filesize($EventLog) >= $Truncate) ? 'wb' : 'ab';
31+
if (!\is_resource($Handle = \fopen($EventLog, $WriteMode))) {
32+
\trigger_error('The "writeToPHPMailerEventLog" event failed to open "' . $EventLog . '" for writing.');
3333
return false;
3434
}
35-
fwrite($Handle, $Data);
36-
fclose($Handle);
35+
\fwrite($Handle, $Data);
36+
\fclose($Handle);
3737
if ($WriteMode === 'wb') {
3838
$this->logRotation($this->Configuration['phpmailer']['event_log']);
3939
}
@@ -49,7 +49,7 @@
4949
if (!isset($this->CIDRAM['LogPatterns'])) {
5050
$this->CIDRAM['LogPatterns'] = [];
5151
}
52-
if (strlen($this->Configuration['phpmailer']['event_log'])) {
52+
if (\strlen($this->Configuration['phpmailer']['event_log'])) {
5353
$this->CIDRAM['LogPatterns'][] = $this->buildLogPattern($this->Configuration['phpmailer']['event_log'], true);
5454
}
5555
return true;
@@ -73,7 +73,7 @@
7373
[$Recipients, $Subject, $Body, $AltBody, $Attachments] = $Data;
7474

7575
/** Prepare event logging. */
76-
$EventLogData = sprintf(
76+
$EventLogData = \sprintf(
7777
'%s - %s - ',
7878
$this->Configuration['legal']['pseudonymise_ip_addresses'] ? $this->pseudonymiseIp($this->ipAddr) : $this->ipAddr,
7979
$this->FE['DateTime'] ?? $this->timeFormat($this->Now, $this->Configuration['general']['time_format'])
@@ -83,7 +83,7 @@
8383
$State = false;
8484

8585
/** Check whether class exists to either load it and continue or fail the operation. */
86-
if (!class_exists('\PHPMailer\PHPMailer\PHPMailer')) {
86+
if (!\class_exists('\PHPMailer\PHPMailer\PHPMailer')) {
8787
$EventLogData .= $this->L10N->getString('response.Task failed because a necessary component is unavailable') . "\n";
8888
} else {
8989
try {
@@ -173,7 +173,7 @@
173173
$Mail->AltBody = $AltBody;
174174

175175
/** Process attachments. */
176-
if (is_array($Attachments)) {
176+
if (\is_array($Attachments)) {
177177
foreach ($Attachments as $Attachment) {
178178
$Mail->addAttachment($Attachment);
179179
}
@@ -183,7 +183,7 @@
183183
$State = $Mail->send();
184184

185185
/** Log the results of the send attempt. */
186-
$EventLogData .= ($State ? sprintf(
186+
$EventLogData .= ($State ? \sprintf(
187187
$this->L10N->getString('response.Email successfully sent to %s'),
188188
$SuccessDetails
189189
) : $this->L10N->getString('response.Error') . ' - ' . $Mail->ErrorInfo) . "\n";

modules/refspam.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Referrer spam module (last modified: 2026.01.14).
11+
* This file: Referrer spam module (last modified: 2026.03.18).
1212
*
1313
* False positive risk (an approximate, rough estimate only): « [ ]Low [x]Medium [ ]High »
1414
*/
@@ -31,33 +31,33 @@
3131
}
3232

3333
/** Process to get the domain part. */
34-
$Domain = preg_replace(['~^[a-z]+:[\\/]*(?:www\d*\.)?~i', '~[\\/:].*$~', '[ \n\r]'], '', $this->BlockInfo['Referrer']);
34+
$Domain = \preg_replace(['~^[a-z]+:[\\/]*(?:www\d*\.)?~i', '~[\\/:].*$~', '[ \n\r]'], '', $this->BlockInfo['Referrer']);
3535

3636
/** Lower-case domain part. */
37-
$RefLC = strtolower($Domain);
37+
$RefLC = \strtolower($Domain);
3838

3939
/** Convert punycode to UTF-8 (as long as Intl is available). */
40-
if (strpos($RefLC, 'xn--') !== false && function_exists('idn_to_utf8')) {
41-
$Domain = explode('.', $Domain);
40+
if (\strpos($RefLC, 'xn--') !== false && \function_exists('idn_to_utf8')) {
41+
$Domain = \explode('.', $Domain);
4242
foreach ($Domain as &$DomainPart) {
43-
if (strtolower(substr($DomainPart, 0, 4)) !== 'xn--') {
43+
if (\strtolower(\substr($DomainPart, 0, 4)) !== 'xn--') {
4444
continue;
4545
}
4646
try {
47-
$DomainPartTest = idn_to_utf8($DomainPart);
47+
$DomainPartTest = \idn_to_utf8($DomainPart);
4848
if ($DomainPartTest) {
4949
$DomainPart = $DomainPartTest;
5050
}
5151
} catch (\Exception $e) {
5252
}
5353
}
5454
unset($DomainPartTest, $e, $DomainPart);
55-
$Domain = implode('.', $Domain);
55+
$Domain = \implode('.', $Domain);
5656
}
5757

5858
/** Signatures begin here. */
5959
if (
60-
$this->trigger(preg_match(
60+
$this->trigger(\preg_match(
6161
'~(?:(?:\d{1,8}[a-z]{1,2}|a(?:dviceforum|llknow|llwomen|rtdeko|vkzaraboto' .
6262
'k)|b(?:estoffer[a-z]{1,8}|if-ru|izru|luerobot|rillianty|uy-cheap-online)' .
6363
'|call-of-duty|earnian-money|f(?:inansov|or-marketersy|orsex|orum69|reeno' .
@@ -84,7 +84,7 @@
8484
'ue)\.xyz)$~i',
8585
$Domain
8686
), 'Referrer spam detected (' . $Domain . ')') || // (info, site, top, tv, xyz) 2020.04.13
87-
$this->trigger(preg_match(
87+
$this->trigger(\preg_match(
8888
'~(?:(?:(?:ai-?|auto|-)seo-(?:services?|traffic)|3(?:-letter-domains|wayn' .
8989
'etworks)?|\d-\d{0,4}(?:seo|best|free)(?:-?seo|-?best|-?free|-?share-butt' .
9090
'ons)|\d{0,4}(?:-reasons-for-seo|dollars-seo|searchengines)|\d{1,2}(?:\D' .
@@ -99,7 +99,7 @@
9999
'vice|solution|tip)s?)\.(?:blue|com|pro|tk))$~i',
100100
$Domain
101101
), 'Referrer spam detected (' . $Domain . ')') || // (Generic SEO/traffic refspam) 2019.09.28
102-
$this->trigger(preg_match(
102+
$this->trigger(\preg_match(
103103
'~(?:-blanca|-fulldrive|-zheleza|[a-z]{2,3}-lk-rt|allvacancy|artclipart|b' .
104104
'eclean-nn|dev-seo|dojki-devki|ege-essay|englishtopic|fialka\.tomsk|gelst' .
105105
'ate|gidonline|hit-kino|iskussnica|kabinet-[-a-z\d]{1,16}|lalalove|mamyli' .
@@ -108,7 +108,7 @@
108108
'ufa|ximoda|your-tales)\.(?:blog|mobi|ru)$~i',
109109
$Domain
110110
), 'Referrer spam detected (' . $Domain . ')') || // (blog, mobi, ru) 2019.09.28
111-
$this->trigger(preg_match(
111+
$this->trigger(\preg_match(
112112
'~(?:(?:-kredit|predmety|ukrtvory|пептиды|zagadki)\.in|-dereva\.kiev|auto' .
113113
'blog\.org|credit\.co|(?:kakadu-interior|naturalpharm|shopfishing|supermo' .
114114
'dni|vezdevoz)\.com)\.ua$|(?:ecommerce-seo|generalporn)\.org|-on-you\.ga|' .
@@ -119,18 +119,18 @@
119119
'|xtraffic\.|fetish\.(?:com|site)$|coast\.com$|library\.cc$~i',
120120
$Domain
121121
), 'Referrer spam detected (' . $Domain . ')') || // (ua, su, porn refspam, etc) 2020.04.13
122-
$this->trigger(preg_match(
122+
$this->trigger(\preg_match(
123123
'~(?:(?:drev|mrbojikobi4|s-forum)\.biz|infogame\.name|(?:expediacustomers' .
124124
'ervicenumber|kinostar)\.online|(?:anabolics|veles)\.shop)$~i',
125125
$Domain
126126
), 'Referrer spam detected (' . $Domain . ')') || // (biz, name, online, shop) 2019.09.28
127-
$this->trigger(preg_match(
127+
$this->trigger(\preg_match(
128128
'~(?:aitiman\.ae|rutor\.group|(?:medbrowse|piluli)\.info|(?:dantk|kazlent' .
129129
'a)\.kz|rxshop\.md|(?:belreferatov|mnogabukaff|sexuria|sssexxx|torrentgam' .
130130
'er)\.net|vseigru\.one|draniki\.org|vpdr\.pl)$~i',
131131
$Domain
132132
), 'Referrer spam detected (' . $Domain . ')') || // (misc. other) 2019.09.28
133-
$this->trigger(preg_match(
133+
$this->trigger(\preg_match(
134134
'~(?:-poesie?|(?:arabic|spain)-poetry|-v-krym|\d[a-z]{2}\d|24h|4-less|alb' .
135135
'uteroli|automobile-spec|avcoast|backlinks-fast-top|baixar-musicas-gratis' .
136136
'|beauty-lesson|bestfortraders|bin-brokers|break-the-chains|buttons?-for-' .
@@ -153,15 +153,15 @@
153153
}
154154

155155
if ($this->trigger(
156-
preg_match('~delta-?search|vi-view\.com~i', $Domain),
156+
\preg_match('~delta-?search|vi-view\.com~i', $Domain),
157157
'Referrer spam detected (' . $Domain . ')'
158158
)) {
159159
$this->Reporter->report([10, 20], [
160160
'Referrer spam with recognised correlation to malware originating from this address detected (host might be compromised).'
161161
], $this->BlockInfo['IPAddr']);
162162
} // 2019.08.12
163163

164-
if ($this->trigger(preg_match(
164+
if ($this->trigger(\preg_match(
165165
'~(?:[-b-df-hj-np-tv-z\d\.]{5}\.xyz|\.(?:country|cricket|gq|kim|link|part' .
166166
'y|review|science|work|xxx|xzone|zip)|powernetshop\.at|3w1\.eu|(?:cat-tre' .
167167
'e-house|doctoryuval|justfree|netvibes|traf(?:ers|ficfaker)|webscutest)\.' .
@@ -174,7 +174,7 @@
174174
], $this->BlockInfo['IPAddr']);
175175
} // 2019.08.14 mod 2026.01.14 (removed some old entries)
176176

177-
if ($this->trigger(preg_match(
177+
if ($this->trigger(\preg_match(
178178
'~(?:android-style|anti-crisis-seo|hvd-store|med-dopomoga|oohlivecams|pai' .
179179
'nting-planet|vzubkah)\.com|quickchange\.cc|(?:sharebutton|spravkavspb)\.' .
180180
'net|elvel\.com\.ua|shoppingmiracles\.co\.uk|(?:biz-law|brothers-smaller|' .
@@ -193,7 +193,7 @@
193193
], $this->BlockInfo['IPAddr']);
194194
} // (circa ~2020 additions) 2020.04.13
195195

196-
if ($this->trigger(preg_match(
196+
if ($this->trigger(\preg_match(
197197
'~anonymousfox\.co|binance\.com~i',
198198
$Domain
199199
), 'Referrer spam detected (' . $Domain . ')')) {
@@ -202,7 +202,7 @@
202202
], $this->BlockInfo['IPAddr']);
203203
} // 2023.06.16
204204

205-
if ($this->trigger(preg_match('~//blog//wp-login\.php$~i', $this->BlockInfo['Referrer']), 'Hack attempt via referrer header injection detected')) {
205+
if ($this->trigger(\preg_match('~//blog//wp-login\.php$~i', $this->BlockInfo['Referrer']), 'Hack attempt via referrer header injection detected')) {
206206
$this->Reporter->report([10, 15, 21], ['Hack attempt via referrer header injection detected.'], $this->BlockInfo['IPAddr']);
207207
} // 2025.07.24
208208

0 commit comments

Comments
 (0)