�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: Debug.php Size: 18.35 KB
/home2/astrociv/public_html/astrologicalremidies.com/wp-content/plugins/imunify-security/inc/App/Debug.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/
 */

namespace CloudLinux\Imunify\App;

/**
 * Debug
 */
class Debug {
	/**
	 * Transient key prefix for error throttling.
	 */
	const ERROR_THROTTLE_PREFIX = 'imunify_security_error_';

	/**
	 * Set once the transient layer throws, so the rest of the request skips it.
	 *
	 * @var bool
	 */
	private static $throttleUnavailable = false;

	/**
	 * Website url.
	 *
	 * @var string
	 */
	private $website = '';

	/**
	 * Home path.
	 *
	 * @var string
	 */
	private $home_path = '';

	/**
	 * User.
	 *
	 * @var string
	 */
	private $user = '';

	/**
	 * System user, null until looked up.
	 *
	 * @var string|null
	 */
	private $system_user = null;

	/**
	 * Request uri.
	 *
	 * @var string
	 */
	private $request_uri = '';

	/**
	 * Http code.
	 *
	 * @var int
	 */
	private $http_code = 0;

	/**
	 * Server ip.
	 *
	 * @var string
	 */
	private $server_ip = '';

	/**
	 * Error codes.
	 *
	 * @var array<string>
	 *
	 * PHP Core Exceptions
	 */
	public $codes = array(
		E_ERROR             => 'E_ERROR',
		E_WARNING           => 'E_WARNING',
		E_PARSE             => 'E_PARSE',
		E_NOTICE            => 'E_NOTICE',
		E_CORE_ERROR        => 'E_CORE_ERROR',
		E_CORE_WARNING      => 'E_CORE_WARNING',
		E_COMPILE_ERROR     => 'E_COMPILE_ERROR',
		E_COMPILE_WARNING   => 'E_COMPILE_WARNING',
		E_USER_ERROR        => 'E_USER_ERROR',
		E_USER_WARNING      => 'E_USER_WARNING',
		E_USER_NOTICE       => 'E_USER_NOTICE',
		// E_STRICT is deprecated as of PHP 8.4.0. It is added in the constructor conditionally.
		E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
		E_DEPRECATED        => 'E_DEPRECATED',
		E_USER_DEPRECATED   => 'E_USER_DEPRECATED',
		E_ALL               => 'E_ALL',
	);

	/**
	 * Environment.
	 *
	 * @var Environment
	 */
	private $environment;

	/**
	 * Constructor.
	 *
	 * @param Environment $environment Environment instance.
	 */
	public function __construct( $environment ) {
		$this->environment = $environment;
		add_action( 'imunify_security_set_error', array( $this, 'error' ), 10, 5 );
		add_action( 'imunify_security_set_error_handler', array( $this, 'setErrorHandler' ), 10, 0 );
		add_action( 'imunify_security_restore_error_handler', array( $this, 'restoreErrorHandler' ), 10, 0 );

		// E_STRICT is deprecated as of PHP 8.4.0.
		if ( PHP_VERSION_ID < 80400 ) {
			$this->codes[ E_STRICT ] = 'E_STRICT';
		}
	}

	/**
	 * Get the site home URL via the WordPress API.
	 *
	 * The home_url() function reads the `home` option — which reflects the
	 * WP_HOME constant through the `option_home` filter — and applies the
	 * `home_url` filter. Guarded so the accessor degrades to '' before
	 * WordPress is loaded.
	 *
	 * @return string
	 */
	protected function wpHome() {
		if ( function_exists( 'home_url' ) ) {
			return (string) home_url();
		}

		return '';
	}

	/**
	 * Get option home.
	 *
	 * @return string
	 */
	protected function wpHomeOption() {
		if ( function_exists( 'get_option' ) ) {
			$home = get_option( 'home' );
			if ( is_string( $home ) ) {
				return $home;
			}
		}

		return '';
	}

	/**
	 * Get home path.
	 *
	 * @return string
	 */
	public function homePath() {
		if ( ! empty( $this->home_path ) ) {
			return $this->home_path;
		}

		if ( defined( 'ABSPATH' ) ) {
			return ABSPATH;
		}

		return $this->home_path;
	}

