HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/lipovac/wp-content/plugins/the-events-calendar/common/src/Tribe/Support/Obfuscator.php
<?php


class Tribe__Support__Obfuscator {

	/**
	 * @var array
	 */
	protected $prefixes = array();

	/**
	 * Tribe__Support__Obfuscator constructor.
	 *
	 * @param array $prefixes
	 */
	public function __construct( array $prefixes = array() ) {
		$this->prefixes = $prefixes;
	}

	/**
	 * Whether a value should be obfuscated or not.
	 *
	 * @param string $key
	 *
	 * @return bool
	 */
	public function should_obfuscate( $key ) {
		foreach ( $this->prefixes as $prefix ) {
			if ( strpos( $key, $prefix ) === 0 ) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Conditionally obfuscates a string value.
	 *
	 * @param string $key
	 * @param mixed $string_value
	 *
	 * @return mixed Either the obfuscated string or the original value if not a string.
	 */
	public function obfuscate( $key, $string_value ) {
		if ( ! is_string( $string_value ) ) {
			return $string_value;
		}
		if ( ! $this->should_obfuscate( $key ) ) {
			return $string_value;
		}

		$length = strlen( $string_value );
		if ( $length <= 3 ) {
			return preg_replace( "/./", "#", $string_value );
		} elseif ( $length > 3 && $length <= 5 ) {
			return preg_replace( '/^(.{1}).*$/', '$1' . str_repeat( '#', $length - 1 ) . '$2', $string_value );
		} elseif ( $length > 5 && $length <= 9 ) {
			return preg_replace( '/^(.{1}).*(.{1})$/', '$1' . str_repeat( '#', $length - 2 ) . '$2', $string_value );
		} elseif ( $length > 9 && $length <= 19 ) {
			return preg_replace( '/^(.{2}).*(.{2})$/', '$1' . str_repeat( '#', $length - 4 ) . '$2', $string_value );
		} elseif ( $length > 19 && $length <= 31 ) {
			return preg_replace( '/^(.{3}).*(.{3})$/', '$1' . str_repeat( '#', $length - 6 ) . '$2', $string_value );
		}

		return preg_replace( '/^(.{4}).*(.{4})$/', '$1' . str_repeat( '#', $length - 8 ) . '$2', $string_value );
	}
}