�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`� 0x0x
PHP 8.1.34
Preview: SignatureRefresher.php Size: 15.82 KB
/home2/astrociv/www/avadhutholidays.in/wp-content/plugins/imunify-security/inc/App/Bot/SignatureRefresher.php
<?php
/**
 * Copyright (с) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2025 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * https://www.cloudlinux.com/legal/
 *
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fopen
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fwrite
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fread
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fclose
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_flock
 * phpcs:disable WordPress.WP.AlternativeFunctions.rename_rename
 * phpcs:disable WordPress.WP.AlternativeFunctions.unlink_unlink
 * phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
 * phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_export
 * phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
 */

namespace CloudLinux\Imunify\App\Bot;

/**
 * Wp-cron-driven refresher for bot-protection data.
 *
 * Polls the CloudLinux mirror (`MIRROR_BASE_URL`) on a 6-hour schedule
 * wired via `scheduleHooks()` / `BotLifecycle::activate()`. Fetches
 * `description.json` first (cheap MD5 check); only downloads `all.json`
 * when its MD5 differs from the locally-cached value. Both downloads go
 * through `MirrorDownloader`, which verifies and retries them, so nothing
 * here parses or caches a body the mirror did not fully deliver. Delegates
 * JSON→PHP bundle conversion to `BotDataConverter`, which writes files
 * atomically into the overlay directory
 * (`wp-content/imunify-security/bot-data/`). `BundledData` picks up overlay
 * files on the next classification call, transparently superseding the
 * snapshot shipped under `inc/App/Bot/data/`.
 *
 * Safety invariants:
 *   - Network failures and MD5 mismatches leave existing overlay files
 *     untouched (fail-open: never degrade on transient network error).
 *   - A POSIX advisory lock on `<overlay>/.refresh.lock` prevents two
 *     concurrently-firing wp-cron workers from racing each other.
 *   - Every run books its next attempt before touching the network, so a
 *     failing mirror costs one attempt per schedule tick even if wp-cron
 *     fires the hook on every page load.
 *
 * @since 4.0.0
 */
class SignatureRefresher {

	const CRON_HOOK_REFRESH          = 'imunify_security_bot_refresh';
	const LOCK_FILENAME              = '.refresh.lock';
	const MIRROR_BASE_URL            = 'https://files.imunify360.com/static/crawler-intel/v1';
	const MIRROR_MD5_OPTION          = 'imunify_security_bot_mirror_md5sum';
	const MIRROR_GENERATED_AT_OPTION = 'imunify_security_bot_mirror_generated_at';
	const MIRROR_NEXT_ATTEMPT_OPTION = 'imunify_security_bot_mirror_next_attempt';

	/**
	 * Shortest gap between two refresh attempts: the 6-hour schedule minus a
	 * 15-minute allowance, so a tick that fires slightly early still runs while
	 * a wp-cron that keeps re-firing the hook cannot turn every page load into
	 * a mirror request.
	 */
	const MIN_REFRESH_INTERVAL_SECONDS = 6 * 3600 - 900;

	const MIN_SIGNATURE_LENGTH = 4;
	const SIGNATURE_DENYLIST   = array(
		'mozilla',
		'chrome',
		'safari',
		'firefox',
		'edge',
		'opera',
		'msie',
		'trident',
		'applewebkit',
		'gecko',
		'webkit',
	);

	/**
	 * Absolute path to the overlay root.
	 *
	 * @var string
	 */
	private $overlay_dir;

	/**
	 * Injected HTTP client, handed to a MirrorDownloader on each refresh.
	 *
	 * @var HttpClient
	 */
	private $http;

	/**
	 * Downloader used for both mirror objects; built from $http when not given.
	 *
	 * @var MirrorDownloader|null
	 */
	private $downloader;

	/**
	 * Build a refresher bound to an overlay directory.
	 *
	 * @param string                $overlay_dir Absolute path to the overlay root.
	 * @param HttpClient            $http        HTTP client (WpHttpClient in production, fake in tests).
	 * @param MirrorDownloader|null $downloader  Downloader to use; built from $http when null.
	 */
	public function __construct( $overlay_dir, $http, $downloader = null ) {
		$this->overlay_dir = rtrim( (string) $overlay_dir, '/' );
		$this->http        = $http;
		$this->downloader  = $downloader;
	}

	/**
	 * Reject signature tokens that are too short or match common browser substrings.
	 *
	 * Public so `bin/update-bot-data.php` can apply the same rule when
	 * generating bundled data files, keeping bundled and cron-refreshed
	 * overlays byte-for-byte comparable.
	 *
	 * @param array $items Raw signature tokens.
	 * @return array Sanitized tokens, re-indexed.
	 */
	public static function sanitizeSignatures( $items ) {
		$out = array();
		foreach ( $items as $token ) {
			if ( strlen( $token ) < self::MIN_SIGNATURE_LENGTH ) {
				continue;
			}
			$lower = strtolower( $token );
			if ( in_array( $lower, self::SIGNATURE_DENYLIST, true ) ) {
				continue;
			}
			$out[] = $token;
		}
		return $out;
	}

	/**
	 * Bucket a sorted list of CIDRs into the shape CidrMatcher::matchesAnyBucketed() expects.
	 *
	 * Public so bin/update-bot-data.php can produce the same bucketed structure,
	 * keeping dev-bundled and cron-refreshed overlays byte-identical.
	 *
	 * @param array $sorted_ranges Sorted CIDR strings.
	 * @return array { 'ranges_by_octet' => int[] => string[], 'ranges_broad' => string[] }
	 */
	public static function bucketRanges( $sorted_ranges ) {
		$by_octet = array();
		$broad    = array();
		foreach ( $sorted_ranges as $cidr ) {
			if ( ! is_string( $cidr ) ) {
				continue;
			}
			$slash = strpos( $cidr, '/' );
			if ( false === $slash ) {
				continue;
			}
			$network    = substr( $cidr, 0, $slash );
			$prefix_str = substr( $cidr, $slash + 1 );
			if ( '' === $prefix_str || ! ctype_digit( $prefix_str ) ) {
				continue;
			}
			$prefix = (int) $prefix_str;
			$bin    = @inet_pton( $network );
			if ( false === $bin ) {
				continue;
			}
			if ( 16 === strlen( $bin ) && "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" === substr( $bin, 0, 12 ) ) {
				$bin     = substr( $bin, 12 );
				$prefix -= 96;
			}
			if ( $prefix < 8 ) {
				$broad[] = $cidr;
			} else {
				$octet                = ord( $bin[0] );
				$by_octet[ $octet ][] = $cidr;
			}
		}
		ksort( $by_octet );
		return array(
			'ranges_by_octet' => $by_octet,
			'ranges_broad'    => $broad,
		);
	}

	/**
	 * Extract IPv4/IPv6 prefixes from a Google-shape JSON payload.
	 *
	 * Shared between bin/update-bot-data.php fetchers and cron-spec parsers so
	 * both paths apply identical parsing.
	 *
	 * @param array $data Decoded JSON array.
	 * @return array List of CIDR strings.
	 * @throws \RuntimeException When the payload does not match the expected shape.
	 */
	public static function parseGoogleShape( $data ) {
		if ( ! isset( $data['prefixes'] ) || ! is_array( $data['prefixes'] ) ) {
			throw new \RuntimeException( 'unexpected JSON shape: missing prefixes[]' );
		}
		$out = array();
		foreach ( $data['prefixes'] as $p ) {
			if ( isset( $p['ipv4Prefix'] ) ) {
				$out[] = $p['ipv4Prefix'];
			} elseif ( isset( $p['ipv6Prefix'] ) ) {
				$out[] = $p['ipv6Prefix'];
			}
		}
		if ( empty( $out ) ) {
			throw new \RuntimeException( 'no prefixes found in payload' );
		}
		return $out;
	}

	/**
	 * Acquire the refresher's POSIX advisory lock.
	 *
	 * @return resource|null Lock file handle on success, null when another worker holds the lock.
	 */
	private function acquireLock() {
		if ( ! is_dir( $this->overlay_dir ) && ! mkdir( $this->overlay_dir, 0755, true ) && ! is_dir( $this->overlay_dir ) ) {
			return null;
		}
		$path = $this->overlay_dir . '/' . self::LOCK_FILENAME;
		$h    = fopen( $path, 'c+' );
		if ( false === $h ) {
			return null;
		}
		if ( ! flock( $h, LOCK_EX | LOCK_NB ) ) {
			fclose( $h );
			return null;
		}
		return $h;
	}

	/**
	 * Release a previously-acquired lock handle.
	 *
	 * @param resource $handle File handle returned by acquireLock().
	 */
	private function releaseLock( $handle ) {
		flock( $handle, LOCK_UN );
		fclose( $handle );
	}

	/**
	 * Download all.json from the mirror if its md5 has changed, verify integrity,
	 * and convert to PHP bundle files via BotDataConverter.
	 *
	 * Fetches description.json first (small, cheap); only downloads the full
	 * all.json when its md5 entry differs from the locally-cached value.
	 *
	 * @param string $mirror_base_url Base URL of the mirror (no trailing slash).
	 */
	public function refreshFromMirror( $mirror_base_url = self::MIRROR_BASE_URL ) {
		$lock = $this->acquireLock();
		if ( null === $lock ) {
			return; // Another worker holds the refresh lock — skip this run.
		}
		try {
			$this->doMirrorRefresh( $mirror_base_url );
		} finally {
			$this->releaseLock( $lock );
		}
	}

	/**
	 * Mirror-refresh body. Always invoked under the refresh lock by
	 * refreshFromMirror(); that caller's finally guarantees the lock is
	 * released on every exit path, including thrown errors.
	 *
	 * @param string $mirror_base_url Base URL of the mirror (no trailing slash).
	 */
	private function doMirrorRefresh( $mirror_base_url ) {
		$now = time();
		if ( $now < (int) get_option( self::MIRROR_NEXT_ATTEMPT_OPTION, 0 ) ) {
			return;
		}
		// Booked before the first request, so a failed — or fatally interrupted —
		// refresh still costs one attempt per schedule tick instead of one per
		// wp-cron tick.
		update_option( self::MIRROR_NEXT_ATTEMPT_OPTION, $now + self::MIN_REFRESH_INTERVAL_SECONDS, false );

		$downloader  = null === $this->downloader ? new MirrorDownloader( $this->http ) : $this->downloader;
		$description = $downloader->download( rtrim( $mirror_base_url, '/' ) . '/description.json' );
		if ( ! $description->isSuccess() ) {
			$this->reportDownloadFailure( 'description.json', 'description-fetch-failed', $description );
			return;
		}

		$manifest = json_decode( $description->body(), true );
		if ( ! is_array( $manifest ) || ! isset( $manifest['items'] ) || ! is_array( $manifest['items'] ) ) {
			BundledData::reportFailOpenError( 'refreshFromMirror', 'description.json: unexpected shape', array( 'bot-refresh', 'description-shape-invalid' ) );
			return;
		}

		$entry = null;
		foreach ( $manifest['items'] as $item ) {
			if ( isset( $item['name'] ) && 'all.json' === $item['name'] ) {
				$entry = $item;
				break;
			}
		}
		if ( null === $entry || ! isset( $entry['url'] ) ) {
			BundledData::reportFailOpenError( 'refreshFromMirror', 'all.json not found in description.json', array( 'bot-refresh', 'all-json-not-in-manifest' ) );
			return;
		}

		$remote_md5 = isset( $entry['md5sum'] )
			? (string) $entry['md5sum']
			: ( isset( $entry['md5'] ) ? (string) $entry['md5'] : '' );
		if ( '' === $remote_md5 ) {
			BundledData::reportFailOpenError( 'refreshFromMirror', 'all.json entry has no md5sum in description.json', array( 'bot-refresh', 'all-json-no-md5sum' ) );
			return;
		}

		$base           = rtrim( $mirror_base_url, '/' );
		$allowed_scheme = wp_parse_url( $base, PHP_URL_SCHEME );
		$allowed_host   = wp_parse_url( $base, PHP_URL_HOST );
		$entry_url      = (string) $entry['url'];
		$entry_scheme   = wp_parse_url( $entry_url, PHP_URL_SCHEME );
		$entry_host     = wp_parse_url( $entry_url, PHP_URL_HOST );
		if ( null === $allowed_host || $entry_scheme !== $allowed_scheme || $entry_host !== $allowed_host ) {
			BundledData::reportFailOpenError( 'refreshFromMirror', 'all.json URL does not match expected mirror origin — discarding', array( 'bot-refresh', 'all-json-url-origin-mismatch' ) );
			return;
		}

		if ( $remote_md5 === $this->readMirrorMd5() && $this->overlayHasData() ) {
			return;
		}

		$download = $downloader->download( $entry_url, $remote_md5 );
		if ( ! $download->isSuccess() ) {
			$this->reportDownloadFailure( 'all.json', 'all-json-fetch-failed', $download );
			return;
		}

		try {
			$converter = new BotDataConverter( $this->overlay_dir );
			$written   = $converter->convert( $download->body() );
			if ( $written > 0 ) {
				// The md5 is the short-circuit sentinel for the next run, so it is
				// written after the value it vouches for. Losing the second write
				// then costs one redundant download instead of pinning the intel
				// version empty until the mirror content changes.
				$this->saveIntelGeneratedAt( $converter->generatedAt() );
				$this->saveMirrorMd5( $remote_md5 );
			}
		} catch ( \Exception $e ) {
			BundledData::reportFailOpenError( 'refreshFromMirror', 'convert failed: ' . $e->getMessage(), array( 'bot-refresh', 'convert-failed' ) );
		}
	}

	/**
	 * Report a download that could not be verified, once per refresh cycle.
	 *
	 * Deliberately not throttled: the 6-hour schedule already caps this at four
	 * events per site per day, and throttling would drop the `x-req-id` values
	 * the Server team needs to find the request in the mirror logs.
	 *
	 * @param string               $object_name    Mirror object that failed, for the message.
	 * @param string               $fingerprint_id Fingerprint segment identifying the call site.
	 * @param MirrorDownloadResult $result         Failed download.
	 */
	private function reportDownloadFailure( $object_name, $fingerprint_id, $result ) {
		BundledData::reportFailOpenError(
			'refreshFromMirror',
			$object_name . ' download failed (' . $result->reason() . ') after ' . $result->attempts() . ' attempt(s)',
			array( 'bot-refresh', $fingerprint_id, $result->reason() ),
			$result->context(),
			false
		);
	}

	/**
	 * Version of the crawler-intel dataset this site is running on: the
	 * `generated_at` of the last successfully applied all.json. The mirror
	 * always publishes it in UTC, so the offset is stripped and the bare
	 * timestamp is what downstream consumers store and compare.
	 *
	 * A site that has never applied a mirror refresh runs on the snapshot
	 * bundled with the plugin, which carries no dataset version of its own —
	 * that case is reported as unknown.
	 *
	 * @return string Offset-free ISO-8601 timestamp, or '' when unknown.
	 */
	public static function intelVersion() {
		$generated_at = (string) get_option( self::MIRROR_GENERATED_AT_OPTION, '' );
		return (string) preg_replace( '/(?:Z|[+-]\d{2}:?\d{2})$/', '', $generated_at );
	}

	/**
	 * Read the md5sum stored from the last successfully applied all.json.
	 *
	 * @return string Stored md5sum, or '' when none has been applied yet.
	 */
	private function readMirrorMd5() {
		return (string) get_option( self::MIRROR_MD5_OPTION, '' );
	}

	/**
	 * Persist the md5sum of the last successfully applied all.json.
	 *
	 * @param string $md5 md5sum the mirror reported for the applied all.json.
	 */
	private function saveMirrorMd5( $md5 ) {
		update_option( self::MIRROR_MD5_OPTION, $md5, false );
	}

	/**
	 * Persist the `generated_at` of the last successfully applied all.json.
	 *
	 * @param string $generated_at Timestamp the mirror stamped on the dataset.
	 */
	private function saveIntelGeneratedAt( $generated_at ) {
		update_option( self::MIRROR_GENERATED_AT_OPTION, $generated_at, false );
	}

	/**
	 * Whether the overlay holds at least one converted bundle file.
	 *
	 * Guards the md5sum short-circuit: a matching stored md5sum must not skip the
	 * download when the overlay data has been wiped, otherwise the site would run
	 * indefinitely on bundled data with no way to repopulate until the mirror changes.
	 *
	 * @return bool
	 */
	private function overlayHasData() {
		$files = glob( $this->overlay_dir . '/*/*.php' );
		return is_array( $files ) && count( $files ) > 0;
	}

	/**
	 * Register the daily wp-cron events driving the mirror refresh.
	 *
	 * Called from BotLifecycle::activate() so events are scheduled
	 * on plugin activation and survive across site requests.
	 */
	public static function scheduleHooks() {
		$current = \wp_get_schedule( self::CRON_HOOK_REFRESH );
		if ( false !== $current && 'imunify_six_hours' !== $current ) {
			\wp_clear_scheduled_hook( self::CRON_HOOK_REFRESH );
			$current = false;
		}
		if ( false === $current ) {
			\wp_schedule_event(
				// phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand -- cron jitter offset, not security
				\time() + \mt_rand( 0, 21599 ),
				'imunify_six_hours',
				self::CRON_HOOK_REFRESH
			);
		}
	}
}

Directory Contents

Dirs: 1 × Files: 77
Name Size Perms Modified Actions
data DIR
- drwxr-xr-x 2026-11-03 01:06:32
Edit Download
11.48 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.43 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.47 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.38 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
4.45 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.17 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.01 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
21.21 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.34 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
17.81 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
3.38 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.79 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
13.17 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
8.77 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.67 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
14.53 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
4.25 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.72 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.58 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.55 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
14.00 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.58 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.99 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.88 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.41 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.53 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.61 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
4.73 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.49 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
17.86 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
14.97 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.47 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
4.76 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.06 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.26 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.64 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.68 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
10.47 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.49 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
17.09 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
8.51 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
12.60 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
3.46 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
835 B lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.71 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
22.44 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.65 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.33 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
892 B lrw-r--r-- 2026-11-03 01:06:32
Edit Download
924 B lrw-r--r-- 2026-11-03 01:06:32
Edit Download
4.69 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
18.57 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
6.92 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
3.87 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.94 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
18.17 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
8.48 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.80 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
9.49 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.84 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.45 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.28 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.27 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
9.90 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
15.82 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
20.41 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
7.79 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.61 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.80 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
30.46 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
2.79 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
1.41 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
3.72 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
9.60 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.05 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
6.56 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
5.16 KB lrw-r--r-- 2026-11-03 01:06:32
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI