PluginProbe
Redirection / 5.4.1
Redirection v5.4.1
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / ip.php

ip.php in Redirection 5.4.1, at models/ip.php

26 lines 486 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Redirection_IP {
4 private $ip;
5
6 public function __construct( $ip = '' ) {
7 $this->ip = '';
8
9 $ip = sanitize_text_field( $ip );
10 $ip = explode( ',', $ip );
11 $ip = array_shift( $ip );
12 $ip = filter_var( $ip, FILTER_VALIDATE_IP );
13
14 // Convert to binary
15 // phpcs:ignore
16 $ip = @inet_pton( trim( $ip ) );
17 if ( $ip !== false ) {
18 // phpcs:ignore
19 $this->ip = @inet_ntop( $ip ); // Convert back to string
20 }
21 }
22
23 public function get() {
24 return $this->ip;
25 }
26 }