PluginProbe
Redirection / 3.7
Redirection v3.7
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.7, at models/request.php

88 lines 2.0 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_server_name() {
5 $host = '';
6
7 if ( isset( $_SERVER['HTTP_HOST'] ) ) {
8 $host = $_SERVER['HTTP_HOST'];
9 }
10
11 if ( isset( $_SERVER['SERVER_NAME'] ) ) {
12 $host = $_SERVER['SERVER_NAME'];
13 }
14
15 return apply_filters( 'redirection_request_server', $host );
16 }
17
18 public static function get_request_url() {
19 $url = '';
20
21 if ( isset( $_SERVER['REQUEST_URI'] ) ) {
22 $url = $_SERVER['REQUEST_URI'];
23 }
24
25 return apply_filters( 'redirection_request_url', $url );
26 }
27
28 public static function get_user_agent() {
29 $agent = '';
30
31 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
32 $agent = $_SERVER['HTTP_USER_AGENT'];
33 }
34
35 return apply_filters( 'redirection_request_agent', $agent );
36 }
37
38 public static function get_referrer() {
39 $referrer = '';
40
41 if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
42 $referrer = $_SERVER['HTTP_REFERER'];
43 }
44
45 return apply_filters( 'redirection_request_referrer', $referrer );
46 }
47
48 public static function get_ip() {
49 $ip = '';
50
51 if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
52 $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
53 } elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
54 $ip = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
55 $ip = array_shift( $ip );
56 } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
57 $ip = $_SERVER['REMOTE_ADDR'];
58 }
59
60 // Convert to binary
61 $ip = @inet_pton( trim( $ip ) );
62 if ( $ip !== false ) {
63 $ip = @inet_ntop( $ip ); // Convert back to string
64 }
65
66 return apply_filters( 'redirection_request_ip', $ip ? $ip : '' );
67 }
68
69 public static function get_cookie( $cookie ) {
70 if ( isset( $_COOKIE[ $cookie ] ) ) {
71 return apply_filters( 'redirection_request_cookie', $_COOKIE[ $cookie ], $cookie );
72 }
73
74 return false;
75 }
76
77 public static function get_header( $name ) {
78 $name = 'HTTP_' . strtoupper( $name );
79 $name = str_replace( '-', '_', $name );
80
81 if ( isset( $_SERVER[ $name ] ) ) {
82 return apply_filters( 'redirection_request_header', $_SERVER[ $name ], $name );
83 }
84
85 return false;
86 }
87 }
88