403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/test21.chuangfenglink.xyz/wp-content/themes/dt-the7/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/test21.chuangfenglink.xyz/wp-content/themes/dt-the7/inc/class-the7-avatar.php
<?php
/**
 * The7 avatar class.
 *
 * @package The7
 */

defined( 'ABSPATH' ) || exit;

/**
 * Class The7_Avatar
 */
class The7_Avatar {

	const CACHE_KEY = 'the7_avatar_cache';

	/**
	 * Wrapper for get_avatar() with some filters.
	 *
	 * @param mixed      $id_or_email ID or Email.
	 * @param int        $size Image size.
	 * @param string     $default Default avatar image url.
	 * @param string     $alt Avatar image alt.
	 * @param null|array $args Arguments.
	 *
	 * @return false|string
	 */
	public static function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {
		add_filter( 'get_avatar', [ __CLASS__, 'check_gravatar_existence_filter' ], 10, 6 );
		$avatar = get_avatar( $id_or_email, $size, $default, $alt, $args );
		remove_filter( 'get_avatar', [ __CLASS__, 'check_gravatar_existence_filter' ] );

		return $avatar;
	}

	/**
	 * Return false if gravatar in use and user do not have one.
	 *
	 * @param string $avatar Avatar url.
	 * @param string $id_or_email Uler ID or Email.
	 * @param int    $args_size Image size.
	 * @param string $args_default Default avatar.
	 * @param string $args_alt Avatar image alt.
	 * @param array  $args Arguments.
	 *
	 * @return bool
	 */
	public static function check_gravatar_existence_filter( $avatar, $id_or_email, $args_size, $args_default, $args_alt, $args = [] ) {
		$args = wp_parse_args(
			$args,
			[
				'url' => '',
			]
		);

		if ( ! preg_match( '/.*\.gravatar\.com.*/', $avatar ) || self::is_gravatar_exists( $args['url'] ) ) {
			// non gravatar or gravatar exists.
			return $avatar;
		}

		return false;
	}

	/**
	 * Check if provided gravatar url response with 200.
	 *
	 * Cache result for $url in wp_cache for one week.
	 *
	 * @param string $url Gravatar url.
	 *
	 * @return bool
	 */
	public static function is_gravatar_exists( $url ) {
		if ( ! $url ) {
			return false;
		}

		$test_url = remove_query_arg( [ 's', 'd', 'f', 'r' ], $url );
		$code     = self::cache_get( $test_url );
		if ( empty( $code ) ) {
			$response = wp_remote_head( add_query_arg( 'd', '404', $test_url ) );
			if ( is_wp_error( $response ) ) {
				$code = 'not200';
			} else {
				$code = (string) $response['response']['code'];
			}

			self::cache_add( $test_url, $code );
		}

		return $code === '200';
	}

	/**
	 * @param string $url Gravatar url.
	 * @param string $code Response code.
	 *
	 * @return void
	 */
	protected static function cache_add( $url, $code ) {
		$hash  = self::hash_url( $url );
		$cache = get_transient( self::CACHE_KEY );
		if ( ! is_array( $cache ) ) {
			$cache = [];
		}
		$cache[ $hash ] = $code;

		set_transient( self::CACHE_KEY, $cache, WEEK_IN_SECONDS );
	}

	/**
	 * @param string $url Gravatar url.
	 *
	 * @return string|null
	 */
	protected static function cache_get( $url ) {
		$hash  = self::hash_url( $url );
		$cache = get_transient( self::CACHE_KEY );

		return isset( $cache[ $hash ] ) ? (string) $cache[ $hash ] : null;
	}

	/**
	 * @param string $url Gravatar url.
	 *
	 * @return string
	 */
	protected static function hash_url( $url ) {
		return md5( strtolower( trim( $url ) ) );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit