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/wp.5/wp-content/plugins/woocommerce-payments/includes/multi-currency/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.5/wp-content/plugins/woocommerce-payments/includes/multi-currency/Geolocation.php
<?php
/**
 * WooCommerce Payments Multi-Currency Geolocation Class
 *
 * @package WooCommerce\Payments
 */

namespace WCPay\MultiCurrency;

use WCPay\MultiCurrency\Interfaces\MultiCurrencyLocalizationInterface;

defined( 'ABSPATH' ) || exit;

/**
 * Geolocation.
 */
class Geolocation {
	/**
	 * MultiCurrencyLocalizationInterface instance.
	 *
	 * @var MultiCurrencyLocalizationInterface
	 */
	protected $localization_service;

	/**
	 * Constructor.
	 *
	 * @param MultiCurrencyLocalizationInterface $localization_service The Localization Service instance.
	 */
	public function __construct( MultiCurrencyLocalizationInterface $localization_service ) {
		$this->localization_service = $localization_service;
	}

	/**
	 * Gets the customer's currency based on their location.
	 *
	 * @return string|null Currency code or null if not found.
	 */
	public function get_currency_by_customer_location() {
		$country = $this->get_country_by_customer_location();

		return $this->localization_service->get_country_locale_data( $country )['currency_code'] ?? null;
	}

	/**
	 * Gets the customer's country based on their location.
	 *
	 * @return string Country code.
	 */
	public function get_country_by_customer_location() {
		$country = $this->geolocate_customer();

		if ( $country ) {
			// Once we have a location, ensure it's valid, otherwise fallback to the default country.
			$allowed_country_codes = WC()->countries->get_allowed_countries();
			if ( ! array_key_exists( $country, $allowed_country_codes ) ) {
				$country = null;
			}
		}

		if ( ! $country ) {
			$default_location = get_option( 'woocommerce_default_country', '' );
			$location         = wc_format_country_state_string( apply_filters( 'woocommerce_customer_default_location', $default_location ) );
			$country          = $location['country'];
		}

		return $country;
	}

	/**
	 * Attempts to guess the customer's country based on their IP.
	 *
	 * @return string|null Country code, or NULL if it couldn't be determined.
	 */
	private function geolocate_customer() {
		// Exclude common bots from geolocation by user agent.
		$ua = wc_get_user_agent();
		if ( stripos( $ua, 'bot' ) !== false || stripos( $ua, 'spider' ) !== false || stripos( $ua, 'crawl' ) !== false ) {
			return null;
		}

		$geolocation = \WC_Geolocation::geolocate_ip( '', true, true );
		return $geolocation['country'] ?? null;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit