PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 0.9.0
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v0.9.0
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / classes / input.php
wp-all-export / classes Last commit date
arrayaccess.php 12 years ago config.php 12 years ago download.php 12 years ago helper.php 12 years ago input.php 12 years ago session.php 12 years ago
input.php
72 lines
1 <?php
2 class PMXE_Input {
3 protected $filters = array('stripslashes');
4
5 public function read($inputArray, $paramName, $default = NULL) {
6 if (is_array($paramName) and ! is_null($default)) {
7 throw new Exception('Either array of parameter names with default values as the only argument or param name and default value as seperate arguments are expected.');
8 }
9 if (is_array($paramName)) {
10 foreach ($paramName as $param => $def) {
11 if (isset($inputArray[$param])) {
12 $paramName[$param] = $this->applyFilters($inputArray[$param]);
13 }
14 }
15 return $paramName;
16 } else {
17 return isset($inputArray[$paramName]) ? $this->applyFilters($inputArray[$paramName]) : $default;
18 }
19 }
20
21 public function get($paramName, $default = NULL) {
22 return $this->read($_GET, $paramName, $default);
23 }
24
25 public function post($paramName, $default = NULL) {
26 return $this->read($_POST, $paramName, $default);
27 }
28
29 public function cookie($paramName, $default = NULL) {
30 return $this->read($_COOKIE, $paramName, $default);
31 }
32
33 public function request($paramName, $default = NULL) {
34 return $this->read($_GET + $_POST + $_COOKIE, $paramName, $default);
35 }
36
37 public function getpost($paramName, $default = NULL) {
38 return $this->read($_GET + $_POST, $paramName, $default);
39 }
40
41 public function server($paramName, $default = NULL) {
42 return $this->read($_SERVER, $paramName, $default);
43 }
44
45 public function addFilter($callback) {
46 if ( ! is_callable($callback)) {
47 throw new Exception(get_class($this) . '::' . __METHOD__ . ' parameter must be a proper callback function reference.');
48 }
49 if ( ! in_array($callback, $this->filters)) {
50 $this->filters[] = $callback;
51 }
52 return $this;
53 }
54
55 public function removeFilter($callback) {
56 $this->filters = array_diff($this->filters, array($callback));
57 return $this;
58 }
59
60 protected function applyFilters($val) {
61 if (is_array($val)) {
62 foreach ($val as $k => $v) {
63 $val[$k] = $this->applyFilters($v);
64 }
65 } else {
66 foreach ($this->filters as $filter) {
67 $val = call_user_func($filter, $val);
68 }
69 }
70 return $val;
71 }
72 }