Skip to content

Commit

Permalink
Fix. Important files monitoring. Do not follow redirects on check.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergull committed Sep 13, 2024
1 parent 27cbba8 commit c6482b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/CleantalkSP/Common/Helpers/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,22 @@ public static function removeParametersFromURL($url, $parameters)
* Requesting HTTP response code for $url
*
* @param string $url
* @param bool $ignore_redirects - if it needs to ignore redirects
*
* @return false|int
*/
public static function getResponseCode($url)
public static function getResponseCode($url, $ignore_redirects = false)
{
$http = new Request();

$presets = ['get_code', 'no_cache'];

if ($ignore_redirects) {
$presets[] = 'dont_follow_redirects';
}

$code = $http->setUrl($url)
->setPresets(['get_code', 'no_cache'])
->setPresets($presets)
->request();

if (!empty($code['error'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ public function important_files_listing() // phpcs:ignore PSR1.Methods.CamelCaps

foreach ( $addresses_to_check_accessibility as $address ) {
$url_to_check = get_option('home') . $address;
if ( HTTP::getResponseCode($url_to_check) === 200 ) {
if ( HTTP::getResponseCode($url_to_check, true) === 200 ) {
$out['accessible_urls'][] = array('url' => $address, 'type' => 'accessible');
}
}
Expand Down

0 comments on commit c6482b4

Please sign in to comment.