/home/techb158/balacoffee.com/wp-content/plugins/woocommerce/includes
NameSizeModeActions
abstracts/-0755rm
admin/-0755rm
blocks/-0755rm
cli/-0755rm
customizer/-0755rm
data-stores/-0755rm
emails/-0755rm
export/-0755rm
gateways/-0755rm
import/-0755rm
integrations/-0755rm
interfaces/-0755rm
legacy/-0755rm
libraries/-0755rm
log-handlers/-0755rm
payment-tokens/-0755rm
product-usage/-0755rm
queue/-0755rm
react-admin/-0755rm
rest-api/-0755rm
shipping/-0755rm
shortcodes/-0755rm
theme-support/-0755rm
tracks/-0755rm
traits/-0755rm
walkers/-0755rm
wccom-site/-0755rm
widgets/-0755rm
class-wc-ajax.php1345980644editdlrm
class-wc-auth.php129950644editdlrm
class-wc-autoloader.php53940644editdlrm
class-wc-background-emailer.php46850644editdlrm
class-wc-background-updater.php35350644editdlrm
class-wc-brands-brand-settings-manager.php18260644editdlrm
class-wc-brands-coupons.php70590644editdlrm
class-wc-brands.php356350644editdlrm
class-wc-breadcrumb.php106600644editdlrm
class-wc-cache-helper.php129980644editdlrm
class-wc-cart-fees.php34480644editdlrm
class-wc-cart-session.php259750644editdlrm
class-wc-cart-totals.php291630644editdlrm
class-wc-cart.php773860644editdlrm
class-wc-checkout.php513490644editdlrm
class-wc-cli.php34190644editdlrm
class-wc-comments.php236310644editdlrm
class-wc-countries.php518810644editdlrm
class-wc-coupon.php449200644editdlrm
class-wc-customer-download-log.php34520644editdlrm
class-wc-customer-download.php105870644editdlrm
class-wc-customer.php340000644editdlrm
class-wc-data-exception.php13210644editdlrm
class-wc-data-store.php67520644editdlrm
class-wc-datetime.php23100644editdlrm
class-wc-deprecated-action-hooks.php67460644editdlrm
class-wc-deprecated-filter-hooks.php75180644editdlrm
class-wc-discounts.php375230644editdlrm
class-wc-download-handler.php290530644editdlrm
class-wc-emails.php402440644editdlrm
class-wc-embed.php43420644editdlrm
class-wc-form-handler.php493270644editdlrm
class-wc-frontend-scripts.php351850644editdlrm
class-wc-geo-ip.php311590644editdlrm
class-wc-geolite-integration.php20360644editdlrm
class-wc-geolocation.php116150644editdlrm
class-wc-https.php44390644editdlrm
class-wc-install.php1190170644editdlrm
class-wc-integrations.php13080644editdlrm
class-wc-log-levels.php39920644editdlrm
class-wc-logger.php96390644editdlrm
class-wc-meta-data.php22600644editdlrm
class-wc-order-factory.php89510644editdlrm
class-wc-order-item-coupon.php41750644editdlrm
class-wc-order-item-fee.php102280644editdlrm
class-wc-order-item-meta.php59420644editdlrm
class-wc-order-item-product.php179620644editdlrm
class-wc-order-item-shipping.php98150644editdlrm
class-wc-order-item-tax.php66440644editdlrm
class-wc-order-item.php219070644editdlrm
class-wc-order-query.php26130644editdlrm
class-wc-order-refund.php61350644editdlrm
class-wc-order.php794230644editdlrm
class-wc-payment-gateways.php146010644editdlrm
class-wc-payment-tokens.php63900644editdlrm
class-wc-post-data.php396170644editdlrm
class-wc-post-types.php336800644editdlrm
class-wc-privacy-background-process.php18330644editdlrm
class-wc-privacy-erasers.php139410644editdlrm
class-wc-privacy-exporters.php150440644editdlrm
class-wc-privacy.php176290644editdlrm
class-wc-product-attribute.php80570644editdlrm
class-wc-product-download.php134940644editdlrm
class-wc-product-external.php51040644editdlrm
class-wc-product-factory.php46980644editdlrm
class-wc-product-grouped.php69740644editdlrm
class-wc-product-query.php23280644editdlrm
class-wc-product-simple.php27650644editdlrm
class-wc-product-variable.php243340644editdlrm
class-wc-product-variation.php206610644editdlrm
class-wc-query.php342990644editdlrm
class-wc-rate-limiter.php41000644editdlrm
class-wc-regenerate-images-request.php79230644editdlrm
class-wc-regenerate-images.php158060644editdlrm
class-wc-register-wp-admin-settings.php51710644editdlrm
class-wc-rest-authentication.php220680644editdlrm
class-wc-rest-exception.php2760644editdlrm
class-wc-session-handler.php251620644editdlrm
class-wc-shipping-rate.php95660644editdlrm
class-wc-shipping-zone.php133920644editdlrm
class-wc-shipping-zones.php51150644editdlrm
class-wc-shipping.php133710644editdlrm
class-wc-shortcodes.php192740644editdlrm
class-wc-structured-data.php250110644editdlrm
class-wc-tax.php406940644editdlrm
class-wc-template-loader.php209110644editdlrm
class-wc-tracker.php527310644editdlrm
class-wc-validation.php59290644editdlrm
class-wc-webhook.php308070644editdlrm
class-woocommerce.php638140644editdlrm
wc-account-functions.php144850644editdlrm
wc-attribute-functions.php223770644editdlrm
wc-brands-functions.php42700644editdlrm
wc-cart-functions.php213080644editdlrm
wc-conditional-functions.php159020644editdlrm
wc-core-functions.php806030644editdlrm
wc-coupon-functions.php56980644editdlrm
wc-deprecated-functions.php407310644editdlrm
wc-formatting-functions.php510930644editdlrm
wc-interactivity-api-functions.php22190644editdlrm
wc-notice-functions.php86960644editdlrm
wc-order-functions.php450650644editdlrm
wc-order-item-functions.php51530644editdlrm
wc-order-step-logger-functions.php61140644editdlrm
wc-page-functions.php96570644editdlrm
wc-product-functions.php689920644editdlrm
wc-rest-functions.php142680644editdlrm
wc-stock-functions.php178510644editdlrm
wc-template-functions.php1454760644editdlrm
wc-template-hooks.php131510644editdlrm
wc-term-functions.php251580644editdlrm
wc-update-functions.php1048370644editdlrm
wc-user-functions.php361970644editdlrm
wc-webhook-functions.php59050644editdlrm
wc-widget-functions.php20630644editdlrm
Edit: /home/techb158/balacoffee.com/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php (11615B)
'http://api.ipify.org/', 'ipecho' => 'http://ipecho.net/plain', 'ident' => 'http://ident.me', 'tnedi' => 'http://tnedi.me', ); /** * API endpoints for geolocating an IP address * * @var array */ private static $geoip_apis = array( 'ipinfo.io' => 'https://ipinfo.io/%s/json', 'ip-api.com' => 'http://ip-api.com/json/%s', ); /** * Check if geolocation is enabled. * * @since 3.4.0 * @param string $current_settings Current geolocation settings. * @return bool */ private static function is_geolocation_enabled( $current_settings ) { return in_array( $current_settings, array( 'geolocation', 'geolocation_ajax' ), true ); } /** * Get current user IP Address. * * @return string */ public static function get_ip_address() { if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); } elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 // Make sure we always only send through the first IP in the list which should always be the client IP. $value = trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ); // Account for the ':', '[]' and '[]:' cases, removing the port. // The regular expression is oversimplified on purpose, later 'rest_is_ip_address' will do the actual IP address validation. $value = preg_replace( '/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\:.*|\[([^]]+)\].*/', '$1$2', $value ); return (string) rest_is_ip_address( $value ); } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // Make sure we always only send through the first IP in the list which should always be the client IP. $value = trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) ) ) ); return (string) rest_is_ip_address( $value ); } return ''; } /** * Get user IP Address using an external service. * This can be used as a fallback for users on localhost where * get_ip_address() will be a local IP and non-geolocatable. * * @return string */ public static function get_external_ip_address() { $external_ip_address = '0.0.0.0'; if ( '' !== self::get_ip_address() ) { $transient_name = 'external_ip_address_' . self::get_ip_address(); $external_ip_address = get_transient( $transient_name ); } if ( false === $external_ip_address ) { $external_ip_address = '0.0.0.0'; $ip_lookup_services = apply_filters( 'woocommerce_geolocation_ip_lookup_apis', self::$ip_lookup_apis ); $ip_lookup_services_keys = array_keys( $ip_lookup_services ); shuffle( $ip_lookup_services_keys ); foreach ( $ip_lookup_services_keys as $service_name ) { $service_endpoint = $ip_lookup_services[ $service_name ]; $response = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2, 'user-agent' => 'WooCommerce/' . wc()->version, ) ); if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) { $external_ip_address = apply_filters( 'woocommerce_geolocation_ip_lookup_api_response', wc_clean( $response['body'] ), $service_name ); break; } } set_transient( $transient_name, $external_ip_address, DAY_IN_SECONDS ); } return $external_ip_address; } /** * Geolocate an IP address. * * @param string $ip_address IP Address. * @param bool $fallback If true, fallbacks to alternative IP detection (can be slower). * @param bool $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower). * @return array */ public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) { /** * Filter to allow custom geolocation of the IP address. * * @since 3.9.0 * @param string $geolocation Country code. * @param string $ip_address IP Address. * @param bool $fallback If true, fallbacks to alternative IP detection (can be slower). * @param bool $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower). * @return string */ $country_code = apply_filters( 'woocommerce_geolocate_ip', false, $ip_address, $fallback, $api_fallback ); if ( false !== $country_code ) { return array( 'country' => $country_code, 'state' => '', 'city' => '', 'postcode' => '', ); } if ( empty( $ip_address ) ) { $ip_address = self::get_ip_address(); $country_code = self::get_country_code_from_headers(); } /** * Get geolocation filter. * * @since 3.9.0 * @param array $geolocation Geolocation data, including country, state, city, and postcode. * @param string $ip_address IP Address. */ $geolocation = apply_filters( 'woocommerce_get_geolocation', array( 'country' => $country_code ? $country_code : '', 'state' => '', 'city' => '', 'postcode' => '', ), $ip_address ); // If we still haven't found a country code, let's consider doing an API lookup. if ( '' === $geolocation['country'] && $api_fallback ) { $geolocation['country'] = self::geolocate_via_api( $ip_address ); } // It's possible that we're in a local environment, in which case the geolocation needs to be done from the // external address. if ( '' === $geolocation['country'] && $fallback ) { $external_ip_address = self::get_external_ip_address(); // Only bother with this if the external IP differs. if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) { return self::geolocate_ip( $external_ip_address, false, $api_fallback ); } } return array( 'country' => $geolocation['country'], 'state' => $geolocation['state'], 'city' => $geolocation['city'], 'postcode' => $geolocation['postcode'], ); } /** * Path to our local db. * * @deprecated 3.9.0 * @param string $deprecated Deprecated since 3.4.0. * @return string */ public static function get_local_database_path( $deprecated = '2' ) { wc_deprecated_function( 'WC_Geolocation::get_local_database_path', '3.9.0' ); $integration = wc()->integrations->get_integration( 'maxmind_geolocation' ); return $integration->get_database_service()->get_database_path(); } /** * Update geoip database. * * @deprecated 3.9.0 * Extract files with PharData. Tool built into PHP since 5.3. */ public static function update_database() { wc_deprecated_function( 'WC_Geolocation::update_database', '3.9.0' ); $integration = wc()->integrations->get_integration( 'maxmind_geolocation' ); $integration->update_database(); } /** * Fetches the country code from the request headers, if one is available. * * @since 3.9.0 * @return string The country code pulled from the headers, or empty string if one was not found. */ private static function get_country_code_from_headers() { $country_code = ''; $headers = array( 'MM_COUNTRY_CODE', 'GEOIP_COUNTRY_CODE', 'HTTP_CF_IPCOUNTRY', 'HTTP_X_COUNTRY_CODE', ); foreach ( $headers as $header ) { if ( empty( $_SERVER[ $header ] ) ) { continue; } $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) ); break; } return $country_code; } /** * Use APIs to Geolocate the user. * * Geolocation APIs can be added through the use of the woocommerce_geolocation_geoip_apis filter. * Provide a name=>value pair for service-slug=>endpoint. * * If APIs are defined, one will be chosen at random to fulfil the request. After completing, the result * will be cached in a transient. * * @param string $ip_address IP address. * @return string */ private static function geolocate_via_api( $ip_address ) { $country_code = get_transient( 'geoip_' . $ip_address ); if ( false === $country_code ) { $geoip_services = apply_filters( 'woocommerce_geolocation_geoip_apis', self::$geoip_apis ); if ( empty( $geoip_services ) ) { return ''; } $geoip_services_keys = array_keys( $geoip_services ); shuffle( $geoip_services_keys ); foreach ( $geoip_services_keys as $service_name ) { $service_endpoint = $geoip_services[ $service_name ]; $response = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2, 'user-agent' => 'WooCommerce/' . wc()->version, ) ); if ( ! is_wp_error( $response ) && $response['body'] ) { switch ( $service_name ) { case 'ipinfo.io': $data = json_decode( $response['body'] ); $country_code = isset( $data->country ) ? $data->country : ''; break; case 'ip-api.com': $data = json_decode( $response['body'] ); $country_code = isset( $data->countryCode ) ? $data->countryCode : ''; // @codingStandardsIgnoreLine break; default: $country_code = apply_filters( 'woocommerce_geolocation_geoip_response_' . $service_name, '', $response['body'] ); break; } $country_code = sanitize_text_field( strtoupper( $country_code ) ); if ( $country_code ) { break; } } } set_transient( 'geoip_' . $ip_address, $country_code, DAY_IN_SECONDS ); } return $country_code; } /** * Hook in geolocation functionality. * * @deprecated 3.9.0 * @return null */ public static function init() { wc_deprecated_function( 'WC_Geolocation::init', '3.9.0' ); return null; } /** * Prevent geolocation via MaxMind when using legacy versions of php. * * @deprecated 3.9.0 * @since 3.4.0 * @param string $default_customer_address current value. * @return string */ public static function disable_geolocation_on_legacy_php( $default_customer_address ) { wc_deprecated_function( 'WC_Geolocation::disable_geolocation_on_legacy_php', '3.9.0' ); if ( self::is_geolocation_enabled( $default_customer_address ) ) { $default_customer_address = 'base'; } return $default_customer_address; } /** * Maybe trigger a DB update for the first time. * * @deprecated 3.9.0 * @param string $new_value New value. * @param string $old_value Old value. * @return string */ public static function maybe_update_database( $new_value, $old_value ) { wc_deprecated_function( 'WC_Geolocation::maybe_update_database', '3.9.0' ); if ( $new_value !== $old_value && self::is_geolocation_enabled( $new_value ) ) { self::update_database(); } return $new_value; } }