	/**
	 * Get website.
	 *
	 * @return string
	 */
	public function website() {
		if ( ! empty( $this->website ) ) {
			return $this->website;
		}

		$wp_home        = $this->wpHome();
		$wp_home_option = $this->wpHomeOption();

		if ( ! empty( $wp_home ) ) {
			$this->website = $wp_home;
		} elseif ( ! empty( $wp_home_option ) ) {
			$this->website = $wp_home_option;
		} elseif ( array_key_exists( 'SERVER_NAME', $_SERVER ) ) {
			$this->website = esc_url_raw( wp_unslash( $_SERVER['SERVER_NAME'] ) );
		}

		return $this->website;
	}

	/**
	 * Get user.
	 *
	 * @return string
	 */
	public function user() {
		if ( ! empty( $this->user ) ) {
			return $this->user;
		}

		$parse = wp_parse_url( $this->website() );
		if ( is_array( $parse ) && array_key_exists( 'host', $parse ) ) {
			$this->user = $parse['host'];
		}

		return $this->user;
	}

	/**
	 * Get the system account PHP runs as.
	 *
	 * @since 4.1.4
	 *
	 * @return string
	 */
	public function systemUser() {
		if ( null !== $this->system_user ) {
			return $this->system_user;
		}

		$this->system_user = '';
		if ( function_exists( 'posix_geteuid' ) && function_exists( 'posix_getpwuid' ) ) {
			$pw = posix_getpwuid( posix_geteuid() );
			if ( is_array( $pw ) && ! empty( $pw['name'] ) ) {
				$this->system_user = $pw['name'];
			}
		}

		// Disabled functions are undefined on PHP 8, so calling one is fatal.
		if ( '' === $this->system_user && function_exists( 'get_current_user' ) ) {
			$this->system_user = (string) get_current_user();
		}

		return $this->system_user;
	}

	/**
	 * Get request uri.
	 *
	 * @return string
	 */
	public function requestUri() {
		if ( ! empty( $this->request_uri ) ) {
			return $this->request_uri;
		}

		if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) {
			$this->request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
		}

		return $this->request_uri;
	}

	/**
	 * Get http code.
	 *
	 * @return int
	 */
	public function httpCode() {
		if ( ! empty( $this->http_code ) ) {
			return $this->http_code;
		}

		if ( function_exists( 'http_response_code' ) ) {
			$this->http_code = (int) http_response_code();
		}

		return $this->http_code;
	}

	/**
	 * Get current server IP Address.
	 *
	 * @return string
	 */
	public function serverIp() {
		if ( ! empty( $this->server_ip ) ) {
			return $this->server_ip;
		}

		if ( isset( $_SERVER['SERVER_ADDR'] ) ) {
			$ip = filter_var( sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ), FILTER_VALIDATE_IP );
			if ( is_string( $ip ) ) {
				$this->server_ip = $ip;

				return $this->server_ip;
			}
		}

		if ( function_exists( 'gethostbyname' ) && function_exists( 'gethostname' ) ) {
			$hostname = gethostname();
			if ( is_string( $hostname ) ) {
				$ip = gethostbyname( $hostname );
				if ( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
					$this->server_ip = $ip;
				}
			}
		}

		return $this->server_ip;
	}

	/**
	 * Set error handler.
	 *
	 * @return void
	 */
	public function setErrorHandler() {
		// @phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
		set_error_handler( array( $this, 'handlePhpError' ), E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED ); // @phpstan-ignore-line
	}

	/**
	 * PHP error handler installed by setErrorHandler().
	 *
	 * Keyed on the level, file and line rather than the message, so a warning
	 * whose text varies per request still occupies one slot.
	 *
	 * @param int     $errno   number.
	 * @param string  $errstr  message.
	 * @param ?string $errfile file.
	 * @param ?int    $errline line.
	 * @param array   $extra   extra data.
	 *
	 * @return void
	 *
	 * @since 4.1.2
	 */
	public function handlePhpError( $errno, $errstr, $errfile = null, $errline = null, $extra = array() ) {
		// nosemgrep: php.lang.security.weak-crypto.weak-crypto -- bounds the transient key length, not cryptography.
		if ( self::throttleGate( 'php_error_' . md5( $errno . ':' . $errfile . ':' . $errline ) ) ) {
			$this->error( $errno, $errstr, $errfile, $errline, $extra );
		}
	}

	/**
	 * Restore error handler.
	 *
	 * @return void
	 */
	public function restoreErrorHandler() {
		restore_error_handler();
	}

	/**
	 * Send error.
	 *
	 * @param int     $errno number.
	 * @param string  $errstr message.
	 * @param ?string $errfile file.
	 * @param ?int    $errline line.
	 * @param array   $extra extra data.
	 *
	 * @return void
	 */
	public function error( $errno, $errstr, $errfile = null, $errline = null, $extra = array() ) {
		if ( in_array( $errno, array( E_DEPRECATED, E_USER_DEPRECATED ) ) ) {
			return;
		}

		$data = $this->data( $errno, $errstr, $errfile, $errline, $extra );

		// Filter out events that don't contain our plugin's code in the stack trace.
		if ( isset( $data['sentry.interfaces.Exception']['values'][0]['stacktrace']['frames'] ) ) {
			$frames = $data['sentry.interfaces.Exception']['values'][0]['stacktrace']['frames'];
			if ( ! $this->hasPluginCodeInFrames( $frames ) ) {
				return;
			}
		}

		$this->send( $data );
	}

	/**
	 * Data.
	 *
	 * @param int     $errno number.
	 * @param string  $errstr message.
	 * @param ?string $errfile file.
	 * @param ?int    $errline line.
	 * @param array   $extra extra data.
	 *
	 * @return array
	 */
	public function data( $errno, $errstr, $errfile = null, $errline = null, $extra = array() ) {
		$fingerprint = null;
		if ( is_array( $extra ) && array_key_exists( 'fingerprint', $extra ) ) {
			$fingerprint = $extra['fingerprint'];
			unset( $extra['fingerprint'] );
		}

		$result = array(
			'environment'                 => $this->environment->get(),
			'release'                     => $this->release(),
			'tags'                        => $this->tags(),
			'extra'                       => array_merge(
				$this->extra(),
				$extra
			),
			'user'                        => $this->userdata(),
			// Sentry's message filter reads logentry, not tags; "|" is literal in its globs, "[" is not.
			'logentry'                    => array(
				'formatted' => sprintf( '%s | user=%s | domain=%s |', $errstr, $this->systemUser(), $this->user() ),
			),
			'sentry.interfaces.Exception' => array(
				'exc_omitted' => null,
				'values'      => array(
					array(
						'stacktrace' => array(
							'frames'         => $this->prepare_stack_frames( $errfile, $errno ),
							'frames_omitted' => null,
						),
						'type'       => isset( $this->codes[ $errno ] ) ? $this->codes[ $errno ] : 'Undefined: ' . $errno,
						'value'      => $errstr,
					),
				),
			),
		);

		if ( $fingerprint ) {
			$result['fingerprint'] = $fingerprint;
		}

		return $result;
	}

	/**
	 * Send to sentry.
	 *
	 * @param array $body send.
	 *
	 * @return string|false
	 */
	public function send( $body ) {
		if ( ! function_exists( 'curl_init' ) || empty( $body ) || defined( 'IS_TESTING' ) ) {
			return false;
		}

		$url     = 'https://im360.sentry.cloudlinux.com/api/' . $this->project_id() . '/store/';
		$headers = array(
			'Content-Type: application/json',
			'X-Sentry-Auth: Sentry sentry_version=7,sentry_timestamp=' . time() . ',sentry_client=php-curl/1.0,sentry_key=' . $this->key(),
		);

		$ch = curl_init();
		curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
		curl_setopt( $ch, CURLOPT_URL, $url );
		curl_setopt( $ch, CURLOPT_POST, true );
		curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
		curl_setopt( $ch, CURLOPT_POSTFIELDS, wp_json_encode( $body ) );
		curl_setopt( $ch, CURLOPT_TIMEOUT, 1 );
		curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 1 );
		curl_setopt( $ch, CURLOPT_HEADER, false );
		curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
		$response = curl_exec( $ch );
		curl_close( $ch );

		return $response;
	}

	/**
	 * Prepares stack trace data for Sentry.
	 *
	 * @param string $errfile File name.
	 * @param int    $errline Line number.
	 *
	 * @return array
	 *
	 * @phpcs:disable PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
	 */
	private function prepare_stack_frames( $errfile = null, $errline = null ) {

		// Default result will contain only the error file and line.
		$default = array(
			array(
				'filename' => $errfile,
				'lineno'   => $errline,
			),
		);

		if ( ! function_exists( 'debug_backtrace' ) ) {
			return $default;
		}

		$backtrace = debug_backtrace(); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace

		// Ignore last couple of frames that are not relevant to the error.
		$frames_to_omit = array(
			'App/Debug.php', // Call to CloudLinux\Imunify\App::prepare_stack_frames().
			'App/Debug.php', // Call to CloudLinux\Imunify\App::data().
			'wp-includes/class-wp-hook.php', // WordPress executing a filter.
			'wp-includes/class-wp-hook.php', // WordPress executing a filter.
			'wp-includes/plugin.php', // Call to apply_filters().
		);

		foreach ( $frames_to_omit as $frame_to_omit ) {
			if ( isset( $backtrace[0]['file'] ) && strpos( $backtrace[0]['file'], $frame_to_omit ) !== false ) {
				array_shift( $backtrace );
			}
		}

		$frames = array();
		while ( ! empty( $backtrace ) ) {
			$frame = array_pop( $backtrace );
			if ( isset( $frame['file'] ) && isset( $frame['line'] ) ) {
				$frames[] = array(
					'filename' => $frame['file'],
					'lineno'   => $frame['line'],
				);
			}
		}

		if ( empty( $frames ) ) {
			return $default;
		}

		return $frames;
	}

	/**
	 * Determines the plugin version.
	 *
	 * @return string Plugin version.
	 */
	public function pluginVersion() {
		return defined( 'IMUNIFY_SECURITY_VERSION' ) ? IMUNIFY_SECURITY_VERSION : 'dev';
	}

	/**
	 * Get environment instance.
	 *
	 * @return Environment
	 */
	public function environment() {
		return $this->environment;
	}

	/**
	 * Get release name.
	 *
	 * @return string Release name.
	 */
	public function release() {
		return 'imunify-security-wp-plugin@' . $this->pluginVersion();
	}

	/**
	 * Get Sentry key.
	 *
	 * @return string Sentry Key.
	 */
	public function key() {
		return '0f3f9fb22ff84c0c80144b570dea433a';
	}

	/**
	 * Get Sentry project ID.
	 *
	 * @return int Sentry project ID.
	 */
	public function project_id() {
		return 34;
	}

	/**
	 * Get tags.
	 *
	 * @return array<string> Tags.
	 */
	public function tags() {
		$tags = array(
			'php_version'    => phpversion(),
			'plugin_version' => $this->pluginVersion(),
		);

		global $wp_version;
		if ( is_string( $wp_version ) && '' !== $wp_version ) {
			$tags['wp_version'] = $wp_version;
		}

		// A tag, not only extra data, so an issue's spread across hosts can be queried.
		$server_ip = $this->serverIp();
		if ( '' !== $server_ip ) {
			$tags['server_ip'] = $server_ip;
		}

		// Merge Imunify package versions as Sentry tags. Wrapped in try/catch
		// so that version tagging can never disrupt error reporting.
		try {
			$versions = function_exists( 'get_option' )
				? get_option( DataStore::PACKAGE_VERSIONS_OPTION, array() )
				: array();
			if ( is_array( $versions ) ) {
				foreach ( $versions as $package => $version ) {
					if ( 'wp_version' !== $package && is_string( $version ) && ! isset( $tags[ $package ] ) ) {
						$tags[ $package ] = $version;
					}
				}
			}
		} catch ( \Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch -- version tags are non-critical.
		}

		return $tags;
	}

	/**
	 * Get user data.
	 *
	 * @return array<string> User data.
	 */
	public function userdata() {
		return array(
			'username' => $this->user(),
		);
	}

	/**
	 * Get extra data.
	 *
	 * @return array<string, int|string> Extra data.
	 */
	public function extra() {
		return array(
			'website'     => $this->website(),
			'home_path'   => $this->homePath(),
			'request_uri' => $this->requestUri(),
			'http_code'   => $this->httpCode(),
			'server_ip'   => $this->serverIp(),
		);
	}

	/**
	 * Check if any frame in the stack trace contains plugin code.
	 *
	 * @param array $frames Array of stack trace frames.
	 * @return bool True if any frame contains plugin code, false otherwise.
	 */
	public function hasPluginCodeInFrames( $frames ) {
		foreach ( $frames as $frame ) {
			if ( isset( $frame['filename'] ) && strpos( $frame['filename'], IMUNIFY_SECURITY_PATH ) !== false ) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Handles errors while ensuring that the same error is not reported more than once per hour.
	 *
	 * @param string $message The error message.
	 * @param string $errorCode The unique error identifier.
	 * @param array  $context Additional context data.
	 *
	 * @return void
	 *
	 * @since 2.1.0
	 */
	public function sendThrottledError( $message, $errorCode, $context = array() ) {
		if ( self::throttleGate( $errorCode ) ) {
			$this->error(
				E_WARNING,
				$message,
				__FILE__,
				__LINE__,
				array(
					'fingerprint' => array( $errorCode ),
					'context'     => $context,
				)
			);
		}
	}

	/**
	 * Claim the hourly reporting slot for an error code.
	 *
	 * Any error raised from a code path that can run on every HTTP request
	 * must pass through this gate (directly, or via sendThrottledError())
	 * before it reaches Sentry — an ungated report on such a path sends one
	 * event per page view.
	 *
	 * Callers that need to keep a custom Sentry fingerprint or a flat extra
	 * payload gate the raw do_action() with this; everything else should use
	 * sendThrottledError(), which wraps it.
	 *
	 * Degrades to "report it" when the transient API is unavailable, which
	 * happens only before WordPress is loaded. A transient layer that fails —
	 * by throwing, or by refusing the write — is the opposite case: it degrades
	 * to "stay quiet" for the rest of the request, because an open gate there
	 * means one blocking report per request, on a site whose object cache is
	 * already failing.
	 *
	 * @param string $errorCode The unique error identifier.
	 *
	 * @return bool True when the caller may report, false when throttled.
	 *
	 * @since 4.1.2
	 */
	public static function throttleGate( $errorCode ) {
		if ( ! function_exists( 'get_transient' ) || ! function_exists( 'set_transient' ) ) {
			return true;
		}

		if ( self::$throttleUnavailable ) {
			return false;
		}

		$transientKey = self::ERROR_THROTTLE_PREFIX . $errorCode;
		try {
			if ( get_transient( $transientKey ) ) {
				return false;
			}

			// A backend that refuses the write reports false instead of
			// throwing, and leaves no slot behind — so the next request would
			// be let through, and every one after it.
			if ( ! set_transient( $transientKey, true, HOUR_IN_SECONDS ) ) {
				// WordPress stores a new transient with add_option(), which
				// also returns false when a concurrent request created the same
				// key a moment ago. A slot that exists now means a lost race,
				// not a broken backend: throttle this code, leave the rest of
				// the request alone.
				if ( get_transient( $transientKey ) ) {
					return false;
				}

				return self::throttleUnavailable();
			}
		} catch ( \Exception $e ) {
			unset( $e );
			return self::throttleUnavailable();
		} catch ( \Throwable $e ) {
			unset( $e );
			return self::throttleUnavailable();
		}

		return true;
	}

	/**
	 * Remember that the transient layer is unusable and stay quiet.
	 *
	 * @return bool Always false.
	 *
	 * @since 4.1.2
	 */
	private static function throttleUnavailable() {
		self::$throttleUnavailable = true;

		return false;
	}
}

Directory Contents

Dirs: 9 × Files: 9
Name Size Perms Modified Actions
Api DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Bot DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Defender DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Exception DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Helpers DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Lifecycle DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Model DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
Views DIR
- drwxr-xr-x 2026-11-03 01:06:39
Edit Download
4.89 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
5.04 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
4.58 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
14.35 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
18.35 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
1.67 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
12.06 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
1.67 KB lrw-r--r-- 2026-11-03 01:06:39
Edit Download
1.33 KB lrw-r--r-- 2026-11-03 01:06:39
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