Skip to content

Commit 762db85

Browse files
committed
Upd. Settings. Improved server option.
1 parent 157052b commit 762db85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cleantalk.antispam/options.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,20 @@
203203
}
204204

205205
// Custom server
206+
if (isset($_POST['use_custom_server']) && $_POST['use_custom_server'] == '' && COption::GetOptionString($sModuleId, "use_custom_server") !== '') {
207+
Option::set( $sModuleId, 'use_custom_server', '' );
208+
}
206209
if (isset($_POST['use_custom_server']) && $_POST['use_custom_server'] !== '') {
207210
// Remove path, query, fragment
208211
$domain = preg_replace('/[\/\?#].*$/', '', $_POST['use_custom_server']);
209212
// Remove invalid characters (keep letters, numbers, hyphens, dots)
210213
$domain = preg_replace('/[^a-zA-Z0-9\.\-]/', '', $domain);
211214
// Convert to lowercase and trim
212215
$domain = strtolower(trim($domain));
213-
if (file_get_contents('https://moderate.' . $domain) === false) {
216+
// use default bitrix http client to make request
217+
$httpClient = new \Bitrix\Main\Web\HttpClient();
218+
$response = $httpClient->get('https://moderate.' . $domain);
219+
if ($response === false) {
214220
Option::set( $sModuleId, 'use_custom_server', '' );
215221
CAdminNotify::Add(array(
216222
'MESSAGE' => GetMessage( 'CLEANTALK_SERVER_NOT_AVAILABLE' ),

0 commit comments

Comments
 (0)