1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
<?php /** * SPAW Editor v.2 Utility classes * * @package spaw2 * @subpackage Util * @author Alan Mendelevich <alan@solmetra.lt> * @copyright UAB Solmetra */
/** * Variable access class * * Returns values of variable from global arrays independent of PHP version and settings * @package spaw2 * @subpackage Util */ class SpawVars { /** * Returns GET variable value * @param string $var_name variable name * @param string $empty_value value to return if variable is empty * @returns string * @static */ function getGetVar($var_name, $empty_value='') { global $HTTP_GET_VARS; if (!empty($_GET[$var_name])) return $_GET[$var_name]; elseif (!empty($HTTP_GET_VARS[$var_name])) return $HTTP_GET_VARS[$var_name]; else return $empty_value; }
/** * Returns POST variable value * @param string $var_name variable name * @param string $empty_value value to return if variable is empty * @returns string * @static */ function getPostVar($var_name, $empty_value='') { global $HTTP_POST_VARS; if (!empty($_POST[$var_name])) return $_POST[$var_name]; else if (!empty($HTTP_POST_VARS[$var_name])) return $HTTP_POST_VARS[$var_name]; else return $empty_value; } /** * Returns FILES variable value * @param string $var_name variable name * @param string $empty_value value to return if variable is empty * @returns mixed * @static */ function getFilesVar($var_name, $empty_value='') { global $HTTP_POST_FILES; if (!empty($_FILES[$var_name])) return $_FILES[$var_name]; else if (!empty($HTTP_POST_FILES[$var_name])) return $HTTP_POST_FILES[$var_name]; else return $empty_value; } /** * Returns SERVER variable value * @param string $var_name variable name * @param string $empty_value value to return if variable is empty * @returns string * @static */ function getServerVar($var_name, $empty_value='') { global $HTTP_SERVER_VARS; if (!empty($_SERVER[$var_name])) return $_SERVER[$var_name]; else if (!empty($HTTP_SERVER_VARS[$var_name])) return $HTTP_SERVER_VARS[$var_name]; else return $empty_value; }
/** * Returns SESSION variable value * @param string $var_name variable name * @param string $empty_value value to return if variable is empty * @returns string * @static */ function getSessionVar($var_name, $empty_value='') { global $HTTP_SESSION_VARS; if (!empty($_SESSION[$var_name])) return $_SESSION[$var_name]; else if (!empty($HTTP_SESSION_VARS[$var_name])) return $HTTP_SESSION_VARS[$var_name]; else return $empty_value; }
/** * Sets SESSION variable value * @param string $var_name variable name * @param string $value value to set * @static */ function setSessionVar($var_name, $value='') { global $HTTP_SESSION_VARS; if (isset($_SESSION)) $_SESSION[$var_name] = $value; else if (isset($HTTP_SESSION_VARS)) $HTTP_SESSION_VARS[$var_name] = $value; } /** * Strips slashes from variable if magic_quotes is on * @param string $var variable * @returns string * @static */ function stripSlashes($var) { if (get_magic_quotes_gpc()) { return stripslashes($var); } return $var; }
}
/** * Usupported browser */ define("SPAW_AGENT_UNSUPPORTED", 0); /** * Microsoft Internet Explorer for Windows version 5.5 or higher */ define("SPAW_AGENT_IE", 15); /** * Gecko based browser with engine built on 2003-03-12 or later */ define("SPAW_AGENT_GECKO", 240); /** * Opera 9 or higher */ define("SPAW_AGENT_OPERA", 3840); /** * Safari 3 or higher */ define("SPAW_AGENT_SAFARI", 61440); /** * All supported browsers */ define("SPAW_AGENT_ALL", 65535);
/** * Provides itformation about current user agent (browser) * @package spaw2 * @subpackage Util */ class SpawAgent { /** * Returns constant representing user agent (browser) in SPAW terms * @returns integer * @static * @see SPAW_AGENT_UNSUPPORTED, SPAW_AGENT_IE, SPAW_AGENT_GECKO */ function getAgent() { $result = SPAW_AGENT_UNSUPPORTED; $browser = SpawVars::GetServerVar('HTTP_USER_AGENT'); //echo $browser; // check if msie if (eregi("MSIE[^;]*",$browser,$msie)) { // get version if (eregi("[0-9]+\.[0-9]+",$msie[0],$version)) { // check version if ((float)$version[0]>=5.5) { // finally check if it's not opera impersonating ie if (!eregi("opera",$browser)) { $result = SPAW_AGENT_IE; } } } } elseif (ereg("Gecko/([0-9]*)",$browser,$build)) { // build date of Mozilla version 1.3 is 20030312 if ($build[1] > "20030312") $result = SPAW_AGENT_GECKO; } elseif (eregi("Opera/([0-9]*)", $browser, $opera)) { if ((float)$opera[1] >= 9) $result = SPAW_AGENT_OPERA; } elseif (eregi("Safari/([0-9]*)", $browser, $safari)) { // safari build 500 or higher (safari 3 or newer) if ((float)$safari[1] >= 500) $result = SPAW_AGENT_SAFARI; } return $result; } /** * Returns string representation of current user agent to be used as part of file extension or dir name * @returns string * @static */ function getAgentName() { $result = ''; switch(SpawAgent::getAgent()) { case SPAW_AGENT_IE: $result = 'ie'; break; case SPAW_AGENT_GECKO: $result = 'gecko'; break; case SPAW_AGENT_OPERA: $result = 'opera'; break; case SPAW_AGENT_SAFARI: $result = 'safari'; break; default: $result = ''; break; } return $result; } }
?>
|