PluginProbe
Advanced Access Manager – Access Governance for WordPress / 6.9.0
Advanced Access Manager – Access Governance for WordPress v6.9.0
7.1.4 7.1.2 7.1.3 6.8.4 6.8.5 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13 6.9.14 6.9.15 6.9.16 6.9.17 6.9.18 6.9.19 6.9.2 6.9.20 6.9.21 6.9.22 6.9.23 6.9.24 6.9.25 6.9.26 All 210 releases
advanced-access-manager / application / Core / Request.php
Request.php
133 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ======================================================================
5 * LICENSE: This file is subject to the terms and conditions defined in *
6 * file 'license.txt', which is part of this source code package. *
7 * ======================================================================
8 */
9
10 /**
11 * HTTP request layer
12 *
13 * @package AAM
14 * @version 6.0.0
15 */
16 class AAM_Core_Request
17 {
18
19 /**
20 * Get parameter from global _GET array
21 *
22 * @param string $param GET Parameter
23 * @param mixed $default Default value
24 *
25 * @return mixed
26 *
27 * @access public
28 * @version 6.0.0
29 */
30 public static function get($param = null, $default = null)
31 {
32 return self::readArray($_GET, $param, $default);
33 }
34
35 /**
36 * Get parameter from global _POST array
37 *
38 * @param string $param POST Parameter
39 * @param mixed $default Default value
40 *
41 * @return mixed
42 *
43 * @access public
44 * @version 6.0.0
45 */
46 public static function post($param = null, $default = null)
47 {
48 return self::readArray($_POST, $param, $default);
49 }
50
51 /**
52 * Get parameter from global _REQUEST array
53 *
54 * @param string $param REQUEST Parameter
55 * @param mixed $default Default value
56 *
57 * @return mixed
58 *
59 * @access public
60 * @version 6.0.0
61 */
62 public static function request($param = null, $default = null)
63 {
64 return self::readArray($_REQUEST, $param, $default);
65 }
66
67 /**
68 * Get parameter from global _SERVER array
69 *
70 * @param string $param SERVER Parameter
71 * @param mixed $default Default value
72 *
73 * @return mixed
74 *
75 * @access public
76 * @version 6.0.0
77 */
78 public static function server($param = null, $default = null)
79 {
80 return self::readArray($_SERVER, $param, $default);
81 }
82
83 /**
84 * Get parameter from global _COOKIE array
85 *
86 * @param string $param _COOKIE Parameter
87 * @param mixed $default Default value
88 *
89 * @return mixed
90 *
91 * @access public
92 * @version 6.0.0
93 */
94 public static function cookie($param = null, $default = null)
95 {
96 return self::readArray($_COOKIE, $param, $default);
97 }
98
99 /**
100 * Check array for specified parameter and return the it's value or
101 * default one
102 *
103 * @param array $array Global array _GET, _POST etc
104 * @param string $param Array Parameter
105 * @param mixed $default Default value
106 *
107 * @return mixed
108 *
109 * @access protected
110 * @version 6.0.0
111 */
112 protected static function readArray($array, $param, $default)
113 {
114 $value = $default;
115 if (is_null($param)) {
116 $value = $array;
117 } else {
118 $chunks = explode('.', $param);
119 $value = $array;
120 foreach ($chunks as $chunk) {
121 if (isset($value[$chunk])) {
122 $value = $value[$chunk];
123 } else {
124 $value = $default;
125 break;
126 }
127 }
128 }
129
130 return $value;
131 }
132
133 }