# double-opt-in/3.0.61/core/IPHelper.class.php

Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification, version 3.0.61. 31 lines.

- Page: https://pluginprobe.com/plugins/double-opt-in/3.0.61/code/core/IPHelper.class.php
- Raw: https://pluginprobe.com/plugins/double-opt-in/3.0.61/raw/core/IPHelper.class.php
- Modified: 2024-08-13T13:52:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/double-opt-in/3.0.61/code/core/IPHelper.class.php#L10-L20`.

```php
<?php

namespace forge12\contactform7\CF7DoubleOptIn;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class IPHelper {
	/**
	 * Retrieves the IP address of the current client.
	 *
	 * The method checks if the IP address is obtained from a shared internet, proxy, or remote address.
	 *
	 * @return string The IP address of the current client.
	 */
	public static function getIPAdress(): string {
		//whether ip is from share internet
		if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
			$ip_address = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
		} //whether ip is from proxy
		elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
			$ip_address = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
		} //whether ip is from remote address
		else {
			$ip_address = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
		}

		return $ip_address;
	}
}
```
