PluginProbe
Redirection / 3.0.1
Redirection v3.0.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 / request.php

request.php in Redirection 3.0.1, at models/request.php

55 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Redirection_Request {
4 public static function get_request_url() {
5 $url = '';
6
7 if ( isset( $_SERVER['REQUEST_URI'] ) ) {
8 $url = $_SERVER['REQUEST_URI'];
9 }
10
11 return apply_filters( 'redirection_request_url', $url );
12 }
13
14 public static function get_user_agent() {
15 $agent = '';
16
17 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
18 $agent = $_SERVER['HTTP_USER_AGENT'];
19 }
20
21 return apply_filters( 'redirection_request_agent', $agent );
22 }
23
24 public static function get_referrer() {
25 $referrer = '';
26
27 if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
28 $referrer = $_SERVER['HTTP_REFERER'];
29 }
30
31 return apply_filters( 'redirection_request_referrer', $referrer );
32 }
33
34 public static function get_ip() {
35 $ip = '';
36
37 if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
38 $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
39 } elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
40 $ip = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
41 $ip = array_shift( $ip );
42 } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
43 $ip = $_SERVER['REMOTE_ADDR'];
44 }
45
46 // Convert to binary
47 $ip = @inet_pton( trim( $ip ) );
48 if ( $ip !== false ) {
49 $ip = @inet_ntop( $ip ); // Convert back to string
50 }
51
52 return apply_filters( 'redirection_request_ip', $ip ? $ip : '' );
53 }
54 }
55