PluginProbe
FeedWordPress / 2013.0504
FeedWordPress v2013.0504
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / externals / myphp / myphp.class.php

myphp.class.php in FeedWordPress 2013.0504, at externals/myphp/myphp.class.php

89 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!class_exists('MyPHP')) :
3 class MyPHP {
4 // For dealing with HTTP GET/POST parameters sent to us as input
5 static public function param ($key, $default = NULL, $type = 'REQUEST') {
6 // PHP 5.4 introduces "just-in-time" initialization of
7 // $GLOBALS. Which seems to me largely to defeat the
8 // purpose of the $GLOBALS array. But whatever. Force
9 // $_GET, $_POST, and $_REQUEST into the array.
10 global $_GET, $_POST, $_REQUEST;
11
12 $where = '_'.strtoupper($type);
13 $ret = $default;
14 if (isset($GLOBALS[$where]) and is_array($GLOBALS[$where])) :
15 if (isset($GLOBALS[$where][$key])) :
16 $ret = $GLOBALS[$where][$key];
17
18 // Magic quotes are like the stupidest
19 // thing ever.
20 if (get_magic_quotes_gpc()) :
21 $ret = self::stripslashes_deep($ret);
22 endif;
23 endif;
24 endif;
25
26 return $ret;
27 } /* MyPHP::param () */
28
29 static function post ($key, $default = NULL) {
30 return self::param($key, $default, 'POST');
31 } /*MyPHP::post () */
32
33 static function get ($key, $default = NULL) {
34 return self::param($key, $default, "GET");
35 } /* MyPHP::get () */
36
37 static function request ($key, $default = NULL) {
38 return self::param($key, $default, "REQUEST");
39 } /* MyPHP::request () */
40
41 static function stripslashes_deep ($value) {
42 if ( is_array($value) ) {
43 $value = array_map(array(__CLASS__, 'stripslashes_deep'), $value);
44 } elseif ( is_object($value) ) {
45 $vars = get_object_vars( $value );
46 foreach ($vars as $key=>$data) {
47 $value->{$key} = stripslashes_deep( $data );
48 }
49 } else {
50 $value = stripslashes($value);
51 }
52 return $value;
53 } /* MyPHP::stripslashes_deep () */
54
55 static function url ($url, $params = array()) {
56 $sep = '?';
57 if (strpos($url, '?') !== false) :
58 $sep = '&';
59 endif;
60 $url .= $sep . self::to_http_post($params);
61
62 return $url;
63 } /* MyPHP::url () */
64
65 /**
66 * MyPHP::to_http_post () -- convert a hash table or object into
67 * an application/x-www-form-urlencoded query string
68 */
69 static function to_http_post ($params) {
70 $getQuery = array();
71 foreach ($params as $key => $value) :
72 if (is_scalar($value)) :
73 $getQuery[] = urlencode($key) . '=' . urlencode($value);
74 else :
75 // Make some attempt to deal with array and
76 // object members. Really we should descend
77 // recursively to get the whole thing....
78 foreach ((array) $value as $k => $v) :
79 $getQuery[] = urlencode($key.'['.$k.']') . '=' . urlencode($v);
80 endforeach;
81 endif;
82 endforeach;
83 return implode("&", $getQuery);
84 } /* MyPHP::to_http_post () */
85 }
86 endif;
87
88
89