Acunetix WP Security - Version 3.0.5

Version Description

Download this release

Release Info

Developer WebsiteDefender
Plugin Icon wp plugin Acunetix WP Security
Version 3.0.5
Comparing to
See all releases

Code changes from version 2.7.4 to 3.0.5

css/wsd.css ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /********************************************************
2
+ * BEGIN >> General styling
3
+ */
4
+ p.wsd-error-summary {
5
+ background-color: #F9EFAC;
6
+ border: 1px dotted #f00;
7
+ color: #DC143C;
8
+ padding: 5px 10px;
9
+ margin: 10px;
10
+ font-weight: bold;
11
+ cursor: default;
12
+ }
13
+
14
+ span.wsd-error-summary-detail {
15
+ color: #000;
16
+ font-weight: normal;
17
+ font-size: 11px;
18
+ cursor: default;
19
+ }
20
+
21
+
22
+ p.wsd-success-summary {
23
+ background-color: #90EE90;
24
+ border: 1px dotted #f00;
25
+ color: #000;
26
+ padding: 5px 10px;
27
+ margin: 10px;
28
+ font-weight: bold;
29
+ cursor: default;
30
+ }
31
+
32
+ span.wsd-success-summary-detail {
33
+ color: #000;
34
+ font-weight: normal;
35
+ font-size: 11px;
36
+ cursor: default;
37
+ }
38
+
39
+
40
+ p.wsd-login-notice {
41
+ font-weight: bold;
42
+ color: #000;
43
+ margin-top: -10px;
44
+ margin-bottom: 20px;
45
+ }
46
+
47
+ .wsd-inside {
48
+ padding: 10px;
49
+ font-family: Verdana, Arial, sans-serif !important;
50
+ font-size: 100% !important;
51
+ }
52
+
53
+ p.wsd-error-summary a, .wsd-inside a {
54
+ color: #CC0000;
55
+ text-decoration: none;
56
+ }
57
+
58
+ p.wsd-error-summary a:hover, .wsd-inside a:hover {
59
+ color: #CC0000;
60
+ text-decoration: underline;
61
+ }
62
+
63
+ /********************************************************
64
+ * BEGIN >> Login form styling
65
+ */
66
+ #wsd_login_form {
67
+ margin: 0px;
68
+ }
69
+
70
+ #wsd_login_form .wsd-login-section {
71
+ display: block;
72
+ float: left;
73
+ width: 100%;
74
+ margin-bottom: 5px;
75
+ }
76
+
77
+ #wsd_login_form .wsd-login-section label {
78
+ display: block;
79
+ float: left;
80
+ width: 70px;
81
+ padding-top: 6px;
82
+ }
83
+
84
+ #wsd_login_form .wsd-login-section input {
85
+ display: block;
86
+ width: 200px;
87
+ float: left;
88
+ }
89
+
90
+ #wsd_login_form #wsd-login {
91
+ clear: left;
92
+ margin-left: 70px;
93
+ }
94
+
95
+
96
+
97
+ /********************************************************
98
+ * BEGIN >> Registration form styling
99
+ */
100
+ #wsd_new_user_form {
101
+ margin: 0px;
102
+ }
103
+
104
+ #wsd_new_user_form .wsd-new-user-section {
105
+ display: block;
106
+ float: left;
107
+ width: 100%;
108
+ margin-bottom: 5px;
109
+ }
110
+
111
+ #wsd_new_user_form .wsd-new-user-section label {
112
+ display: block;
113
+ float: left;
114
+ width: 120px;
115
+ padding-top: 6px;
116
+ }
117
+
118
+ #wsd_new_user_form .wsd-new-user-section input {
119
+ display: block;
120
+ width: 200px;
121
+ float: left;
122
+ }
123
+
124
+ #wsd_new_user_form #wsd-login {
125
+ clear: left;
126
+ margin-left: 70px;
127
+ }
128
+
129
+
130
+
131
+ /********************************************************
132
+ * BEGIN >> Initial scan widget styling
133
+ */
134
+ #wsd-information-scan-list {
135
+ list-style-type: disc;
136
+ margin: 10px;
137
+ padding-left: 20px;
138
+ }
139
+
140
+
141
+
142
+ #wsd-initial-scan { }
143
+
144
+ #wsd-initial-scan .wsd-initial-scan-section {
145
+ line-height: 1.4em;
146
+ display: block;
147
+ color: #090;
148
+ }
149
+
150
+
151
+ /********************************************************
152
+ * BEGIN >> Target update form styling
153
+ */
154
+ #wsd_target_id_form {
155
+ width: 100%;
156
+ }
157
+
158
+ #wsd_target_id_form #targetid {
159
+ width: 300px;
160
+ }
161
+
162
+
163
+
164
+ /********************************************************
165
+ * BEGIN >> Status content styling
166
+ */
167
+ div#wsd-target-status-holder {
168
+ overflow: hidden;
169
+ }
170
+
171
+ p.wsd-target-status-title {
172
+ font-weight: bold;
173
+ }
174
+
175
+ div.wsd-target-status-section {
176
+ display: block;
177
+ float: left;
178
+ margin-right: 5px;
179
+ }
180
+
181
+ span.wsd-target-status-section-label {
182
+ display: block;
183
+ padding: 5px 4px;
184
+ float: left;
185
+ color: #999999
186
+ }
187
+
188
+ span.wsd-target-status-section-enabled {
189
+ display: block;
190
+ padding: 5px 0px;
191
+ background-color: #0f0;
192
+ color: #000;
193
+ float: left;
194
+ width: 50px;
195
+ height: 24px;
196
+ border-radius: 3px;
197
+ -moz-border-radius: 3px;
198
+ -webkit-border-radius: 3px;
199
+ text-align: center;
200
+ font-weight: bold;
201
+
202
+ background: url('../images/agent-green.png') no-repeat scroll left top transparent;
203
+ }
204
+
205
+ span.wsd-target-status-section-disabled {
206
+ display: block;
207
+ padding: 5px 0px;
208
+ background-color: #f00;
209
+ color: #fff;
210
+ float: left;
211
+ width: 50px;
212
+ height: 24px;
213
+ border-radius: 3px;
214
+ -moz-border-radius: 3px;
215
+ -webkit-border-radius: 3px;
216
+ text-align: center;
217
+ font-weight: bold;
218
+
219
+ background: url('../images/agent-red.png') no-repeat scroll left top transparent;
220
+ }
221
+
222
+
223
+
224
+
225
+ /********************************************************
226
+ * BEGIN >> Password meter styling
227
+ */
228
+ #wsd_new_user_form label.password-meter {
229
+ display: none;
230
+ -webkit-border-radius: 3px;
231
+ -moz-border-radius: 3px;
232
+ font-weight: bolder;
233
+ border-radius: 3px;
234
+ text-align: center;
235
+ font-size: 12px;
236
+ color: #000;
237
+ width: 80px;
238
+ margin-left: 20px;
239
+ padding: 4px;
240
+ cursor: default;
241
+ }
242
+
243
+
244
+ /*
245
+ * 3.0.2
246
+ */
247
+ .scanpass { color: #090; }
248
+
249
+ .mrt_wpss_note {
250
+ text-align: center;
251
+ color: grey;
252
+ margin-top: 20px;
253
+ margin-bottom: 20px;
254
+ }
255
+
256
+ .wpss_icon {
257
+ background: url(../images/wsd-logo.png) no-repeat left center;
258
+ margin-top: 10px !important;
259
+ padding: 5px 0 3px 50px !important;
260
+ }
261
+
262
+ .wsd_user_notify {
263
+ border: solid 1px #fc0; background: #ffc;
264
+ padding: 5px 5px;
265
+ font-size: 100%;
266
+ }
267
+ .wsd_user_information {
268
+ border: solid 1px #324FB2; background: #E5EAF0;
269
+ padding: 5px 5px;
270
+ font-size: 100%;
271
+ }
272
+ .wsd_user_success {
273
+ border: solid 1px #030; background: #090;
274
+ padding: 5px 5px;
275
+ font-size: 100%;
276
+ color: #fff;
277
+ }
278
+ .wsd_info_list {
279
+ list-style-type: disc;
280
+ list-style-position: outside;
281
+ margin: 0 0 10px 25px;
282
+ }
283
+ div.wsd_user_information, div.wsd_user_notify, div.wsd_user_success { margin: 1em 0 !important; }
284
+
285
+ #Words { overflow: hidden; min-height: 1px; margin: 0 0 0 0 !important; padding: 0 0 0 0 !important; }
286
+ #Words p { float: left; display: block; width: 150px; line-height: normal !important; padding: 0 0 0 0; margin: 6px 0 0 0 !important; }
287
+ #Words p.indicator { height: 4px; }
288
+ #Words p.indicator-1 { background: #f00;}
289
+ #Words p.indicator-2 { background: #990000; }
290
+ #Words p.indicator-3 { background: #990099; }
291
+ #Words p.indicator-4 { background: #000099; }
292
+ #Words p.indicator-5 { background: #0000ff; }
293
+ #Words p.indicator-6 { background: #ffffff; }
294
+ #Words p+p {margin: 0 0 0 5px !important; padding: 0 0 0 0 !important; line-height: normal !important;}
295
+ #wsd_pwdtool { margin-top: 10px; }
296
+
297
+ .wsd_commonList {
298
+ list-style-type: none;
299
+ margin: 0 0 10px 0;
300
+ padding-left: 0;
301
+ }
302
+ .wsd_commonList li {
303
+ font-style: italic !important;
304
+ background: url('../images/wsd-logo-small-list.png') no-repeat 0 50%;
305
+ padding: 2px 0 2px 20px !important;
306
+ }
307
+
308
+ .wsd-inside p, .wsd-inside ul, .wsd-inside ol, .wsd-inside blockquote, .wsd-inside input, .wsd-inside select {
309
+ font-size: 100%;
310
+ }
311
+
312
+ .wsd-inside, .wsd-inside p, .wsd-inside li, .wsd-inside dl, .wsd-inside dd, .wsd-inside dt {
313
+ line-height: normal !important;
314
+ }
315
+
316
+ #wsd_db_wrapper .inner-sidebar1 { margin: 10px 10px 0 10px; }
317
+ #wsd_db_wrapper, #wsd_db_wrapper .metabox-holder {overflow:hidden; min-height:1px; }
318
+ #wsd_permissions_table { margin: 15px 0; }
319
+ #wsd_permissions_table th,
320
+ #wsd_permissions_table td { text-align: left; }
321
+ #wsd_permissions_table td { padding: 1px 7px;}
322
+ #wsd_tables_list_block { clear: both;}
323
+
324
+ .wsd_cursor_help { cursor: help; border-bottom: dotted 1px #000; }
325
+
326
+
327
+
328
+
329
+
database.php DELETED
@@ -1,162 +0,0 @@
1
- <?php
2
- /*
3
- Thank you Philipp Heinze.
4
- */
5
-
6
- function mrt_sub3(){
7
- ?>
8
- <div class=wrap>
9
- <h2><?php _e('WP - Database Security') ?></h2>
10
- <div style="height:299px"><br />
11
- <h3><i>Make a backup of your database before using this tool:</i></h3>
12
-
13
- <?php /*global $wpdb;
14
- $mrtright = $wpdb->get_results("SHOW GRANTS FOR '".DB_USER."'@'".DB_HOST."'", ARRAY_N);
15
- echo "rights: ";
16
- print_r($mrtright);*/
17
- ?>
18
-
19
- <p>Change your database table prefix to mitigate zero-day SQL Injection attacks.</p>
20
- <p><b>Before running this script:</b>
21
- <ul><li>wp-config must be set to writable before running this script.</li>
22
- <li>the database user you're using with WordPress must have ALTER rights</li></ul>
23
-
24
- <form action='' method='post' name='prefixchanging'>
25
- <?php
26
- if (function_exists('wp_nonce_field')) {
27
- wp_nonce_field('prefix-changer-change_prefix');
28
- }
29
- ?>
30
- Change the current:<input type="Text" name="prefix_n" value="<?php echo($GLOBALS['table_prefix']);?>" size="20" maxlength="50"> prefix to something different if it's the default wp_<br />
31
- Allowed Chars are all latin Alphanumeric Chars as well as the Chars <strong>-</strong> and <strong>_</strong>.
32
- <input type='submit' name='renameprefix' value='Start Renaming'/>
33
- </form>
34
-
35
- <?php
36
- if (isset($_POST['prefix_n'])) {
37
- check_admin_referer('prefix-changer-change_prefix');
38
- $wpdb =& $GLOBALS['wpdb'];
39
- $newpref = ereg_replace("[^0-9a-zA-Z_-]", "", $_POST['prefix_n']);
40
- //checking if user has enough rights to alter the Tablestructure
41
- $rights = $wpdb->get_results("SHOW GRANTS FOR '".DB_USER."'@'".DB_HOST."'", ARRAY_N);
42
- foreach ($rights as $right) {
43
- if (ereg("ALTER(.*)(\*|`".str_replace("_", "\\_", DB_NAME)."`)\.(\*|`".DB_HOST."`) TO '".DB_USER."'@'".DB_HOST."'", $right[0]) || ereg("ALL PRIVILEGES ON (\*|`".str_replace("_", "\\_", DB_NAME)."`)\.(\*|`".DB_HOST."`) TO '".DB_USER."'@'".DB_HOST."'", $right[0])) {
44
- $rightsenough = true;
45
- $rightstomuch = true;
46
- break;
47
- } else {
48
- if (ereg("ALTER(.*)`".DB_NAME."`", $right[0])) {
49
- $rightsenough = true;
50
- break;
51
- }
52
- }
53
- }
54
- if (!isset($rightsenough) && $rightsenough != true) {
55
- exit('<font color="#ff0000">Your User which is used to access your Wordpress Tables/Database, hasn\'t enough rights( is missing ALTER-right) to alter your Tablestructure. Please visit the plugin <a href="http://semperfiwebdesign.com/documentation/wp-security-scan/change-wordpress-database-table-name-prefix/" target=_blank">documentation</a> for more information. If you believe you have alter rights, please <a href="http://semperfiwebdesign.com/contact/">contact</a> the plugin author for assistance.<br />');
56
- }
57
- if (isset($rightstomuch) && $rightstomuch === true) {
58
- echo ('<font color="#FF9B05">Your currently used User to Access the Wordpress Database, holds too many rights. '.
59
- 'We suggest that you limit his rights or to use another User with more limited rights instead, to increase your Security.</font><br />');
60
- }
61
- if ($newpref == $GLOBALS['table_prefix']) {
62
- exit ("No change: Please select a new table_prefix value.</div>");
63
- } elseif (strlen($newpref) < strlen($_POST['prefix_n'])){
64
- echo ("You used some Chars which aren't allowed within Tablenames".
65
- "The sanitized prefix is used instead: " . $newpref);
66
- }
67
-
68
- echo("<h2>Started Prefix Changer:</h2>");
69
-
70
- //we rename the tables before we change the Config file, so We can aviod changed Configs, without changed prefixes.
71
- echo("<h3>&nbsp;&nbsp;Start Renaming of Tables:</h3>");
72
- $oldtables = $wpdb->get_results("SHOW TABLES LIKE '".$GLOBALS['table_prefix']."%'", ARRAY_N);//retrieving all tables named with the prefix on start
73
- $table_c = count($oldtables);
74
- $table_s = 0;//holds the count of successful changed tables.
75
- $table_f[] = '';//holds all table names which failed to be changed
76
- for($i = 0; $i < $table_c; $i++) {//renaming each table to the new prefix
77
- $wpdb->hide_errors();
78
- $table_n = str_replace($GLOBALS['table_prefix'], $newpref, $oldtables[$i][0]);
79
- echo "&nbsp;&nbsp;&nbsp;Renaming ".$oldtables[$i][0]." to $table_n:";
80
- $table_r = $wpdb->query("RENAME TABLE ".$oldtables[$i][0]." TO $table_n");
81
- if ($table_r === 0) {
82
- echo ('<font color="#00ff00"> Success</font><br />');
83
- $table_s++;
84
- } elseif ($table_r === FALSE) {
85
- echo ('<font color="#ff0000"> Failed</font><br />');
86
- $table_f[] = $oldtables[$i][0];
87
- }
88
- }//changing some "hardcoded" wp values within the tables
89
- echo ("<h3>&nbsp;&nbsp;Start changing Databasesettings:</h3>");
90
- if ($wpdb->query($wpdb->prepare("UPDATE ".$newpref."options SET option_name='".$newpref."user_roles' WHERE option_name='".$GLOBALS['table_prefix']."user_roles' LIMIT 1")) <> 1) {
91
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$newpref.'options: 1/1 <font color="#ff0000">Failed</font><br />');
92
- } else {
93
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'options 1/1: <font color="#00ff00">Success</font><br />');
94
- }
95
- if ($wpdb->query($wpdb->prepare("UPDATE ".$newpref."usermeta SET meta_key='".$newpref."capabilities' WHERE meta_key='".$GLOBALS['table_prefix']."capabilities'") <> 1)) {
96
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 1/3: <font color="#ff0000">Failed</font><br />');
97
- } else {
98
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 1/3: <font color="#00ff00">Success</font><br />');
99
- }
100
- if ($wpdb->query($wpdb->prepare("UPDATE ".$newpref."usermeta SET meta_key='".$newpref."user_level' WHERE meta_key='".$GLOBALS['table_prefix']."user_level'")) === FALSE)
101
- {
102
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 2/3: <font color="#ff0000">Failed</font><br />');
103
- } else {
104
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 2/3: <font color="#00ff00">Success</font><br />');
105
- }
106
- if ($wpdb->query($wpdb->prepare("UPDATE ".$newpref."usermeta SET meta_key='".$newpref."autosave_draft_ids' WHERE meta_key='".$GLOBALS['table_prefix']."autosave_draft_ids'")) === 0) {
107
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 3/3: <font color="#000000">Value doesn\'t exist</font><br />');
108
- } else {
109
- echo ('&nbsp;&nbsp;&nbsp;Changing values in table '.$GLOBALS['table_prefix'].'usermeta 3/3: <font color="#00ff00">Success</font><br />');
110
- }
111
-
112
- if ($table_s == 0) {
113
- exit('<font color="#ff0000">Some Error occured, it wasn\'t possible to change any Tableprefix. Please retry, no changes are done to your wp-config File.</font><br />');
114
- } elseif ($table_s < $table_c) {
115
- echo('<font color="#ff0000">It wasn\'t possible to rename some of your Tables prefix. Please change them manually. Following you\'ll see all failed tables:<br />');
116
- for ($i = 1; $i < count($tables_f); $i++) {
117
- echo ($tables_f[$i])."<br />";
118
- }
119
- exit('No changes where done to your wp-config File.</font><br />');
120
- }
121
-
122
- echo("<h3>Changing Config File:</h3>");
123
- $conf_f = "../wp-config.php";
124
-
125
- @chmod($conf_f, 0777);//making the the config readable to change the prefix
126
- if (!is_writeable($conf_f)) {//when automatic config file changing isn't possible the user get's all needed information to do it manually
127
- echo('&nbsp;&nbsp;1/1 file writeable: <font color="#ff0000">Not Writeable</font><br />');
128
- echo('<b>Please make your wp-config.php file writable for this process.</b>');
129
- die("</div>");
130
- } else {//changing if possible the config file automatically
131
- echo('&nbsp;&nbsp;1/3 file writeable: <font color="#00ff00"> Writeable</font><br />');
132
- $handle = @fopen($conf_f, "r+");
133
- if ($handle) {
134
- while (!feof($handle)) {
135
- $lines[] = fgets($handle, 4096);
136
- }//while feof
137
- fclose($handle);
138
- $handle = @fopen($conf_f, "w+");
139
- foreach ($lines as $line) {
140
- if (strpos($line, $GLOBALS['table_prefix'])) {
141
- $line = str_replace($GLOBALS['table_prefix'], $newpref, $line);
142
- echo('&nbsp;&nbsp;2/3 <font color="#00ff00">table prefix changed!</font><br />');
143
- }//if strpos
144
- fwrite($handle, $line);
145
- }//foreach $lines
146
- fclose($handle);
147
- if (chmod ($conf_f, 0644)) {
148
- echo('&nbsp;&nbsp;3/3 <font color="#00ff00">Config files permission set to 644, for security purpose.</font><br />');
149
- } else {
150
- echo ('&nbsp;&nbsp;3/3 wasn\'t able to set chmod to 644, please check if your files permission is set back to 644!<br />');
151
- }//if chmod
152
- }//if handle
153
- }//if is_writeable
154
-
155
- }//if prefix
156
- ?>
157
- </div>
158
- Plugin by <a href="http://semperfiwebdesign.com/" title="Semper Fi Web Design">Semper Fi Web Design</a>
159
- </div>
160
- <?php
161
- }//function prefix_changer
162
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
-
3
- function make_seed() {
4
- list($usec, $sec) = explode(' ', microtime());
5
- return (float) $sec + ((float) $usec * 100000);
6
- }
7
-
8
- function make_password($password_length){
9
- srand(make_seed());
10
- $alfa = "!@123!@4567!@890qwer!@tyuiopa@!sdfghjkl@!zxcvbn@!mQWERTYUIO@!PASDFGH@!JKLZXCVBNM!@";
11
- $token = "";
12
- for($i = 0; $i < $password_length; $i ++) {
13
- $token .= $alfa[rand(0, strlen($alfa))];
14
- }
15
- return $token;
16
- }
17
-
18
- function check_perms($name,$path,$perm)
19
- {
20
- clearstatcache();
21
- // $configmod = fileperms($path);
22
- $configmod = substr(sprintf(".%o.", fileperms($path)), -4);
23
- $trcss = (($configmod != $perm) ? "background-color:#fd7a7a;" : "background-color:#91f587;");
24
- echo "<tr style=".$trcss.">";
25
- echo '<td style="border:0px;">' . $name . "</td>";
26
- echo '<td style="border:0px;">'. $path ."</td>";
27
- echo '<td style="border:0px;">' . $perm . '</td>';
28
- echo '<td style="border:0px;">' . $configmod . '</td>';
29
- // echo '<td style="border:0px;">' . '<input type="submit" name="' . $perm . '" value="Change now.">' . '</td>';
30
- echo "</tr>";
31
- }
32
-
33
- function mrt_get_serverinfo() {
34
- global $wpdb;
35
- $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
36
- $mysqlinfo = $wpdb->get_results("SHOW VARIABLES LIKE 'sql_mode'");
37
- if (is_array($mysqlinfo)) $sql_mode = $mysqlinfo[0]->Value;
38
- if (empty($sql_mode)) $sql_mode = __('Not set');
39
- if(ini_get('safe_mode')) $safe_mode = __('On');
40
- else $safe_mode = __('Off');
41
- if(ini_get('allow_url_fopen')) $allow_url_fopen = __('On');
42
- else $allow_url_fopen = __('Off');
43
- if(ini_get('upload_max_filesize')) $upload_max = ini_get('upload_max_filesize');
44
- else $upload_max = __('N/A');
45
- if(ini_get('post_max_size')) $post_max = ini_get('post_max_size');
46
- else $post_max = __('N/A');
47
- if(ini_get('max_execution_time')) $max_execute = ini_get('max_execution_time');
48
- else $max_execute = __('N/A');
49
- if(ini_get('memory_limit')) $memory_limit = ini_get('memory_limit');
50
- else $memory_limit = __('N/A');
51
- if (function_exists('memory_get_usage')) $memory_usage = round(memory_get_usage() / 1024 / 1024, 2) . __(' MByte');
52
- else $memory_usage = __('N/A');
53
- if (is_callable('exif_read_data')) $exif = __('Yes'). " ( V" . substr(phpversion('exif'),0,4) . ")" ;
54
- else $exif = __('No');
55
- if (is_callable('iptcparse')) $iptc = __('Yes');
56
- else $iptc = __('No');
57
- if (is_callable('xml_parser_create')) $xml = __('Yes');
58
- else $xml = __('No');
59
-
60
- ?>
61
- <li><?php _e('Operating System'); ?> : <strong><?php echo PHP_OS; ?></strong></li>
62
- <li><?php _e('Server'); ?> : <strong><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></strong></li>
63
- <li><?php _e('Memory usage'); ?> : <strong><?php echo $memory_usage; ?></strong></li>
64
- <li><?php _e('MYSQL Version'); ?> : <strong><?php echo $sqlversion; ?></strong></li>
65
- <li><?php _e('SQL Mode'); ?> : <strong><?php echo $sql_mode; ?></strong></li>
66
- <li><?php _e('PHP Version'); ?> : <strong><?php echo PHP_VERSION; ?></strong></li>
67
- <li><?php _e('PHP Safe Mode'); ?> : <strong><?php echo $safe_mode; ?></strong></li>
68
- <li><?php _e('PHP Allow URL fopen'); ?> : <strong><?php echo $allow_url_fopen; ?></strong></li>
69
- <li><?php _e('PHP Memory Limit'); ?> : <strong><?php echo $memory_limit; ?></strong></li>
70
- <li><?php _e('PHP Max Upload Size'); ?> : <strong><?php echo $upload_max; ?></strong></li>
71
- <li><?php _e('PHP Max Post Size'); ?> : <strong><?php echo $post_max; ?></strong></li>
72
- <li><?php _e('PHP Max Script Execute Time'); ?> : <strong><?php echo $max_execute; ?>s</strong></li>
73
- <li><?php _e('PHP Exif support'); ?> : <strong><?php echo $exif; ?></strong></li>
74
- <li><?php _e('PHP IPTC support'); ?> : <strong><?php echo $iptc; ?></strong></li>
75
- <li><?php _e('PHP XML support'); ?> : <strong><?php echo $xml; ?></strong></li>
76
- <?php
77
- }
78
-
79
- function mrt_check_table_prefix(){
80
- if($GLOBALS['table_prefix']=='wp_'){
81
- echo '<font color="red">Your table prefix should not be <i>wp_</i>. <a href="admin.php?page=database">Click here</a> to change it.</font><br />';
82
- }else{
83
- echo '<font color="green">Your table prefix is not <i>wp_</i>.</font><br />';
84
- }
85
- }
86
-
87
- function mrt_errorsoff(){
88
- echo '<font color="green">WordPress DB Errors turned off.</font><br />';
89
- }
90
-
91
- function mrt_wpdberrors()
92
- {
93
- global $wpdb;
94
- $wpdb->show_errors = false;
95
-
96
- }
97
-
98
- function mrt_version_removal(){
99
- global $wp_version;
100
- echo '<font color="green">Your WordPress version is successfully hidden.</font><br />';
101
- }
102
-
103
- function mrt_remove_wp_version()
104
- {
105
-
106
- function filter_generator( $gen, $type ) {
107
- switch ( $type ) {
108
- case 'html':
109
- $gen = '<meta name="generator" content="WordPress">';
110
- break;
111
- case 'xhtml':
112
- $gen = '<meta name="generator" content="WordPress" />';
113
- break;
114
- case 'atom':
115
- $gen = '<generator uri="http://wordpress.org/">WordPress</generator>';
116
- break;
117
- case 'rss2':
118
- $gen = '<generator>http://wordpress.org/?v=</generator>';
119
- break;
120
- case 'rdf':
121
- $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=" />';
122
- break;
123
- case 'comment':
124
- $gen = '<!-- generator="WordPress" -->';
125
- break;
126
- }
127
- return $gen;
128
- }
129
- foreach ( array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment' ) as $type )
130
- add_filter( "get_the_generator_$type", 'filter_generator', 10, 2 );
131
-
132
-
133
- }
134
-
135
- function mrt_check_version(){
136
- //echo "WordPress Version: ";
137
- global $wp_version;
138
- $mrt_wp_ver = ereg_replace("[^0-9]", "", $wp_version);
139
- while ($mrt_wp_ver > 10){
140
- $mrt_wp_ver = $mrt_wp_ver/10;
141
- }
142
- if ($mrt_wp_ver >= "2.8") $g2k5 = '<font color="green"><strong>WordPress version: ' . $wp_version . '</strong> &nbsp;&nbsp;&nbsp; You have the latest stable version of WordPress.</font><br />';
143
- if ($mrt_wp_ver < "2.8") $g2k5 = '<font color="red"><strong>WordPress version: ' . $wp_version . '</strong> &nbsp;&nbsp;&nbsp; You need version 2.8.6. Please <a href="http://wordpress.org/download/">upgrade</a> immediately.</font><br />';
144
- /*echo "<b>" . $wp_version . "</b> &nbsp;&nbsp;&nbsp " ;*/echo $g2k5;
145
- }
146
-
147
-
148
- function mrt_javascript(){
149
- $siteurl = get_option('siteurl');
150
- ?><script language="JavaScript" type="text/javascript" src="<?php echo WP_PLUGIN_DIR;?>/wp-security-scan/js/scripts.js"></script><?php
151
- }?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/acunetix.png ADDED
Binary file
images/agent-green.png ADDED
Binary file
images/agent-red.png ADDED
Binary file
images/bt.gif DELETED
Binary file
images/facebook.gif ADDED
Binary file
images/iblogpro.jpg DELETED
Binary file
images/loading45.gif ADDED
Binary file
images/pagelines.jpg DELETED
Binary file
images/whitehouse.jpg DELETED
Binary file
images/wpss_icon_large.png ADDED
Binary file
lock.png → images/wpss_icon_small_combined.png RENAMED
Binary file
images/wsd-logo-small-list.png ADDED
Binary file
images/wsd-logo-small.png ADDED
Binary file
images/wsd-logo.png ADDED
Binary file
inc/admin/db.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function mrt_sub3()
3
+ {
4
+ // Show header
5
+ mrt_wpss_menu_head('WP - Database Security');
6
+
7
+ $wsd_wpConfigFile = ABSPATH.'wp-config.php';
8
+
9
+ // internal flag
10
+ $canLoadPage = false;
11
+ if (wsd_wpConfigCheckPermissions($wsd_wpConfigFile)) {
12
+ $canLoadPage = true;
13
+ }
14
+ ?>
15
+ <p class="wsd_user_notify">
16
+ <strong>Important</strong>: Make a backup of your database before using this tool!
17
+ </p>
18
+ <?php
19
+ if (!$canLoadPage) {
20
+ // Display the error message
21
+ echo wsd_eInfo('
22
+ The <strong>wp-config.php</strong> file MUST be writable in order to perform this action.
23
+ You have to manually change permissions for this file.');
24
+ }
25
+ ?>
26
+
27
+
28
+ <?php /*[ BEGIN PAGE DATABASE ]*/ ?>
29
+ <div id="wsd_db_wrapper">
30
+ <?php
31
+ /* Display the Database backup page */
32
+ echo wsd_getTemplate('db-backup');
33
+ ?>
34
+
35
+ <br/>
36
+ <div style="clear:both;"></div>
37
+
38
+ <?php
39
+ /* Stop here if the wp-config file is not writable or if we cannot change its permissions */
40
+ if ($canLoadPage)
41
+ {
42
+ // Display the Change Database Table prefix page
43
+ echo wsd_getTemplate('db-change-prefix',array(
44
+ 'wsd_wpConfigFile' => $wsd_wpConfigFile,
45
+ 'old_prefix' => $GLOBALS['table_prefix'],
46
+ 'new_prefix' => (empty($_POST['newPrefixInput']) ? '' : $_POST['newPrefixInput']),
47
+ 'isPostBack' => (($_SERVER['REQUEST_METHOD'] == 'POST') ? true : false)
48
+ ));
49
+ }
50
+ ?>
51
+ </div>
52
+ <?php /*[ END PAGE DATABASE ]*/ ?>
53
+
54
+ <p style="height:200px;"></p>
55
+
56
+ <?php
57
+ // Show footer
58
+ mrt_wpss_menu_footer();
59
+ }//function mrt_sub3
60
+ ?>
inc/admin/pwtool.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function mrt_sub1(){
3
+
4
+ mrt_wpss_menu_head('WP - Password Tools');
5
+
6
+ ?>
7
+
8
+ <div style="height:299px">
9
+ <?php
10
+ echo "<br /><strong>Password Strength Tool</strong>";
11
+ ?>
12
+ <table id="wsd_pwdtool">
13
+ <tr valign="top">
14
+ <td>
15
+ <form name="commandForm">
16
+ Type password: <input type="password" size="30" maxlength="50" name="password" onkeyup="testPassword(this.value);" value="" />
17
+ <br/>
18
+ <span style="color:#808080">Minimum 6 Characters</span>
19
+ </form>
20
+ </td>
21
+ <td style="padding-left: 6px;">
22
+ <span>Password Strength:</span>
23
+ <div id="Words">
24
+ <p class="indicator"></p>
25
+ <p><strong>Begin Typing</strong></p>
26
+ </div>
27
+ </td>
28
+ </tr>
29
+ </table>
30
+
31
+ <br /><hr align="left" size="2" width="612px" />
32
+ <?php
33
+ echo "<br /><br /><strong>Strong Password Generator</strong><br />";
34
+ echo "Strong Password: " . '<span style="color:#f00;">' . make_password(15) . "</span>";
35
+ ?>
36
+ </div>
37
+
38
+ <?php
39
+ mrt_wpss_menu_footer();
40
+
41
+ } ?>
inc/admin/scanner.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function mrt_sub0(){
3
+
4
+ mrt_wpss_menu_head('WP - Security Scan');?>
5
+
6
+ <div>
7
+ <table id="wsd_permissions_table" width="100%" border="0" cellspacing="0" cellpadding="3" style="text-align:center;">
8
+ <thead>
9
+ <th style="border:0px;"><b>Name</b></th>
10
+ <th style="border:0px;"><b>File/Dir</b></th>
11
+ <th style="border:0px;"><b>Needed Chmod</b></th>
12
+ <th style="border:0px;"><b>Current Chmod</b></th>
13
+ </thead>
14
+ <tbody>
15
+ <?php
16
+ // DIR_NAME | DIR_PATH | EXPECTED_PERMISSION
17
+ check_perms("root directory","../","0755");
18
+ check_perms("wp-includes/","../wp-includes","0755");
19
+ check_perms(".htaccess","../.htaccess","0644");
20
+ check_perms("wp-admin/index.php","index.php","0644");
21
+ check_perms("wp-admin/js/","js/","0755");
22
+ check_perms("wp-content/themes/","../wp-content/themes","0755");
23
+ check_perms("wp-content/plugins/","../wp-content/plugins","0755");
24
+ check_perms("wp-admin/","../wp-admin","0755");
25
+ check_perms("wp-content/","../wp-content","0755");
26
+ ?>
27
+ </tbody>
28
+ </table>
29
+
30
+ </div>
31
+ <?php
32
+ mrt_wpss_menu_footer();
33
+ } ?>
inc/admin/security.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function mrt_opt_mng_pg() {
4
+ mrt_wpss_menu_head('WP-Security Admin tools by WebsiteDefender');
5
+
6
+ add_meta_box("wpss_mrt_1", 'Initial Scan', "wpss_mrt_meta_box", "wpss");
7
+ add_meta_box("wpss_mrt_2", 'System Information Scan', "wpss_mrt_meta_box2", "wpss2");
8
+ add_meta_box("wpss_mrt_3", 'About Website Defender', "wsd_render_main", "wpss_wsd");
9
+
10
+ echo '
11
+ <div class="metabox-holder">
12
+ <div style="float:left; width:48%;" class="inner-sidebar1">';
13
+
14
+ do_meta_boxes('wpss','advanced','');
15
+ do_meta_boxes('wpss2','advanced','');
16
+
17
+ echo '
18
+ </div>
19
+ <div style="float:right;width:48%;" class="inner-sidebar1">';
20
+ do_meta_boxes('wpss_wsd','advanced','');
21
+ echo '
22
+ </div>
23
+
24
+ <div style="clear:both"></div>
25
+ </div>';
26
+
27
+ mrt_wpss_menu_footer();
28
+
29
+ }
30
+ ?>
inc/admin/support.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function mrt_sub2()
3
+ {
4
+ mrt_wpss_menu_head('WP - Security Support');
5
+ ?>
6
+ <div>
7
+ <br/>
8
+ <p>Under Construction...</p>
9
+ <br /><br />
10
+ <ul>
11
+ <li><a href='http://www.websitedefender.com/category/faq/' target="_blank">Documentation</a></li>
12
+ </ul>
13
+ <br /><br />
14
+ <strong>Backup early, backup often!</strong>
15
+ <br /><br /><br /><br /><br />
16
+ </div>
17
+
18
+ <?php
19
+ mrt_wpss_menu_footer();
20
+ }
21
+ ?>
inc/admin/templates/db-backup.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Backup Database
4
+ */
5
+ ?>
6
+ <?php
7
+ /*
8
+ * BACKUP DATABASE SECTION
9
+ */
10
+ ?>
11
+ <br/><br/>
12
+ <h2 class="wpss_icon">Backup your database</h2>
13
+
14
+ <?php
15
+ /*
16
+ * Check if the backups directory is writable
17
+ */
18
+ $wsd_bckDirPath = ABSPATH.PLUGINDIR.'/wp-security-scan/backups/';
19
+ if (is_dir($wsd_bckDirPath) && is_writable($wsd_bckDirPath)) :
20
+ ?>
21
+
22
+ <div style="padding: 7px 7px; margin: 10px 10px;">
23
+ <form action="#bck" method="post">
24
+ <input type="hidden" name="wsd_db_backup"/>
25
+ <input type="submit" name="backupDatabaseButton" value="Backup now!"/>
26
+ </form>
27
+ </div>
28
+
29
+ <?php
30
+ if ($_SERVER['REQUEST_METHOD'] == 'POST')
31
+ {
32
+ if (isset($_POST['wsd_db_backup']))
33
+ {
34
+ $tables = '*';
35
+ if (isset($_POST['tables'])) {
36
+ $tables = implode(',',$_POST['tables']);
37
+ }
38
+
39
+ if (($fname = wsd_backupDatabase($tables)) <> '') {
40
+ echo '<p id="bck" class="wsd_user_success">';
41
+ echo '<span style="color:#fff;">Database successfully backed up!</span>';
42
+ echo '<br/><span style="color:#fff;">Download backup file: </span>';
43
+ echo '<a href="',get_option('siteurl'),'/wp-content/plugins/wp-security-scan/backups/',$fname,'" style="color:#0f0">',$fname,'</a>';
44
+ echo '</p>';
45
+ }
46
+ else {
47
+ echo '<p id="bck" class="wsd_user_notify">';
48
+ echo 'The database could not be backed up!';
49
+ echo '<br/>A posible error might be that you didn\'t set up writing permissions for the backups directory!';
50
+ echo '</p>';
51
+ }
52
+ }
53
+ }
54
+ ?>
55
+ <?php else :
56
+ // The directory is not writable. Display info message
57
+ echo wsd_eInfo('<strong>Important</strong>: The <strong title="'.$wsd_bckDirPath.'" class="wsd_cursor_help">backups</strong> directory must be writable in order to use this functionality!');
58
+ endif; ?>
59
+
60
+
61
+
62
+ <?php
63
+ /*
64
+ * DISPLAY AVAILABLE DOWNLOADS
65
+ */
66
+ ?>
67
+ <?php
68
+ function wsd_db_download_list()
69
+ {
70
+ echo '<div>';
71
+ $files = wsd_getAvailableBackupFiles();
72
+ if (empty($files)) {
73
+ echo '<p style="margin:5px 5px;">There are no backup files available for download yet!</p>';
74
+ }
75
+ else {
76
+ echo '<ul id="wsd-information-scan-list">';
77
+ foreach($files as $fileName) {
78
+ echo '<li>';
79
+ echo '<a href="',get_option('siteurl'),'/wp-content/plugins/wp-security-scan/backups/',$fileName,'">',$fileName,'</a>';
80
+ echo '</li>';
81
+ }
82
+ echo '</ul>';
83
+ }
84
+ echo '</div>';
85
+ }
86
+ add_meta_box("wpss_mrt_1", 'Available database backups', "wsd_db_download_list", "wsd_db_bck_dwl");
87
+ echo '<div style="float:left; width:50%;" class="inner-sidebar1">';
88
+ echo '<div class="metabox-holder">';
89
+ do_meta_boxes('wsd_db_bck_dwl','advanced','');
90
+ echo '</div></div>';
91
+ ?>
inc/admin/templates/db-change-prefix.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Change Database table Prefix
4
+ */
5
+ ?>
6
+ <br/><br/>
7
+ <h2 class="wpss_icon">Change database table prefix</h2>
8
+
9
+ <?php
10
+ // Holds the error/info messages generated on form postback
11
+ $infoMessage = '';
12
+
13
+ // Check if user has enough rights to alter the Table structure
14
+ $wsd_userDbRights = wsd_getDbUserRights();
15
+ $showPage = false; // assume we don't have ALTER rights
16
+ if ($wsd_userDbRights['rightsEnough']) {
17
+ $showPage = true;
18
+ $canAlter = '<span style="color: #060; font-weight: 900;">(Yes)</span>';
19
+ }
20
+ else { $canAlter = '<span style="color: #f00; font-weight: 900;">(No)</span>'; }
21
+ ?>
22
+ <p>Change your database table prefix to mitigate zero-day SQL Injection attacks.</p>
23
+ <p><strong>Before running this script:</strong>
24
+ <ul class="wsd_info_list">
25
+ <li>The <strong title="<?php echo ABSPATH.'wp-config.php'; ?>" class="wsd_cursor_help">wp-config.php</strong> file must be set to writable before running this script. <span style="color: #060; font-weight: 900;">(Yes)</span></li>
26
+ <li>The database user you're using with WordPress must have <strong>ALTER</strong> rights. <?php echo $canAlter;?></li>
27
+ </ul>
28
+ <?php
29
+ /*
30
+ * If the user doesn't have ALTER rights
31
+ */
32
+ if ( ! $showPage )
33
+ {
34
+ echo wsd_eInfo('The User: <strong>'.DB_USER.'</strong> used to access the database server must have <strong>ALTER</strong> rights in order to perform this action!');
35
+
36
+ // Stop here, no need to load the rest of the page
37
+ return;
38
+ }
39
+ ?>
40
+
41
+ <?php
42
+ /*
43
+ * Issue the file permissions warning
44
+ */
45
+ $infoMessage = 'It\'s a security risk to have your files writable (0777)!
46
+ Please make sure that after running this script, the <strong title="'.ABSPATH.'wp-config.php" class="wsd_cursor_help">wp-config.php</strong> file\'s permissions are set to 0644!
47
+ <br/> See: <a href="http://codex.wordpress.org/Changing_File_Permissions" target="_blank">http://codex.wordpress.org/Changing_File_Permissions</a> for more information.';
48
+ echo wsd_eInfo($infoMessage,'information');
49
+ ?>
50
+
51
+
52
+ <?php
53
+ /*
54
+ * VALIDATE FORM
55
+ */
56
+ if (!empty($_POST['newPrefixInput']) && isset($_POST['changePrefixButton']))
57
+ {
58
+ $wsd_isPostBack = true;
59
+
60
+ check_admin_referer('prefix-changer-change_prefix');
61
+
62
+ $wpdb =& $GLOBALS['wpdb'];
63
+ $new_prefix = preg_replace("[^0-9a-zA-Z_]", "", $_POST['newPrefixInput']);
64
+ if (empty($wsd_userDbRights['rightsEnough'])) {
65
+ $wsd_Message .= wsd_eInfo('The User which is used to access your Wordpress Database, hasn\'t enough rights (is missing the ALTER right) to alter the Table structure.
66
+ <br/>Please visit the <a href="http://www.websitedefender.com/category/faq/" target=_blank">WebsiteDefender WP Security Scan WordPress plugin documentation</a> website for more information.
67
+ <br/>If the user has ALTER rights and the tool is still not working, please <a href="http://semperfiwebdesign.com/contact/" target="_blank">contact</a> the plugin author for assistance.');
68
+ }
69
+ if (!empty($wsd_userDbRights['rightsTooMuch'])) {
70
+ $wsd_Message .= wsd_eInfo('Your currently used User to access the Wordpress Database, holds too many rights.'.
71
+ '<br/>We suggest that you limit his rights or to use another User with more limited rights instead, to increase your Security.','information');
72
+ }
73
+ if (strlen($new_prefix) < strlen($_POST['newPrefixInput'])){
74
+ $wsd_Message .= wsd_eInfo('You used some characters disallowed in Table names. The sanitized prefix will be used instead: '. $new_prefix,'information');
75
+ }
76
+ if ($new_prefix == $old_prefix) {
77
+ $wsd_Message .= wsd_eInfo('No change! Please select a new table prefix value.');
78
+ }
79
+ else
80
+ {
81
+ // Get the list of tables to modify
82
+ $tables = wsd_getTablesToAlter();
83
+ if (empty($tables))
84
+ {
85
+ $wsd_Message .= wsd_eInfo('There are no tables to rename!');
86
+ }
87
+ else
88
+ {
89
+ $result = wsd_renameTables($tables, $old_prefix, $new_prefix);
90
+
91
+ // check for errors
92
+ if (!empty($result))
93
+ {
94
+ $wsd_Message .= wsd_eInfo('All tables have been successfully updated!','success');
95
+
96
+ // try to rename the fields
97
+ $wsd_Message .= wsd_renameDbFields($old_prefix, $new_prefix);
98
+
99
+ if (wsd_updateWpConfigTablePrefix($wsd_wpConfigFile, $old_prefix, $new_prefix))
100
+ {
101
+ $wsd_Message .= wsd_eInfo('The wp-config file has been successfully updated!','success');
102
+ }
103
+ else {
104
+ $wsd_Message .= wsd_eInfo('The wp-config file could not be updated! You have to manually update the table_prefix variable
105
+ to the one you have specified: '.$new_prefix);
106
+ }
107
+ }// End if tables successfully renamed
108
+ else {
109
+ $wsd_Message .= wsd_eInfo('An error has occurred and the tables could not be updated!');
110
+ }
111
+ }// End if there are tables to rename
112
+ }
113
+ }// End if (!empty($_POST['newPrefixInput']))
114
+ else {
115
+ $new_prefix = $old_prefix;
116
+ }
117
+ ?>
118
+
119
+
120
+
121
+ <br/>
122
+ <form action="#cdtp" method="post" name="prefixchanging">
123
+ <?php
124
+ if (function_exists('wp_nonce_field')) {
125
+ wp_nonce_field('prefix-changer-change_prefix');
126
+ }
127
+ ?>
128
+ <p>Change the current:
129
+ <input type="text" name="newPrefixInput" value="<?php echo $new_prefix;?>" size="20" maxlength="15"/>
130
+ table prefix to something different.</p>
131
+ <p>Allowed characters: all latin alphanumeric as well as the <strong>_</strong> (underscore).</p>
132
+ <input type="submit" name="changePrefixButton" value="Start Renaming" />
133
+ </form>
134
+
135
+ <div id="cdtp">
136
+ <?php
137
+ // Display status information
138
+ if ($isPostBack)
139
+ {
140
+ echo $wsd_Message;
141
+ }
142
+ ?>
143
+ </div>
inc/admin/templates/footer.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function mrt_wpss_menu_footer(){
4
+ echo '
5
+ <div style="clear:both;"></div>
6
+ <br />
7
+ <em>For comments, suggestions, queries and bug reports please visit
8
+ the <a href="http://www.websitedefender.com/forums/" target="_blank"
9
+ title="WebsiteDefender Forums">WebsiteDefender Forums</a></em>.
10
+
11
+ Plugin by <a href="http://websitedefender.com/" target="_blank"
12
+ title="WebsiteDefender">WebsiteDefender</a>
13
+ </div>
14
+ ';
15
+ }
16
+
17
+ ?>
inc/admin/templates/header.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function mrt_wpss_menu_head($title){
4
+
5
+ echo '
6
+ <div class="wrap">
7
+ <h2 class="wpss_icon">' . $title . '</h2>';
8
+
9
+ }
10
+
11
+ ?>
js/json.js ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ http://www.JSON.org/json2.js
3
+ 2010-03-20
4
+
5
+ Public Domain.
6
+
7
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
+
9
+ See http://www.JSON.org/js.html
10
+
11
+
12
+ This code should be minified before deployment.
13
+ See http://javascript.crockford.com/jsmin.html
14
+
15
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
16
+ NOT CONTROL.
17
+
18
+
19
+ This file creates a global JSON object containing two methods: stringify
20
+ and parse.
21
+
22
+ JSON.stringify(value, replacer, space)
23
+ value any JavaScript value, usually an object or array.
24
+
25
+ replacer an optional parameter that determines how object
26
+ values are stringified for objects. It can be a
27
+ function or an array of strings.
28
+
29
+ space an optional parameter that specifies the indentation
30
+ of nested structures. If it is omitted, the text will
31
+ be packed without extra whitespace. If it is a number,
32
+ it will specify the number of spaces to indent at each
33
+ level. If it is a string (such as '\t' or '&nbsp;'),
34
+ it contains the characters used to indent at each level.
35
+
36
+ This method produces a JSON text from a JavaScript value.
37
+
38
+ When an object value is found, if the object contains a toJSON
39
+ method, its toJSON method will be called and the result will be
40
+ stringified. A toJSON method does not serialize: it returns the
41
+ value represented by the name/value pair that should be serialized,
42
+ or undefined if nothing should be serialized. The toJSON method
43
+ will be passed the key associated with the value, and this will be
44
+ bound to the value
45
+
46
+ For example, this would serialize Dates as ISO strings.
47
+
48
+ Date.prototype.toJSON = function (key) {
49
+ function f(n) {
50
+ // Format integers to have at least two digits.
51
+ return n < 10 ? '0' + n : n;
52
+ }
53
+
54
+ return this.getUTCFullYear() + '-' +
55
+ f(this.getUTCMonth() + 1) + '-' +
56
+ f(this.getUTCDate()) + 'T' +
57
+ f(this.getUTCHours()) + ':' +
58
+ f(this.getUTCMinutes()) + ':' +
59
+ f(this.getUTCSeconds()) + 'Z';
60
+ };
61
+
62
+ You can provide an optional replacer method. It will be passed the
63
+ key and value of each member, with this bound to the containing
64
+ object. The value that is returned from your method will be
65
+ serialized. If your method returns undefined, then the member will
66
+ be excluded from the serialization.
67
+
68
+ If the replacer parameter is an array of strings, then it will be
69
+ used to select the members to be serialized. It filters the results
70
+ such that only members with keys listed in the replacer array are
71
+ stringified.
72
+
73
+ Values that do not have JSON representations, such as undefined or
74
+ functions, will not be serialized. Such values in objects will be
75
+ dropped; in arrays they will be replaced with null. You can use
76
+ a replacer function to replace those with JSON values.
77
+ JSON.stringify(undefined) returns undefined.
78
+
79
+ The optional space parameter produces a stringification of the
80
+ value that is filled with line breaks and indentation to make it
81
+ easier to read.
82
+
83
+ If the space parameter is a non-empty string, then that string will
84
+ be used for indentation. If the space parameter is a number, then
85
+ the indentation will be that many spaces.
86
+
87
+ Example:
88
+
89
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
90
+ // text is '["e",{"pluribus":"unum"}]'
91
+
92
+
93
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
94
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
95
+
96
+ text = JSON.stringify([new Date()], function (key, value) {
97
+ return this[key] instanceof Date ?
98
+ 'Date(' + this[key] + ')' : value;
99
+ });
100
+ // text is '["Date(---current time---)"]'
101
+
102
+
103
+ JSON.parse(text, reviver)
104
+ This method parses a JSON text to produce an object or array.
105
+ It can throw a SyntaxError exception.
106
+
107
+ The optional reviver parameter is a function that can filter and
108
+ transform the results. It receives each of the keys and values,
109
+ and its return value is used instead of the original value.
110
+ If it returns what it received, then the structure is not modified.
111
+ If it returns undefined then the member is deleted.
112
+
113
+ Example:
114
+
115
+ // Parse the text. Values that look like ISO date strings will
116
+ // be converted to Date objects.
117
+
118
+ myData = JSON.parse(text, function (key, value) {
119
+ var a;
120
+ if (typeof value === 'string') {
121
+ a =
122
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
123
+ if (a) {
124
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
125
+ +a[5], +a[6]));
126
+ }
127
+ }
128
+ return value;
129
+ });
130
+
131
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
132
+ var d;
133
+ if (typeof value === 'string' &&
134
+ value.slice(0, 5) === 'Date(' &&
135
+ value.slice(-1) === ')') {
136
+ d = new Date(value.slice(5, -1));
137
+ if (d) {
138
+ return d;
139
+ }
140
+ }
141
+ return value;
142
+ });
143
+
144
+
145
+ This is a reference implementation. You are free to copy, modify, or
146
+ redistribute.
147
+ */
148
+
149
+ /*jslint evil: true, strict: false */
150
+
151
+ /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
153
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
154
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
155
+ test, toJSON, toString, valueOf
156
+ */
157
+
158
+
159
+ // Create a JSON object only if one does not already exist. We create the
160
+ // methods in a closure to avoid creating global variables.
161
+
162
+ if (!this.JSON) {
163
+ this.JSON = {};
164
+ }
165
+
166
+ (function () {
167
+
168
+ function f(n) {
169
+ // Format integers to have at least two digits.
170
+ return n < 10 ? '0' + n : n;
171
+ }
172
+
173
+ if (typeof Date.prototype.toJSON !== 'function') {
174
+
175
+ Date.prototype.toJSON = function (key) {
176
+
177
+ return isFinite(this.valueOf()) ?
178
+ this.getUTCFullYear() + '-' +
179
+ f(this.getUTCMonth() + 1) + '-' +
180
+ f(this.getUTCDate()) + 'T' +
181
+ f(this.getUTCHours()) + ':' +
182
+ f(this.getUTCMinutes()) + ':' +
183
+ f(this.getUTCSeconds()) + 'Z' : null;
184
+ };
185
+
186
+ String.prototype.toJSON =
187
+ Number.prototype.toJSON =
188
+ Boolean.prototype.toJSON = function (key) {
189
+ return this.valueOf();
190
+ };
191
+ }
192
+
193
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
194
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
195
+ gap,
196
+ indent,
197
+ meta = { // table of character substitutions
198
+ '\b': '\\b',
199
+ '\t': '\\t',
200
+ '\n': '\\n',
201
+ '\f': '\\f',
202
+ '\r': '\\r',
203
+ '"' : '\\"',
204
+ '\\': '\\\\'
205
+ },
206
+ rep;
207
+
208
+
209
+ function quote(string) {
210
+
211
+ // If the string contains no control characters, no quote characters, and no
212
+ // backslash characters, then we can safely slap some quotes around it.
213
+ // Otherwise we must also replace the offending characters with safe escape
214
+ // sequences.
215
+
216
+ escapable.lastIndex = 0;
217
+ return escapable.test(string) ?
218
+ '"' + string.replace(escapable, function (a) {
219
+ var c = meta[a];
220
+ return typeof c === 'string' ? c :
221
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
222
+ }) + '"' :
223
+ '"' + string + '"';
224
+ }
225
+
226
+
227
+ function str(key, holder) {
228
+
229
+ // Produce a string from holder[key].
230
+
231
+ var i, // The loop counter.
232
+ k, // The member key.
233
+ v, // The member value.
234
+ length,
235
+ mind = gap,
236
+ partial,
237
+ value = holder[key];
238
+
239
+ // If the value has a toJSON method, call it to obtain a replacement value.
240
+
241
+ if (value && typeof value === 'object' &&
242
+ typeof value.toJSON === 'function') {
243
+ value = value.toJSON(key);
244
+ }
245
+
246
+ // If we were called with a replacer function, then call the replacer to
247
+ // obtain a replacement value.
248
+
249
+ if (typeof rep === 'function') {
250
+ value = rep.call(holder, key, value);
251
+ }
252
+
253
+ // What happens next depends on the value's type.
254
+
255
+ switch (typeof value) {
256
+ case 'string':
257
+ return quote(value);
258
+
259
+ case 'number':
260
+
261
+ // JSON numbers must be finite. Encode non-finite numbers as null.
262
+
263
+ return isFinite(value) ? String(value) : 'null';
264
+
265
+ case 'boolean':
266
+ case 'null':
267
+
268
+ // If the value is a boolean or null, convert it to a string. Note:
269
+ // typeof null does not produce 'null'. The case is included here in
270
+ // the remote chance that this gets fixed someday.
271
+
272
+ return String(value);
273
+
274
+ // If the type is 'object', we might be dealing with an object or an array or
275
+ // null.
276
+
277
+ case 'object':
278
+
279
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
280
+ // so watch out for that case.
281
+
282
+ if (!value) {
283
+ return 'null';
284
+ }
285
+
286
+ // Make an array to hold the partial results of stringifying this object value.
287
+
288
+ gap += indent;
289
+ partial = [];
290
+
291
+ // Is the value an array?
292
+
293
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
294
+
295
+ // The value is an array. Stringify every element. Use null as a placeholder
296
+ // for non-JSON values.
297
+
298
+ length = value.length;
299
+ for (i = 0; i < length; i += 1) {
300
+ partial[i] = str(i, value) || 'null';
301
+ }
302
+
303
+ // Join all of the elements together, separated with commas, and wrap them in
304
+ // brackets.
305
+
306
+ v = partial.length === 0 ? '[]' :
307
+ gap ? '[\n' + gap +
308
+ partial.join(',\n' + gap) + '\n' +
309
+ mind + ']' :
310
+ '[' + partial.join(',') + ']';
311
+ gap = mind;
312
+ return v;
313
+ }
314
+
315
+ // If the replacer is an array, use it to select the members to be stringified.
316
+
317
+ if (rep && typeof rep === 'object') {
318
+ length = rep.length;
319
+ for (i = 0; i < length; i += 1) {
320
+ k = rep[i];
321
+ if (typeof k === 'string') {
322
+ v = str(k, value);
323
+ if (v) {
324
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
325
+ }
326
+ }
327
+ }
328
+ } else {
329
+
330
+ // Otherwise, iterate through all of the keys in the object.
331
+
332
+ for (k in value) {
333
+ if (Object.hasOwnProperty.call(value, k)) {
334
+ v = str(k, value);
335
+ if (v) {
336
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ // Join all of the member texts together, separated with commas,
343
+ // and wrap them in braces.
344
+
345
+ v = partial.length === 0 ? '{}' :
346
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
347
+ mind + '}' : '{' + partial.join(',') + '}';
348
+ gap = mind;
349
+ return v;
350
+ }
351
+ }
352
+
353
+ // If the JSON object does not yet have a stringify method, give it one.
354
+
355
+ if (typeof JSON.stringify !== 'function') {
356
+ JSON.stringify = function (value, replacer, space) {
357
+
358
+ // The stringify method takes a value and an optional replacer, and an optional
359
+ // space parameter, and returns a JSON text. The replacer can be a function
360
+ // that can replace values, or an array of strings that will select the keys.
361
+ // A default replacer method can be provided. Use of the space parameter can
362
+ // produce text that is more easily readable.
363
+
364
+ var i;
365
+ gap = '';
366
+ indent = '';
367
+
368
+ // If the space parameter is a number, make an indent string containing that
369
+ // many spaces.
370
+
371
+ if (typeof space === 'number') {
372
+ for (i = 0; i < space; i += 1) {
373
+ indent += ' ';
374
+ }
375
+
376
+ // If the space parameter is a string, it will be used as the indent string.
377
+
378
+ } else if (typeof space === 'string') {
379
+ indent = space;
380
+ }
381
+
382
+ // If there is a replacer, it must be a function or an array.
383
+ // Otherwise, throw an error.
384
+
385
+ rep = replacer;
386
+ if (replacer && typeof replacer !== 'function' &&
387
+ (typeof replacer !== 'object' ||
388
+ typeof replacer.length !== 'number')) {
389
+ throw new Error('JSON.stringify');
390
+ }
391
+
392
+ // Make a fake root object containing our value under the key of ''.
393
+ // Return the result of stringifying the value.
394
+
395
+ return str('', {'': value});
396
+ };
397
+ }
398
+
399
+
400
+ // If the JSON object does not yet have a parse method, give it one.
401
+
402
+ if (typeof JSON.parse !== 'function') {
403
+ JSON.parse = function (text, reviver) {
404
+
405
+ // The parse method takes a text and an optional reviver function, and returns
406
+ // a JavaScript value if the text is a valid JSON text.
407
+
408
+ var j;
409
+
410
+ function walk(holder, key) {
411
+
412
+ // The walk method is used to recursively walk the resulting structure so
413
+ // that modifications can be made.
414
+
415
+ var k, v, value = holder[key];
416
+ if (value && typeof value === 'object') {
417
+ for (k in value) {
418
+ if (Object.hasOwnProperty.call(value, k)) {
419
+ v = walk(value, k);
420
+ if (v !== undefined) {
421
+ value[k] = v;
422
+ } else {
423
+ delete value[k];
424
+ }
425
+ }
426
+ }
427
+ }
428
+ return reviver.call(holder, key, value);
429
+ }
430
+
431
+
432
+ // Parsing happens in four stages. In the first stage, we replace certain
433
+ // Unicode characters with escape sequences. JavaScript handles many characters
434
+ // incorrectly, either silently deleting them, or treating them as line endings.
435
+
436
+ text = String(text);
437
+ cx.lastIndex = 0;
438
+ if (cx.test(text)) {
439
+ text = text.replace(cx, function (a) {
440
+ return '\\u' +
441
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
442
+ });
443
+ }
444
+
445
+ // In the second stage, we run the text against regular expressions that look
446
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
447
+ // because they can cause invocation, and '=' because it can cause mutation.
448
+ // But just to be safe, we want to reject all unexpected forms.
449
+
450
+ // We split the second stage into 4 regexp operations in order to work around
451
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
452
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
453
+ // replace all simple value tokens with ']' characters. Third, we delete all
454
+ // open brackets that follow a colon or comma or that begin the text. Finally,
455
+ // we look to see that the remaining characters are only whitespace or ']' or
456
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
457
+
458
+ if (/^[\],:{}\s]*$/.
459
+ test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
460
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
461
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
462
+
463
+ // In the third stage we use the eval function to compile the text into a
464
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
465
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
466
+ // in parens to eliminate the ambiguity.
467
+
468
+ j = eval('(' + text + ')');
469
+
470
+ // In the optional fourth stage, we recursively walk the new structure, passing
471
+ // each name/value pair to a reviver function for possible transformation.
472
+
473
+ return typeof reviver === 'function' ?
474
+ walk({'': j}, '') : j;
475
+ }
476
+
477
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
478
+
479
+ throw new SyntaxError('JSON.parse');
480
+ };
481
+ }
482
+ }());
js/md5.js ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var wsdMD5 = function (string)
2
+ {
3
+
4
+ function RotateLeft(lValue, iShiftBits) {
5
+ return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
6
+ }
7
+
8
+ function AddUnsigned(lX,lY) {
9
+ var lX4,lY4,lX8,lY8,lResult;
10
+ lX8 = (lX & 0x80000000);
11
+ lY8 = (lY & 0x80000000);
12
+ lX4 = (lX & 0x40000000);
13
+ lY4 = (lY & 0x40000000);
14
+ lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
15
+ if (lX4 & lY4) {
16
+ return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
17
+ }
18
+ if (lX4 | lY4) {
19
+ if (lResult & 0x40000000) {
20
+ return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
21
+ } else {
22
+ return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
23
+ }
24
+ } else {
25
+ return (lResult ^ lX8 ^ lY8);
26
+ }
27
+ }
28
+
29
+ function F(x,y,z) { return (x & y) | ((~x) & z); }
30
+ function G(x,y,z) { return (x & z) | (y & (~z)); }
31
+ function H(x,y,z) { return (x ^ y ^ z); }
32
+ function I(x,y,z) { return (y ^ (x | (~z))); }
33
+
34
+ function FF(a,b,c,d,x,s,ac) {
35
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
36
+ return AddUnsigned(RotateLeft(a, s), b);
37
+ };
38
+
39
+ function GG(a,b,c,d,x,s,ac) {
40
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
41
+ return AddUnsigned(RotateLeft(a, s), b);
42
+ };
43
+
44
+ function HH(a,b,c,d,x,s,ac) {
45
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
46
+ return AddUnsigned(RotateLeft(a, s), b);
47
+ };
48
+
49
+ function II(a,b,c,d,x,s,ac) {
50
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
51
+ return AddUnsigned(RotateLeft(a, s), b);
52
+ };
53
+
54
+ function ConvertToWordArray(string) {
55
+ var lWordCount;
56
+ var lMessageLength = string.length;
57
+ var lNumberOfWords_temp1=lMessageLength + 8;
58
+ var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
59
+ var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
60
+ var lWordArray=Array(lNumberOfWords-1);
61
+ var lBytePosition = 0;
62
+ var lByteCount = 0;
63
+ while ( lByteCount < lMessageLength ) {
64
+ lWordCount = (lByteCount-(lByteCount % 4))/4;
65
+ lBytePosition = (lByteCount % 4)*8;
66
+ lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
67
+ lByteCount++;
68
+ }
69
+ lWordCount = (lByteCount-(lByteCount % 4))/4;
70
+ lBytePosition = (lByteCount % 4)*8;
71
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
72
+ lWordArray[lNumberOfWords-2] = lMessageLength<<3;
73
+ lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
74
+ return lWordArray;
75
+ };
76
+
77
+ function WordToHex(lValue) {
78
+ var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
79
+ for (lCount = 0;lCount<=3;lCount++) {
80
+ lByte = (lValue>>>(lCount*8)) & 255;
81
+ WordToHexValue_temp = "0" + lByte.toString(16);
82
+ WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
83
+ }
84
+ return WordToHexValue;
85
+ };
86
+
87
+ function Utf8Encode(string) {
88
+ string = string.replace(/\r\n/g,"\n");
89
+ var utftext = "";
90
+
91
+ for (var n = 0; n < string.length; n++) {
92
+
93
+ var c = string.charCodeAt(n);
94
+
95
+ if (c < 128) {
96
+ utftext += String.fromCharCode(c);
97
+ }
98
+ else if((c > 127) && (c < 2048)) {
99
+ utftext += String.fromCharCode((c >> 6) | 192);
100
+ utftext += String.fromCharCode((c & 63) | 128);
101
+ }
102
+ else {
103
+ utftext += String.fromCharCode((c >> 12) | 224);
104
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
105
+ utftext += String.fromCharCode((c & 63) | 128);
106
+ }
107
+
108
+ }
109
+
110
+ return utftext;
111
+ };
112
+
113
+ var x=Array();
114
+ var k,AA,BB,CC,DD,a,b,c,d;
115
+ var S11=7, S12=12, S13=17, S14=22;
116
+ var S21=5, S22=9 , S23=14, S24=20;
117
+ var S31=4, S32=11, S33=16, S34=23;
118
+ var S41=6, S42=10, S43=15, S44=21;
119
+
120
+ string = Utf8Encode(string);
121
+
122
+ x = ConvertToWordArray(string);
123
+
124
+ a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
125
+
126
+ for (k=0;k<x.length;k+=16) {
127
+ AA=a; BB=b; CC=c; DD=d;
128
+ a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
129
+ d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
130
+ c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
131
+ b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
132
+ a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
133
+ d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
134
+ c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
135
+ b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
136
+ a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
137
+ d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
138
+ c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
139
+ b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
140
+ a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
141
+ d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
142
+ c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
143
+ b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
144
+ a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
145
+ d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
146
+ c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
147
+ b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
148
+ a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
149
+ d=GG(d,a,b,c,x[k+10],S22,0x2441453);
150
+ c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
151
+ b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
152
+ a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
153
+ d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
154
+ c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
155
+ b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
156
+ a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
157
+ d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
158
+ c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
159
+ b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
160
+ a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
161
+ d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
162
+ c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
163
+ b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
164
+ a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
165
+ d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
166
+ c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
167
+ b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
168
+ a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
169
+ d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
170
+ c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
171
+ b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
172
+ a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
173
+ d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
174
+ c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
175
+ b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
176
+ a=II(a,b,c,d,x[k+0], S41,0xF4292244);
177
+ d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
178
+ c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
179
+ b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
180
+ a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
181
+ d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
182
+ c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
183
+ b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
184
+ a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
185
+ d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
186
+ c=II(c,d,a,b,x[k+6], S43,0xA3014314);
187
+ b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
188
+ a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
189
+ d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
190
+ c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
191
+ b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
192
+ a=AddUnsigned(a,AA);
193
+ b=AddUnsigned(b,BB);
194
+ c=AddUnsigned(c,CC);
195
+ d=AddUnsigned(d,DD);
196
+ }
197
+
198
+ var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
199
+
200
+ return temp.toLowerCase();
201
+ };
js/remove_wp_version.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ $("#wp-version-message, #footer-upgrade").remove();
3
+ });
js/scripts.js CHANGED
@@ -1,27 +1,27 @@
1
- function displaymessage()
2
- {
3
- alert("Hello World!");
4
- }
 
 
 
 
5
 
6
- $('myForm').addEvent('submit', function(e) {
7
- /**
8
- * Prevent the submit event
9
- */
10
- new Event(e).stop();
11
-
12
- /**
13
- * This empties the log and shows the spinning indicator
14
- */
15
- var log = $('log_res').empty().addClass('ajax-loading');
16
-
17
- /**
18
- * send takes care of encoding and returns the Ajax instance.
19
- * onComplete removes the spinner from the log.
20
- */
21
- this.send({
22
- update: log,
23
- onComplete: function() {
24
- log.removeClass('ajax-loading');
25
- }
26
- });
27
- });
1
+ function testPassword(passwd){
2
+ var description = new Array();
3
+ description[0] = '<p class="indicator indicator-1"></p> <p><strong>Weakest</strong></p>';
4
+ description[1] = '<p class="indicator indicator-2"></p> <p><strong>Weak</strong></p>';
5
+ description[2] = '<p class="indicator indicator-3"></p> <p><strong>Improving</strong></p>';
6
+ description[3] = '<p class="indicator indicator-4"></p> <p><strong>Strong</strong></p>';
7
+ description[4] = '<p class="indicator indicator-5"></p> <p><strong>Strongest</strong></p>';
8
+ description[5] = '<p class="indicator indicator-6"></p> <p><strong>Begin Typing</strong></p>';
9
 
10
+ var base = 0
11
+ var combos = 0
12
+ if (passwd.match(/[a-z]/))base = (base+26);
13
+ if (passwd.match(/[A-Z]/))base = (base+26);
14
+ if (passwd.match(/\d+/))base = (base+10);
15
+ if (passwd.match(/[>!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/))base = (base+33);
16
+
17
+ combos=Math.pow(base,passwd.length);
18
+
19
+ if(combos == 1)strVerdict = description[5];
20
+ else if(combos > 1 && combos < 1000000)strVerdict = description[0];
21
+ else if (combos >= 1000000 && combos < 1000000000000)strVerdict = description[1];
22
+ else if (combos >= 1000000000000 && combos < 1000000000000000000)strVerdict = description[2];
23
+ else if (combos >= 1000000000000000000 && combos < 1000000000000000000000000)strVerdict = description[3];
24
+ else strVerdict = description[4];
25
+
26
+ document.getElementById("Words").innerHTML= (strVerdict);
27
+ }
 
 
 
 
js/wsd.js ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ if(console===undefined){var console={log:function(){return;}};}
2
+
3
+
4
+ function wsdPassStrengthProvider($) {
5
+ this.badPass=['abc123','password','computer','123456','tigger','a1b2c3','qwerty','password1','carmen','mickey','secret','summer','internet','service','canada','ranger','shadow','baseball','donald','harley','hockey','letmein','maggie','mustang','snoopy','buster','dragon','jordan','michael','michelle','patrick','123abc','andrew','calvin','changeme','diamond','fuckme','fuckyou','matthew','miller','trustno1','12345678','123456789','avalon','brandy','chelsea','coffee','falcon','freedom','gandalf','helpme','merlin','molson','newyork','soccer','thomas','wizard','Monday','asdfgh','bandit','batman','butthead','dorothy','eeyore','fishing',
6
+ 'football','george','iloveyou','jennifer','jonathan','marina','master','monday','monkey','natasha','ncc1701','newpass','pamela','pepper','piglet','poohbear','pookie','rabbit','rachel','rocket','sparky','spring','steven','success','sunshine','thx1138','victoria','whatever','zapata','8675309','Internet','amanda','august','barney','biteme','boomer','cowboy','doctor','fisher','foobar','island','joshua','marley','orange','please','rascal','richard','scooter','shalom','silver','skippy','stanley','taylor','welcome','zephyr','111111','aaaaaa','access','albert','alexander','andrea','anthony','asdfjkl;','ashley','basketball',
7
+ 'beavis','booboo','bradley','brandon','caitlin','camaro','charlie','chicken','cricket','dakota','dallas','daniel','debbie','dolphin','elephant','friend','fucker','ginger','goodluck','hammer','heather','iceman','jessica','joseph','jupiter','justin','knight','lacrosse','lakers','lizard','madison','mother','muffin','murphy','ncc1701d','newuser','nirvana','pentium','phoenix','picture','rainbow','saturn','shannon','shithead','skeeter','sophie','special','stephanie','stephen','sweetie','teacher','tennis','test123','topgun','tristan','william','wilson','1q2w3e','654321','666666','a12345','a1b2c3d4','angela','archie','blazer',
8
+ 'bond007','booger','charles','christin','claire','control','david1','dennis','digital','disney','edward','flipper','franklin','horses','hunter','indigo','jasper','jeremy','julian','kelsey','killer','kingfish','lauren','maryjane','matrix','maverick','mayday','mercury','mitchell','morgan','mountain','niners','nothing','oliver','peanut','pearljam','phantom','popcorn','princess','psycho','pumpkin','purple','rebecca','reddog','robert','salmon','samson','sharon','sierra','smokey','startrek','steelers','stimpy','sunflower','superman','support','sydney','techno','telecom','walter','willie','willow','winner','zxcvbnm','absolut',
9
+ 'alaska','alexis','animal','apples','babylon5','backup','barbara','benjamin','bird33','bluebird','bonnie','camera','chocolate','claudia','cocacola','compton','connect','cookie','cruise','deliver','douglas','dreamer','dreams','duckie','eagles','einstein','explorer','family','ferrari','flamingo','flower','foxtrot','francis','freddy','friday','froggy','galileo','giants','global','gopher','hansolo','happy1','hendrix','herman','houston','iguana','indiana','insane','inside','ironman','jasmin','jeanne','justice','katherine','kermit','leslie','martin','minnie','nascar','nelson','netware','pantera','parker','passwd','penguin',
10
+ 'porsche911','prince','punkin','pyramid','raymond','rosebud','route66','running','security','sergei','sheena','sheila','skiing','snapple','snowball','sparrow','spencer','stealth','student','sylvia','tamara','taurus','teresa','theresa','thunderbird','tigers','toyota','training','travel','tuesday','victory','viper1','wesley','whisky','winnie','winter','wolves','xyz123','123123','1234567','696969','888888','Anthony','Bond007','Friday','Hendrix','Joshua','Matthew','October','Taurus','Tigger','abcdef','adidas','adrian','alexandr','alfred','arthur','athena','austin','awesome','badger','bamboo','beagle','beatles','beautiful',
11
+ 'beaver','bigmac','blonde','boogie','boston','brenda','bright','bubba1','bubbles','button','buttons','cactus','captain','carlos','caroline','carrie','casper','catalog','catch22','challenge','chance','charity','charlotte','cheese','cheryl','chris1','clancy','clipper','coltrane','compaq','conrad','cooper','cooter','copper','cosmos','cougar','cracker','crawford','crystal','curtis','cyclone','cyrano','deutsch','diablo','dilbert','dollars','dookie','dumbass','dundee','e-mail','elizabeth','europe','export','farmer','firebird','fletcher','fluffy','fountain','france','freak1','friends','fuckoff','gabriel','gabriell','galaxy',
12
+ 'gambit','garden','garfield','garlic','garnet','genesis','genius','godzilla','goforit','golfer','goober','grateful','greenday','groovy','grover','guitar','hacker','hector','herbert','horizon','hornet','howard','icecream','imagine','impala','informix','janice','jasmine','jason1','jeanette','jeffrey','jenifer','jesus1','jewels','julie1','junior','justin1','kathleen','kelly1','kennedy','kevin1','knicks','larry1','ledzep','leonard','lestat','library','lincoln','lionking','london','louise','lucky1','maddog','mailman','majordomo','mantra','margaret','mariposa','market','marlboro','martin1','master1','mazda1','mensuck','mercedes',
13
+ 'metallic','midori','millie','mirage','money1','monica','monopoly','mookie','moroni','nathan','ncc1701e','nesbitt','nguyen','nicholas','nicole','nimrod','october','olivia','online','oxford','pacific','painter','peaches','penelope','petunia','philip','phoenix1','pickle','player','poiuyt','porsche','porter','python','quality','raquel','remember','republic','research','robbie','robert1','runner','russell','sailing','sailor','samantha','savage','scarlett','school','shadow1','shelby','simple','skipper','smiley','snickers','sniper','snoopdog','snowman','spitfire','sprite','spunky','starwars','station','stella','stingray',
14
+ 'stormy','stupid','sumuinen','sunny1','sunrise','surfer','teddy1','testing','theboss','theking','thumper','tintin','tomcat','trebor','trevor','tweety','unicorn','valentine','valerie','vanilla','veronica','victor','vincent','warrior','warriors','weasel','wheels','wilbur','winston','wisdom','wombat','xanadu','xavier','yellow','zaphod','zeppelin','!@#$%^','!@#$%^&*','10sne1','1p2o3i','3bears','Andrew','Broadway','Champs','Family','Fisher','Friends','Jeanne','Killer','Knight','Master','Michael','Michelle','Pentium','Pepper','Raistlin','Sierra','Snoopy','Tennis','Tuesday','abacab','abcd1234','abcdefg','abigail','account',
15
+ 'acropolis','alice1','allison','alpine','anders','andre1','andrea1','angel1','annette','antares','apache','apollo','aragorn','arizona','arnold','arsenal','asdfasdf','asdfghjk','avenger','avenir','babydoll','bailey','banana','basket','batman1','beaner','beatrice','bertha','bigben','bigdog','biggles','bigman','biology','bishop','blondie','blowfish','bluefish','bobcat','braves','brazil','bridges','brutus','buffalo','bulldog','bullet','bullshit','business','butler','butter','california','cannondale','carebear','carol1','carole','cassie','castle','catalina','catherine','catnip','cccccc','celine','center','champion','chanel',
16
+ 'chelsea1','chester1','chicago','christian','christy','church','cinder','colleen','colorado','columbia','commander','connie','content','cookies','cooking','cordelia','corona','cowboys','coyote','crack1','creative','cuddles','cuervo','daisie','daniel1','danielle','database','davids','deadhead','denali','depeche','design','destiny','dickens','dickhead','digger','dodger','dougie','dragonfly','eclipse','electric','emerald','emmitt','entropy','etoile','excalibur','express','farout','farside','feedback','fender','fireman','firenze','fletch','florida','flowers','foster','fozzie','francesco','francine','francois','french','fuckface',
17
+ 'gargoyle','gasman','gemini','general','gerald','germany','gilbert','goaway','golden','goldfish','gordon','graham','graphic','gregory','gretchen','gunner','hal9000','hannah','harold','harrison','harvey','hawkeye','heaven','helena','herzog','hithere','hobbit','ibanez','idontknow','integra','intern','intrepid','ireland','isabel','jackie','jackson','jaguar','jamaica','jenny1','jessie','jethrotull','jkl123','johanna1','johnny','joker1','jordan23','judith','jumanji','kangaroo','karen1','keepout','keith1','kenneth','kidder','kimberly','kingdom','kitkat','kramer','kristen','lambda','laurie','lawrence','lawyer','legend','liberty',
18
+ 'lindsay','lindsey','liverpool','logical','lonely','lorrie','lovely','loveme','madonna','malcolm','malibu','marathon','marcel','maria1','mariah','mariah1','marilyn','mariner','marvin','maurice','maxine','maxwell','meggie','melanie','melissa','melody','merlot','mexico','michael1','michele','midnight','midway','miracle','mishka','mmouse','molly1','monique','montreal','moocow','morris','mortimer','mouse1','mulder','nautica','nellie','nermal','newton','nicarao','nirvana1','nissan','norman','notebook','olivier','oranges','oregon','overkill','pacers','packer','pandora','panther','passion','patricia','peewee','pencil','people',
19
+ 'person','peter1','picard','picasso','pierre','pinkfloyd','polaris','police','pookie1','predator','preston','primus','prometheus','public','q1w2e3','queenie','quentin','random','rangers','raptor','rastafarian','reality','redrum','remote','reptile','reynolds','rhonda','ricardo','ricardo1','roadrunner','robinhood','robotech','rocknroll','rocky1','ronald','ruthie','sabrina','sakura','salasana','sampson','samuel','sandra','sapphire','scarecrow','scarlet','scorpio','scott1','scottie','scruffy','scuba1','seattle','serena','sergey','shanti','shogun','singer','skibum','skywalker','slacker','smashing','smiles','snowflake','snowski',
20
+ 'snuffy','soccer1','soleil','spanky','speedy','spider','spooky','stacey','star69','starter','steven1','sting1','stinky','strawberry','stuart','sunbird','sundance','superfly','suzanne','suzuki','swimmer','swimming','system','tarzan','teddybear','teflon','temporal','terminal','theatre','thejudge','thunder','thursday','tinker','tootsie','tornado','tricia','trident','trojan','truman','trumpet','tucker','turtle','utopia','valhalla','voyager','warcraft','warlock','warren','williams','windsurf','winona','woofwoof','wrangler','wright','xcountry','xfiles','xxxxxx','yankees','yvonne','zenith','zigzag','zombie','zxc123','000000',
21
+ '007007','11111111','123321','171717','181818','1a2b3c','1chris','1kitty','1qw23e','4runner','57chevy','7777777','789456','7dwarfs','88888888','Abcdefg','Alexis','Animals','Bailey','Bastard','Beavis','Bismillah','Booboo','Boston','Canucks','Cardinal','Celtics','ChangeMe','Charlie','Computer','Cougar','Creative','Curtis','Daniel','Darkman','Denise','Dragon','Eagles','Elizabeth','Esther','Figaro','Fishing','Fortune','Freddy','Front242','Gandalf','Geronimo','Gingers','Golden','Goober','Gretel','HARLEY','Hacker','Hammer','Harley','Heather','Hershey','Jackson','Jennifer','Jersey','Jessica','Joanna','Johnson','Jordan','KILLER',
22
+ 'Kitten','Liberty','Lindsay','Lizard','Madeline','Margaret','Maxwell','Mellon','Merlot','Metallic','Michel1','Monster','Montreal','Newton','Nicholas','Noriko','Paladin','Pamela','Password','Peaches','Peanuts','Phoenix','Piglet','Pookie','Princess','Purple','Rabbit','Raiders','Random','Rebecca','Robert','Russell','Saturn','Service','Shadow','Sidekick','Skeeter','Smokey','Sparky','Speedy','Sterling','Steven','Summer','Sunshine','Superman','Sverige','Swoosh','Taylor','Theresa','Thomas','Thunder','Vernon','Victoria','Vincent','Waterloo','Webster','Willow','Winnie','Wolverine','Woodrow','aardvark','abbott','abcd123','accord',
23
+ 'active','admin1','adrock','aerobics','africa','airborne','airwolf','aki123','alfaro','alicia','aliens','alison','allegro','allstate','alpha1','altamira','althea','altima','altima1','amanda1','amazing','america','anderson','andrew!','andrew1','andromed','angels','angie1','anneli','anything','apple1','apple2','applepie','aptiva','aquarius','ariane','arlene','artemis','asdf1234','asdf;lkj','asdfjkl','ashley1','ashraf','ashton','assmunch','asterix','attila','autumn','avatar','ayelet','aylmer','baraka','barbie','barney1','barnyard','barrett','bartman','beaches','beanie','beasty','beauty','beavis1','belgium','belize','belmont',
24
+ 'benson','beowulf','bernardo','betacam','bharat','bichon','bigboss','bigred','billy1','bimmer','bioboy','biochem','birdie','birthday','biscuit','bitter','blackjack','blanche','blinds','blowjob','blowme','blueeyes','bluejean','bogart','bombay','boobie','bootsie','boulder','bourbon','boxers','branch','brandi','brewster','bridge','britain','broker','bronco','bronte','brooke','brother','bubble','buddha','budgie','buffett','burton','butterfly','c00per','calendar','calgary','calvin1','camille','campbell','camping','cancer','canela','cannon','carbon','carnage','carolyn','carrot','cascade','catfish','catwoman','cecile','celica',
25
+ 'cement','cessna','chainsaw','chameleon','change','chantal','charger','cherry','chiara','chiefs','chinacat','chinook','chouette','chris123','christ1','christmas','christopher','chronos','cicero','cindy1','cinema','circuit','cirque','cirrus','clapton','clarkson','claude','claudel','clueless','cobain','colette','college','colors','colt45','concept','concorde','confused','coolbean','cornflake','corvette','corwin','country','courier','crescent','crowley','crusader','cthulhu','cunningham','cupcake','current','cutlass','cynthia','daedalus','dagger','dagger1','dammit','damogran','dancer','daphne','darkstar','darren','darryl',
26
+ 'darwin','datatrain','daytek','deborah','december','decker','deedee','deeznuts','delano','delete','denise','desert','deskjet','detroit','devine','dexter','dharma','dianne','diesel','dillweed','dipper','director','dodgers','dogbert','doitnow','dollar','dominique','domino','dontknow','doogie','doudou','downtown','dragon1','driver','dudley','dutchess','dwight','eagle1','easter','eastern','edmund','element','elina1','elissa','elliot','empire','engage','enigma','enterprise','ernie1','escort','escort1','estelle','eugene','evelyn','explore','faculty','fairview','family1','fatboy','felipe','fenris','ferguson','ferret','ferris',
27
+ 'finance','fireball','fishes','fishhead','fishie','flanders','fleurs','flight','florida1','flowerpot','flyboy','forward','franka','freddie','frederic','freebird','freeman','frisco','froggie','froggies','front242','frontier','fugazi','funguy','funtime','future','gaelic','gambler','gammaphi','garcia','garfunkel','gaston','gateway','gateway2','gator1','george1','georgia','german','germany1','getout','ggeorge','gibbons','gibson','gilgamesh','giselle','glider1','gmoney','goblin','goblue','godiva','goethe','gofish','gollum','gramps','grandma','gravis','gremlin','gretzky','grizzly','grumpy','guitar1','gustavo','h2opolo','haggis',
28
+ 'hailey','halloween','hallowell','hamilton','hamlet','hanson','happy123','happyday','hardcore','harley1','harriet','harris','harvard','hawkeye1','health','health1','heather1','heather2','hedgehog','heikki','helene','hello1','hello123','hello8','hellohello','help123','helper','hermes','heythere','highland','hillary','histoire','history','hitler','hobbes','holiday','homerj','honda1','hongkong','hoosier','hootie','hosehead','hotrod','hudson','hummer','huskies','hydrogen','ib6ub9','if6was9','iforget','ilmari','iloveu','impact','indonesia','ingvar','insight','instruct','integral','iomega','irmeli','isabelle','israel','italia',
29
+ 'j1l2t3','jackie1','james1','jamesbond','jamjam','jeepster','jeffrey1','jennie','jensen','jesse1','jester','jethro','jetta1','jimbob','joanie','joanna','joelle','john316','jordie','journey','jubilee','juhani','julia2','julien','juliet','junebug','juniper','justdoit','justice4','kalamazo','karine','katerina','katie1','keeper','keller','kendall','kerala','kerrya','ketchup','kissa2','kissme','kitten','kittycat','kkkkkk','kleenex','kombat','kristi','kristine','labtec','laddie','ladybug','laserjet','lassie1','laurel','lawson','leader','leblanc','leland','lester','letter','letters','lexus1','lights','lionel','lissabon','little',
30
+ 'logger','loislane','lolita','lonestar','longer','longhorn','looney','lovers','loveyou','lucifer','lucky14','macross','macse30','maddie','madmax','madoka','magic1','magnum','maiden','makeitso','mallard','manageme','manson','manuel','marcus','marielle','marine','marino','marshall','martha','matti1','mattingly','maxmax','meatloaf','mechanic','medical','meister','melina','memphis','mercer','mermaid','merrill','michal','michel','michigan','michou','mickel','mickey1','microsoft','midvale','mikael','milano','millenium','million','miranda','miriam','mission','mmmmmm','mobile','mobydick','monkey1','monroe','montana','montana3',
31
+ 'montrose','moomoo','moonbeam','morecats','morpheus','motorola','movies','mowgli','mozart','mulder1','munchkin','murray','muscle','mustang1','nadine','napoleon','nation','national','nesbit','nestle','neutrino','newaccount','newlife','newyork1','nexus6','nichole','nicklaus','nightshadow','nightwind','nikita','nintendo','nomore','nopass','normal','norton','notta1','nouveau','novell','nugget','number9','numbers','nutmeg','oaxaca','obiwan','obsession','ohshit','oicu812','openup','orchid','orlando','orville','paagal','packard','packers','packrat','paloma','pancake','paradigm','parola','parrot','partner','pascal','patches',
32
+ 'patriots','pauline','payton','peanuts','pedro1','perfect','performa','peterk','peterpan','phialpha','philips','phillips','phishy','piano1','pianoman','pianos','pierce','pigeon','pioneer','pipeline','piper1','pirate','pisces','playboy','poetic','poetry','pontiac','pookey','popeye','prayer','precious','prelude','premier','printing','provider','puddin','pulsar','pussy1','qqq111','quebec','qwerty12','qwertyui','rabbit1','racerx','rachelle','racoon','rafiki','raleigh','randy1','rasta1','ravens','redcloud','redfish','redman','redskins','redwing','redwood','reggae','reggie','reliant','renegade','rescue','revolution','reznor',
33
+ 'rhjrjlbk','richard1','richards','richmond','ripper','ripple','roberts','robocop','robotics','rocket1','rockie','rockon','roger1','rogers','roland','rommel','rookie','rootbeer','rossigno','rugger','ruthless','sabbath','sabina','safety','safety1','saigon','samIam','samiam','sammie','samsam','sanjose','saphire','sarah1','saskia','satori','saturday','saturn5','schnapps','science','scooby','scoobydoo','scooter1','scorpion','scotch','scotty','scouts','search','secret3','seeker','september','server','services','seven7','shaggy','shanghai','shanny','shaolin','shasta','shayne','shazam','shelly','shelter','sherry','shirley',
34
+ 'shorty','shotgun','sidney','sigmachi','signal','signature','simba1','simsim','sinatra','sirius','skipper1','skydive','skyler','slayer','sleepy','slider','smegma','smile1','smiths','smitty','smurfy','snakes','snapper','sober1','solomon','sonics','sophia','sparks','spartan','sphynx','spike1','sponge','sprocket','squash','starbuck','stargate','starlight','steph1','stephi','steve1','stevens','stewart','stivers','stocks','storage','stranger','strato','stretch','strong','student2','studio','stumpy','sucker','suckme','sultan','summit','sunfire','sunset','superstar','surfing','susan1','susanna','sutton','swanson','sweden',
35
+ 'sweetpea','sweety','switzer','swordfish','system5','t-bone','tabatha','tacobell','taiwan','tamtam','tanner','tapani','targas','target','tarheel','tattoo','tazdevil','tequila','terry1','tester','testtest','thankyou','theend','thelorax','thisisit','thompson','thorne','thrasher','tiger2','tightend','timber','timothy','tinkerbell','topcat','topher','toshiba','tototo','toucan','transfer','transit','transport','trapper','travis','treasure','tricky','triton','trombone','trophy','trouble','trucker','tucson','turbo2','tyler1','ultimate','unique','united','upsilon','ursula','vacation','valley','vampire','vanessa','vedder',
36
+ 'venice','vermont','victor1','vikram','vincent1','violet','violin','virago','virgil','virginia','vision','visual','volcano','volley','voodoo','vortex','waiting','walden','walleye','wanker','warner','water1','wayne1','webmaster','webster','weezer','wendy1','western','whale1','whitney','whocares','whoville','wibble','wildcat','william1','window','winniethepooh','wolfgang','wolverine','wombat1','wonder','x-files','xxx123','xxxxxxxx','yamaha','yankee','yogibear','yolanda','yomama','yvette','zachary','zebras','zepplin','zoltan','zoomer','zxcvbn','!@#$%^&','00000000','121212','1234qwer','131313','21122112','99999999',
37
+ '@#$%^&','ABC123','Abcdef','Asdfgh','Changeme','FuckYou','Fuckyou','JSBach','Michel','NCC1701','Qwerty','Windows','Zxcvbnm','action','amelie','anaconda','apollo13','artist','asshole','benoit','bernard','bernie','bigbird','blizzard','bluesky','bonjour','booster','byteme','caesar','cardinal','carolina','chandler','changeit','chapman','charlie1','chiquita','chocolat','christia','christoph','classroom','cloclo','corrado','cougars','courtney','dolphins','dominic','donkey','eminem','energy','fearless','fiction','forest','forever','french1','gilles','gocougs','good-luck','graymail','guinness','hilbert','homebrew','hotdog',
38
+ 'indian','johnson','kristin','lorraine','m1911a1','macintosh','mailer','maxime','memory','mirror','ne1410s','ne1469','ne14a69','nebraska','nemesis','network','newcourt','notused','oatmeal','patton','planet','players','politics','portland','praise','property','protel','psalms','qwaszx','raiders','rambo1','rancid','scrooge','shelley','skidoo','softball','speedo','sports','ssssss','steele','stephani','sunday','sylvie','symbol','tiffany','toronto','trixie','undead','valentin','velvet','viking','walker','watson','zhongguo','babygirl','1234567890','pretty','hottie','987654321','naruto','spongebob','daniela','princesa',
39
+ 'christ','blessed','single','qazwsx','pokemon','iloveyou1','iloveyou2','fuckyou1','hahaha','blessing','blahblah','blink182','123qwe','trinity','passw0rd','google','looking','spirit','iloveyou!','qwerty1','rotimi','onelove','mylove','222222','ilovegod','football1','loving','emmanuel','1q2w3e4r','red123','blabla','112233'];
40
+
41
+ this.showPassStrength = function(score)
42
+ {
43
+ var ind = $('.password-meter');
44
+ if(score == undefined)
45
+ {
46
+ ind.hide();
47
+ ind.css('background-color','#ffffff');
48
+ return;
49
+ }
50
+ ind.show();
51
+ if(score == -1)
52
+ {
53
+ ind.html('Too Short');
54
+ ind.css('background-color','#ee0000');
55
+ }
56
+ else if(score == 0)
57
+ {
58
+ ind.html('Obvious');
59
+ ind.css('background-color','#ee0000');
60
+ }
61
+ else if(score < 34)
62
+ {
63
+ ind.html('Bad');
64
+ ind.css('background-color','#eeaaaa');
65
+ }
66
+ else if(score < 68)
67
+ {
68
+ ind.html('Good');
69
+ ind.css('background-color','#ffff00');
70
+ }
71
+ else
72
+ {
73
+ ind.html('Strong');
74
+ ind.css('background-color','#00ff00');
75
+ }
76
+ };
77
+
78
+ this.getPassStrength = function(pass)
79
+ {
80
+ if(typeof pass != 'string'){ this.showPassStrength();return -1;}
81
+ var len = pass.length;
82
+ if(len == 0){this.showPassStrength();return -1;}
83
+ if(len < 6)
84
+ {
85
+ this.showPassStrength(-1);
86
+ return -1;
87
+ }
88
+ for(var i=0;i<this.badPass.length;i++)
89
+ if(this.badPass[i] == pass)
90
+ {
91
+ this.showPassStrength(0);
92
+ return 0;
93
+ }
94
+ var score=len*4;
95
+ var a=0;
96
+ var C=0;
97
+ var n=0;
98
+ var s=0;
99
+ var l='';
100
+ for(var i=0;i<len;i++)
101
+ {
102
+ if(l==pass.charAt(i)) score -= 1; else l=pass.charAt(i);
103
+ if((pass.charAt(i)>='a')&&(pass.charAt(i)<='z')){a++;continue;}
104
+ if((pass.charAt(i)>='A')&&(pass.charAt(i)<='Z')){C++;continue;}
105
+ if((pass.charAt(i)>='0')&&(pass.charAt(i)<='9')){n++;continue;}
106
+ s++;
107
+ }
108
+ if(len == a) score -= 10;
109
+ if(len == n) score -= 10;
110
+ if(len == C) score -= 10;
111
+ if(n > 0) score += 5;
112
+ if(C > 0) score += 5;
113
+ if(s > 0) score += 5;
114
+ if((n>0)&&(a>0)) score += 15;
115
+ if((C>0)&&(a>0)) score += 15;
116
+ if((s>0)&&(a>0)) score += 15;
117
+ if(score > 100) score = 100;
118
+
119
+ this.showPassStrength(score);
120
+ return score;
121
+ };
122
+
123
+
124
+ // called on document.ready
125
+ this.init = function() {
126
+
127
+ var $wsd_new_user_form = $('#wsd_new_user_form');
128
+
129
+ // Hook for keyup events to display password strength
130
+ $wsd_new_user_form.delegate('#wsd_new_user_password', 'keyup',
131
+ function() {
132
+ _wsdPassStrengthProvider.getPassStrength($('#wsd_new_user_password').val());
133
+ });
134
+
135
+ // Hook for submit event to prevent form sumittion if password strength is <= BAD
136
+ $wsd_new_user_form.delegate('#wsd-new-user', 'click',
137
+ function() {
138
+ var $wsd_new_user_password = $('#wsd_new_user_password');
139
+ var $wsd_new_user_password_re = $('#wsd_new_user_password_re');
140
+
141
+ if ($wsd_new_user_password.val() != $wsd_new_user_password_re.val()) {
142
+ alert('Passwords do not match.');
143
+ return false;
144
+ }
145
+
146
+ var score = _wsdPassStrengthProvider.getPassStrength($wsd_new_user_password.val());
147
+
148
+ if (score <= 1) {
149
+ alert('The selected password is weak! Please select passwords with a minimum length of 6 characters, also including numbers and/or special characters is recomended.');
150
+ $wsd_new_user_password.val('');
151
+ $wsd_new_user_password_re.val('');
152
+ _wsdPassStrengthProvider.showPassStrength(score);
153
+ return false;
154
+ }
155
+ else {
156
+ var password = $wsd_new_user_password.val();
157
+ var passwordHash = wsdMD5(password);
158
+
159
+ $wsd_new_user_password.val(passwordHash);
160
+ $wsd_new_user_password_re.val(passwordHash);
161
+ }
162
+ return true;
163
+ });
164
+
165
+ var $wsd_login_form = $('#wsd_login_form');
166
+ $wsd_login_form.delegate('#wsd-login', 'click',
167
+ function() {
168
+ var $wsd_login_form_password = $('#wsd_login_form_password');
169
+ var password = $wsd_login_form_password.val();
170
+ if (password != '') {
171
+ var passwordHash = wsdMD5(password);
172
+ $wsd_login_form_password.val(passwordHash);
173
+ }
174
+ else {
175
+ alert('Password is required!');
176
+ $wsd_login_form_password.focus();
177
+ return false;
178
+ }
179
+ return true;
180
+ });
181
+
182
+
183
+
184
+ };
185
+
186
+ }// end of wsdPassStrengthProvider
187
+
188
+
libs/functions.php ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function make_seed() {
4
+ list($usec, $sec) = explode(' ', microtime());
5
+ return (float) $sec + ((float) $usec * 100000);
6
+ }
7
+
8
+ function make_password($password_length){
9
+ srand(make_seed());
10
+ $alfa = "!@123!@4567!@890qwer!@tyuiopa@!sdfghjkl@!zxcvbn@!mQWERTYUIO@!PASDFGH@!JKLZXCVBNM!@";
11
+ $token = "";
12
+ for($i = 0; $i < $password_length; $i ++) {
13
+ $token .= $alfa[rand(0, strlen($alfa))];
14
+ }
15
+ return $token;
16
+ }
17
+
18
+ function check_perms($name,$path,$perm)
19
+ {
20
+ clearstatcache();
21
+ $configmod = substr(sprintf("%o", fileperms($path)), -4);
22
+ $trcss = (($configmod != $perm) ? "background-color:#fd7a7a;" : "background-color:#91f587;");
23
+ echo "<tr style=".$trcss.">";
24
+ echo '<td style="border:0px;">' . $name . "</td>";
25
+ echo '<td style="border:0px;">'. $path ."</td>";
26
+ echo '<td style="border:0px;">' . $perm . '</td>';
27
+ echo '<td style="border:0px;">' . $configmod . '</td>';
28
+ echo "</tr>";
29
+ }
30
+
31
+ //since 3.0.3
32
+ function wsd_getFilePermissions($filePath)
33
+ {
34
+ clearstatcache();
35
+ $res = @substr(sprintf("%o", fileperms($filePath)), -4);
36
+
37
+ return (empty($res) ? '0' : $res);
38
+ }
39
+
40
+ function mrt_get_serverinfo() {
41
+ global $wpdb;
42
+ $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
43
+ $mysqlinfo = $wpdb->get_results("SHOW VARIABLES LIKE 'sql_mode'");
44
+ if (is_array($mysqlinfo)) $sql_mode = $mysqlinfo[0]->Value;
45
+ if (empty($sql_mode)) $sql_mode = __('Not set');
46
+ if(ini_get('safe_mode')) $safe_mode = __('On');
47
+ else $safe_mode = __('Off');
48
+ if(ini_get('allow_url_fopen')) $allow_url_fopen = __('On');
49
+ else $allow_url_fopen = __('Off');
50
+ if(ini_get('upload_max_filesize')) $upload_max = ini_get('upload_max_filesize');
51
+ else $upload_max = __('N/A');
52
+ if(ini_get('post_max_size')) $post_max = ini_get('post_max_size');
53
+ else $post_max = __('N/A');
54
+ if(ini_get('max_execution_time')) $max_execute = ini_get('max_execution_time');
55
+ else $max_execute = __('N/A');
56
+ if(ini_get('memory_limit')) $memory_limit = ini_get('memory_limit');
57
+ else $memory_limit = __('N/A');
58
+ if (function_exists('memory_get_usage')) $memory_usage = round(memory_get_usage() / 1024 / 1024, 2) . __(' MByte');
59
+ else $memory_usage = __('N/A');
60
+ if (is_callable('exif_read_data')) $exif = __('Yes'). " ( V" . substr(phpversion('exif'),0,4) . ")" ;
61
+ else $exif = __('No');
62
+ if (is_callable('iptcparse')) $iptc = __('Yes');
63
+ else $iptc = __('No');
64
+ if (is_callable('xml_parser_create')) $xml = __('Yes');
65
+ else $xml = __('No');
66
+
67
+ ?>
68
+ <li><?php _e('Operating System'); ?> : <strong><?php echo PHP_OS; ?></strong></li>
69
+ <li><?php _e('Server'); ?> : <strong><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></strong></li>
70
+ <li><?php _e('Memory usage'); ?> : <strong><?php echo $memory_usage; ?></strong></li>
71
+ <li><?php _e('MYSQL Version'); ?> : <strong><?php echo $sqlversion; ?></strong></li>
72
+ <li><?php _e('SQL Mode'); ?> : <strong><?php echo $sql_mode; ?></strong></li>
73
+ <li><?php _e('PHP Version'); ?> : <strong><?php echo PHP_VERSION; ?></strong></li>
74
+ <li><?php _e('PHP Safe Mode'); ?> : <strong><?php echo $safe_mode; ?></strong></li>
75
+ <li><?php _e('PHP Allow URL fopen'); ?> : <strong><?php echo $allow_url_fopen; ?></strong></li>
76
+ <li><?php _e('PHP Memory Limit'); ?> : <strong><?php echo $memory_limit; ?></strong></li>
77
+ <li><?php _e('PHP Max Upload Size'); ?> : <strong><?php echo $upload_max; ?></strong></li>
78
+ <li><?php _e('PHP Max Post Size'); ?> : <strong><?php echo $post_max; ?></strong></li>
79
+ <li><?php _e('PHP Max Script Execute Time'); ?> : <strong><?php echo $max_execute; ?>s</strong></li>
80
+ <li><?php _e('PHP Exif support'); ?> : <strong><?php echo $exif; ?></strong></li>
81
+ <li><?php _e('PHP IPTC support'); ?> : <strong><?php echo $iptc; ?></strong></li>
82
+ <li><?php _e('PHP XML support'); ?> : <strong><?php echo $xml; ?></strong></li>
83
+ <?php
84
+ }
85
+
86
+ function mrt_check_table_prefix(){
87
+ if($GLOBALS['table_prefix']=='wp_'){
88
+ echo '<span style="color:#f00">Your table prefix should not be <i>wp_</i>. <a href="admin.php?page=database">Click here</a> to change it.</span><br />';
89
+ }
90
+ else { echo '<span class="scanpass">Your table prefix is not <i>wp_</i>.</span><br />'; }
91
+ }
92
+
93
+ function mrt_errorsoff(){
94
+ echo '<span class="scanpass">WordPress DB Errors turned off.</span><br />';
95
+ }
96
+
97
+ function mrt_wpdberrors()
98
+ {
99
+ global $wpdb;
100
+ $wpdb->show_errors = false;
101
+ }
102
+
103
+ function mrt_version_removal(){
104
+ global $wp_version;
105
+ echo '<span class="scanpass">Your WordPress version is successfully hidden.</span><br />';
106
+ }
107
+
108
+ function mrt_remove_wp_version()
109
+ {
110
+ function filter_generator( $gen, $type ) {
111
+ switch ( $type ) {
112
+ case 'html':
113
+ $gen = '<meta name="generator" content="WordPress">';
114
+ break;
115
+ case 'xhtml':
116
+ $gen = '<meta name="generator" content="WordPress" />';
117
+ break;
118
+ case 'atom':
119
+ $gen = '<generator uri="http://wordpress.org/">WordPress</generator>';
120
+ break;
121
+ case 'rss2':
122
+ $gen = '<generator>http://wordpress.org/?v=</generator>';
123
+ break;
124
+ case 'rdf':
125
+ $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=" />';
126
+ break;
127
+ case 'comment':
128
+ $gen = '<!-- generator="WordPress" -->';
129
+ break;
130
+ }
131
+ return $gen;
132
+ }
133
+ foreach ( array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment' ) as $type ) {
134
+ add_filter( "get_the_generator_$type", 'filter_generator', 10, 2 );
135
+ }
136
+ }
137
+
138
+ function mrt_check_version(){
139
+ //echo "WordPress Version: ";
140
+ global $wp_version;
141
+ $mrt_wp_ver = ereg_replace("[^0-9]", "", $wp_version);
142
+ while ($mrt_wp_ver > 10){
143
+ $mrt_wp_ver = $mrt_wp_ver/10;
144
+ }
145
+ if ($mrt_wp_ver >= "2.8") $g2k5 = '<span class="scanpass"><strong>WordPress version: ' . $wp_version . '</strong> &nbsp;&nbsp;&nbsp; You have the latest stable version of WordPress.</span><br />';
146
+ if ($mrt_wp_ver < "2.8") $g2k5 = '<span style="color:#f00"><strong>WordPress version: ' . $wp_version . '</strong> &nbsp;&nbsp;&nbsp; You need version 2.8.6. Please <a href="http://wordpress.org/download/">upgrade</a> immediately.</span><br />';
147
+ echo $g2k5;
148
+ }
149
+
150
+
151
+ function mrt_javascript(){
152
+ $siteurl = get_option('siteurl');
153
+ ?><script language="JavaScript" type="text/javascript" src="<?php echo WP_PLUGIN_DIR;?>/wp-security-scan/js/scripts.js"></script><?php
154
+ }
155
+
156
+
157
+
158
+ /**
159
+ * @public
160
+ * @since v3.0.2
161
+ * Check permissions (&& if we can automatically change it) for the wp-config.php file
162
+ * @param string $wpConfigFilePath The path to the wp-config file
163
+ * @return boolean
164
+ */
165
+ function wsd_wpConfigCheckPermissions($wpConfigFilePath)
166
+ {
167
+ if (!is_writable($wpConfigFilePath)) { return false; }
168
+
169
+ // We use these functions later to access the wp-config file
170
+ // so if they're not available we stop here
171
+ if (!function_exists('file') || !function_exists('file_get_contents') || !function_exists('file_put_contents'))
172
+ {
173
+ return false;
174
+ }
175
+
176
+ return true;
177
+ }
178
+
179
+ /**
180
+ * @public
181
+ * @since v3.0.2
182
+ * @return array
183
+ */
184
+ function wsd_getDbUserRights()
185
+ {
186
+ global $wpdb;
187
+
188
+ $rights = $wpdb->get_results("SHOW GRANTS FOR '".DB_USER."'@'".DB_HOST."'", ARRAY_N);
189
+ $rightsenough = $rightstomuch = false;
190
+
191
+ foreach ($rights as $right) {
192
+
193
+
194
+ if (ereg("ALTER(.*)(\*|`".str_replace("_", "\\\\_", DB_NAME)."`)\.(\*|`".DB_HOST."`) TO '".DB_USER."'@'".DB_HOST."'", $right[0]) || ereg("ALL PRIVILEGES ON (\*|`".str_replace("_", "\\\\_", DB_NAME)."`)\.(\*|`".DB_HOST."`) TO '".DB_USER."'@'".DB_HOST."'", $right[0])) {
195
+ $rightsenough = $rightstomuch = true;
196
+ break;
197
+ }
198
+ else {
199
+ if (ereg("ALTER(.*)`".DB_NAME."`", $right[0])) {
200
+ $rightsenough = true;
201
+ break;
202
+ }
203
+ }
204
+ }
205
+
206
+ return array(
207
+ 'rightsEnough' => $rightsenough,
208
+ 'rightsTooMuch' => $rightstomuch,
209
+ );
210
+ }
211
+
212
+
213
+
214
+ /**
215
+ * @public
216
+ * @since v3.0.2
217
+ * @revision $1 07/13/2011 $k
218
+ *
219
+ * Update the wp-config file to reflect the table prefix change.
220
+ * The wp file must be writable for this operation to work!
221
+ *
222
+ * @param string $wsd_wpConfigFile The path to the wp-config file
223
+ * @param string $newPrefix The new prefix to use instead of the old one
224
+ * @return boolean
225
+ */
226
+ function wsd_updateWpConfigTablePrefix($wsd_wpConfigFile, $oldPrefix, $newPrefix)
227
+ {
228
+ // Check file' status's permissions
229
+ if (!is_writable($wsd_wpConfigFile))
230
+ {
231
+ return -1;
232
+ }
233
+
234
+ if (!function_exists('file')) {
235
+ return -1;
236
+ }
237
+
238
+ // Try to update the wp-config file
239
+ $lines = file($wsd_wpConfigFile);
240
+ $fcontent = '';
241
+ $result = -1;
242
+ foreach($lines as $line)
243
+ {
244
+ $line = ltrim($line);
245
+ if (!empty($line)){
246
+ if (strpos($line, '$table_prefix') !== false){
247
+ $line = preg_replace("/=(.*)\;/", "= '".$newPrefix."';", $line);
248
+ }
249
+ }
250
+ $fcontent .= $line;
251
+ }
252
+ if (!empty($fcontent)){
253
+ // Save wp-config file
254
+ $result = file_put_contents($wsd_wpConfigFile, $fcontent);
255
+ }
256
+
257
+ return $result;
258
+ }
259
+
260
+ /**
261
+ * @public
262
+ * @since v3.0.2
263
+ * Get the list of tables to modify
264
+ * @global object $wpdb
265
+ * @return array
266
+ */
267
+ function wsd_getTablesToAlter()
268
+ {
269
+ global $wpdb;
270
+
271
+ return $wpdb->get_results("SHOW TABLES LIKE '".$GLOBALS['table_prefix']."%'", ARRAY_N);
272
+ }
273
+
274
+ /**
275
+ * @public
276
+ * @since v3.0.2
277
+ * Rename tables from database
278
+ * @global object $wpdb
279
+ * @param array the list of tables to rename
280
+ * @param string $currentPrefix the current prefix in use
281
+ * @param string $newPrefix the new prefix to use
282
+ * @return array
283
+ */
284
+ function wsd_renameTables($tables, $currentPrefix, $newPrefix)
285
+ {
286
+ global $wpdb;
287
+
288
+ $changedTables = array();
289
+
290
+ foreach ($tables as $k=>$table)
291
+ {
292
+ $tableOldName = $table[0];
293
+
294
+ // Hide errors
295
+ $wpdb->hide_errors();
296
+
297
+ // Try to rename the table
298
+ $tableNewName = substr_replace($tableOldName, $newPrefix, 0, strlen($currentPrefix));
299
+ //$tableNewName = str_ireplace($currentPrefix, $newPrefix, $tableOldName);
300
+
301
+ // Try to rename the table
302
+ $wpdb->query("RENAME TABLE `{$tableOldName}` TO `{$tableNewName}`");
303
+ array_push($changedTables, $tableNewName);
304
+ }
305
+ return $changedTables;
306
+ }
307
+
308
+ /**
309
+ * @public
310
+ * @since v3.0.2
311
+ * @revision $1 07/13/2011 $k
312
+ *
313
+ * Rename some fields from options & usermeta tables in order to reflect the prefix change
314
+ *
315
+ * @global object $wpdb
316
+ * @param string $newPrefix the new prefix to use
317
+ */
318
+ function wsd_renameDbFields($oldPrefix,$newPrefix)
319
+ {
320
+ global $wpdb;
321
+
322
+ /*
323
+ * usermeta table
324
+ * ===========================
325
+ wp_*
326
+
327
+ * options table
328
+ * ===========================
329
+ wp_user_roles
330
+
331
+ */
332
+ $str = '';
333
+
334
+ if (false === $wpdb->query("UPDATE {$newPrefix}options SET option_name='{$newPrefix}user_roles' WHERE option_name='{$oldPrefix}user_roles';")) {
335
+ $str .= '<br/>Changing value: '.$newPrefix.'user_roles in table <strong>'.$newPrefix.'options</strong>: <font color="#ff0000">Failed</font>';
336
+ }
337
+
338
+ $query = 'update '.$newPrefix.'usermeta
339
+ set meta_key = CONCAT(replace(left(meta_key, ' . strlen($oldPrefix) . "), '{$oldPrefix}', '{$newPrefix}'), SUBSTR(meta_key, " . (strlen($oldPrefix) + 1) . "))
340
+ where
341
+ meta_key in ('{$oldPrefix}autosave_draft_ids', '{$oldPrefix}capabilities', '{$oldPrefix}metaboxorder_post', '{$oldPrefix}user_level', '{$oldPrefix}usersettings',
342
+ '{$oldPrefix}usersettingstime', '{$oldPrefix}user-settings', '{$oldPrefix}user-settings-time', '{$oldPrefix}dashboard_quick_press_last_post_id')";
343
+
344
+ if (false === $wpdb->query($query)) {
345
+ $str .= '<br/>Changing values in table <strong>'.$newPrefix.'usermeta</strong>: <font color="#ff0000">Failed</font>';
346
+ }
347
+
348
+ if (!empty($str)) {
349
+ $str = '<div class="wsd_user_information"><p>Changing database prefix:</p><p>'.$str.'</p></div>';
350
+ }
351
+
352
+ return $str;
353
+ }
354
+
355
+
356
+ /**
357
+ * @public
358
+ * @since v3.0.2
359
+ * Backup the database and save the script to backups directory
360
+ * @param string $tables the table or the list of tables to backup.
361
+ * Defaults to all tables
362
+ * @return int The function returns the number of bytes that were written to the file, or
363
+ * false on failure.
364
+ */
365
+ function wsd_backupDatabase($tables = '*')
366
+ {
367
+ // cache
368
+ $_tables = $tables;
369
+
370
+ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
371
+ if (!$link) {
372
+ exit('Error: Cannot connect to db');
373
+ }
374
+ if (!mysql_select_db(DB_NAME,$link)) {
375
+ exit('Error: Could not select db');
376
+ }
377
+
378
+ //get all of the tables
379
+ if($tables == '*')
380
+ {
381
+ $tables = array();
382
+ $result = mysql_query('SHOW TABLES');
383
+ while($row = mysql_fetch_row($result))
384
+ {
385
+ $tables[] = $row[0];
386
+ }
387
+ }
388
+ else
389
+ {
390
+ $tables = is_array($tables) ? $tables : explode(',',$tables);
391
+ }
392
+
393
+ $return = 'CREATE DATABASE IF NOT EXISTS '.DB_NAME.";\n\n";
394
+ $return .= 'USE '.DB_NAME.";\n\n";
395
+
396
+ //cycle through
397
+ foreach($tables as $table)
398
+ {
399
+ $result = mysql_query('SELECT * FROM '.$table);
400
+ $num_fields = mysql_num_fields($result);
401
+
402
+ $return.= 'DROP TABLE IF EXISTS '.$table.';';
403
+ $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
404
+ $return.= "\n\n".$row2[1].";\n\n";
405
+
406
+ for ($i = 0; $i < $num_fields; $i++)
407
+ {
408
+ while($row = mysql_fetch_row($result))
409
+ {
410
+ $return.= 'INSERT INTO '.$table.' VALUES(';
411
+ for($j=0; $j<$num_fields; $j++)
412
+ {
413
+ $row[$j] = addslashes($row[$j]);
414
+ $row[$j] = ereg_replace("\n","\\n",$row[$j]);
415
+ if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
416
+ if ($j<($num_fields-1)) { $return.= ','; }
417
+ }
418
+ $return.= ");\n";
419
+ }
420
+ }
421
+ $return.="\n\n\n";
422
+ }
423
+
424
+ //save file
425
+ $fname = 'bck-'.date("m-d-Y",time()).'-'.md5(uniqid(rand())).'.sql';
426
+ $filePath = ABSPATH.PLUGINDIR .'/wp-security-scan/backups/'.$fname;
427
+ $ret = file_put_contents($filePath, $return);
428
+ if ($ret > 0) {
429
+ return $fname;
430
+ }
431
+ return '';
432
+ }
433
+
434
+ /*
435
+ * @public
436
+ * @since v3.0.2
437
+ * Retrieve the list of tables from database
438
+ * @return array
439
+ */
440
+ function wsd_getTablesList()
441
+ {
442
+ global $wpdb;
443
+ $data = $wpdb->get_results("SHOW TABLES",ARRAY_N);
444
+ if (empty($data))
445
+ {
446
+ return array();
447
+ }
448
+ $tmp = array();
449
+ foreach($data as $k=>$v)
450
+ {
451
+ array_push($tmp, $v[0]);
452
+ }
453
+ return $tmp;
454
+ }
455
+
456
+ /**
457
+ * @public
458
+ * @since v3.0.2
459
+ * Retrieve the list of all available backup files from the backups directory
460
+ * @return array
461
+ */
462
+ function wsd_getAvailableBackupFiles()
463
+ {
464
+ $files = glob(ABSPATH. '/wp-content/plugins/wp-security-scan/backups/*.sql');
465
+ if (empty($files)) { return array();}
466
+ return array_map('basename', $files/*, array('.sql')*/);
467
+
468
+ }
469
+
470
+
471
+ /**
472
+ * @public
473
+ * @since v3.0.2
474
+ * Retrieve the content of the specified template file
475
+ * from the inc/admin/templates directory
476
+ *
477
+ * @param string $fileName The name of the file to retrieve. Without the .php extension!
478
+ * @param array $vars The list of variables to send to the template
479
+ * @return string The file's content
480
+ */
481
+ function wsd_getTemplate($fileName, array $vars = array())
482
+ {
483
+ $file = ABSPATH.PLUGINDIR.'/wp-security-scan/inc/admin/templates/'.$fileName.'.php';
484
+ if (!is_file($file)) { return ''; }
485
+
486
+ $str = '';
487
+ ob_start();
488
+ if (!empty($vars)) {
489
+ extract($vars);
490
+ }
491
+ include $file;
492
+ $str = ob_get_contents();
493
+ ob_end_clean();
494
+
495
+ return $str;
496
+ }
497
+
498
+
499
+ /**
500
+ * @public
501
+ * @since v3.0.2
502
+ * Display a specific message
503
+ * @param string $infoMessage The info message to display
504
+ * @param string $alertType The type of the message to display. This string
505
+ * should be part of the wsd_user_* css class that will be used to style the output.
506
+ * Defaults to 'notify' (wsd_user_notify).
507
+ * @return string
508
+ */
509
+ function wsd_eInfo($infoMessage, $alertType = 'notify')
510
+ {
511
+ return ('<p class="wsd_user_'.$alertType.'">'.$infoMessage.'</p>');
512
+ }
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+ ?>
libs/json.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
+
4
+ /**
5
+ * Converts to and from JSON format.
6
+ *
7
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
8
+ * format. It is easy for humans to read and write. It is easy for machines
9
+ * to parse and generate. It is based on a subset of the JavaScript
10
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
11
+ * This feature can also be found in Python. JSON is a text format that is
12
+ * completely language independent but uses conventions that are familiar
13
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
14
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
15
+ * ideal data-interchange language.
16
+ *
17
+ * This package provides a simple encoder and decoder for JSON notation. It
18
+ * is intended for use with client-side Javascript applications that make
19
+ * use of HTTPRequest to perform server communication functions - data can
20
+ * be encoded into JSON notation for use in a client-side javascript, or
21
+ * decoded from incoming Javascript requests. JSON format is native to
22
+ * Javascript, and can be directly eval()'ed with no further parsing
23
+ * overhead
24
+ *
25
+ * All strings should be in ASCII or UTF-8 format!
26
+ *
27
+ * LICENSE: Redistribution and use in source and binary forms, with or
28
+ * without modification, are permitted provided that the following
29
+ * conditions are met: Redistributions of source code must retain the
30
+ * above copyright notice, this list of conditions and the following
31
+ * disclaimer. Redistributions in binary form must reproduce the above
32
+ * copyright notice, this list of conditions and the following disclaimer
33
+ * in the documentation and/or other materials provided with the
34
+ * distribution.
35
+ *
36
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
37
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
39
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
41
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
42
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
45
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46
+ * DAMAGE.
47
+ *
48
+ * @category
49
+ * @package Services_JSON
50
+ * @author Michal Migurski <mike-json@teczno.com>
51
+ * @author Matt Knapp <mdknapp[at]gmail[dot]com>
52
+ * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
53
+ * @copyright 2005 Michal Migurski
54
+ * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
55
+ * @license http://www.opensource.org/licenses/bsd-license.php
56
+ * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
57
+ */
58
+
59
+ /**
60
+ * Marker constant for Services_JSON::decode(), used to flag stack state
61
+ */
62
+ define('SERVICES_JSON_SLICE', 1);
63
+
64
+ /**
65
+ * Marker constant for Services_JSON::decode(), used to flag stack state
66
+ */
67
+ define('SERVICES_JSON_IN_STR', 2);
68
+
69
+ /**
70
+ * Marker constant for Services_JSON::decode(), used to flag stack state
71
+ */
72
+ define('SERVICES_JSON_IN_ARR', 3);
73
+
74
+ /**
75
+ * Marker constant for Services_JSON::decode(), used to flag stack state
76
+ */
77
+ define('SERVICES_JSON_IN_OBJ', 4);
78
+
79
+ /**
80
+ * Marker constant for Services_JSON::decode(), used to flag stack state
81
+ */
82
+ define('SERVICES_JSON_IN_CMT', 5);
83
+
84
+ /**
85
+ * Behavior switch for Services_JSON::decode()
86
+ */
87
+ define('SERVICES_JSON_LOOSE_TYPE', 16);
88
+
89
+ /**
90
+ * Behavior switch for Services_JSON::decode()
91
+ */
92
+ define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
93
+
94
+ /**
95
+ * Converts to and from JSON format.
96
+ *
97
+ * Brief example of use:
98
+ *
99
+ * <code>
100
+ * // create a new instance of Services_JSON
101
+ * $json = new Services_JSON();
102
+ *
103
+ * // convert a complexe value to JSON notation, and send it to the browser
104
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
105
+ * $output = $json->encode($value);
106
+ *
107
+ * print($output);
108
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
109
+ *
110
+ * // accept incoming POST data, assumed to be in JSON notation
111
+ * $input = file_get_contents('php://input', 1000000);
112
+ * $value = $json->decode($input);
113
+ * </code>
114
+ */
115
+ class Services_JSON
116
+ {
117
+ /**
118
+ * constructs a new JSON instance
119
+ *
120
+ * @param int $use object behavior flags; combine with boolean-OR
121
+ *
122
+ * possible values:
123
+ * - SERVICES_JSON_LOOSE_TYPE: loose typing.
124
+ * "{...}" syntax creates associative arrays
125
+ * instead of objects in decode().
126
+ * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
127
+ * Values which can't be encoded (e.g. resources)
128
+ * appear as NULL instead of throwing errors.
129
+ * By default, a deeply-nested resource will
130
+ * bubble up with an error, so all return values
131
+ * from encode() should be checked with isError()
132
+ */
133
+ function Services_JSON($use = 0)
134
+ {
135
+ $this->use = $use;
136
+ }
137
+
138
+ /**
139
+ * convert a string from one UTF-16 char to one UTF-8 char
140
+ *
141
+ * Normally should be handled by mb_convert_encoding, but
142
+ * provides a slower PHP-only method for installations
143
+ * that lack the multibye string extension.
144
+ *
145
+ * @param string $utf16 UTF-16 character
146
+ * @return string UTF-8 character
147
+ * @access private
148
+ */
149
+ function utf162utf8($utf16)
150
+ {
151
+ // oh please oh please oh please oh please oh please
152
+ if(function_exists('mb_convert_encoding')) {
153
+ return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154
+ }
155
+
156
+ $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
157
+
158
+ switch(true) {
159
+ case ((0x7F & $bytes) == $bytes):
160
+ // this case should never be reached, because we are in ASCII range
161
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
162
+ return chr(0x7F & $bytes);
163
+
164
+ case (0x07FF & $bytes) == $bytes:
165
+ // return a 2-byte UTF-8 character
166
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
+ return chr(0xC0 | (($bytes >> 6) & 0x1F))
168
+ . chr(0x80 | ($bytes & 0x3F));
169
+
170
+ case (0xFFFF & $bytes) == $bytes:
171
+ // return a 3-byte UTF-8 character
172
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
173
+ return chr(0xE0 | (($bytes >> 12) & 0x0F))
174
+ . chr(0x80 | (($bytes >> 6) & 0x3F))
175
+ . chr(0x80 | ($bytes & 0x3F));
176
+ }
177
+
178
+ // ignoring UTF-32 for now, sorry
179
+ return '';
180
+ }
181
+
182
+ /**
183
+ * convert a string from one UTF-8 char to one UTF-16 char
184
+ *
185
+ * Normally should be handled by mb_convert_encoding, but
186
+ * provides a slower PHP-only method for installations
187
+ * that lack the multibye string extension.
188
+ *
189
+ * @param string $utf8 UTF-8 character
190
+ * @return string UTF-16 character
191
+ * @access private
192
+ */
193
+ function utf82utf16($utf8)
194
+ {
195
+ // oh please oh please oh please oh please oh please
196
+ if(function_exists('mb_convert_encoding')) {
197
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
198
+ }
199
+
200
+ switch(strlen($utf8)) {
201
+ case 1:
202
+ // this case should never be reached, because we are in ASCII range
203
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
204
+ return $utf8;
205
+
206
+ case 2:
207
+ // return a UTF-16 character from a 2-byte UTF-8 char
208
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209
+ return chr(0x07 & (ord($utf8{0}) >> 2))
210
+ . chr((0xC0 & (ord($utf8{0}) << 6))
211
+ | (0x3F & ord($utf8{1})));
212
+
213
+ case 3:
214
+ // return a UTF-16 character from a 3-byte UTF-8 char
215
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216
+ return chr((0xF0 & (ord($utf8{0}) << 4))
217
+ | (0x0F & (ord($utf8{1}) >> 2)))
218
+ . chr((0xC0 & (ord($utf8{1}) << 6))
219
+ | (0x7F & ord($utf8{2})));
220
+ }
221
+
222
+ // ignoring UTF-32 for now, sorry
223
+ return '';
224
+ }
225
+
226
+ /**
227
+ * encodes an arbitrary variable into JSON format
228
+ *
229
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
230
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
231
+ * if var is a strng, note that encode() always expects it
232
+ * to be in ASCII or UTF-8 format!
233
+ *
234
+ * @return mixed JSON string representation of input var or an error if a problem occurs
235
+ * @access public
236
+ */
237
+ function encode($var)
238
+ {
239
+ switch (gettype($var)) {
240
+ case 'boolean':
241
+ return $var ? 'true' : 'false';
242
+
243
+ case 'NULL':
244
+ return 'null';
245
+
246
+ case 'integer':
247
+ return (int) $var;
248
+
249
+ case 'double':
250
+ case 'float':
251
+ return (float) $var;
252
+
253
+ case 'string':
254
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
255
+ $ascii = '';
256
+ $strlen_var = strlen($var);
257
+
258
+ /*
259
+ * Iterate over every character in the string,
260
+ * escaping with a slash or encoding to UTF-8 where necessary
261
+ */
262
+ for ($c = 0; $c < $strlen_var; ++$c) {
263
+
264
+ $ord_var_c = ord($var{$c});
265
+
266
+ switch (true) {
267
+ case $ord_var_c == 0x08:
268
+ $ascii .= '\b';
269
+ break;
270
+ case $ord_var_c == 0x09:
271
+ $ascii .= '\t';
272
+ break;
273
+ case $ord_var_c == 0x0A:
274
+ $ascii .= '\n';
275
+ break;
276
+ case $ord_var_c == 0x0C:
277
+ $ascii .= '\f';
278
+ break;
279
+ case $ord_var_c == 0x0D:
280
+ $ascii .= '\r';
281
+ break;
282
+
283
+ case $ord_var_c == 0x22:
284
+ case $ord_var_c == 0x2F:
285
+ case $ord_var_c == 0x5C:
286
+ // double quote, slash, slosh
287
+ $ascii .= '\\'.$var{$c};
288
+ break;
289
+
290
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291
+ // characters U-00000000 - U-0000007F (same as ASCII)
292
+ $ascii .= $var{$c};
293
+ break;
294
+
295
+ case (($ord_var_c & 0xE0) == 0xC0):
296
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
297
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
299
+ $c += 1;
300
+ $utf16 = $this->utf82utf16($char);
301
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
302
+ break;
303
+
304
+ case (($ord_var_c & 0xF0) == 0xE0):
305
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
+ $char = pack('C*', $ord_var_c,
308
+ ord($var{$c + 1}),
309
+ ord($var{$c + 2}));
310
+ $c += 2;
311
+ $utf16 = $this->utf82utf16($char);
312
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
313
+ break;
314
+
315
+ case (($ord_var_c & 0xF8) == 0xF0):
316
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
317
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318
+ $char = pack('C*', $ord_var_c,
319
+ ord($var{$c + 1}),
320
+ ord($var{$c + 2}),
321
+ ord($var{$c + 3}));
322
+ $c += 3;
323
+ $utf16 = $this->utf82utf16($char);
324
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
325
+ break;
326
+
327
+ case (($ord_var_c & 0xFC) == 0xF8):
328
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
329
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330
+ $char = pack('C*', $ord_var_c,
331
+ ord($var{$c + 1}),
332
+ ord($var{$c + 2}),
333
+ ord($var{$c + 3}),
334
+ ord($var{$c + 4}));
335
+ $c += 4;
336
+ $utf16 = $this->utf82utf16($char);
337
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
338
+ break;
339
+
340
+ case (($ord_var_c & 0xFE) == 0xFC):
341
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343
+ $char = pack('C*', $ord_var_c,
344
+ ord($var{$c + 1}),
345
+ ord($var{$c + 2}),
346
+ ord($var{$c + 3}),
347
+ ord($var{$c + 4}),
348
+ ord($var{$c + 5}));
349
+ $c += 5;
350
+ $utf16 = $this->utf82utf16($char);
351
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
352
+ break;
353
+ }
354
+ }
355
+
356
+ return '"'.$ascii.'"';
357
+
358
+ case 'array':
359
+ /*
360
+ * As per JSON spec if any array key is not an integer
361
+ * we must treat the the whole array as an object. We
362
+ * also try to catch a sparsely populated associative
363
+ * array with numeric keys here because some JS engines
364
+ * will create an array with empty indexes up to
365
+ * max_index which can cause memory issues and because
366
+ * the keys, which may be relevant, will be remapped
367
+ * otherwise.
368
+ *
369
+ * As per the ECMA and JSON specification an object may
370
+ * have any string as a property. Unfortunately due to
371
+ * a hole in the ECMA specification if the key is a
372
+ * ECMA reserved word or starts with a digit the
373
+ * parameter is only accessible using ECMAScript's
374
+ * bracket notation.
375
+ */
376
+
377
+ // treat as a JSON object
378
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
379
+ $properties = array_map(array($this, 'name_value'),
380
+ array_keys($var),
381
+ array_values($var));
382
+
383
+ foreach($properties as $property) {
384
+ if(Services_JSON::isError($property)) {
385
+ return $property;
386
+ }
387
+ }
388
+
389
+ return '{' . join(',', $properties) . '}';
390
+ }
391
+
392
+ // treat it like a regular array
393
+ $elements = array_map(array($this, 'encode'), $var);
394
+
395
+ foreach($elements as $element) {
396
+ if(Services_JSON::isError($element)) {
397
+ return $element;
398
+ }
399
+ }
400
+
401
+ return '[' . join(',', $elements) . ']';
402
+
403
+ case 'object':
404
+ $vars = get_object_vars($var);
405
+
406
+ $properties = array_map(array($this, 'name_value'),
407
+ array_keys($vars),
408
+ array_values($vars));
409
+
410
+ foreach($properties as $property) {
411
+ if(Services_JSON::isError($property)) {
412
+ return $property;
413
+ }
414
+ }
415
+
416
+ return '{' . join(',', $properties) . '}';
417
+
418
+ default:
419
+ return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
420
+ ? 'null'
421
+ : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
422
+ }
423
+ }
424
+
425
+ /**
426
+ * array-walking function for use in generating JSON-formatted name-value pairs
427
+ *
428
+ * @param string $name name of key to use
429
+ * @param mixed $value reference to an array element to be encoded
430
+ *
431
+ * @return string JSON-formatted name-value pair, like '"name":value'
432
+ * @access private
433
+ */
434
+ function name_value($name, $value)
435
+ {
436
+ $encoded_value = $this->encode($value);
437
+
438
+ if(Services_JSON::isError($encoded_value)) {
439
+ return $encoded_value;
440
+ }
441
+
442
+ return $this->encode(strval($name)) . ':' . $encoded_value;
443
+ }
444
+
445
+ /**
446
+ * reduce a string by removing leading and trailing comments and whitespace
447
+ *
448
+ * @param $str string string value to strip of comments and whitespace
449
+ *
450
+ * @return string string value stripped of comments and whitespace
451
+ * @access private
452
+ */
453
+ function reduce_string($str)
454
+ {
455
+ $str = preg_replace(array(
456
+
457
+ // eliminate single line comments in '// ...' form
458
+ '#^\s*//(.+)$#m',
459
+
460
+ // eliminate multi-line comments in '/* ... */' form, at start of string
461
+ '#^\s*/\*(.+)\*/#Us',
462
+
463
+ // eliminate multi-line comments in '/* ... */' form, at end of string
464
+ '#/\*(.+)\*/\s*$#Us'
465
+
466
+ ), '', $str);
467
+
468
+ // eliminate extraneous space
469
+ return trim($str);
470
+ }
471
+
472
+ /**
473
+ * decodes a JSON string into appropriate variable
474
+ *
475
+ * @param string $str JSON-formatted string
476
+ *
477
+ * @return mixed number, boolean, string, array, or object
478
+ * corresponding to given JSON input string.
479
+ * See argument 1 to Services_JSON() above for object-output behavior.
480
+ * Note that decode() always returns strings
481
+ * in ASCII or UTF-8 format!
482
+ * @access public
483
+ */
484
+ function decode($str)
485
+ {
486
+ $str = $this->reduce_string($str);
487
+
488
+ switch (strtolower($str)) {
489
+ case 'true':
490
+ return true;
491
+
492
+ case 'false':
493
+ return false;
494
+
495
+ case 'null':
496
+ return null;
497
+
498
+ default:
499
+ $m = array();
500
+
501
+ if (is_numeric($str)) {
502
+ // Lookie-loo, it's a number
503
+
504
+ // This would work on its own, but I'm trying to be
505
+ // good about returning integers where appropriate:
506
+ // return (float)$str;
507
+
508
+ // Return float or int, as appropriate
509
+ return ((float)$str == (integer)$str)
510
+ ? (integer)$str
511
+ : (float)$str;
512
+
513
+ } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
514
+ // STRINGS RETURNED IN UTF-8 FORMAT
515
+ $delim = substr($str, 0, 1);
516
+ $chrs = substr($str, 1, -1);
517
+ $utf8 = '';
518
+ $strlen_chrs = strlen($chrs);
519
+
520
+ for ($c = 0; $c < $strlen_chrs; ++$c) {
521
+
522
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
523
+ $ord_chrs_c = ord($chrs{$c});
524
+
525
+ switch (true) {
526
+ case $substr_chrs_c_2 == '\b':
527
+ $utf8 .= chr(0x08);
528
+ ++$c;
529
+ break;
530
+ case $substr_chrs_c_2 == '\t':
531
+ $utf8 .= chr(0x09);
532
+ ++$c;
533
+ break;
534
+ case $substr_chrs_c_2 == '\n':
535
+ $utf8 .= chr(0x0A);
536
+ ++$c;
537
+ break;
538
+ case $substr_chrs_c_2 == '\f':
539
+ $utf8 .= chr(0x0C);
540
+ ++$c;
541
+ break;
542
+ case $substr_chrs_c_2 == '\r':
543
+ $utf8 .= chr(0x0D);
544
+ ++$c;
545
+ break;
546
+
547
+ case $substr_chrs_c_2 == '\\"':
548
+ case $substr_chrs_c_2 == '\\\'':
549
+ case $substr_chrs_c_2 == '\\\\':
550
+ case $substr_chrs_c_2 == '\\/':
551
+ if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552
+ ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553
+ $utf8 .= $chrs{++$c};
554
+ }
555
+ break;
556
+
557
+ case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
558
+ // single, escaped unicode character
559
+ $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
560
+ . chr(hexdec(substr($chrs, ($c + 4), 2)));
561
+ $utf8 .= $this->utf162utf8($utf16);
562
+ $c += 5;
563
+ break;
564
+
565
+ case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566
+ $utf8 .= $chrs{$c};
567
+ break;
568
+
569
+ case ($ord_chrs_c & 0xE0) == 0xC0:
570
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
571
+ //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
572
+ $utf8 .= substr($chrs, $c, 2);
573
+ ++$c;
574
+ break;
575
+
576
+ case ($ord_chrs_c & 0xF0) == 0xE0:
577
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
578
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
579
+ $utf8 .= substr($chrs, $c, 3);
580
+ $c += 2;
581
+ break;
582
+
583
+ case ($ord_chrs_c & 0xF8) == 0xF0:
584
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
585
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
586
+ $utf8 .= substr($chrs, $c, 4);
587
+ $c += 3;
588
+ break;
589
+
590
+ case ($ord_chrs_c & 0xFC) == 0xF8:
591
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
592
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
593
+ $utf8 .= substr($chrs, $c, 5);
594
+ $c += 4;
595
+ break;
596
+
597
+ case ($ord_chrs_c & 0xFE) == 0xFC:
598
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
599
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
600
+ $utf8 .= substr($chrs, $c, 6);
601
+ $c += 5;
602
+ break;
603
+
604
+ }
605
+
606
+ }
607
+
608
+ return $utf8;
609
+
610
+ } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611
+ // array, or object notation
612
+
613
+ if ($str{0} == '[') {
614
+ $stk = array(SERVICES_JSON_IN_ARR);
615
+ $arr = array();
616
+ } else {
617
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
618
+ $stk = array(SERVICES_JSON_IN_OBJ);
619
+ $obj = array();
620
+ } else {
621
+ $stk = array(SERVICES_JSON_IN_OBJ);
622
+ $obj = new stdClass();
623
+ }
624
+ }
625
+
626
+ array_push($stk, array('what' => SERVICES_JSON_SLICE,
627
+ 'where' => 0,
628
+ 'delim' => false));
629
+
630
+ $chrs = substr($str, 1, -1);
631
+ $chrs = $this->reduce_string($chrs);
632
+
633
+ if ($chrs == '') {
634
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
635
+ return $arr;
636
+
637
+ } else {
638
+ return $obj;
639
+
640
+ }
641
+ }
642
+
643
+ //print("\nparsing {$chrs}\n");
644
+
645
+ $strlen_chrs = strlen($chrs);
646
+
647
+ for ($c = 0; $c <= $strlen_chrs; ++$c) {
648
+
649
+ $top = end($stk);
650
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
651
+
652
+ if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653
+ // found a comma that is not inside a string, array, etc.,
654
+ // OR we've reached the end of the character list
655
+ $slice = substr($chrs, $top['where'], ($c - $top['where']));
656
+ array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
657
+ //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
658
+
659
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
660
+ // we are in an array, so just push an element onto the stack
661
+ array_push($arr, $this->decode($slice));
662
+
663
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
664
+ // we are in an object, so figure
665
+ // out the property name and set an
666
+ // element in an associative array,
667
+ // for now
668
+ $parts = array();
669
+
670
+ if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
671
+ // "name":value pair
672
+ $key = $this->decode($parts[1]);
673
+ $val = $this->decode($parts[2]);
674
+
675
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
676
+ $obj[$key] = $val;
677
+ } else {
678
+ $obj->$key = $val;
679
+ }
680
+ } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
681
+ // name:value pair, where name is unquoted
682
+ $key = $parts[1];
683
+ $val = $this->decode($parts[2]);
684
+
685
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
686
+ $obj[$key] = $val;
687
+ } else {
688
+ $obj->$key = $val;
689
+ }
690
+ }
691
+
692
+ }
693
+
694
+ } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695
+ // found a quote, and we are not inside a string
696
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
697
+ //print("Found start of string at {$c}\n");
698
+
699
+ } elseif (($chrs{$c} == $top['delim']) &&
700
+ ($top['what'] == SERVICES_JSON_IN_STR) &&
701
+ ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702
+ // found a quote, we're in a string, and it's not escaped
703
+ // we know that it's not escaped becase there is _not_ an
704
+ // odd number of backslashes at the end of the string so far
705
+ array_pop($stk);
706
+ //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707
+
708
+ } elseif (($chrs{$c} == '[') &&
709
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710
+ // found a left-bracket, and we are in an array, object, or slice
711
+ array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712
+ //print("Found start of array at {$c}\n");
713
+
714
+ } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715
+ // found a right-bracket, and we're in an array
716
+ array_pop($stk);
717
+ //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718
+
719
+ } elseif (($chrs{$c} == '{') &&
720
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721
+ // found a left-brace, and we are in an array, object, or slice
722
+ array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723
+ //print("Found start of object at {$c}\n");
724
+
725
+ } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726
+ // found a right-brace, and we're in an object
727
+ array_pop($stk);
728
+ //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
729
+
730
+ } elseif (($substr_chrs_c_2 == '/*') &&
731
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
732
+ // found a comment start, and we are in an array, object, or slice
733
+ array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
734
+ $c++;
735
+ //print("Found start of comment at {$c}\n");
736
+
737
+ } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
738
+ // found a comment end, and we're in one now
739
+ array_pop($stk);
740
+ $c++;
741
+
742
+ for ($i = $top['where']; $i <= $c; ++$i)
743
+ $chrs = substr_replace($chrs, ' ', $i, 1);
744
+
745
+ //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
746
+
747
+ }
748
+
749
+ }
750
+
751
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
752
+ return $arr;
753
+
754
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
755
+ return $obj;
756
+
757
+ }
758
+
759
+ }
760
+ }
761
+ }
762
+
763
+ /**
764
+ * @todo Ultimately, this should just call PEAR::isError()
765
+ */
766
+ function isError($data, $code = null)
767
+ {
768
+ if (class_exists('pear')) {
769
+ return PEAR::isError($data, $code);
770
+ } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
771
+ is_subclass_of($data, 'services_json_error'))) {
772
+ return true;
773
+ }
774
+
775
+ return false;
776
+ }
777
+ }
778
+
779
+ if (class_exists('PEAR_Error')) {
780
+
781
+ class Services_JSON_Error extends PEAR_Error
782
+ {
783
+ function Services_JSON_Error($message = 'unknown error', $code = null,
784
+ $mode = null, $options = null, $userinfo = null)
785
+ {
786
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
787
+ }
788
+ }
789
+
790
+ } else {
791
+
792
+ /**
793
+ * @todo Ultimately, this class shall be descended from PEAR_Error
794
+ */
795
+ class Services_JSON_Error
796
+ {
797
+ function Services_JSON_Error($message = 'unknown error', $code = null,
798
+ $mode = null, $options = null, $userinfo = null)
799
+ {
800
+
801
+ }
802
+ }
803
+
804
+ }
805
+
806
+ ?>
libs/recaptchalib.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * This is a PHP library that handles calling reCAPTCHA.
4
+ * - Documentation and latest version
5
+ * http://recaptcha.net/plugins/php/
6
+ * - Get a reCAPTCHA API Key
7
+ * https://www.google.com/recaptcha/admin/create
8
+ * - Discussion group
9
+ * http://groups.google.com/group/recaptcha
10
+ *
11
+ * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
12
+ * AUTHORS:
13
+ * Mike Crawford
14
+ * Ben Maurer
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in
24
+ * all copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
+ * THE SOFTWARE.
33
+ */
34
+
35
+ /**
36
+ * The reCAPTCHA server URL's
37
+ */
38
+ define("WSD_RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
39
+ define("WSD_RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
40
+ define("WSD_RECAPTCHA_VERIFY_SERVER", "www.google.com");
41
+
42
+ /**
43
+ * Encodes the given data into a query string format
44
+ * @param $data - array of string elements to be encoded
45
+ * @return string - encoded request
46
+ */
47
+ function wsd__recaptcha_qsencode ($data) {
48
+ $req = "";
49
+ foreach ( $data as $key => $value )
50
+ $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
51
+
52
+ // Cut the last '&'
53
+ $req=substr($req,0,strlen($req)-1);
54
+ return $req;
55
+ }
56
+
57
+
58
+
59
+ /**
60
+ * Submits an HTTP POST to a reCAPTCHA server
61
+ * @param string $host
62
+ * @param string $path
63
+ * @param array $data
64
+ * @param int port
65
+ * @return array response
66
+ */
67
+ function wsd__recaptcha_http_post($host, $path, $data, $port = 80) {
68
+
69
+ $req = wsd__recaptcha_qsencode ($data);
70
+
71
+ $http_request = "POST $path HTTP/1.0\r\n";
72
+ $http_request .= "Host: $host\r\n";
73
+ $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
74
+ $http_request .= "Content-Length: " . strlen($req) . "\r\n";
75
+ $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
76
+ $http_request .= "\r\n";
77
+ $http_request .= $req;
78
+
79
+ $response = '';
80
+ if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
81
+ die ('Could not open socket');
82
+ }
83
+
84
+ fwrite($fs, $http_request);
85
+
86
+ while ( !feof($fs) )
87
+ $response .= fgets($fs, 1160); // One TCP-IP packet
88
+ fclose($fs);
89
+ $response = explode("\r\n\r\n", $response, 2);
90
+
91
+ return $response;
92
+ }
93
+
94
+
95
+
96
+ /**
97
+ * Gets the challenge HTML (javascript and non-javascript version).
98
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
99
+ * is embedded within the HTML form it was called from.
100
+ * @param string $pubkey A public key for reCAPTCHA
101
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
102
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
103
+
104
+ * @return string - The HTML to be embedded in the user's form.
105
+ */
106
+ function wsd_recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
107
+ {
108
+ if ($pubkey == null || $pubkey == '') {
109
+ die ('To use reCAPTCHA you must get an API key from <a href="https://www.google.com/recaptcha/admin/create" target="_blank">https://www.google.com/recaptcha/admin/create</a>');
110
+ }
111
+
112
+ if ($use_ssl) {
113
+ $server = WSD_RECAPTCHA_API_SECURE_SERVER;
114
+ } else {
115
+ $server = WSD_RECAPTCHA_API_SERVER;
116
+ }
117
+
118
+ $errorpart = "";
119
+ if ($error) {
120
+ $errorpart = "&amp;error=" . $error;
121
+ }
122
+ return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
123
+
124
+ <noscript>
125
+ <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
126
+ <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
127
+ <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
128
+ </noscript>';
129
+ }
130
+
131
+
132
+
133
+
134
+ /**
135
+ * A wsd_ReCaptchaResponse is returned from wsd_recaptcha_check_answer()
136
+ */
137
+ class wsd_ReCaptchaResponse {
138
+ var $is_valid;
139
+ var $error;
140
+ }
141
+
142
+
143
+ /**
144
+ * Calls an HTTP POST function to verify if the user's guess was correct
145
+ * @param string $privkey
146
+ * @param string $remoteip
147
+ * @param string $challenge
148
+ * @param string $response
149
+ * @param array $extra_params an array of extra variables to post to the server
150
+ * @return wsd_ReCaptchaResponse
151
+ */
152
+ function wsd_recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
153
+ {
154
+ if ($privkey == null || $privkey == '') {
155
+ die ('To use reCAPTCHA you must get an API key from <a href="https://www.google.com/recaptcha/admin/create" target="_blank">https://www.google.com/recaptcha/admin/create</a>');
156
+ }
157
+
158
+ if ($remoteip == null || $remoteip == '') {
159
+ die ('For security reasons, you must pass the remote ip to reCAPTCHA');
160
+ }
161
+
162
+
163
+
164
+ //discard spam submissions
165
+ if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
166
+ $recaptcha_response = new wsd_ReCaptchaResponse();
167
+ $recaptcha_response->is_valid = false;
168
+ $recaptcha_response->error = 'incorrect-captcha-sol';
169
+ return $recaptcha_response;
170
+ }
171
+
172
+ $response = wsd__recaptcha_http_post (WSD_RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
173
+ array (
174
+ 'privatekey' => $privkey,
175
+ 'remoteip' => $remoteip,
176
+ 'challenge' => $challenge,
177
+ 'response' => $response
178
+ ) + $extra_params
179
+ );
180
+
181
+ $answers = explode ("\n", $response [1]);
182
+ $recaptcha_response = new wsd_ReCaptchaResponse();
183
+
184
+ if (trim ($answers [0]) == 'true') {
185
+ $recaptcha_response->is_valid = true;
186
+ }
187
+ else {
188
+ $recaptcha_response->is_valid = false;
189
+ $recaptcha_response->error = $answers [1];
190
+ }
191
+ return $recaptcha_response;
192
+
193
+ }
194
+
195
+ /**
196
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
197
+ * has a configuration page where you enter a key, you should provide a link
198
+ * using this function.
199
+ * @param string $domain The domain where the page is hosted
200
+ * @param string $appname The name of your application
201
+ */
202
+ function wsd_recaptcha_get_signup_url ($domain = null, $appname = null) {
203
+ return 'https://www.google.com/recaptcha/admin/create?' . wsd__recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
204
+ }
205
+
206
+ function wsd__recaptcha_aes_pad($val) {
207
+ $block_size = 16;
208
+ $numpad = $block_size - (strlen ($val) % $block_size);
209
+ return str_pad($val, strlen ($val) + $numpad, chr($numpad));
210
+ }
211
+
212
+ /* Mailhide related code */
213
+
214
+ function wsd__recaptcha_aes_encrypt($val,$ky) {
215
+ if (! function_exists ("mcrypt_encrypt")) {
216
+ die ('To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.');
217
+ }
218
+ $mode=MCRYPT_MODE_CBC;
219
+ $enc=MCRYPT_RIJNDAEL_128;
220
+ $val=wsd__recaptcha_aes_pad($val);
221
+ return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
222
+ }
223
+
224
+
225
+ function wsd__wsd_recaptcha_mailhide_urlbase64 ($x) {
226
+ return strtr(base64_encode ($x), '+/', '-_');
227
+ }
228
+
229
+ /* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
230
+ function wsd_recaptcha_mailhide_url($pubkey, $privkey, $email) {
231
+ if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
232
+ die ('To use reCAPTCHA Mailhide, you have to sign up for a public and private key, ' .
233
+ 'you can do so at <a href="http://www.google.com/recaptcha/mailhide/apikey" target="_blank">http://www.google.com/recaptcha/mailhide/apikey</a>');
234
+ }
235
+
236
+
237
+ $ky = pack('H*', $privkey);
238
+ $cryptmail = wsd__recaptcha_aes_encrypt ($email, $ky);
239
+
240
+ return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . wsd__wsd_recaptcha_mailhide_urlbase64 ($cryptmail);
241
+ }
242
+
243
+ /**
244
+ * gets the parts of the email to expose to the user.
245
+ * eg, given johndoe@example,com return ["john", "example.com"].
246
+ * the email is then displayed as john...@example.com
247
+ */
248
+ function wsd__recaptcha_mailhide_email_parts ($email) {
249
+ $arr = preg_split("/@/", $email );
250
+
251
+ if (strlen ($arr[0]) <= 4) {
252
+ $arr[0] = substr ($arr[0], 0, 1);
253
+ } else if (strlen ($arr[0]) <= 6) {
254
+ $arr[0] = substr ($arr[0], 0, 3);
255
+ } else {
256
+ $arr[0] = substr ($arr[0], 0, 4);
257
+ }
258
+ return $arr;
259
+ }
260
+
261
+ /**
262
+ * Gets html to display an email address given a public an private key.
263
+ * to get a key, go to:
264
+ *
265
+ * http://www.google.com/recaptcha/mailhide/apikey
266
+ */
267
+ function wsd_recaptcha_mailhide_html($pubkey, $privkey, $email) {
268
+ $emailparts = wsd__recaptcha_mailhide_email_parts ($email);
269
+ $url = wsd_recaptcha_mailhide_url ($pubkey, $privkey, $email);
270
+
271
+ return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
272
+ "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
273
+
274
+ }
275
+
276
+
277
+ ?>
libs/wsd.php ADDED
@@ -0,0 +1,798 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define("WSD_URL", "https://dashboard.websitedefender.com/");
3
+ define("WSD_URL_RPC", WSD_URL . "jsrpc.php");
4
+ define("WSD_URL_DOWN", WSD_URL . "download.php");
5
+ define("WSD_SOURCE", 2);
6
+ //error codes
7
+ define('WSD_ERROR_LIMITATION' ,0x27);
8
+ define('WSD_ERROR_WPP_SERVICE_DOWN' ,0x50);
9
+ define('WSD_ERROR_WPP_ERROR_INVALID_URL' ,0x51);
10
+ define('WSD_ERROR_WPP_URL_REGISTERED' ,0x52);
11
+ define('WSD_WSD_ERROR_WPP_NEWUSR_PARAM' ,0x53);
12
+ define('WSD_ERROR_WPP_INVALID_CAPTCHA' ,0x54);
13
+ define('WSD_ERROR_WPP_USER_EXIST' ,0x55);
14
+ define('WSD_ERROR_WPP_URL_EXIST' ,0x56);
15
+ //http status
16
+ define("HTTP_STATUS", 0);
17
+ define("HTTP_HEADERS", 1);
18
+ define("HTTP_BODY", 2);
19
+ define("HTTP_CHUNK_HEADER", 3);
20
+ define("HTTP_CHUNK_BODY", 4);
21
+ //globals
22
+ $GLOBALS['wsd_last_err'] = array('code'=>0, 'message'=>'');
23
+ function wsd_site_url(){return get_option( "siteurl" )."/";}
24
+
25
+ function wsd_parseUrl($url)
26
+ {
27
+ $result = parse_url($url);
28
+ if($result === NULL) return array("error"=>"Invalid URL.");
29
+ $result["error"] = NULL;
30
+ if(!array_key_exists("port", $result)) $result["port"] = 80;
31
+ if(!array_key_exists("scheme", $result)) $result["scheme"] = "http";
32
+ if(!array_key_exists("query", $result)) $result["query"] = ""; else $result["query"] = "?" . $result["query"];
33
+ if(array_key_exists("host", $result))
34
+ {
35
+ if(!array_key_exists("path", $result)) $result["path"] = "";
36
+ }
37
+ else
38
+ {
39
+ if(array_key_exists("path", $result))
40
+ {
41
+ $dirs = explode("/", $result["path"], 2);
42
+ $result["host"] = $dirs[0];
43
+ if(count($dirs)>1)
44
+ $result["path"] = "/".$dirs[1];
45
+ else
46
+ $result["path"] = "/";
47
+ }
48
+ else return array("error"=>"Invalid URL (no host).");
49
+ }
50
+
51
+ if($result["host"] == "") return array("error"=>"Invalid URL (no host).");
52
+
53
+ $scheme = "http";
54
+ if(array_key_exists("scheme", $result)) $scheme = $result["scheme"];
55
+
56
+ if((strcasecmp($scheme,"http")!=0) && (strcasecmp($scheme,"https")!=0)) return array("error"=>"Invalid URL (unknown scheme).");
57
+
58
+ if(strcasecmp($scheme,"https")==0) $result["port"] = 443;
59
+
60
+ $userPass = "";
61
+ if(array_key_exists("user", $result) && array_key_exists("pass", $result))
62
+ $userPass = $result["user"].":".$result["pass"]."@";
63
+
64
+ $port = "";
65
+ if(array_key_exists("port", $result)) $port = ":".$result["port"];
66
+
67
+ $result["all"] = $scheme."://".$userPass.$result["host"].$port;
68
+ return $result;
69
+ }
70
+
71
+ function wsd_httpRequest($verb, $url, $body="", $headers=array(), $timeout = 10)
72
+ {
73
+ $e = error_reporting(0);
74
+
75
+ $result = array();
76
+ $result["cookie"] = NULL;
77
+ $result["body"] = "";
78
+ $result["length"] = NULL;
79
+ $result["error"] = NULL;
80
+
81
+ $now = time();
82
+ $url = wsd_parseUrl($url);
83
+
84
+ if($url["error"] !== NULL) return $url;
85
+
86
+ $scheme = $url["scheme"]=="https" ? "ssl://" : "";
87
+
88
+ $fp = fsockopen($scheme.$url["host"], $url["port"] , $errno, $errstr, $timeout);
89
+
90
+ if (!$fp)
91
+ {
92
+ if($scheme == "ssl://")
93
+ {
94
+ $fp = fsockopen($url["host"], 80 , $errno, $errstr, $timeout);
95
+ if (!$fp)
96
+ {
97
+ error_reporting($e);
98
+ return array("error"=>"Can't connect to server [$errno].");
99
+ }
100
+ }
101
+ else
102
+ {
103
+ error_reporting($e);
104
+ return array("error"=>"Can't connect to server [$errno].");
105
+ }
106
+ }
107
+
108
+ $out = $verb." ".$url["path"].$url["query"]." HTTP/1.1\r\n";
109
+ $out .= "Host: ". $url["host"] . "\r\n";
110
+ $out .= "Connection: Close\r\n";
111
+ $out .= "Accept-Encoding: identity\r\n";
112
+ if($verb == "POST") $out .= "Content-Length: " . strlen($body) . "\r\n";
113
+ foreach ($headers as $name => $value) $out .= $name .": " . $value . "\r\n";
114
+ $out .= "\r\n";
115
+ if($verb == "POST") $out .= $body;
116
+ fwrite($fp, $out);
117
+ fflush($fp);
118
+
119
+ //print "<br>".str_replace("\r\n", "<br>", $out)."<br>";
120
+
121
+ $status = HTTP_STATUS;
122
+ $chunked = False;
123
+ $lastChunk = "";
124
+ $chunkLength = 0;
125
+
126
+ while (!feof($fp))
127
+ {
128
+ $remaining = $timeout - (time() - $now);
129
+ if($remaining < 0) return array("error"=>"Request timed out [1].");
130
+
131
+ stream_set_timeout($fp, $remaining + 1);
132
+ $data = fgets($fp, 4096);
133
+ $info = stream_get_meta_data($fp);
134
+
135
+ if ($info["timed_out"])
136
+ {
137
+ error_reporting($e);
138
+ return array("error"=>"Request timed out [2].");
139
+ }
140
+
141
+ //print($data."<br>");
142
+
143
+ if($status == HTTP_STATUS)
144
+ {
145
+ //TODO: check status for 200, error on rest, eventually work arround 302 303
146
+ $resultStatus = trim($data);
147
+ $status = HTTP_HEADERS;
148
+ continue;
149
+ }
150
+
151
+ if($status == HTTP_HEADERS)
152
+ {
153
+ if($data == "\r\n")
154
+ {
155
+ if($chunked)
156
+ $status = HTTP_CHUNK_HEADER;
157
+ else
158
+ $status = HTTP_BODY;
159
+ continue;
160
+ }
161
+
162
+ $data = trim($data);
163
+ $separator = strpos($data, ": ");
164
+
165
+ if(($separator === False)||($separator == 0) || ($separator >= (strlen($data) -2)))
166
+ return array("error"=>"Invalid HTTP response header.");
167
+
168
+ $name = substr($data, 0, $separator);
169
+ $value = substr($data, $separator + 2);
170
+ if(strcasecmp("Set-Cookie", $name) == 0)
171
+ {
172
+ $result["cookie"] = $value;
173
+ continue;
174
+ }
175
+ if(strcasecmp("Content-Length", $name) == 0)
176
+ {
177
+ $result["length"] = $value + 0;
178
+ continue;
179
+ }
180
+ if((strcasecmp("Transfer-Encoding", $name) == 0) && (strpos($value, 'chunked') !== False) )
181
+ {
182
+ $chunked = True;
183
+ continue;
184
+ }
185
+ continue;
186
+ }
187
+
188
+ if($status == HTTP_CHUNK_HEADER)
189
+ {
190
+ $data = trim($data);
191
+ $sc = strpos($data, ';');
192
+ if($sc !== False) $data = substr($data, 0, $sc);
193
+ $chunkLength = hexdec($data);
194
+ if($chunkLength == 0)
195
+ break;
196
+ $lastChunk = "";
197
+ $status = HTTP_CHUNK_BODY;
198
+ continue;
199
+ }
200
+
201
+ if($status == HTTP_CHUNK_BODY)
202
+ {
203
+ $lastChunk .= $data;
204
+ if(strlen($lastChunk) >= $chunkLength)
205
+ {
206
+ $result["body"] .= substr($lastChunk, 0, $chunkLength);
207
+ $status = HTTP_CHUNK_HEADER;
208
+ }
209
+ continue;
210
+ }
211
+
212
+ if($status == HTTP_BODY)
213
+ {
214
+ $result["body"] .= $data;
215
+ if(($result["length"] !== NULL) && (strlen($result["body"]) >= $result["length"]))
216
+ break;
217
+ continue;
218
+ }
219
+ }
220
+ fclose($fp);
221
+
222
+ if(($result["length"] !== NULL) && (strlen($result["body"]) != $result["length"]))
223
+ array("error"=>"Invalid HTTP body length.");
224
+
225
+ error_reporting($e);
226
+ return $result;
227
+ }
228
+
229
+ function wsd_jsonHttpRequest($url, $data, $timeout = 10)
230
+ {
231
+ $body = json_encode($data);
232
+ $headers = array("Content-type" => "application/json");
233
+
234
+ $cookie = '';
235
+ $option_cookie = get_option("WSD-COOKIE");
236
+ if($option_cookie !== False) $cookie = $option_cookie;
237
+
238
+ $token = get_option("WSD-TOKEN");
239
+ if($token !== False)
240
+ {
241
+ if($cookie != '') $cookie .= '; ';
242
+ $cookie .= "token=".$token;
243
+ }
244
+
245
+ if($cookie != '')
246
+ $headers["Cookie"] = $cookie;
247
+
248
+ $result = wsd_httpRequest("POST", $url, $body, $headers, $timeout);
249
+
250
+ if($result["cookie"] !== NULL)
251
+ {
252
+ if($option_cookie === False)
253
+ add_option("WSD-COOKIE", $result["cookie"]);
254
+ else
255
+ update_option("WSD-COOKIE", $result["cookie"]);
256
+ }
257
+
258
+ if($result["error"] === NULL)
259
+ {
260
+ $decoded = json_decode($result["body"], true);
261
+ if($decoded == NULL) $result["error"] = "Invalid JSON response.".$result["body"];
262
+ $result["body"] = $decoded;
263
+ }
264
+ return $result;
265
+ }
266
+
267
+ function wsd_jsonRPC($url, $method, $params, $timeout = 10)
268
+ {
269
+ $GLOBALS['wsd_last_err'] = array('code'=>0, 'message'=>'');
270
+ $id = rand(1,100);
271
+
272
+ $token = get_option("WSD-TOKEN");
273
+ if($token === False)
274
+ $request = array("jsonrpc"=>"2.0", "id"=>$id, "method"=>$method, "params"=>$params);
275
+ else
276
+ $request = array("jsonrpc"=>"2.0", "id"=>$id, "method"=>$method, "params"=>$params, "token"=>$token);
277
+
278
+ $response = wsd_jsonHttpRequest($url, $request, $timeout);
279
+
280
+ //print("request:");print_r($request); print("<hr>"); print("response:");print_r($response); print("<hr>");
281
+
282
+ if($response["error"] !== NULL)
283
+ {
284
+ $GLOBALS['wsd_last_err'] = array("code" => 0, "message" => $response["error"]);
285
+ return NULL;
286
+ }
287
+
288
+ if((! array_key_exists("id", $response["body"])) || ($response["body"]["id"] != $id) )
289
+ {
290
+ $GLOBALS['wsd_last_err'] = array("code" => 0, "message" => "Invalid JSONRPC response [0].");
291
+ return NULL;
292
+ }
293
+
294
+ if( array_key_exists("token", $response["body"]))
295
+ {
296
+ if($token === False) add_option("WSD-TOKEN", $response["body"]['token']);
297
+ else update_option("WSD-TOKEN", $response["body"]['token']);
298
+ }
299
+
300
+ if(array_key_exists("error", $response["body"]))
301
+ {
302
+ $GLOBALS['wsd_last_err'] = $response["body"]["error"];
303
+ return NULL;
304
+ }
305
+
306
+ if(! array_key_exists("result", $response["body"]))
307
+ {
308
+ $GLOBALS['wsd_last_err'] = array("code" => 0, "message" => "Invalid JSONRPC response [1].");
309
+ return NULL;
310
+ }
311
+
312
+ return $response["body"]["result"];
313
+ }
314
+
315
+ // ========================= RENDER UI ===========================================================
316
+
317
+ function wsd_render_error($custom_message = null)
318
+ {
319
+ $html = '';
320
+ if ($custom_message === NULL)
321
+ $html = '<p class="wsd-error-summary">' . $GLOBALS['wsd_last_err']['message'];
322
+ else
323
+ $html = '<p class="wsd-error-summary">' . $custom_message;
324
+ $html .= '<br /><span class="wsd-error-summary-detail">If the problem persists please continue at <a href="https://dashboard.websitedefender.com" target="_blank">Website Defender</a>.</span></p>';
325
+ echo $html;
326
+ }
327
+
328
+ function wsd_render_agent_install_issues($message)
329
+ {
330
+ //echo "wsd_render_agent_install_issues<br>";
331
+ $html = '<p class="wsd-error-summary">' . $message;
332
+ $html .= '<br /><span class="wsd-error-summary-detail">It has to be installed manually from the <a href="https://dashboard.websitedefender.com" target="_blank">WebsiteDefender dashboard</a>.</span></p>';
333
+ echo $html;
334
+ }
335
+
336
+ function wsd_render_user_login($error = '')
337
+ {
338
+ if($error !== '') wsd_render_error($error);
339
+ ?>
340
+
341
+ <?php if(!empty($error)) { ?>
342
+ <div class="wsd-inside">
343
+ <?php } ?>
344
+
345
+ <p class="wsd-login-notice">Login here if you already have a WSD account.</p>
346
+ <form action="" method="post" id="wsd_login_form" name="wsd_login_form">
347
+ <div>
348
+ <div class="wsd-login-section">
349
+ <label for="wsd_login_form_email">Email:</label>
350
+ <input type="text" name="wsd_login_form_email" id="wsd_login_form_email" value="<?php echo get_option("admin_email"); ?>" />
351
+ </div>
352
+ <div class="wsd-login-section">
353
+ <label for="wsd_login_form_password">Password:</label>
354
+ <input type="password" name="wsd_login_form_password" id="wsd_login_form_password" />
355
+ </div>
356
+ <input type="submit" name="wsd-login" id="wsd-login" value="Login">
357
+ </div>
358
+ </form>
359
+
360
+ <?php if(!empty($error)) { ?>
361
+ </div>
362
+ <?php } ?>
363
+
364
+ <?php
365
+ }
366
+
367
+ function wsd_render_new_user($error = '')
368
+ {
369
+ //print "wsd_render_new_user $error<br>";
370
+
371
+ $form = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.getfrm", wsd_site_url());
372
+ if ($form === NULL)
373
+ {
374
+ wsd_render_error();
375
+ return;
376
+ }
377
+ $recaptcha_publickey = $form['captcha'];
378
+ if(empty($recaptcha_publickey))
379
+ {
380
+ wsd_render_error('Invalid server response.');
381
+ return;
382
+ }
383
+
384
+ //intro text
385
+ echo '<p class="wsd-inside" style="margin-top: 0px;">';
386
+ _e('WebsiteDefender.com is based upon web application scanning technology from <a href="http://www.acunetix.com/" target="_blank">Acunetix</a>; a pioneer in website security. <a href="http://www.websitedefender.com" target="_blank">WebsiteDefender</a> requires no installation, no learning curve and no maintenance. Above all, there is no impact on site performance! WebsiteDefender regularly scans and monitors your WordPress website/blog effortlessly, efficient, easily and is available for Free! Start scanning your WordPress website/blog against malware and hackers, absolutely free!', FB_SWP_TEXTDOMAIN);
387
+ echo "</p>";
388
+
389
+ ?>
390
+ <div class="wsd-inside">
391
+ <?php
392
+ wsd_render_user_login();
393
+ ?>
394
+
395
+ <h4><?php _e('Register here to use all the WebsiteDefender.com advanced features', FB_SWP_TEXTDOMAIN)?></h4>
396
+ <p><?php _e('WebsiteDefender is an online service that protects your website from any hacker activity by monitoring and auditing the security of your website, giving you easy to understand solutions to keep your website safe, always! WebsiteDefender\'s enhanced WordPress Security Checks allow it to optimise any threats on a blog or site powered by WordPress.', FB_SWP_TEXTDOMAIN)?></p>
397
+ <p><?php _e('<strong>With WebsiteDefender you can:</strong>', FB_SWP_TEXTDOMAIN)?></p>
398
+ <ul class="wsd_commonList">
399
+ <li><span>Detect Malware present on your website</span></li>
400
+ <li><span>Audit your website for security issues</span></li>
401
+ <li><span>Avoid getting blacklisted by Google</span></li>
402
+ <li><span>Keep your website content and data safe</span></li>
403
+ <li><span>Get alerted to suspicious hacker activity</span></li>
404
+ </ul>
405
+
406
+ <p><?php _e('WebsiteDefender.com does all this an more via an easy-to-understand web-based dashboard, which gives step by step solutions on how to make sure your website stays secure!', FB_SWP_TEXTDOMAIN)?></p>
407
+
408
+ <h4><?php _e('Sign up for your FREE account here', FB_SWP_TEXTDOMAIN)?></h4>
409
+
410
+ <?php
411
+ if($error !== '') wsd_render_error($error);
412
+ ?>
413
+
414
+ <form action="#em" method="post" id="wsd_new_user_form" name="wsd_new_user_form">
415
+ <div id="em" class="wsd-new-user-section">
416
+ <label for="wsd_new_user_email">Email:</label>
417
+ <input type="text" name="wsd_new_user_email" id="wsd_new_user_email" value="<?php echo get_option("admin_email"); ?>" />
418
+ </div>
419
+ <div class="wsd-new-user-section">
420
+ <label for="wsd_new_user_name">Name:</label>
421
+ <input type="text" name="wsd_new_user_name" id="wsd_new_user_name" value="<?php echo isset($_POST['wsd_new_user_name']) ? $_POST['wsd_new_user_name'] : '' ?>" />
422
+ </div>
423
+ <div class="wsd-new-user-section">
424
+ <label for="wsd_new_user_surname">Surname:</label>
425
+ <input type="text" name="wsd_new_user_surname" id="wsd_new_user_surname" value="<?php echo isset($_POST['wsd_new_user_surname']) ? $_POST['wsd_new_user_surname']: '' ?>" />
426
+ </div>
427
+ <div class="wsd-new-user-section">
428
+ <label for="wsd_new_user_password">Password:</label>
429
+ <input type="password" name="wsd_new_user_password" id="wsd_new_user_password"/>
430
+ <label class="password-meter" style="background-color: rgb(238, 0, 0);">Too Short</label>
431
+ </div>
432
+ <div class="wsd-new-user-section">
433
+ <label for="wsd_new_user_password_re">Retype Password:</label>
434
+ <input type="password" name="wsd_new_user_password_re" id="wsd_new_user_password_re"/>
435
+ </div>
436
+ <div class="wsd-new-user-section">
437
+ <?php
438
+ echo wsd_recaptcha_get_html($recaptcha_publickey, NULL, true);
439
+ ?>
440
+ </div>
441
+ <input type="submit" name="wsd-new-user" id="wsd-new-user" value="Register">
442
+ </form>
443
+ </div>
444
+ <?php
445
+ }
446
+
447
+
448
+ function wsd_process_login()
449
+ {
450
+ $email = isset($_POST['wsd_login_form_email']) ? $_POST['wsd_login_form_email'] : null;
451
+ $password = isset($_POST['wsd_login_form_password']) ? $password = $_POST['wsd_login_form_password'] : null;
452
+
453
+ if (empty($email)) {
454
+ wsd_render_user_login('Email address is required.');
455
+ return;
456
+ }
457
+
458
+ if (empty($password)) {
459
+ wsd_render_user_login('Password is required.');
460
+ return;
461
+ }
462
+
463
+ // $password is received as MD5 hash
464
+ $login = wsd_jsonRPC(WSD_URL_RPC, "cUser.login", array($email, $password));
465
+
466
+ if ($login == NULL) {
467
+ wsd_render_user_login('Invalid login');
468
+ return;
469
+ }
470
+
471
+ $user = get_option("WSD-USER");
472
+ if ($user === False)
473
+ add_option("WSD-USER", $email);
474
+ else
475
+ update_option("WSD-USER", $email);
476
+
477
+ wsd_add_or_process_target();
478
+ }
479
+
480
+ function wsd_render_add_target_id()
481
+ {
482
+ ?>
483
+ <div class="wsd-inside">
484
+ <?php if(!empty($error)) wsd_render_error($error); ?>
485
+ <form action="" method="post" id="wsd_target_id_form" name="wsd_target_id_form">
486
+ <label for="wsd_target_update_id">Target ID:</label>
487
+ <input type="text" name="targetid" id="targetid"/>
488
+ <input type="submit" name="wsd_update_target_id" value="Update" />
489
+ </form>
490
+ </div>
491
+ <?php
492
+ }
493
+
494
+ function wsd_process_add_target_id()
495
+ {
496
+ //echo "wsd_process_add_target_id<br>";
497
+ add_option('WSD-TARGETID', $_POST['targetid']);
498
+ wsd_render_target_status();
499
+ }
500
+
501
+ function wsd_add_or_process_target()
502
+ {
503
+ //check if we already registered
504
+ $targetid = get_option('WSD-TARGETID');
505
+
506
+ if($targetid !== false)
507
+ {
508
+ wsd_render_target_status();
509
+ return;
510
+ }
511
+ else
512
+ {
513
+ //check first is this url is already there
514
+ $target = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.urlstatus", wsd_site_url());
515
+ if($target === NULL)
516
+ {
517
+ wsd_render_error();
518
+ return;
519
+ }
520
+ if(array_key_exists('id', $target) && ($target['id'] != NULL))
521
+ {
522
+ if($targetid === False) add_option('WSD-TARGETID', $target['id']);
523
+ else update_option('WSD-TARGETID', $target['id']);
524
+ wsd_render_target_status();
525
+ return;
526
+ }
527
+ }
528
+
529
+ //the target was not there so we have to register a new one
530
+ $newtarget = wsd_jsonRPC(WSD_URL_RPC, "cTargets.add", wsd_site_url());
531
+ if($newtarget === NULL)
532
+ {
533
+ if($GLOBALS['wsd_last_err']['code'] == WSD_ERROR_LIMITATION)
534
+ {
535
+ wsd_render_error("This account reached the maximum number of targets.");
536
+ return;
537
+ }
538
+ if($GLOBALS['wsd_last_err']['code'] == WSD_ERROR_WPP_URL_EXIST)
539
+ {
540
+ wsd_render_add_target_id();
541
+ return;
542
+ }
543
+ print_r($GLOBALS['wsd_last_err']);
544
+ return;
545
+ }
546
+
547
+ if(!array_key_exists("id", $newtarget))
548
+ {
549
+ wsd_render_error("Invalid WSD response received.");
550
+ return;
551
+ }
552
+
553
+ delete_option('WSD-TARGETID');
554
+ add_option('WSD-TARGETID', $newtarget['id']);
555
+
556
+ //download agent
557
+ $targetInstalError = '';
558
+
559
+ $headers = array("a"=>"a");
560
+ $option_cookie = get_option("WSD-COOKIE");
561
+ if($option_cookie !== False) $headers["Cookie"] = $option_cookie;
562
+
563
+ //print "<br>Downloading: ". WSD_URL_DOWN.'?id='.$newtarget['id'] ."#". print_r($headers, true). "<br>";
564
+
565
+ $agent = wsd_httpRequest("GET", WSD_URL_DOWN.'?id='.$newtarget['id'], "", $headers);
566
+
567
+ if($agent["error"] !== NULL)
568
+ $targetInstalError = 'The WebsiteDefender Agent failed to install automatically [0x01].'; //can't download
569
+ else
570
+ {
571
+ //try to copy the target
572
+ $agentURL = $agent["sensor_url"];
573
+ if(preg_match('/[a-f0-9]{40}.php/', $newtarget["sensor_url"], $matches))
574
+ {
575
+ $path = rtrim(ABSPATH, '/');
576
+ $path .= '/'.$matches[0];
577
+
578
+ $r = file_put_contents($path, $agent['body']);
579
+ if(!$r) $targetInstalError = 'The WebsiteDefender Agent failed to install automatically [0x02].'; //can't save
580
+ }
581
+ else $targetInstalError = 'The WebsiteDefender Agent failed to install automatically [0x03].'; //other
582
+ }
583
+
584
+ //test the agent, this will triger agentless if agent not functioning
585
+ $testTarget = wsd_jsonRPC(WSD_URL_RPC, "cTargets.agenttest", $newtarget['id']);
586
+ $enbableTarget = wsd_jsonRPC(WSD_URL_RPC, "cTargets.enable", array($newtarget['id'], true));
587
+
588
+ if($targetInstalError != '')wsd_render_agent_install_issues($targetInstalError);
589
+
590
+ wsd_render_target_status();
591
+ }
592
+
593
+ function wsd_process_new_user_form()
594
+ {
595
+ //print "wsd_process_new_user_form<br>";
596
+
597
+ $email = $_POST['wsd_new_user_email'];
598
+ $name = $_POST['wsd_new_user_name'];
599
+ $surname = $_POST['wsd_new_user_surname'];
600
+ $password = $_POST['wsd_new_user_password'];
601
+ $password_re = $_POST['wsd_new_user_password_re'];
602
+
603
+ if (empty($email)) {
604
+ wsd_render_new_user('Email is required.');
605
+ return;
606
+ }
607
+ if (empty($name)) {
608
+ wsd_render_new_user('Name is required.');
609
+ return;
610
+ }
611
+ if (empty($surname)) {
612
+ wsd_render_new_user('Surname is required.');
613
+ return;
614
+ }
615
+ if (empty($password)) {
616
+ wsd_render_new_user('Password is required.');
617
+ return;
618
+ }
619
+ if ($password != $password_re) {
620
+ wsd_render_new_user('Passwords do not match.');
621
+ return;
622
+ }
623
+
624
+ $register = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.register",
625
+ array(
626
+ array("challenge"=>$_POST['recaptcha_challenge_field'],
627
+ "response"=>$_POST['recaptcha_response_field']),
628
+ array(
629
+ "url" => wsd_site_url(),
630
+ "email" => $email,
631
+ "name" => $name,
632
+ "surname" => $surname,
633
+ // the password comes from the client already as a hash
634
+ "pass" => $password,
635
+ "source" => WSD_SOURCE
636
+ )
637
+ ));
638
+ if($register == NULL)
639
+ {
640
+ if($GLOBALS['wsd_last_err']['code'] == WSD_ERROR_WPP_INVALID_CAPTCHA)
641
+ {
642
+ wsd_render_new_user('Invalid captcha. Please try again.');
643
+ return;
644
+ }
645
+ if($GLOBALS['wsd_last_err']['code'] == WSD_ERROR_WPP_USER_EXIST)
646
+ {
647
+ wsd_render_new_user("This user is already registered. To continue with this user, please use the login form above or register with a new user name.");
648
+ return;
649
+ }
650
+ wsd_render_new_user('Registration failed! Please try again.');
651
+ return;
652
+ }
653
+ $user = get_option("WSD-USER");
654
+ if($user === False) add_option("WSD-USER", $email); else update_option("WSD-USER", $email);
655
+ wsd_add_or_process_target();
656
+ }
657
+
658
+ function wsd_render_target_status()
659
+ {
660
+ #echo "wsd_render_target_status<br>";
661
+ $user = get_option('WSD-USER');
662
+ if((!is_string($user))||($user == "") ) $user = get_option("admin_email");
663
+ $status = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.status", array($user, get_option('WSD-TARGETID')));
664
+ if($status === NULL)
665
+ {
666
+ wsd_render_error();
667
+ return;
668
+ }
669
+ if((!array_key_exists('active', $status)) || ($status['active'] !== 1))
670
+ {
671
+ //our target is not valid anymore
672
+ delete_option('WSD-TARGETID');
673
+ return False;
674
+ }
675
+
676
+ echo '<p class="wsd-inside">';
677
+ echo 'Thank you for registering with WebsiteDefender. Please navigate to the <a target="_blank" href="https://dashboard.websitedefender.com/">WebsiteDefender dashboard</a> to see the alerts.';
678
+ echo "</p>";
679
+
680
+ $enabled = array_key_exists('enabled', $status) ? $status['enabled'] : null;
681
+ $scanned = array_key_exists('scanned', $status) ? $status['scanned'] : null;
682
+ $agentless = array_key_exists('agentless', $status) ? $status['agentless'] : null;
683
+
684
+ if (!is_numeric($enabled) || !is_numeric($scanned) || !is_numeric($agentless))
685
+ {
686
+ wsd_render_error('Invalid server response.');
687
+ return;
688
+ }
689
+ $enabled = intval($enabled);
690
+ $scanned = intval($scanned);
691
+ $agentless = intval($agentless);
692
+ ?>
693
+
694
+ <div id="wsd-target-status-holder" class="wsd-inside">
695
+ <p class="wsd-target-status-title">
696
+ Website status on Website Defender
697
+ </p>
698
+ <div class="wsd-target-status-section">
699
+ <?php
700
+ $statusText = 'NO';
701
+ if ($enabled == 1) {
702
+ $statusText = 'YES';
703
+ }
704
+ echo '<span class="wsd-target-status-section-label">Enabled: </span>',
705
+ '<span class="wsd-target-status-section-', $enabled ? 'enabled' : 'disabled', '">', $statusText, '</span>';
706
+ ?>
707
+ </div>
708
+ <div class="wsd-target-status-section">
709
+ <?php
710
+ $statusText = 'NO';
711
+ if ($scanned == 1) {
712
+ $statusText = 'YES';
713
+ }
714
+ echo '<span class="wsd-target-status-section-label">Scanned: </span>',
715
+ '<span class="wsd-target-status-section-', $scanned ? 'enabled' : 'disabled', '">', $statusText, '</span>';
716
+ ?>
717
+ </div>
718
+ <div class="wsd-target-status-section">
719
+ <?php
720
+ $statusText = 'UP';
721
+ if ($agentless == 1) {
722
+ $statusText = 'DOWN';
723
+ }
724
+ echo '<span class="wsd-target-status-section-label">Agent status: </span>',
725
+ '<span class="wsd-target-status-section-', $agentless ? 'disabled' : 'enabled', '">', $statusText, '</span>';
726
+ ?>
727
+ </div>
728
+ </div>
729
+
730
+ <?php
731
+
732
+ return True;
733
+ }
734
+
735
+ function wsd_render_main()
736
+ {
737
+ if(1==0)
738
+ {
739
+ delete_option('WSD-TARGETID');
740
+ delete_option("WSD-COOKIE");
741
+ delete_option("WSD-USER");
742
+ return;
743
+ }
744
+
745
+ if(isset($_POST['wsd-new-user']))
746
+ {
747
+ wsd_process_new_user_form();
748
+ return;
749
+ }
750
+
751
+ if(isset($_POST['wsd-login']))
752
+ {
753
+ wsd_process_login();
754
+ return;
755
+ }
756
+
757
+ if(isset($_POST['wsd_update_target_id']))
758
+ {
759
+ wsd_process_add_target_id();
760
+ return;
761
+ }
762
+
763
+ $targetid = get_option("WSD-TARGETID");
764
+ if($targetid !== False)
765
+ {
766
+ wsd_render_target_status();
767
+ return;
768
+ }
769
+
770
+ $hello = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.hello", wsd_site_url());
771
+
772
+ if($hello == NULL)
773
+ {
774
+ wsd_render_error();
775
+ return;
776
+ }
777
+
778
+ if($hello == 'registered')
779
+ {
780
+ wsd_render_add_target_id();
781
+ return;
782
+ }
783
+ elseif($hello == 'new')
784
+ {
785
+ //$user = get_option("WSD-USER"); if($user === FALSE)
786
+ wsd_render_new_user();
787
+ //else wsd_render_user_login();
788
+ }
789
+ else
790
+ {
791
+ wsd_render_error("Invalid server response.");
792
+ return;
793
+ }
794
+ }
795
+
796
+
797
+
798
+ ?>
password_tools.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- function mrt_sub1(){?>
3
- <div class=wrap>
4
- <h2><?php _e('WP - Password Tools') ?></h2>
5
- <div style="height:299px">
6
- <?php
7
- echo "<br /><strong>Password Strength Tool</strong>";
8
- ?>
9
- <table><tr valign=top><td><form name="commandForm">
10
- Type password: <input type=password size=30 maxlength=50 name=password onkeyup="testPassword(document.forms.commandForm.password.value);" value="">
11
- <br/><font color="#808080">Minimum 6 Characters</td><td><font size="1"> Password Strength:</font><a id="Words"><table><tr><td><table><tr><td height=4 width=150 bgcolor=tan></td></tr></table></td><td> <b>Begin Typing</b></td></tr></table></a></td></tr></table></td></tr></table></form>
12
- <br /><hr align=left size=2 width=612px>
13
- <?php
14
- echo "<br /><br /><strong>Strong Password Generator</strong><br />";
15
- echo "Strong Password: " . '<font color="red">' . make_password(15) . "</font>";
16
- ?>
17
- </div>
18
- Plugin by <a href="http://semperfiwebdesign.com/" title="Semper Fi Web Design">Semper Fi Web Design</a>
19
- </div>
20
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,120 +1,128 @@
1
- === Plugin Name ===
2
- Contributors: WebsiteDefender, hallsofmontezuma
3
- Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=Support%20WordPress%20Security%20Scan%20Plugin&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
- Tags: security, securityscan, chmod, permissions, admin, administration, authentication, database, dashboard, post, notification, password, plugin, posts
5
- plugins, private, protection, tracking, wordpress
6
- Requires at least: 2.5
7
- Tested up to: 3.1
8
- Stable tag: trunk
9
-
10
- Scans your WordPress installation for security vulnerabilities.
11
-
12
- == Description ==
13
-
14
- Scans your WordPress installation for security vulnerabilities and suggests
15
- corrective actions.
16
-
17
- -passwords<br />
18
- -file permissions<br />
19
- -database security<br />
20
- -version hiding<br />
21
- -WordPress admin protection/security<br />
22
- -removes WP Generator META tag from core code<br />
23
-
24
-
25
- **Future Releases**<br />
26
- *one-click change file/folder permissions<br />
27
- *test for XSS vulnerabilities<br />
28
- *intrusion detection/prevention<br />
29
- *lock out/log incorrect login attempts<br />
30
- *user enumeration protection<br />
31
- *.htaccess verification<br />
32
- *doc links<br />
33
-
34
- [Changelog](http://semperfiwebdesign.com/documentation/wp-security-scan/changelog/ "WP Security Scan Changelog")<br />
35
- [Documentation](http://semperfiwebdesign.com/category/documentation/wp-security-scan/ "WP Security Scan
36
- Documentation")
37
-
38
- == Installation ==
39
-
40
- 1. Create backup.
41
- 2. Upload the zip file to the `/wp-content/plugins/` directory
42
- 3. Unzip.
43
- 4. Activate the plugin through the 'Plugins' menu in WordPress
44
-
45
-
46
- Please let me know any bugs, improvements, comments, suggestions.
47
-
48
- == Frequently Asked Questions ==
49
-
50
- = Can I deactivate WP Security Scan once I've run it once? =
51
-
52
- No. WP Security Scan needs to be left activated to work. Version hiding,
53
- turning off DB errors, removing WP ID META tag from HTML output, and other
54
- functionality will cease if you deactivate the plugin.
55
-
56
- = How do I change the file permissions on my WordPress installation? =
57
-
58
- From the linux command line (for advanced users):
59
- chmod xxx filename.ext
60
- (replace xxx with with the permissions settings for the file or folder)
61
-
62
- From your FTP client:
63
- Most FTP clients, such as filezilla, etc, allow for changing file
64
- permissions. Please consult your clients documentation for your specific
65
- directions.
66
-
67
- For more information, please visit http://codex.wordpress.org/Changing_File_Permissions
68
-
69
- = Why do I need to hide my version of WordPress? =
70
-
71
- Alot of attackers and automated tools will try and determine software versions
72
- before launching exploit code. Removing your WordPress blog version may
73
- discourage some attackers and certainly will mitigate virus and worm programs
74
- that rely on software versions.
75
-
76
- NOTE: Hiding your version of WordPress may break any plugins you have which
77
- are version dependant.
78
-
79
- = How do I make Dagon Design's sitemap generator plugin compatible? =
80
- There is currently a small compatibility issue. This can be temporarily
81
- solved by opening securityscan.php and commenting out the line
82
- `add_action("init",mrt_remove_wp_version,1);`
83
- I have contacted Dagon Designs about creating a solution, which should
84
- hopefully be in a future upgrade to their plugin.
85
-
86
- == Screenshots ==
87
-
88
- 1. file/directories permissions check
89
- 2. password tools
90
-
91
- == WordPress Security ==
92
-
93
- <strong>Plugin currently in BETA version.
94
-
95
- == WordPress Security ==
96
-
97
- Security Scanner:
98
-
99
- 1. Scans Wordpress installation for file/directory permissions vulnerabilites
100
- 1. Recommends corrective actions
101
- 1. Scans for general security vulnerabilities
102
-
103
- Join the BETA testers group if:
104
-
105
- * you have experience as a software tester
106
- * you have no experience as a software tester
107
- * you have a WordPress installation dedicated for testing
108
- * you have a general enthusiasm for WordPress use and/or development
109
-
110
-
111
- Visit our homepage at [Semper Fi Web Design](http://semperfiwebdesign.com/ "Raleigh Web Design") or our plugin page at [Semper Fi Plugins][sf plugins].
112
- We look forward to hearing your comments and suggestions.
113
-
114
- [sf plugins]: http://semperfiwebdesign.com/plugins/
115
- "Raleigh Web Design"
116
-
117
- > WordPress Security Scanner for *2.3, 2.5*. Although if you're using lower
118
- > than 2.3 you should go ahead and install it because of **security**.
119
-
120
- `<?php code(); // backticks ?>`
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: WebsiteDefender
3
+ Author: WebsiteDefender
4
+ Tags: security, securityscan, chmod, permissions, admin, administration, authentication, database, dashboard, post, notification, password, plugin, posts, wsd, websitedefender,
5
+ plugins, private, protection, tracking, wordpress
6
+ Requires at least: 2.6
7
+ Tested up to: 3.2.1
8
+ Stable tag: trunk
9
+
10
+ Scans your WordPress installation for security vulnerabilities.
11
+
12
+ == Description ==
13
+
14
+ WP Security Scan checks your WordPress website/blog for security vulnerabilities and suggests corrective actions such as:
15
+
16
+ 1. Passwords
17
+ 2. File permissions
18
+ 3. Database security
19
+ 4. Version hiding
20
+ 5. WordPress admin protection/security
21
+ 6. Removes WP Generator META tag from core code
22
+
23
+ = Requirements =
24
+
25
+ * WordPress version 2.6 and higher (tested at <= 3.2.1)
26
+ * PHP5 (tested with PHP Interpreter >= 5.2.9)
27
+
28
+ For more information on the WP Security Scan and other WordPress security news, visit the <a href="http://www.websitedefender.com/blog" target="_blank">WebsiteDefender Blog</a> and join our <a href="http://www.facebook.com/websitedefender" target="_blank">Facebook</a> page. Post any questions or feedback on the <a href="http://www.websitedefender.com/forums/wp-security-scan-plugin/" target="_blank">WP Security Scan plugin forum</a>.
29
+
30
+
31
+ == Installation ==
32
+
33
+ 1. Make a backup of your current installation
34
+ 2. Unpack the download package
35
+ 3. Upload the extracted files to the /wp-content/plugins/ directory
36
+ 4. Activate the plugin through the 'Plugins' menu in WordPress
37
+
38
+ If you do encounter any bugs, or have comments or suggestions, please contact the WebsiteDefender team on support@websitedefender.com.
39
+
40
+ For more information on the WP Security Scan and other WordPress security news, visit the <a href="http://www.websitedefender.com/blog" target="_blank">WebsiteDefender Blog</a> and join our <a href="http://www.facebook.com/websitedefender" target="_blank">Facebook</a> page. Post any questions or feedback on the <a href="http://www.websitedefender.com/forums/wp-security-scan-plugin/" target="_blank">WP Security Scan plugin forum</a>.
41
+
42
+ == Changelog ==
43
+
44
+ = v3.0.5 (07/20/2011) =
45
+ * Bugfix: Updated the links to websitedefender.com
46
+
47
+ = v3.0.4 (07/20/2011) =
48
+ * Update: the plug-in has been made compatible with Secure WP plug-in
49
+
50
+ = v3.0.3 (07/14/2011) =
51
+ * Bugfix: Fixed the code error in the change database prefix feature
52
+ * Update: More code cleanup
53
+
54
+ = v3.0.2 (07/11/2011) =
55
+ * Feature: Enabled automatic database table prefix rename feature
56
+ * Feature: Database backup functionality used in databse renaming tables
57
+ * Feature: Included more documentation / links for a number of features
58
+ * Feature: Prevent blog owner from changing table prefix if the wp-config.php file is not writable
59
+ * Update: Updated several error messages text (user friendly)
60
+ * Update: major code cleanup
61
+ * Bugfix: Fixed a number of bugs in the database tables rename utility
62
+
63
+ = v3.0.1 (03/24/2011) =
64
+ * Regression: Temporarily disabled database change feature
65
+ * Fixed: Resolved conflict with plugins using the reCAPTCHA library
66
+ * Bugfix: Fixed CSS image background not showing corectly
67
+
68
+ = v3.0.0 (03/22/2011) =
69
+ * Feature: Release new stable version
70
+ * Feature: Rebranding of the plugin
71
+ * Feature: Integrated WebsiteDefender.com registration in Settings
72
+
73
+ For more information on the WP Security Scan and other WordPress security news, visit the <a href="http://www.websitedefender.com/blog" target="_blank">WebsiteDefender Blog</a> and join our <a href="http://www.facebook.com/websitedefender" target="_blank">Facebook</a> page. Post any questions or feedback on the <a href="http://www.websitedefender.com/forums/wp-security-scan-plugin/" target="_blank">WP Security Scan plugin forum</a>.
74
+
75
+ == Frequently Asked Questions ==
76
+
77
+ = Can I deactivate WP Security Scan once I've run it once? =
78
+
79
+ No. WP Security Scan needs to be left activated to work. Version hiding,
80
+ turning off DB errors, removing WP ID META tag from HTML output, and other
81
+ functionality will cease if you deactivate the plugin.
82
+
83
+ = How do I change the file permissions on my WordPress installation? =
84
+
85
+ From the Linux command line (for advanced users):
86
+ chmod xxx filename.ext
87
+ (replace xxx with with the permissions settings for the file or folder).
88
+
89
+ From your FTP client:
90
+ Most FTP clients, such as filezilla, etc, allow for changing file
91
+ permissions. Please consult your client's documentation for your specific
92
+ directions.
93
+
94
+ For more information, please visit http://codex.wordpress.org/Changing_File_Permissions
95
+
96
+ = Why do I need to hide my version of WordPress? =
97
+
98
+ Many attackers and automated tools will try and determine software versions
99
+ before launching exploit code. Removing your WordPress blog version may
100
+ discourage some attackers and certainly will mitigate virus and malware programs
101
+ that rely on software versions.
102
+
103
+ NOTE: Hiding your version of WordPress may break any plugins you have which
104
+ are version dependant.
105
+
106
+ = How do I make Dagon Design's sitemap generator plugin compatible? =
107
+ There is currently a small compatibility issue. This can be temporarily
108
+ solved by opening securityscan.php and commenting out the line
109
+ `add_action("init",mrt_remove_wp_version,1);`
110
+
111
+
112
+ For more information on the WP Security Scan and other WordPress security news, visit the <a href="http://www.websitedefender.com/blog" target="_blank">WebsiteDefender Blog</a> and join our <a href="http://www.facebook.com/websitedefender" target="_blank">Facebook</a> page. Post any questions or feedback on the <a href="http://www.websitedefender.com/forums/wp-security-scan-plugin/" target="_blank">WP Security Scan plugin forum</a>.
113
+
114
+ == Screenshots ==
115
+
116
+ 1. file/directories permissions check
117
+ 2. password tools
118
+
119
+ == WordPress Security ==
120
+
121
+ Security Scanner:
122
+
123
+ 1. Scans Wordpress installation for file/directory permissions vulnerabilites
124
+ 2. Recommends corrective actions
125
+ 3. Scans for general security vulnerabilities
126
+
127
+
128
+ For more information on the WP Security Scan and other WordPress security news, visit the <a href="http://www.websitedefender.com/blog" target="_blank">WebsiteDefender Blog</a> and join our <a href="http://www.facebook.com/websitedefender" target="_blank">Facebook</a> page. Post any questions or feedback on the <a href="http://www.websitedefender.com/forums/wp-security-scan-plugin/" target="_blank">WP Security Scan plugin forum</a>.
scanner.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- function mrt_sub0(){?>
3
- <div class=wrap>
4
- <h2><?php _e('WP - Security Scan') ?></h2>
5
- <div style="height:299px">
6
- <table width="100%" border="0" cellspacing="0" cellpadding="3" style="text-align:center;">
7
- <tr>
8
- <th style="border:0px;"><b>Name</b></th>
9
- <th style="border:0px;"><b>File/Dir</b></th>
10
- <th style="border:0px;"><b>Needed Chmod</b></th>
11
- <th style="border:0px;"><b>Current Chmod</b></th>
12
- <!-- <th style="border:0px;"><b>Change Permissions</b></th>-->
13
- </tr>
14
- <?php
15
- check_perms("root directory","../","0755");
16
- check_perms("wp-includes/","../wp-includes","0755");
17
- check_perms(".htaccess","../.htaccess","0644");
18
- check_perms("wp-admin/index.php","index.php","0644");
19
- check_perms("wp-admin/js/","js/","0755");
20
- check_perms("wp-content/themes/","../wp-content/themes","0755");
21
- check_perms("wp-content/plugins/","../wp-content/plugins","0755");
22
- check_perms("wp-admin/","../wp-admin","0755");
23
- check_perms("wp-content/","../wp-content","0755");
24
- ?>
25
- </table>
26
-
27
-
28
- </div>
29
- Plugin by <a href="http://semperfiwebdesign.com/" title="Semper Fi Web Design">Semper Fi Web Design</a>
30
- </div>
31
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
scripts.js DELETED
@@ -1,28 +0,0 @@
1
- function testPassword(passwd){
2
- var description = new Array();
3
- description[0] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=30 bgcolor=#ff0000></td><td height=4 width=120 bgcolor=tan></td></tr></table></td><td> <b>Weakest</b></td></tr></table>";
4
- description[1] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=60 bgcolor=#990000></td><td height=4 width=90 bgcolor=tan></td></tr></table></td><td> <b>Weak</b></td></tr></table>";
5
- description[2] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=90 bgcolor=#990099></td><td height=4 width=60 bgcolor=tan></td></tr></table></td><td> <b>Improving</b></td></tr></table>";
6
- description[3] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=120 bgcolor=#000099></td><td height=4 width=30 bgcolor=tan></td></tr></table></td><td> <b>Strong</b></td></tr></table>";
7
- description[4] = "<table><tr><td><table><tr><td height=4 width=150 bgcolor=#0000ff></td></tr></table></td><td> <b>Strongest</b></td></tr></table>";
8
- description[5] = "<table><tr><td><table><tr><td height=4 width=150 bgcolor=tan></td></tr></table></td><td> <b>Begin Typing</b></td></tr></table>";
9
-
10
- var base = 0
11
- var combos = 0
12
- if (passwd.match(/[a-z]/))base = (base+26);
13
- if (passwd.match(/[A-Z]/))base = (base+26);
14
- if (passwd.match(/\d+/))base = (base+10);
15
- if (passwd.match(/[>!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/))base = (base+33);
16
-
17
- combos=Math.pow(base,passwd.length);
18
-
19
- if(combos == 1)strVerdict = description[5];
20
- else if(combos > 1 && combos < 1000000)strVerdict = description[0];
21
- else if (combos >= 1000000 && combos < 1000000000000)strVerdict = description[1];
22
- else if (combos >= 1000000000000 && combos < 1000000000000000000)strVerdict = description[2];
23
- else if (combos >= 1000000000000000000 && combos < 1000000000000000000000000)strVerdict = description[3];
24
- else strVerdict = description[4];
25
-
26
- document.getElementById("Words").innerHTML= (strVerdict);
27
- }
28
- ////
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
securityscan.php CHANGED
@@ -1,320 +1,234 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Security Scan
4
- Plugin URI: http://semperfiwebdesign.com/plugins/wp-security-scan/
5
- Description: Perform security scan of WordPress installation.
6
- Author: Michael Torbert, WebsiteDefender
7
- Version: 2.7.4
8
- Author URI: http://semperfiwebdesign.com/
9
- */
10
-
11
- /*
12
- Copyright (C) 2008-2010 Michael Torbert / semperfiwebdesign.com (michael AT semperfiwebdesign DOT com)
13
-
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License as published by
16
- the Free Software Foundation; either version 3 of the License, or
17
- (at your option) any later version.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program. If not, see <http://www.gnu.org/licenses/>.
26
- */
27
-
28
- if ( ! defined( 'WP_CONTENT_URL' ) )
29
- define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
30
- if ( ! defined( 'WP_CONTENT_DIR' ) )
31
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
32
- if ( ! defined( 'WP_PLUGIN_URL' ) )
33
- define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
34
- if ( ! defined( 'WP_PLUGIN_DIR' ) )
35
- define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
36
-
37
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/support.php");
38
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/scanner.php");
39
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/password_tools.php");
40
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/database.php");
41
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/functions.php");
42
- if(!class_exists("SimplePie")){
43
- require_once(WP_PLUGIN_DIR . "/wp-security-scan/simplepie.inc");
44
- }
45
- //require_once(WP_PLUGIN_DIR . "/plugins/wp-security-scan/scripts.js");
46
-
47
-
48
- add_action( 'admin_notices', mrt_update_notice, 5 );
49
- add_action('admin_head', 'mrt_hd');
50
- add_action("init",mrt_wpdberrors,1);
51
- add_action("parse_query",mrt_wpdberrors,1);
52
- add_action('admin_menu', 'add_men_pg');
53
- add_action("init",mrt_remove_wp_version,1); //comment out this line to make ddsitemapgen work
54
-
55
-
56
- remove_action('wp_head', 'wp_generator');
57
- //add_action('admin_head', 'mrt_root_scripts');
58
- function add_men_pg() {
59
- if (function_exists('add_menu_page')){
60
- add_menu_page('Security', 'Security', 8, __FILE__, 'mrt_opt_mng_pg',WP_PLUGIN_URL . '/wp-security-scan/lock.png');
61
- add_submenu_page(__FILE__, 'Scanner', 'Scanner', 8, 'scanner', 'mrt_sub0');
62
- add_submenu_page(__FILE__, 'Password Tool', 'Password Tool', 8, 'passwordtool', 'mrt_sub1');
63
- add_submenu_page(__FILE__, 'Database', 'Database', 8, 'database', 'mrt_sub3');
64
- add_submenu_page(__FILE__, 'Support', 'Support', 8, 'support', 'mrt_sub2');
65
- }
66
- }
67
-
68
- /*function mrt_root_scripts(){
69
- $siteurl = get_option('siteurl');
70
- echo '<script language="JavaScript" type="text/javascript" src="' . WP_PLUGIN_URL . '/wp-security-scan/scripts.js"></script>';
71
- }*/
72
-
73
- function mrt_update_notice(){
74
- /*$mrt_version = "2.2.52";
75
- $mrt_latest = fgets(fopen("http://semperfiwebdesign.com/wp-security-scan.html", "r"));
76
- echo $mrt_latest . " and " . $mrt_version;
77
- if($mrt_latest > $mrt_version)
78
- echo "New Version Available";
79
- else
80
- echo "Latest Version";
81
- */ }
82
-
83
-
84
- function wpss_mrt_meta_box(){
85
-
86
- global $wpdb;
87
- mrt_check_version();
88
- mrt_check_table_prefix();
89
- mrt_version_removal();
90
- mrt_errorsoff();
91
- echo '<div style="color:green">WP ID META tag removed form WordPress core</div>';
92
-
93
- $name = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login='admin'");
94
- if ($name=="admin"){
95
- echo '<a href="http://semperfiwebdesign.com/documentation/wp-security-scan/change-wordpress-admin-username/" title="WordPress Admin" target="_blank"><font color="red">"admin" user exists.</font></a>';
96
- }
97
- else{
98
- echo '<font color="green">No user "admin".</font>';
99
- }
100
- ?><br /><?php
101
- $filename = '.htaccess';
102
- if (file_exists($filename)) {
103
- echo '<font color="green">.htaccess exists in wp-admin/</font>';
104
- } else {
105
- echo '<font color="red">The file .htaccess does not exist in wp-admin/.</font>';
106
- }
107
-
108
- ?>
109
-
110
- <div style="text-align:center;color:grey;margin-top:20px;"><em>**WP Security Scan plugin must remain active for security features to remain**</em></div>
111
-
112
- <div style="text-align:center;font-weight:bold;">Future Releases</div>
113
- <ul><li>one-click change file/folder permissions</li><li>test for XSS vulnerabilities</li><li>intrusion detection/prevention</li><li>lock out/log incorrect login attempts</li><li>user enumeration protection</li><li>WordPress admin protection/security</li></ul>
114
- <?php }
115
-
116
- function wpss_mrt_meta_box4(){ ?>
117
- <div style="padding-left:10px;">
118
- <div style="padding: 10px 10px 10px 10px;border: 1px solid #ddd;">
119
- <div style="margin-bottom:30px;">
120
- We would also like to recommend <a href="http://www.pagelines.com/wpthemes/" target="_blank">PageLines</a> for Professional WordPress Themes. They are attractive, affordable, performance optimized CMS themes that integrate perfectly with All in One SEO Pack to put your professional website at the top of the rankings.
121
- </div>
122
-
123
- <a target="_blank" title="iBlogPro" href="http://www.pagelines.com/wpthemes/">
124
- <img src="<?php echo WP_PLUGIN_URL; ?>/wp-security-scan/images/iblogpro.jpg" alt="<?php _e('iBlogPro theme', 'all_in_one_seo_pack') ?>" /> </a>
125
-
126
- <a target="_blank" title="PageLines Themes" href="http://www.pagelines.com/wpthemes/">
127
- <img src="<?php echo WP_PLUGIN_URL; ?>/wp-security-scan/images/pagelines.jpg" alt="<?php _e('Pagelines Themes', 'all_in_one_seo_pack') ?>" /> </a>
128
-
129
- <a target="_blank" title="WhiteHouse" href="http://www.pagelines.com/wpthemes/">
130
- <img src="<?php echo WP_PLUGIN_URL; ?>/wp-security-scan/images/whitehouse.jpg" alt="<?php _e('WhiteHouse theme', 'all_in_one_seo_pack') ?>" /> </a>
131
-
132
-
133
- </div>
134
-
135
-
136
- </div>
137
-
138
- <?php }
139
-
140
- function wpss_mrt_meta_box2(){ ?>
141
- <div style="padding-left:10px;">
142
- <?php mrt_get_serverinfo(); ?>
143
- </div>
144
-
145
- <?php }
146
-
147
-
148
- function wpss_mrt_meta_box3(){
149
-
150
- ?>
151
- <div style="padding:10px;">
152
- <div style="font-size:13pt;text-align:center;">Highest</div> <?php
153
- // include('WP_PLUGIN_DIR . '/all-in-one-seo-pack/simplepie.inc');
154
-
155
- $feed = new SimplePie();
156
-
157
-
158
- $feed->set_feed_url('feed://donations.semperfiwebdesign.com/category/highest-donations/feed/');
159
- $feed->enable_cache(false);
160
- $feed->strip_htmltags(array('p'));
161
- // $feed->set_cache_location(WP_PLUGIN_DIR . '/wp-security-scan/');
162
- $feed->init();
163
- $feed->handle_content_type();
164
- ?>
165
- <?php if ($feed->data): ?>
166
- <?php $items = $feed->get_items(); ?>
167
-
168
- <?php foreach($items as $item): ?>
169
- <p>
170
- <strong><?php echo $item->get_title(); ?></strong>
171
- <?php echo $item->get_content(); ?>
172
- </p>
173
-
174
- <?php endforeach; ?>
175
- </div>
176
- <?php endif; ?>
177
-
178
-
179
- <div style="font-size:13pt;text-align:center;">Recent</div> <?php
180
- // include(WP_PLUGIN_DIR . '/all-in-one-seo-pack/simplepie.inc');
181
-
182
- $feed = new SimplePie();
183
-
184
-
185
- $feed->set_feed_url('feed://donations.semperfiwebdesign.com/category/wp-security-scan/feed/');
186
- $feed->enable_cache(false);
187
- $feed->strip_htmltags(array('p'));
188
- // $feed->set_cache_location(WP_PLUGIN_DIR . '/wp-security-scan/');
189
- $feed->init();
190
-
191
- $feed->handle_content_type();
192
- ?>
193
- <?php if ($feed->data): ?>
194
- <?php $items = $feed->get_items(); ?>
195
-
196
- <?php foreach($items as $item): ?>
197
- <p>
198
- <strong><?php echo $item->get_title(); ?></strong>
199
- <?php echo $item->get_content(); ?>
200
- </p>
201
-
202
- <?php endforeach; ?>
203
- </div>
204
- <?php endif; ?>
205
-
206
- <hr width="75%"/>
207
-
208
- <div style="text-align:center"><em>This plugin is updated as a free service to the WordPress community. Donations of any size are appreciated.</em>
209
- <br /><br />
210
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=Support%20WordPress%20Security%20Scan%20Plugin&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">Click here to support this plugin.</a>
211
-
212
- </div>
213
-
214
- <!-- <br /><br /><h4>Highest Donations</h4></div> -->
215
-
216
- <?php
217
-
218
- /*$ch = curl_init("http://semperfiwebdesign.com/top_donations.php");
219
- $fp = fopen("top_donations.php", "w");
220
- curl_setopt($ch, CURLOPT_FILE, $fp);
221
- curl_setopt($ch, CURLOPT_HEADER, 0);
222
- curl_exec($ch);
223
- curl_close($ch);
224
- fclose($fp);
225
- */
226
-
227
- /* $ch = curl_init();
228
- curl_setopt($ch, CURLOPT_URL, "http://semperfiwebdesign.com/top_donations.php");
229
- curl_setopt($ch, CURLOPT_HEADER, 0);
230
- curl_exec($ch);
231
- curl_close($ch);
232
- */
233
- ?>
234
- <!-- <br /><br /><div style="text-align:center"><h4>Recent Donations</h4></div>
235
-
236
- -->
237
- <?php
238
-
239
- /*
240
- $ch = curl_init();
241
- curl_setopt($ch, CURLOPT_URL, "http://semperfiwebdesign.com/recent_donations.php");
242
- curl_setopt($ch, CURLOPT_HEADER, 0);
243
- curl_exec($ch);
244
- curl_close($ch);
245
- */
246
- /*
247
- $ch = curl_init("http://semperfiwebdesign.com/recent_donations.php");
248
- $fp = fopen("recent_donations.php", "w");
249
- curl_setopt($ch, CURLOPT_FILE, $fp);
250
- curl_setopt($ch, CURLOPT_HEADER, 0);
251
- curl_exec($ch);
252
- curl_close($ch);
253
- fclose($fp);
254
- */
255
-
256
- }
257
-
258
-
259
- function mrt_opt_mng_pg() {
260
- ?>
261
-
262
-
263
- <div class="wrap">
264
- <h2>WP - Security Admin Tools</h2>
265
-
266
- <!--<div id='update-nag'>A new version of WP Security Scan is available!</div>-->
267
- <?php //$rss = fetch_rss('http://alexrabe.boelinger.com/?tag=nextgen-gallery&feed=rss2');?>
268
-
269
-
270
- <?php
271
-
272
- add_meta_box("wpss_mrt", 'Initial Scan', "wpss_mrt_meta_box", "wpss");
273
- add_meta_box("wpss_mrt", 'System Information Scan', "wpss_mrt_meta_box2", "wpss2");
274
- add_meta_box("wpss_mrt", 'Donations', "wpss_mrt_meta_box3", "wpss3");
275
- add_meta_box("wpss_mrt", 'PageLines WordPress Themes', "wpss_mrt_meta_box4", "wpss4");
276
-
277
- ?>
278
-
279
- <div id="dashboard-widgets-wrap">
280
- <div class="metabox-holder">
281
- <div style="float:left; width:48%;" class="inner-sidebar1">
282
- <?php do_meta_boxes('wpss','advanced',''); ?>
283
- </div>
284
-
285
- <div style="float:right; width:48%; " class="inner-sidebar1">
286
- <?php do_meta_boxes('wpss2','advanced',''); ?>
287
- </div>
288
-
289
- <div style="clear:both"></div>
290
-
291
- <div style="float:left;width:48%;" class="inner-sidebar1">
292
- <?php do_meta_boxes('wpss4','advanced',''); ?>
293
- </div>
294
-
295
- <div style="float:right; width:48%;" class="inner-sidebar1">
296
- <?php do_meta_boxes('wpss3','advanced',''); ?>
297
- </div>
298
- </div>
299
-
300
- <div style="clear:both;"></div>
301
- </div>
302
-
303
- <br /><em>For comments, suggestions, bug reporting, etc please <a href="http://semperfiwebdesign.com/contact/">click here</a>.</em>
304
-
305
-
306
- Plugin by <a href="http://semperfiwebdesign.com/" title="Semper Fi Web Design">Semper Fi Web Design</a>
307
- </div>
308
- <?php }
309
-
310
- function mrt_hd()
311
- {
312
- $siteurl = get_option('siteurl');?>
313
- <script language="JavaScript" type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/js/scripts.js"></script>
314
- <script language="JavaScript" type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/scripts.js"></script>
315
- <script type="text/javascript">
316
- //window.onload=function(){enableTooltips()};
317
- </script>
318
- <!--<link rel="stylesheet" type="text/css" href="<?php //echo WP_PLUGIN_URL;?>/plugins/wp-security-scan/style.css" />-->
319
- <?php }
320
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Security Scan
4
+ Plugin URI: http://www.websitedefender.com/news/free-wordpress-security-scan-plugin/
5
+
6
+ Description: Perform security scan of WordPress installation.
7
+ Author: WebsiteDefender
8
+ Version: 3.0.5
9
+ Author URI: http://www.websitedefender.com/
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2008-2010 Acunetix / http://www.websitedefender.com/
14
+ (info AT websitedefender DOT com)
15
+
16
+
17
+ This program is free software; you can redistribute it and/or modify
18
+ it under the terms of the GNU General Public License as published by
19
+ the Free Software Foundation; either version 3 of the License, or
20
+ (at your option) any later version.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
29
+ */
30
+ if ( ! defined('WP_CONTENT_URL')) {
31
+ define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
32
+ }
33
+ if ( ! defined('WP_CONTENT_DIR')) {
34
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
35
+ }
36
+ if ( ! defined('WP_PLUGIN_URL')) {
37
+ define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
38
+ }
39
+ if ( ! defined('WP_PLUGIN_DIR')) {
40
+ define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
41
+ }
42
+
43
+ //main files
44
+ //## $rev #1 07/17/2011 {c}$
45
+ if(!function_exists('json_encode') || !class_exists('Services_JSON')) {
46
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/libs/json.php");
47
+ }
48
+
49
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/libs/functions.php");
50
+
51
+ //## $rev #1 07/17/2011 {c}$
52
+ if (!defined('WSD_RECAPTCHA_API_SERVER')) {
53
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/libs/recaptchalib.php");
54
+ }
55
+
56
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/libs/wsd.php");
57
+
58
+ //menus
59
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/security.php");
60
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/scanner.php");
61
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/pwtool.php");
62
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/db.php");
63
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/support.php");
64
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/templates/header.php");
65
+ require_once(WP_PLUGIN_DIR . "/wp-security-scan/inc/admin/templates/footer.php");
66
+
67
+
68
+ //## this is the container for header scripts
69
+ add_action('admin_head', 'mrt_hd');
70
+
71
+ //before sending headers
72
+ add_action("init",'mrt_wpdberrors',1);
73
+
74
+ //after executing a query
75
+ add_action("parse_query",'mrt_wpdberrors',1);
76
+
77
+ //## add the sidebar menu
78
+ add_action('admin_menu', 'add_men_pg');
79
+
80
+ add_action("init", 'mrt_remove_wp_version',1); //comment out this line to make ddsitemapgen work
81
+
82
+ //before rendering each admin init
83
+ add_action('admin_init','mrt_wpss_admin_init');
84
+
85
+
86
+ function mrt_wpss_admin_init(){
87
+ wp_enqueue_style('wsd_style', WP_PLUGIN_URL . '/wp-security-scan/css/wsd.css');
88
+ }
89
+
90
+ remove_action('wp_head', 'wp_generator');
91
+ function add_men_pg() {
92
+ if (function_exists('add_menu_page'))
93
+ {
94
+ add_menu_page('Security', 'Security', 'edit_pages', __FILE__, 'mrt_opt_mng_pg', WP_PLUGIN_URL.'/wp-security-scan/images/wsd-logo-small.png');
95
+ add_submenu_page(__FILE__, 'Scanner', 'Scanner', 'edit_pages', 'scanner', 'mrt_sub0');
96
+ add_submenu_page(__FILE__, 'Password Tool', 'Password Tool', 'edit_pages', 'passwordtool', 'mrt_sub1');
97
+ add_submenu_page(__FILE__, 'Database', 'Database', 'edit_pages', 'database', 'mrt_sub3');
98
+ add_submenu_page(__FILE__, 'Support', 'Support', 'edit_pages', 'support', 'mrt_sub2');
99
+ }
100
+ }
101
+
102
+
103
+
104
+ function wpss_admin_head() {
105
+ $scheme = 'http';
106
+ if ( is_ssl() ) {
107
+ $scheme = 'https';
108
+ }
109
+ }
110
+ add_action( 'admin_head', 'wpss_admin_head' );
111
+
112
+
113
+ // function for WP < 2.8
114
+ function get_plugins_url($path = '', $plugin = '') {
115
+
116
+ if ( function_exists('plugin_url') )
117
+ return plugins_url($path, $plugin);
118
+
119
+ if ( function_exists('is_ssl') )
120
+ $scheme = ( is_ssl() ? 'https' : 'http' );
121
+ else
122
+ $scheme = 'http';
123
+ if ( function_exists('plugins_url') )
124
+ $url = plugins_url();
125
+ else
126
+ $url = WP_PLUGIN_URL;
127
+ if ( 0 === strpos($url, 'http') ) {
128
+ if ( function_exists('is_ssl') && is_ssl() )
129
+ $url = str_replace( 'http://', "{$scheme}://", $url );
130
+ }
131
+
132
+ if ( !empty($plugin) && is_string($plugin) )
133
+ {
134
+ $folder = dirname(plugin_basename($plugin));
135
+ if ('.' != $folder)
136
+ $url .= '/' . ltrim($folder, '/');
137
+ }
138
+
139
+ if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
140
+ $url .= '/' . ltrim($path, '/');
141
+
142
+ return apply_filters('plugins_url', $url, $path, $plugin);
143
+ }
144
+
145
+ function wpss_mrt_meta_box()
146
+ {
147
+ ?>
148
+ <div id="wsd-initial-scan" class="wsd-inside">
149
+ <div class="wsd-initial-scan-section">
150
+ <?php mrt_check_version();?>
151
+ </div>
152
+
153
+ <div class="wsd-initial-scan-section">
154
+ <?php mrt_check_table_prefix();?>
155
+ </div>
156
+
157
+ <div class="wsd-initial-scan-section">
158
+ <?php mrt_version_removal();?>
159
+ </div>
160
+
161
+ <div class="wsd-initial-scan-section">
162
+ <?php mrt_errorsoff();?>
163
+ </div>
164
+ <?php
165
+ global $wpdb;
166
+
167
+ echo '<div class="scanpass">WP ID META tag removed form WordPress core</div>';
168
+
169
+ echo '<div class="wsd-initial-scan-section">';
170
+ $name = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login='admin'");
171
+ if ($name == "admin") {
172
+ echo '<a href="http://www.websitedefender.com/wordpress-security/change-wordpress-admin-username" title="Change WordPress Admin username" target="_blank"><font color="red">"admin" user exists.</font></a>';
173
+ }
174
+ else { echo '<span class="scanpass">No user "admin".</span>'; }
175
+ echo '</div>';
176
+
177
+ echo '<div class="wsd-initial-scan-section">';
178
+ if (file_exists('.htaccess')) {
179
+ echo '<span class="scanpass">.htaccess exists in wp-admin/</span>';
180
+ }
181
+ else { echo '<span style="color:#f00;">The file .htaccess does not exist in wp-admin/.</span>'; }
182
+ echo '</div>';
183
+
184
+ ?>
185
+
186
+ <div class="mrt_wpss_note">
187
+ <em>**WP Security Scan plugin <strong>must</strong> remain active for security features to persist**</em>
188
+ </div>
189
+ </div>
190
+ <?php
191
+ }
192
+
193
+
194
+ function wpss_mrt_meta_box2()
195
+ {
196
+ ?>
197
+ <ul id="wsd-information-scan-list"">
198
+ <?php mrt_get_serverinfo(); ?>
199
+ </ul>
200
+ <?php
201
+ }
202
+
203
+ function mrt_hd()
204
+ {
205
+ ?>
206
+ <script type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/js/json.js"></script>
207
+ <script type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/js/md5.js"></script>
208
+ <script type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/js/scripts.js"></script>
209
+ <script type="text/javascript" src="<?php echo WP_PLUGIN_URL;?>/wp-security-scan/js/wsd.js"></script>
210
+ <script type="text/javascript">
211
+ var wordpress_site_name = "<?php echo htmlentities(get_bloginfo('siteurl'));?>"
212
+ </script>
213
+ <script type="text/javascript">
214
+ var _wsdPassStrengthProvider = null;
215
+
216
+ jQuery(document).ready(function($) {
217
+ _wsdPassStrengthProvider = new wsdPassStrengthProvider($);
218
+ _wsdPassStrengthProvider.init();
219
+
220
+ $('#wpss_mrt_1.postbox h3, #wpss_mrt_2.postbox h3, #wpss_mrt_3.postbox h3').click(function() {
221
+ var parent = $(this).parent();
222
+ if (parent) parent.toggleClass('closed');
223
+ });
224
+ $('#wpss_mrt_1.postbox .handlediv, #wpss_mrt_2.postbox .handlediv, #wpss_mrt_3.postbox .handlediv').click(function() {
225
+ var parent = $(this).parent();
226
+ if (parent) parent.toggleClass('closed');
227
+ });
228
+ $('#wpss_mrt_1.postbox.close-me, #wpss_mrt_2.postbox.close-me, #wpss_mrt_3.postbox.close-me').each(function() {
229
+ $(this).addClass("closed");
230
+ });
231
+ });
232
+ </script>
233
+ <?php }
234
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
simplepie.inc DELETED
@@ -1,12658 +0,0 @@
1
- <?php
2
- define('SIMPLEPIE_NAME', 'SimplePie');
3
- define('SIMPLEPIE_VERSION', '1.1.3');
4
- define('SIMPLEPIE_BUILD', 20081219);
5
- define('SIMPLEPIE_URL', 'http://simplepie.org');
6
- define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
7
- define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
8
- define('SIMPLEPIE_LOCATOR_NONE', 0);
9
- define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
10
- define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
11
- define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
12
- define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
13
- define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
14
- define('SIMPLEPIE_LOCATOR_ALL', 31);
15
- define('SIMPLEPIE_TYPE_NONE', 0);
16
- define('SIMPLEPIE_TYPE_RSS_090', 1);
17
- define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
18
- define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
19
- define('SIMPLEPIE_TYPE_RSS_091', 6);
20
- define('SIMPLEPIE_TYPE_RSS_092', 8);
21
- define('SIMPLEPIE_TYPE_RSS_093', 16);
22
- define('SIMPLEPIE_TYPE_RSS_094', 32);
23
- define('SIMPLEPIE_TYPE_RSS_10', 64);
24
- define('SIMPLEPIE_TYPE_RSS_20', 128);
25
- define('SIMPLEPIE_TYPE_RSS_RDF', 65);
26
- define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
27
- define('SIMPLEPIE_TYPE_RSS_ALL', 255);
28
- define('SIMPLEPIE_TYPE_ATOM_03', 256);
29
- define('SIMPLEPIE_TYPE_ATOM_10', 512);
30
- define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
31
- define('SIMPLEPIE_TYPE_ALL', 1023);
32
- define('SIMPLEPIE_CONSTRUCT_NONE', 0);
33
- define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
34
- define('SIMPLEPIE_CONSTRUCT_HTML', 2);
35
- define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
36
- define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
37
- define('SIMPLEPIE_CONSTRUCT_IRI', 16);
38
- define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
39
- define('SIMPLEPIE_CONSTRUCT_ALL', 63);
40
- define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
41
- define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
42
- define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
43
- define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
44
- define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
45
- define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
46
- define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
47
- define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
48
- define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
49
- define('SIMPLEPIE_NAMESPACE_RSS_20', '');
50
- define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
51
- define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
52
- define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
53
- define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
54
- define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
55
- define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
56
- define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
57
- define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
58
- define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
59
- define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
60
- define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
61
- define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
62
- define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
63
- define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
64
- define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
65
- define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
66
- class SimplePie
67
- {
68
- var $data = array();
69
- var $error;
70
- var $sanitize;
71
- var $useragent = SIMPLEPIE_USERAGENT;
72
- var $feed_url;
73
- var $file;
74
- var $raw_data;
75
- var $timeout = 10;
76
- var $force_fsockopen = false;
77
- var $force_feed = false;
78
- var $xml_dump = false;
79
- var $cache = true;
80
- var $cache_duration = 3600;
81
- var $autodiscovery_cache_duration = 604800; // 7 Days.
82
- var $cache_location = './cache';
83
- var $cache_name_function = 'md5';
84
- var $order_by_date = true;
85
- var $input_encoding = false;
86
- var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
87
- var $cache_class = 'SimplePie_Cache';
88
- var $locator_class = 'SimplePie_Locator';
89
- var $parser_class = 'SimplePie_Parser';
90
- var $file_class = 'SimplePie_File';
91
- var $item_class = 'SimplePie_Item';
92
- var $author_class = 'SimplePie_Author';
93
- var $category_class = 'SimplePie_Category';
94
- var $enclosure_class = 'SimplePie_Enclosure';
95
- var $caption_class = 'SimplePie_Caption';
96
- var $copyright_class = 'SimplePie_Copyright';
97
- var $credit_class = 'SimplePie_Credit';
98
- var $rating_class = 'SimplePie_Rating';
99
- var $restriction_class = 'SimplePie_Restriction';
100
- var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
101
- var $source_class = 'SimplePie_Source';
102
- var $javascript = 'js';
103
- var $max_checked_feeds = 10;
104
- var $favicon_handler = '';
105
- var $image_handler = '';
106
- var $multifeed_url = array();
107
- var $multifeed_objects = array();
108
- var $config_settings = null;
109
- var $item_limit = 0;
110
- var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
111
- var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
112
- function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null)
113
- {
114
- $this->sanitize =& new SimplePie_Sanitize;
115
- if ($cache_location !== null)
116
- {
117
- $this->set_cache_location($cache_location);
118
- }
119
- if ($cache_duration !== null)
120
- {
121
- $this->set_cache_duration($cache_duration);
122
- }
123
- if ($feed_url !== null)
124
- {
125
- $this->set_feed_url($feed_url);
126
- $this->init();
127
- }
128
- }
129
- function __toString()
130
- {
131
- return md5(serialize($this->data));
132
- }
133
- function __destruct()
134
- {
135
- if (!empty($this->data['items']))
136
- {
137
- foreach ($this->data['items'] as $item)
138
- {
139
- $item->__destruct();
140
- }
141
- unset($this->data['items']);
142
- }
143
- if (!empty($this->data['ordered_items']))
144
- {
145
- foreach ($this->data['ordered_items'] as $item)
146
- {
147
- $item->__destruct();
148
- }
149
- unset($this->data['ordered_items']);
150
- }
151
- }
152
- function force_feed($enable = false)
153
- {
154
- $this->force_feed = (bool) $enable;
155
- }
156
- function set_feed_url($url)
157
- {
158
- if (is_array($url))
159
- {
160
- $this->multifeed_url = array();
161
- foreach ($url as $value)
162
- {
163
- $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
164
- }
165
- }
166
- else
167
- {
168
- $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
169
- }
170
- }
171
- function set_file(&$file)
172
- {
173
- if (is_a($file, 'SimplePie_File'))
174
- {
175
- $this->feed_url = $file->url;
176
- $this->file =& $file;
177
- return true;
178
- }
179
- return false;
180
- }
181
- function set_raw_data($data)
182
- {
183
- $this->raw_data = $data;
184
- }
185
- function set_timeout($timeout = 10)
186
- {
187
- $this->timeout = (int) $timeout;
188
- }
189
- function force_fsockopen($enable = false)
190
- {
191
- $this->force_fsockopen = (bool) $enable;
192
- }
193
- function enable_xml_dump($enable = false)
194
- {
195
- $this->xml_dump = (bool) $enable;
196
- }
197
- function enable_cache($enable = true)
198
- {
199
- $this->cache = (bool) $enable;
200
- }
201
- function set_cache_duration($seconds = 3600)
202
- {
203
- $this->cache_duration = (int) $seconds;
204
- }
205
- function set_autodiscovery_cache_duration($seconds = 604800)
206
- {
207
- $this->autodiscovery_cache_duration = (int) $seconds;
208
- }
209
- function set_cache_location($location = './cache')
210
- {
211
- $this->cache_location = (string) $location;
212
- }
213
- function enable_order_by_date($enable = true)
214
- {
215
- $this->order_by_date = (bool) $enable;
216
- }
217
- function set_input_encoding($encoding = false)
218
- {
219
- if ($encoding)
220
- {
221
- $this->input_encoding = (string) $encoding;
222
- }
223
- else
224
- {
225
- $this->input_encoding = false;
226
- }
227
- }
228
- function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
229
- {
230
- $this->autodiscovery = (int) $level;
231
- }
232
- function set_cache_class($class = 'SimplePie_Cache')
233
- {
234
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
235
- {
236
- $this->cache_class = $class;
237
- return true;
238
- }
239
- return false;
240
- }
241
- function set_locator_class($class = 'SimplePie_Locator')
242
- {
243
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
244
- {
245
- $this->locator_class = $class;
246
- return true;
247
- }
248
- return false;
249
- }
250
- function set_parser_class($class = 'SimplePie_Parser')
251
- {
252
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
253
- {
254
- $this->parser_class = $class;
255
- return true;
256
- }
257
- return false;
258
- }
259
- function set_file_class($class = 'SimplePie_File')
260
- {
261
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
262
- {
263
- $this->file_class = $class;
264
- return true;
265
- }
266
- return false;
267
- }
268
- function set_sanitize_class($class = 'SimplePie_Sanitize')
269
- {
270
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
271
- {
272
- $this->sanitize =& new $class;
273
- return true;
274
- }
275
- return false;
276
- }
277
- function set_item_class($class = 'SimplePie_Item')
278
- {
279
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
280
- {
281
- $this->item_class = $class;
282
- return true;
283
- }
284
- return false;
285
- }
286
- function set_author_class($class = 'SimplePie_Author')
287
- {
288
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
289
- {
290
- $this->author_class = $class;
291
- return true;
292
- }
293
- return false;
294
- }
295
- function set_category_class($class = 'SimplePie_Category')
296
- {
297
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
298
- {
299
- $this->category_class = $class;
300
- return true;
301
- }
302
- return false;
303
- }
304
- function set_enclosure_class($class = 'SimplePie_Enclosure')
305
- {
306
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
307
- {
308
- $this->enclosure_class = $class;
309
- return true;
310
- }
311
- return false;
312
- }
313
- function set_caption_class($class = 'SimplePie_Caption')
314
- {
315
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
316
- {
317
- $this->caption_class = $class;
318
- return true;
319
- }
320
- return false;
321
- }
322
- function set_copyright_class($class = 'SimplePie_Copyright')
323
- {
324
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
325
- {
326
- $this->copyright_class = $class;
327
- return true;
328
- }
329
- return false;
330
- }
331
- function set_credit_class($class = 'SimplePie_Credit')
332
- {
333
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
334
- {
335
- $this->credit_class = $class;
336
- return true;
337
- }
338
- return false;
339
- }
340
- function set_rating_class($class = 'SimplePie_Rating')
341
- {
342
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
343
- {
344
- $this->rating_class = $class;
345
- return true;
346
- }
347
- return false;
348
- }
349
- function set_restriction_class($class = 'SimplePie_Restriction')
350
- {
351
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
352
- {
353
- $this->restriction_class = $class;
354
- return true;
355
- }
356
- return false;
357
- }
358
- function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
359
- {
360
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
361
- {
362
- $this->content_type_sniffer_class = $class;
363
- return true;
364
- }
365
- return false;
366
- }
367
- function set_source_class($class = 'SimplePie_Source')
368
- {
369
- if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
370
- {
371
- $this->source_class = $class;
372
- return true;
373
- }
374
- return false;
375
- }
376
- function set_useragent($ua = SIMPLEPIE_USERAGENT)
377
- {
378
- $this->useragent = (string) $ua;
379
- }
380
- function set_cache_name_function($function = 'md5')
381
- {
382
- if (is_callable($function))
383
- {
384
- $this->cache_name_function = $function;
385
- }
386
- }
387
- function set_javascript($get = 'js')
388
- {
389
- if ($get)
390
- {
391
- $this->javascript = (string) $get;
392
- }
393
- else
394
- {
395
- $this->javascript = false;
396
- }
397
- }
398
- function set_stupidly_fast($set = false)
399
- {
400
- if ($set)
401
- {
402
- $this->enable_order_by_date(false);
403
- $this->remove_div(false);
404
- $this->strip_comments(false);
405
- $this->strip_htmltags(false);
406
- $this->strip_attributes(false);
407
- $this->set_image_handler(false);
408
- }
409
- }
410
- function set_max_checked_feeds($max = 10)
411
- {
412
- $this->max_checked_feeds = (int) $max;
413
- }
414
- function remove_div($enable = true)
415
- {
416
- $this->sanitize->remove_div($enable);
417
- }
418
- function strip_htmltags($tags = '', $encode = null)
419
- {
420
- if ($tags === '')
421
- {
422
- $tags = $this->strip_htmltags;
423
- }
424
- $this->sanitize->strip_htmltags($tags);
425
- if ($encode !== null)
426
- {
427
- $this->sanitize->encode_instead_of_strip($tags);
428
- }
429
- }
430
- function encode_instead_of_strip($enable = true)
431
- {
432
- $this->sanitize->encode_instead_of_strip($enable);
433
- }
434
- function strip_attributes($attribs = '')
435
- {
436
- if ($attribs === '')
437
- {
438
- $attribs = $this->strip_attributes;
439
- }
440
- $this->sanitize->strip_attributes($attribs);
441
- }
442
- function set_output_encoding($encoding = 'UTF-8')
443
- {
444
- $this->sanitize->set_output_encoding($encoding);
445
- }
446
- function strip_comments($strip = false)
447
- {
448
- $this->sanitize->strip_comments($strip);
449
- }
450
- function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
451
- {
452
- $this->sanitize->set_url_replacements($element_attribute);
453
- }
454
- function set_favicon_handler($page = false, $qs = 'i')
455
- {
456
- if ($page != false)
457
- {
458
- $this->favicon_handler = $page . '?' . $qs . '=';
459
- }
460
- else
461
- {
462
- $this->favicon_handler = '';
463
- }
464
- }
465
- function set_image_handler($page = false, $qs = 'i')
466
- {
467
- if ($page != false)
468
- {
469
- $this->sanitize->set_image_handler($page . '?' . $qs . '=');
470
- }
471
- else
472
- {
473
- $this->image_handler = '';
474
- }
475
- }
476
- function set_item_limit($limit = 0)
477
- {
478
- $this->item_limit = (int) $limit;
479
- }
480
- function init()
481
- {
482
- if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
483
- {
484
- return false;
485
- }
486
- if (isset($_GET[$this->javascript]))
487
- {
488
- if (function_exists('ob_gzhandler'))
489
- {
490
- ob_start('ob_gzhandler');
491
- }
492
- header('Content-type: text/javascript; charset: UTF-8');
493
- header('Cache-Control: must-revalidate');
494
- header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
495
- ?>
496
- function embed_odeo(link) {
497
- document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
498
- }
499
- function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
500
- if (placeholder != '') {
501
- document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
502
- }
503
- else {
504
- document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
505
- }
506
- }
507
- function embed_flash(bgcolor, width, height, link, loop, type) {
508
- document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
509
- }
510
- function embed_flv(width, height, link, placeholder, loop, player) {
511
- document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
512
- }
513
- function embed_wmedia(width, height, link) {
514
- document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
515
- }
516
- <?php
517
- exit;
518
- }
519
- $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
520
- $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
521
-
522
- if ($this->feed_url !== null || $this->raw_data !== null)
523
- {
524
- $this->data = array();
525
- $this->multifeed_objects = array();
526
- $cache = false;
527
-
528
- if ($this->feed_url !== null)
529
- {
530
- $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
531
- if ($this->cache && $parsed_feed_url['scheme'] !== '')
532
- {
533
- $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
534
- }
535
- if ($cache && !$this->xml_dump)
536
- {
537
- $this->data = $cache->load();
538
- if (!empty($this->data))
539
- {
540
- if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
541
- {
542
- $cache->unlink();
543
- $this->data = array();
544
- }
545
- elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
546
- {
547
- $cache = false;
548
- $this->data = array();
549
- }
550
- elseif (isset($this->data['feed_url']))
551
- {
552
- if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
553
- {
554
- if ($this->data['feed_url'] == $this->data['url'])
555
- {
556
- $cache->unlink();
557
- $this->data = array();
558
- }
559
- else
560
- {
561
- $this->set_feed_url($this->data['feed_url']);
562
- return $this->init();
563
- }
564
- }
565
- }
566
- // Check if the cache has been updated
567
- elseif ($cache->mtime() + $this->cache_duration < time())
568
- {
569
- // If we have last-modified and/or etag set
570
- if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
571
- {
572
- $headers = array();
573
- if (isset($this->data['headers']['last-modified']))
574
- {
575
- $headers['if-modified-since'] = $this->data['headers']['last-modified'];
576
- }
577
- if (isset($this->data['headers']['etag']))
578
- {
579
- $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
580
- }
581
- $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
582
- if ($file->success)
583
- {
584
- if ($file->status_code == 304)
585
- {
586
- $cache->touch();
587
- return true;
588
- }
589
- else
590
- {
591
- $headers = $file->headers;
592
- }
593
- }
594
- else
595
- {
596
- unset($file);
597
- }
598
- }
599
- }
600
- // If the cache is still valid, just return true
601
- else
602
- {
603
- return true;
604
- }
605
- }
606
- // If the cache is empty, delete it
607
- else
608
- {
609
- $cache->unlink();
610
- $this->data = array();
611
- }
612
- }
613
- // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
614
- if (!isset($file))
615
- {
616
- if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
617
- {
618
- $file =& $this->file;
619
- }
620
- else
621
- {
622
- $file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
623
- }
624
- }
625
- // If the file connection has an error, set SimplePie::error to that and quit
626
- if (!$file->success)
627
- {
628
- $this->error = $file->error;
629
- if (!empty($this->data))
630
- {
631
- return true;
632
- }
633
- else
634
- {
635
- return false;
636
- }
637
- }
638
-
639
- if (!$this->force_feed)
640
- {
641
- // Check if the supplied URL is a feed, if it isn't, look for it.
642
- $locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
643
- if (!$locate->is_feed($file))
644
- {
645
- // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
646
- unset($file);
647
- if ($file = $locate->find($this->autodiscovery))
648
- {
649
- if ($cache)
650
- {
651
- $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
652
- if (!$cache->save($this))
653
- {
654
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
655
- }
656
- $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
657
- }
658
- $this->feed_url = $file->url;
659
- }
660
- else
661
- {
662
- $this->error = "A feed could not be found at $this->feed_url";
663
- SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
664
- return false;
665
- }
666
- }
667
- $locate = null;
668
- }
669
-
670
- $headers = $file->headers;
671
- $data = $file->body;
672
- $sniffer = new $this->content_type_sniffer_class($file);
673
- $sniffed = $sniffer->get_type();
674
- }
675
- else
676
- {
677
- $data = $this->raw_data;
678
- }
679
-
680
- // Set up array of possible encodings
681
- $encodings = array();
682
-
683
- // First check to see if input has been overridden.
684
- if ($this->input_encoding !== false)
685
- {
686
- $encodings[] = $this->input_encoding;
687
- }
688
-
689
- $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
690
- $text_types = array('text/xml', 'text/xml-external-parsed-entity');
691
-
692
- // RFC 3023 (only applies to sniffed content)
693
- if (isset($sniffed))
694
- {
695
- if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
696
- {
697
- if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
698
- {
699
- $encodings[] = strtoupper($charset[1]);
700
- }
701
- $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
702
- $encodings[] = 'UTF-8';
703
- }
704
- elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
705
- {
706
- if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
707
- {
708
- $encodings[] = $charset[1];
709
- }
710
- $encodings[] = 'US-ASCII';
711
- }
712
- // Text MIME-type default
713
- elseif (substr($sniffed, 0, 5) === 'text/')
714
- {
715
- $encodings[] = 'US-ASCII';
716
- }
717
- }
718
-
719
- // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
720
- $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
721
- $encodings[] = 'UTF-8';
722
- $encodings[] = 'ISO-8859-1';
723
-
724
- // There's no point in trying an encoding twice
725
- $encodings = array_unique($encodings);
726
-
727
- // If we want the XML, just output that with the most likely encoding and quit
728
- if ($this->xml_dump)
729
- {
730
- header('Content-type: text/xml; charset=' . $encodings[0]);
731
- echo $data;
732
- exit;
733
- }
734
-
735
- // Loop through each possible encoding, till we return something, or run out of possibilities
736
- foreach ($encodings as $encoding)
737
- {
738
- // Change the encoding to UTF-8 (as we always use UTF-8 internally)
739
- if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
740
- {
741
- // Create new parser
742
- $parser =& new $this->parser_class();
743
-
744
- // If it's parsed fine
745
- if ($parser->parse($utf8_data, 'UTF-8'))
746
- {
747
- $this->data = $parser->get_data();
748
- if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
749
- {
750
- if (isset($headers))
751
- {
752
- $this->data['headers'] = $headers;
753
- }
754
- $this->data['build'] = SIMPLEPIE_BUILD;
755
-
756
- // Cache the file if caching is enabled
757
- if ($cache && !$cache->save($this))
758
- {
759
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
760
- }
761
- return true;
762
- }
763
- else
764
- {
765
- $this->error = "A feed could not be found at $this->feed_url";
766
- SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
767
- return false;
768
- }
769
- }
770
- }
771
- }
772
- // We have an error, just set SimplePie::error to it and quit
773
- $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
774
- SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
775
- return false;
776
- }
777
- elseif (!empty($this->multifeed_url))
778
- {
779
- $i = 0;
780
- $success = 0;
781
- $this->multifeed_objects = array();
782
- foreach ($this->multifeed_url as $url)
783
- {
784
- if (SIMPLEPIE_PHP5)
785
- {
786
- // This keyword needs to defy coding standards for PHP4 compatibility
787
- $this->multifeed_objects[$i] = clone($this);
788
- }
789
- else
790
- {
791
- $this->multifeed_objects[$i] = $this;
792
- }
793
- $this->multifeed_objects[$i]->set_feed_url($url);
794
- $success |= $this->multifeed_objects[$i]->init();
795
- $i++;
796
- }
797
- return (bool) $success;
798
- }
799
- else
800
- {
801
- return false;
802
- }
803
- }
804
-
805
- /**
806
- * Return the error message for the occured error
807
- *
808
- * @access public
809
- * @return string Error message
810
- */
811
- function error()
812
- {
813
- return $this->error;
814
- }
815
-
816
- function get_encoding()
817
- {
818
- return $this->sanitize->output_encoding;
819
- }
820
-
821
- function handle_content_type($mime = 'text/html')
822
- {
823
- if (!headers_sent())
824
- {
825
- $header = "Content-type: $mime;";
826
- if ($this->get_encoding())
827
- {
828
- $header .= ' charset=' . $this->get_encoding();
829
- }
830
- else
831
- {
832
- $header .= ' charset=UTF-8';
833
- }
834
- header($header);
835
- }
836
- }
837
-
838
- function get_type()
839
- {
840
- if (!isset($this->data['type']))
841
- {
842
- $this->data['type'] = SIMPLEPIE_TYPE_ALL;
843
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
844
- {
845
- $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
846
- }
847
- elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
848
- {
849
- $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
850
- }
851
- elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
852
- {
853
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
854
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
855
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
856
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
857
- {
858
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
859
- }
860
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
861
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
862
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
863
- || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
864
- {
865
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
866
- }
867
- }
868
- elseif (isset($this->data['child']['']['rss']))
869
- {
870
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
871
- if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
872
- {
873
- switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
874
- {
875
- case '0.91':
876
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
877
- if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
878
- {
879
- switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
880
- {
881
- case '0':
882
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
883
- break;
884
-
885
- case '24':
886
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
887
- break;
888
- }
889
- }
890
- break;
891
-
892
- case '0.92':
893
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
894
- break;
895
-
896
- case '0.93':
897
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
898
- break;
899
-
900
- case '0.94':
901
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
902
- break;
903
-
904
- case '2.0':
905
- $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
906
- break;
907
- }
908
- }
909
- }
910
- else
911
- {
912
- $this->data['type'] = SIMPLEPIE_TYPE_NONE;
913
- }
914
- }
915
- return $this->data['type'];
916
- }
917
-
918
- /**
919
- * Returns the URL for the favicon of the feed's website.
920
- *
921
- * @todo Cache atom:icon
922
- * @access public
923
- * @since 1.0
924
- */
925
- function get_favicon()
926
- {
927
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
928
- {
929
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
930
- }
931
- elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
932
- {
933
- $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
934
-
935
- if ($this->cache && $this->favicon_handler)
936
- {
937
- $favicon_filename = call_user_func($this->cache_name_function, $favicon);
938
- $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
939
-
940
- if ($cache->load())
941
- {
942
- return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
943
- }
944
- else
945
- {
946
- $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
947
-
948
- if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
949
- {
950
- $sniffer = new $this->content_type_sniffer_class($file);
951
- if (substr($sniffer->get_type(), 0, 6) === 'image/')
952
- {
953
- if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
954
- {
955
- return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
956
- }
957
- else
958
- {
959
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
960
- return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
961
- }
962
- }
963
- }
964
- }
965
- }
966
- else
967
- {
968
- return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
969
- }
970
- }
971
- return false;
972
- }
973
-
974
- /**
975
- * @todo If we have a perm redirect we should return the new URL
976
- * @todo When we make the above change, let's support <itunes:new-feed-url> as well
977
- * @todo Also, |atom:link|@rel=self
978
- */
979
- function subscribe_url()
980
- {
981
- if ($this->feed_url !== null)
982
- {
983
- return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
984
- }
985
- else
986
- {
987
- return null;
988
- }
989
- }
990
-
991
- function subscribe_feed()
992
- {
993
- if ($this->feed_url !== null)
994
- {
995
- return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
996
- }
997
- else
998
- {
999
- return null;
1000
- }
1001
- }
1002
-
1003
- function subscribe_outlook()
1004
- {
1005
- if ($this->feed_url !== null)
1006
- {
1007
- return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
1008
- }
1009
- else
1010
- {
1011
- return null;
1012
- }
1013
- }
1014
-
1015
- function subscribe_podcast()
1016
- {
1017
- if ($this->feed_url !== null)
1018
- {
1019
- return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
1020
- }
1021
- else
1022
- {
1023
- return null;
1024
- }
1025
- }
1026
-
1027
- function subscribe_itunes()
1028
- {
1029
- if ($this->feed_url !== null)
1030
- {
1031
- return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
1032
- }
1033
- else
1034
- {
1035
- return null;
1036
- }
1037
- }
1038
-
1039
- /**
1040
- * Creates the subscribe_* methods' return data
1041
- *
1042
- * @access private
1043
- * @param string $feed_url String to prefix to the feed URL
1044
- * @param string $site_url String to prefix to the site URL (and
1045
- * suffix to the feed URL)
1046
- * @return mixed URL if feed exists, false otherwise
1047
- */
1048
- function subscribe_service($feed_url, $site_url = null)
1049
- {
1050
- if ($this->subscribe_url())
1051
- {
1052
- $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
1053
- if ($site_url !== null && $this->get_link() !== null)
1054
- {
1055
- $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
1056
- }
1057
- return $return;
1058
- }
1059
- else
1060
- {
1061
- return null;
1062
- }
1063
- }
1064
-
1065
- function subscribe_aol()
1066
- {
1067
- return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
1068
- }
1069
-
1070
- function subscribe_bloglines()
1071
- {
1072
- return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
1073
- }
1074
-
1075
- function subscribe_eskobo()
1076
- {
1077
- return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
1078
- }
1079
-
1080
- function subscribe_feedfeeds()
1081
- {
1082
- return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
1083
- }
1084
-
1085
- function subscribe_feedster()
1086
- {
1087
- return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
1088
- }
1089
-
1090
- function subscribe_google()
1091
- {
1092
- return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
1093
- }
1094
-
1095
- function subscribe_gritwire()
1096
- {
1097
- return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
1098
- }
1099
-
1100
- function subscribe_msn()
1101
- {
1102
- return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
1103
- }
1104
-
1105
- function subscribe_netvibes()
1106
- {
1107
- return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
1108
- }
1109
-
1110
- function subscribe_newsburst()
1111
- {
1112
- return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
1113
- }
1114
-
1115
- function subscribe_newsgator()
1116
- {
1117
- return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
1118
- }
1119
-
1120
- function subscribe_odeo()
1121
- {
1122
- return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
1123
- }
1124
-
1125
- function subscribe_podnova()
1126
- {
1127
- return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
1128
- }
1129
-
1130
- function subscribe_rojo()
1131
- {
1132
- return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
1133
- }
1134
-
1135
- function subscribe_yahoo()
1136
- {
1137
- return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
1138
- }
1139
-
1140
- function get_feed_tags($namespace, $tag)
1141
- {
1142
- $type = $this->get_type();
1143
- if ($type & SIMPLEPIE_TYPE_ATOM_10)
1144
- {
1145
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
1146
- {
1147
- return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
1148
- }
1149
- }
1150
- if ($type & SIMPLEPIE_TYPE_ATOM_03)
1151
- {
1152
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
1153
- {
1154
- return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
1155
- }
1156
- }
1157
- if ($type & SIMPLEPIE_TYPE_RSS_RDF)
1158
- {
1159
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
1160
- {
1161
- return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
1162
- }
1163
- }
1164
- if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
1165
- {
1166
- if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
1167
- {
1168
- return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
1169
- }
1170
- }
1171
- return null;
1172
- }
1173
-
1174
- function get_channel_tags($namespace, $tag)
1175
- {
1176
- $type = $this->get_type();
1177
- if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
1178
- {
1179
- if ($return = $this->get_feed_tags($namespace, $tag))
1180
- {
1181
- return $return;
1182
- }
1183
- }
1184
- if ($type & SIMPLEPIE_TYPE_RSS_10)
1185
- {
1186
- if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
1187
- {
1188
- if (isset($channel[0]['child'][$namespace][$tag]))
1189
- {
1190
- return $channel[0]['child'][$namespace][$tag];
1191
- }
1192
- }
1193
- }
1194
- if ($type & SIMPLEPIE_TYPE_RSS_090)
1195
- {
1196
- if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
1197
- {
1198
- if (isset($channel[0]['child'][$namespace][$tag]))
1199
- {
1200
- return $channel[0]['child'][$namespace][$tag];
1201
- }
1202
- }
1203
- }
1204
- if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
1205
- {
1206
- if ($channel = $this->get_feed_tags('', 'channel'))
1207
- {
1208
- if (isset($channel[0]['child'][$namespace][$tag]))
1209
- {
1210
- return $channel[0]['child'][$namespace][$tag];
1211
- }
1212
- }
1213
- }
1214
- return null;
1215
- }
1216
-
1217
- function get_image_tags($namespace, $tag)
1218
- {
1219
- $type = $this->get_type();
1220
- if ($type & SIMPLEPIE_TYPE_RSS_10)
1221
- {
1222
- if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
1223
- {
1224
- if (isset($image[0]['child'][$namespace][$tag]))
1225
- {
1226
- return $image[0]['child'][$namespace][$tag];
1227
- }
1228
- }
1229
- }
1230
- if ($type & SIMPLEPIE_TYPE_RSS_090)
1231
- {
1232
- if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
1233
- {
1234
- if (isset($image[0]['child'][$namespace][$tag]))
1235
- {
1236
- return $image[0]['child'][$namespace][$tag];
1237
- }
1238
- }
1239
- }
1240
- if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
1241
- {
1242
- if ($image = $this->get_channel_tags('', 'image'))
1243
- {
1244
- if (isset($image[0]['child'][$namespace][$tag]))
1245
- {
1246
- return $image[0]['child'][$namespace][$tag];
1247
- }
1248
- }
1249
- }
1250
- return null;
1251
- }
1252
-
1253
- function get_base($element = array())
1254
- {
1255
- if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
1256
- {
1257
- return $element['xml_base'];
1258
- }
1259
- elseif ($this->get_link() !== null)
1260
- {
1261
- return $this->get_link();
1262
- }
1263
- else
1264
- {
1265
- return $this->subscribe_url();
1266
- }
1267
- }
1268
-
1269
- function sanitize($data, $type, $base = '')
1270
- {
1271
- return $this->sanitize->sanitize($data, $type, $base);
1272
- }
1273
-
1274
- function get_title()
1275
- {
1276
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
1277
- {
1278
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1279
- }
1280
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
1281
- {
1282
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1283
- }
1284
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
1285
- {
1286
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1287
- }
1288
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
1289
- {
1290
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1291
- }
1292
- elseif ($return = $this->get_channel_tags('', 'title'))
1293
- {
1294
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1295
- }
1296
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
1297
- {
1298
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1299
- }
1300
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
1301
- {
1302
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1303
- }
1304
- else
1305
- {
1306
- return null;
1307
- }
1308
- }
1309
-
1310
- function get_category($key = 0)
1311
- {
1312
- $categories = $this->get_categories();
1313
- if (isset($categories[$key]))
1314
- {
1315
- return $categories[$key];
1316
- }
1317
- else
1318
- {
1319
- return null;
1320
- }
1321
- }
1322
-
1323
- function get_categories()
1324
- {
1325
- $categories = array();
1326
-
1327
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
1328
- {
1329
- $term = null;
1330
- $scheme = null;
1331
- $label = null;
1332
- if (isset($category['attribs']['']['term']))
1333
- {
1334
- $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
1335
- }
1336
- if (isset($category['attribs']['']['scheme']))
1337
- {
1338
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1339
- }
1340
- if (isset($category['attribs']['']['label']))
1341
- {
1342
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
1343
- }
1344
- $categories[] =& new $this->category_class($term, $scheme, $label);
1345
- }
1346
- foreach ((array) $this->get_channel_tags('', 'category') as $category)
1347
- {
1348
- $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1349
- }
1350
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
1351
- {
1352
- $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1353
- }
1354
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
1355
- {
1356
- $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1357
- }
1358
-
1359
- if (!empty($categories))
1360
- {
1361
- return SimplePie_Misc::array_unique($categories);
1362
- }
1363
- else
1364
- {
1365
- return null;
1366
- }
1367
- }
1368
-
1369
- function get_author($key = 0)
1370
- {
1371
- $authors = $this->get_authors();
1372
- if (isset($authors[$key]))
1373
- {
1374
- return $authors[$key];
1375
- }
1376
- else
1377
- {
1378
- return null;
1379
- }
1380
- }
1381
-
1382
- function get_authors()
1383
- {
1384
- $authors = array();
1385
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
1386
- {
1387
- $name = null;
1388
- $uri = null;
1389
- $email = null;
1390
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
1391
- {
1392
- $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1393
- }
1394
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
1395
- {
1396
- $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
1397
- }
1398
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
1399
- {
1400
- $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1401
- }
1402
- if ($name !== null || $email !== null || $uri !== null)
1403
- {
1404
- $authors[] =& new $this->author_class($name, $uri, $email);
1405
- }
1406
- }
1407
- if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
1408
- {
1409
- $name = null;
1410
- $url = null;
1411
- $email = null;
1412
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
1413
- {
1414
- $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1415
- }
1416
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
1417
- {
1418
- $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
1419
- }
1420
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
1421
- {
1422
- $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1423
- }
1424
- if ($name !== null || $email !== null || $url !== null)
1425
- {
1426
- $authors[] =& new $this->author_class($name, $url, $email);
1427
- }
1428
- }
1429
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
1430
- {
1431
- $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1432
- }
1433
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
1434
- {
1435
- $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1436
- }
1437
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
1438
- {
1439
- $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
1440
- }
1441
-
1442
- if (!empty($authors))
1443
- {
1444
- return SimplePie_Misc::array_unique($authors);
1445
- }
1446
- else
1447
- {
1448
- return null;
1449
- }
1450
- }
1451
-
1452
- function get_contributor($key = 0)
1453
- {
1454
- $contributors = $this->get_contributors();
1455
- if (isset($contributors[$key]))
1456
- {
1457
- return $contributors[$key];
1458
- }
1459
- else
1460
- {
1461
- return null;
1462
- }
1463
- }
1464
-
1465
- function get_contributors()
1466
- {
1467
- $contributors = array();
1468
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
1469
- {
1470
- $name = null;
1471
- $uri = null;
1472
- $email = null;
1473
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
1474
- {
1475
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1476
- }
1477
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
1478
- {
1479
- $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
1480
- }
1481
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
1482
- {
1483
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1484
- }
1485
- if ($name !== null || $email !== null || $uri !== null)
1486
- {
1487
- $contributors[] =& new $this->author_class($name, $uri, $email);
1488
- }
1489
- }
1490
- foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
1491
- {
1492
- $name = null;
1493
- $url = null;
1494
- $email = null;
1495
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
1496
- {
1497
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1498
- }
1499
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
1500
- {
1501
- $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
1502
- }
1503
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
1504
- {
1505
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1506
- }
1507
- if ($name !== null || $email !== null || $url !== null)
1508
- {
1509
- $contributors[] =& new $this->author_class($name, $url, $email);
1510
- }
1511
- }
1512
-
1513
- if (!empty($contributors))
1514
- {
1515
- return SimplePie_Misc::array_unique($contributors);
1516
- }
1517
- else
1518
- {
1519
- return null;
1520
- }
1521
- }
1522
-
1523
- function get_link($key = 0, $rel = 'alternate')
1524
- {
1525
- $links = $this->get_links($rel);
1526
- if (isset($links[$key]))
1527
- {
1528
- return $links[$key];
1529
- }
1530
- else
1531
- {
1532
- return null;
1533
- }
1534
- }
1535
-
1536
- /**
1537
- * Added for parity between the parent-level and the item/entry-level.
1538
- */
1539
- function get_permalink()
1540
- {
1541
- return $this->get_link(0);
1542
- }
1543
-
1544
- function get_links($rel = 'alternate')
1545
- {
1546
- if (!isset($this->data['links']))
1547
- {
1548
- $this->data['links'] = array();
1549
- if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
1550
- {
1551
- foreach ($links as $link)
1552
- {
1553
- if (isset($link['attribs']['']['href']))
1554
- {
1555
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
1556
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
1557
- }
1558
- }
1559
- }
1560
- if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
1561
- {
1562
- foreach ($links as $link)
1563
- {
1564
- if (isset($link['attribs']['']['href']))
1565
- {
1566
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
1567
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
1568
-
1569
- }
1570
- }
1571
- }
1572
- if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
1573
- {
1574
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1575
- }
1576
- if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
1577
- {
1578
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1579
- }
1580
- if ($links = $this->get_channel_tags('', 'link'))
1581
- {
1582
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1583
- }
1584
-
1585
- $keys = array_keys($this->data['links']);
1586
- foreach ($keys as $key)
1587
- {
1588
- if (SimplePie_Misc::is_isegment_nz_nc($key))
1589
- {
1590
- if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
1591
- {
1592
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
1593
- $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
1594
- }
1595
- else
1596
- {
1597
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
1598
- }
1599
- }
1600
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
1601
- {
1602
- $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
1603
- }
1604
- $this->data['links'][$key] = array_unique($this->data['links'][$key]);
1605
- }
1606
- }
1607
-
1608
- if (isset($this->data['links'][$rel]))
1609
- {
1610
- return $this->data['links'][$rel];
1611
- }
1612
- else
1613
- {
1614
- return null;
1615
- }
1616
- }
1617
-
1618
- function get_description()
1619
- {
1620
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
1621
- {
1622
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1623
- }
1624
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
1625
- {
1626
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1627
- }
1628
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
1629
- {
1630
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1631
- }
1632
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
1633
- {
1634
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1635
- }
1636
- elseif ($return = $this->get_channel_tags('', 'description'))
1637
- {
1638
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
1639
- }
1640
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
1641
- {
1642
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1643
- }
1644
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
1645
- {
1646
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1647
- }
1648
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
1649
- {
1650
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
1651
- }
1652
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
1653
- {
1654
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
1655
- }
1656
- else
1657
- {
1658
- return null;
1659
- }
1660
- }
1661
-
1662
- function get_copyright()
1663
- {
1664
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
1665
- {
1666
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1667
- }
1668
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
1669
- {
1670
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
1671
- }
1672
- elseif ($return = $this->get_channel_tags('', 'copyright'))
1673
- {
1674
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1675
- }
1676
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
1677
- {
1678
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1679
- }
1680
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
1681
- {
1682
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1683
- }
1684
- else
1685
- {
1686
- return null;
1687
- }
1688
- }
1689
-
1690
- function get_language()
1691
- {
1692
- if ($return = $this->get_channel_tags('', 'language'))
1693
- {
1694
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1695
- }
1696
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
1697
- {
1698
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1699
- }
1700
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
1701
- {
1702
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1703
- }
1704
- elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
1705
- {
1706
- return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1707
- }
1708
- elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
1709
- {
1710
- return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1711
- }
1712
- elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
1713
- {
1714
- return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1715
- }
1716
- elseif (isset($this->data['headers']['content-language']))
1717
- {
1718
- return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
1719
- }
1720
- else
1721
- {
1722
- return null;
1723
- }
1724
- }
1725
-
1726
- function get_latitude()
1727
- {
1728
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
1729
- {
1730
- return (float) $return[0]['data'];
1731
- }
1732
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
1733
- {
1734
- return (float) $match[1];
1735
- }
1736
- else
1737
- {
1738
- return null;
1739
- }
1740
- }
1741
-
1742
- function get_longitude()
1743
- {
1744
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
1745
- {
1746
- return (float) $return[0]['data'];
1747
- }
1748
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
1749
- {
1750
- return (float) $return[0]['data'];
1751
- }
1752
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
1753
- {
1754
- return (float) $match[2];
1755
- }
1756
- else
1757
- {
1758
- return null;
1759
- }
1760
- }
1761
-
1762
- function get_image_title()
1763
- {
1764
- if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
1765
- {
1766
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1767
- }
1768
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
1769
- {
1770
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1771
- }
1772
- elseif ($return = $this->get_image_tags('', 'title'))
1773
- {
1774
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1775
- }
1776
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
1777
- {
1778
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1779
- }
1780
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
1781
- {
1782
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1783
- }
1784
- else
1785
- {
1786
- return null;
1787
- }
1788
- }
1789
-
1790
- function get_image_url()
1791
- {
1792
- if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
1793
- {
1794
- return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
1795
- }
1796
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
1797
- {
1798
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1799
- }
1800
- elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
1801
- {
1802
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1803
- }
1804
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
1805
- {
1806
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1807
- }
1808
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
1809
- {
1810
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1811
- }
1812
- elseif ($return = $this->get_image_tags('', 'url'))
1813
- {
1814
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1815
- }
1816
- else
1817
- {
1818
- return null;
1819
- }
1820
- }
1821
-
1822
- function get_image_link()
1823
- {
1824
- if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
1825
- {
1826
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1827
- }
1828
- elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
1829
- {
1830
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1831
- }
1832
- elseif ($return = $this->get_image_tags('', 'link'))
1833
- {
1834
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1835
- }
1836
- else
1837
- {
1838
- return null;
1839
- }
1840
- }
1841
-
1842
- function get_image_width()
1843
- {
1844
- if ($return = $this->get_image_tags('', 'width'))
1845
- {
1846
- return round($return[0]['data']);
1847
- }
1848
- elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
1849
- {
1850
- return 88.0;
1851
- }
1852
- else
1853
- {
1854
- return null;
1855
- }
1856
- }
1857
-
1858
- function get_image_height()
1859
- {
1860
- if ($return = $this->get_image_tags('', 'height'))
1861
- {
1862
- return round($return[0]['data']);
1863
- }
1864
- elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
1865
- {
1866
- return 31.0;
1867
- }
1868
- else
1869
- {
1870
- return null;
1871
- }
1872
- }
1873
-
1874
- function get_item_quantity($max = 0)
1875
- {
1876
- $qty = count($this->get_items());
1877
- if ($max == 0)
1878
- {
1879
- return $qty;
1880
- }
1881
- else
1882
- {
1883
- return ($qty > $max) ? $max : $qty;
1884
- }
1885
- }
1886
-
1887
- function get_item($key = 0)
1888
- {
1889
- $items = $this->get_items();
1890
- if (isset($items[$key]))
1891
- {
1892
- return $items[$key];
1893
- }
1894
- else
1895
- {
1896
- return null;
1897
- }
1898
- }
1899
-
1900
- function get_items($start = 0, $end = 0)
1901
- {
1902
- if (!empty($this->multifeed_objects))
1903
- {
1904
- return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
1905
- }
1906
- elseif (!isset($this->data['items']))
1907
- {
1908
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
1909
- {
1910
- $keys = array_keys($items);
1911
- foreach ($keys as $key)
1912
- {
1913
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
1914
- }
1915
- }
1916
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
1917
- {
1918
- $keys = array_keys($items);
1919
- foreach ($keys as $key)
1920
- {
1921
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
1922
- }
1923
- }
1924
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
1925
- {
1926
- $keys = array_keys($items);
1927
- foreach ($keys as $key)
1928
- {
1929
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
1930
- }
1931
- }
1932
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
1933
- {
1934
- $keys = array_keys($items);
1935
- foreach ($keys as $key)
1936
- {
1937
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
1938
- }
1939
- }
1940
- if ($items = $this->get_channel_tags('', 'item'))
1941
- {
1942
- $keys = array_keys($items);
1943
- foreach ($keys as $key)
1944
- {
1945
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
1946
- }
1947
- }
1948
- }
1949
-
1950
- if (!empty($this->data['items']))
1951
- {
1952
- // If we want to order it by date, check if all items have a date, and then sort it
1953
- if ($this->order_by_date)
1954
- {
1955
- if (!isset($this->data['ordered_items']))
1956
- {
1957
- $do_sort = true;
1958
- foreach ($this->data['items'] as $item)
1959
- {
1960
- if (!$item->get_date('U'))
1961
- {
1962
- $do_sort = false;
1963
- break;
1964
- }
1965
- }
1966
- $item = null;
1967
- $this->data['ordered_items'] = $this->data['items'];
1968
- if ($do_sort)
1969
- {
1970
- usort($this->data['ordered_items'], array(&$this, 'sort_items'));
1971
- }
1972
- }
1973
- $items = $this->data['ordered_items'];
1974
- }
1975
- else
1976
- {
1977
- $items = $this->data['items'];
1978
- }
1979
-
1980
- // Slice the data as desired
1981
- if ($end == 0)
1982
- {
1983
- return array_slice($items, $start);
1984
- }
1985
- else
1986
- {
1987
- return array_slice($items, $start, $end);
1988
- }
1989
- }
1990
- else
1991
- {
1992
- return array();
1993
- }
1994
- }
1995
-
1996
- function sort_items($a, $b)
1997
- {
1998
- return $a->get_date('U') <= $b->get_date('U');
1999
- }
2000
-
2001
- function merge_items($urls, $start = 0, $end = 0, $limit = 0)
2002
- {
2003
- if (is_array($urls) && sizeof($urls) > 0)
2004
- {
2005
- $items = array();
2006
- foreach ($urls as $arg)
2007
- {
2008
- if (is_a($arg, 'SimplePie'))
2009
- {
2010
- $items = array_merge($items, $arg->get_items(0, $limit));
2011
- }
2012
- else
2013
- {
2014
- trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
2015
- }
2016
- }
2017
-
2018
- $do_sort = true;
2019
- foreach ($items as $item)
2020
- {
2021
- if (!$item->get_date('U'))
2022
- {
2023
- $do_sort = false;
2024
- break;
2025
- }
2026
- }
2027
- $item = null;
2028
- if ($do_sort)
2029
- {
2030
- usort($items, array('SimplePie', 'sort_items'));
2031
- }
2032
-
2033
- if ($end == 0)
2034
- {
2035
- return array_slice($items, $start);
2036
- }
2037
- else
2038
- {
2039
- return array_slice($items, $start, $end);
2040
- }
2041
- }
2042
- else
2043
- {
2044
- trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
2045
- return array();
2046
- }
2047
- }
2048
- }
2049
-
2050
- class SimplePie_Item
2051
- {
2052
- var $feed;
2053
- var $data = array();
2054
-
2055
- function SimplePie_Item($feed, $data)
2056
- {
2057
- $this->feed = $feed;
2058
- $this->data = $data;
2059
- }
2060
-
2061
- function __toString()
2062
- {
2063
- return md5(serialize($this->data));
2064
- }
2065
-
2066
- /**
2067
- * Remove items that link back to this before destroying this object
2068
- */
2069
- function __destruct()
2070
- {
2071
- unset($this->feed);
2072
- }
2073
-
2074
- function get_item_tags($namespace, $tag)
2075
- {
2076
- if (isset($this->data['child'][$namespace][$tag]))
2077
- {
2078
- return $this->data['child'][$namespace][$tag];
2079
- }
2080
- else
2081
- {
2082
- return null;
2083
- }
2084
- }
2085
-
2086
- function get_base($element = array())
2087
- {
2088
- return $this->feed->get_base($element);
2089
- }
2090
-
2091
- function sanitize($data, $type, $base = '')
2092
- {
2093
- return $this->feed->sanitize($data, $type, $base);
2094
- }
2095
-
2096
- function get_feed()
2097
- {
2098
- return $this->feed;
2099
- }
2100
-
2101
- function get_id($hash = false)
2102
- {
2103
- if (!$hash)
2104
- {
2105
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
2106
- {
2107
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2108
- }
2109
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
2110
- {
2111
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2112
- }
2113
- elseif ($return = $this->get_item_tags('', 'guid'))
2114
- {
2115
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2116
- }
2117
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
2118
- {
2119
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2120
- }
2121
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
2122
- {
2123
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2124
- }
2125
- elseif (($return = $this->get_permalink()) !== null)
2126
- {
2127
- return $return;
2128
- }
2129
- elseif (($return = $this->get_title()) !== null)
2130
- {
2131
- return $return;
2132
- }
2133
- }
2134
- if ($this->get_permalink() !== null || $this->get_title() !== null)
2135
- {
2136
- return md5($this->get_permalink() . $this->get_title());
2137
- }
2138
- else
2139
- {
2140
- return md5(serialize($this->data));
2141
- }
2142
- }
2143
-
2144
- function get_title()
2145
- {
2146
- if (!isset($this->data['title']))
2147
- {
2148
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2149
- {
2150
- $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2151
- }
2152
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2153
- {
2154
- $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2155
- }
2156
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2157
- {
2158
- $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2159
- }
2160
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2161
- {
2162
- $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2163
- }
2164
- elseif ($return = $this->get_item_tags('', 'title'))
2165
- {
2166
- $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2167
- }
2168
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2169
- {
2170
- $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2171
- }
2172
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2173
- {
2174
- $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2175
- }
2176
- else
2177
- {
2178
- $this->data['title'] = null;
2179
- }
2180
- }
2181
- return $this->data['title'];
2182
- }
2183
-
2184
- function get_description($description_only = false)
2185
- {
2186
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
2187
- {
2188
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2189
- }
2190
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
2191
- {
2192
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2193
- }
2194
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
2195
- {
2196
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2197
- }
2198
- elseif ($return = $this->get_item_tags('', 'description'))
2199
- {
2200
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2201
- }
2202
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2203
- {
2204
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2205
- }
2206
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
2207
- {
2208
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2209
- }
2210
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
2211
- {
2212
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2213
- }
2214
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
2215
- {
2216
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2217
- }
2218
- elseif (!$description_only)
2219
- {
2220
- return $this->get_content(true);
2221
- }
2222
- else
2223
- {
2224
- return null;
2225
- }
2226
- }
2227
-
2228
- function get_content($content_only = false)
2229
- {
2230
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
2231
- {
2232
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2233
- }
2234
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
2235
- {
2236
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2237
- }
2238
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
2239
- {
2240
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2241
- }
2242
- elseif (!$content_only)
2243
- {
2244
- return $this->get_description(true);
2245
- }
2246
- else
2247
- {
2248
- return null;
2249
- }
2250
- }
2251
-
2252
- function get_category($key = 0)
2253
- {
2254
- $categories = $this->get_categories();
2255
- if (isset($categories[$key]))
2256
- {
2257
- return $categories[$key];
2258
- }
2259
- else
2260
- {
2261
- return null;
2262
- }
2263
- }
2264
-
2265
- function get_categories()
2266
- {
2267
- $categories = array();
2268
-
2269
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2270
- {
2271
- $term = null;
2272
- $scheme = null;
2273
- $label = null;
2274
- if (isset($category['attribs']['']['term']))
2275
- {
2276
- $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2277
- }
2278
- if (isset($category['attribs']['']['scheme']))
2279
- {
2280
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2281
- }
2282
- if (isset($category['attribs']['']['label']))
2283
- {
2284
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2285
- }
2286
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
2287
- }
2288
- foreach ((array) $this->get_item_tags('', 'category') as $category)
2289
- {
2290
- $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2291
- }
2292
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2293
- {
2294
- $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2295
- }
2296
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2297
- {
2298
- $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2299
- }
2300
-
2301
- if (!empty($categories))
2302
- {
2303
- return SimplePie_Misc::array_unique($categories);
2304
- }
2305
- else
2306
- {
2307
- return null;
2308
- }
2309
- }
2310
-
2311
- function get_author($key = 0)
2312
- {
2313
- $authors = $this->get_authors();
2314
- if (isset($authors[$key]))
2315
- {
2316
- return $authors[$key];
2317
- }
2318
- else
2319
- {
2320
- return null;
2321
- }
2322
- }
2323
-
2324
- function get_contributor($key = 0)
2325
- {
2326
- $contributors = $this->get_contributors();
2327
- if (isset($contributors[$key]))
2328
- {
2329
- return $contributors[$key];
2330
- }
2331
- else
2332
- {
2333
- return null;
2334
- }
2335
- }
2336
-
2337
- function get_contributors()
2338
- {
2339
- $contributors = array();
2340
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2341
- {
2342
- $name = null;
2343
- $uri = null;
2344
- $email = null;
2345
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2346
- {
2347
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2348
- }
2349
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2350
- {
2351
- $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2352
- }
2353
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2354
- {
2355
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2356
- }
2357
- if ($name !== null || $email !== null || $uri !== null)
2358
- {
2359
- $contributors[] =& new $this->feed->author_class($name, $uri, $email);
2360
- }
2361
- }
2362
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2363
- {
2364
- $name = null;
2365
- $url = null;
2366
- $email = null;
2367
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2368
- {
2369
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2370
- }
2371
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2372
- {
2373
- $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2374
- }
2375
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2376
- {
2377
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2378
- }
2379
- if ($name !== null || $email !== null || $url !== null)
2380
- {
2381
- $contributors[] =& new $this->feed->author_class($name, $url, $email);
2382
- }
2383
- }
2384
-
2385
- if (!empty($contributors))
2386
- {
2387
- return SimplePie_Misc::array_unique($contributors);
2388
- }
2389
- else
2390
- {
2391
- return null;
2392
- }
2393
- }
2394
-
2395
- /**
2396
- * @todo Atom inheritance (item author, source author, feed author)
2397
- */
2398
- function get_authors()
2399
- {
2400
- $authors = array();
2401
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2402
- {
2403
- $name = null;
2404
- $uri = null;
2405
- $email = null;
2406
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2407
- {
2408
- $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2409
- }
2410
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2411
- {
2412
- $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2413
- }
2414
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2415
- {
2416
- $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2417
- }
2418
- if ($name !== null || $email !== null || $uri !== null)
2419
- {
2420
- $authors[] =& new $this->feed->author_class($name, $uri, $email);
2421
- }
2422
- }
2423
- if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2424
- {
2425
- $name = null;
2426
- $url = null;
2427
- $email = null;
2428
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2429
- {
2430
- $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2431
- }
2432
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2433
- {
2434
- $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2435
- }
2436
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2437
- {
2438
- $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2439
- }
2440
- if ($name !== null || $email !== null || $url !== null)
2441
- {
2442
- $authors[] =& new $this->feed->author_class($name, $url, $email);
2443
- }
2444
- }
2445
- if ($author = $this->get_item_tags('', 'author'))
2446
- {
2447
- $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
2448
- }
2449
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2450
- {
2451
- $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2452
- }
2453
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2454
- {
2455
- $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2456
- }
2457
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2458
- {
2459
- $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2460
- }
2461
-
2462
- if (!empty($authors))
2463
- {
2464
- return SimplePie_Misc::array_unique($authors);
2465
- }
2466
- elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
2467
- {
2468
- return $authors;
2469
- }
2470
- elseif ($authors = $this->feed->get_authors())
2471
- {
2472
- return $authors;
2473
- }
2474
- else
2475
- {
2476
- return null;
2477
- }
2478
- }
2479
-
2480
- function get_copyright()
2481
- {
2482
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
2483
- {
2484
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2485
- }
2486
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
2487
- {
2488
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2489
- }
2490
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
2491
- {
2492
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2493
- }
2494
- else
2495
- {
2496
- return null;
2497
- }
2498
- }
2499
-
2500
- function get_date($date_format = 'j F Y, g:i a')
2501
- {
2502
- if (!isset($this->data['date']))
2503
- {
2504
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
2505
- {
2506
- $this->data['date']['raw'] = $return[0]['data'];
2507
- }
2508
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
2509
- {
2510
- $this->data['date']['raw'] = $return[0]['data'];
2511
- }
2512
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
2513
- {
2514
- $this->data['date']['raw'] = $return[0]['data'];
2515
- }
2516
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
2517
- {
2518
- $this->data['date']['raw'] = $return[0]['data'];
2519
- }
2520
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
2521
- {
2522
- $this->data['date']['raw'] = $return[0]['data'];
2523
- }
2524
- elseif ($return = $this->get_item_tags('', 'pubDate'))
2525
- {
2526
- $this->data['date']['raw'] = $return[0]['data'];
2527
- }
2528
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
2529
- {
2530
- $this->data['date']['raw'] = $return[0]['data'];
2531
- }
2532
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
2533
- {
2534
- $this->data['date']['raw'] = $return[0]['data'];
2535
- }
2536
-
2537
- if (!empty($this->data['date']['raw']))
2538
- {
2539
- $parser = SimplePie_Parse_Date::get();
2540
- $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
2541
- }
2542
- else
2543
- {
2544
- $this->data['date'] = null;
2545
- }
2546
- }
2547
- if ($this->data['date'])
2548
- {
2549
- $date_format = (string) $date_format;
2550
- switch ($date_format)
2551
- {
2552
- case '':
2553
- return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
2554
-
2555
- case 'U':
2556
- return $this->data['date']['parsed'];
2557
-
2558
- default:
2559
- return date($date_format, $this->data['date']['parsed']);
2560
- }
2561
- }
2562
- else
2563
- {
2564
- return null;
2565
- }
2566
- }
2567
-
2568
- function get_local_date($date_format = '%c')
2569
- {
2570
- if (!$date_format)
2571
- {
2572
- return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
2573
- }
2574
- elseif (($date = $this->get_date('U')) !== null)
2575
- {
2576
- return strftime($date_format, $date);
2577
- }
2578
- else
2579
- {
2580
- return null;
2581
- }
2582
- }
2583
-
2584
- function get_permalink()
2585
- {
2586
- $link = $this->get_link();
2587
- $enclosure = $this->get_enclosure(0);
2588
- if ($link !== null)
2589
- {
2590
- return $link;
2591
- }
2592
- elseif ($enclosure !== null)
2593
- {
2594
- return $enclosure->get_link();
2595
- }
2596
- else
2597
- {
2598
- return null;
2599
- }
2600
- }
2601
-
2602
- function get_link($key = 0, $rel = 'alternate')
2603
- {
2604
- $links = $this->get_links($rel);
2605
- if ($links[$key] !== null)
2606
- {
2607
- return $links[$key];
2608
- }
2609
- else
2610
- {
2611
- return null;
2612
- }
2613
- }
2614
-
2615
- function get_links($rel = 'alternate')
2616
- {
2617
- if (!isset($this->data['links']))
2618
- {
2619
- $this->data['links'] = array();
2620
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
2621
- {
2622
- if (isset($link['attribs']['']['href']))
2623
- {
2624
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2625
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2626
-
2627
- }
2628
- }
2629
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
2630
- {
2631
- if (isset($link['attribs']['']['href']))
2632
- {
2633
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2634
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2635
- }
2636
- }
2637
- if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2638
- {
2639
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2640
- }
2641
- if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2642
- {
2643
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2644
- }
2645
- if ($links = $this->get_item_tags('', 'link'))
2646
- {
2647
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2648
- }
2649
- if ($links = $this->get_item_tags('', 'guid'))
2650
- {
2651
- if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
2652
- {
2653
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2654
- }
2655
- }
2656
-
2657
- $keys = array_keys($this->data['links']);
2658
- foreach ($keys as $key)
2659
- {
2660
- if (SimplePie_Misc::is_isegment_nz_nc($key))
2661
- {
2662
- if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2663
- {
2664
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2665
- $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2666
- }
2667
- else
2668
- {
2669
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2670
- }
2671
- }
2672
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2673
- {
2674
- $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2675
- }
2676
- $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2677
- }
2678
- }
2679
- if (isset($this->data['links'][$rel]))
2680
- {
2681
- return $this->data['links'][$rel];
2682
- }
2683
- else
2684
- {
2685
- return null;
2686
- }
2687
- }
2688
-
2689
- /**
2690
- * @todo Add ability to prefer one type of content over another (in a media group).
2691
- */
2692
- function get_enclosure($key = 0, $prefer = null)
2693
- {
2694
- $enclosures = $this->get_enclosures();
2695
- if (isset($enclosures[$key]))
2696
- {
2697
- return $enclosures[$key];
2698
- }
2699
- else
2700
- {
2701
- return null;
2702
- }
2703
- }
2704
-
2705
- /**
2706
- * Grabs all available enclosures (podcasts, etc.)
2707
- *
2708
- * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
2709
- *
2710
- * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support.
2711
- *
2712
- * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
2713
- * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
2714
- */
2715
- function get_enclosures()
2716
- {
2717
- if (!isset($this->data['enclosures']))
2718
- {
2719
- $this->data['enclosures'] = array();
2720
-
2721
- // Elements
2722
- $captions_parent = null;
2723
- $categories_parent = null;
2724
- $copyrights_parent = null;
2725
- $credits_parent = null;
2726
- $description_parent = null;
2727
- $duration_parent = null;
2728
- $hashes_parent = null;
2729
- $keywords_parent = null;
2730
- $player_parent = null;
2731
- $ratings_parent = null;
2732
- $restrictions_parent = null;
2733
- $thumbnails_parent = null;
2734
- $title_parent = null;
2735
-
2736
- // Let's do the channel and item-level ones first, and just re-use them if we need to.
2737
- $parent = $this->get_feed();
2738
-
2739
- // CAPTIONS
2740
- if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
2741
- {
2742
- foreach ($captions as $caption)
2743
- {
2744
- $caption_type = null;
2745
- $caption_lang = null;
2746
- $caption_startTime = null;
2747
- $caption_endTime = null;
2748
- $caption_text = null;
2749
- if (isset($caption['attribs']['']['type']))
2750
- {
2751
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2752
- }
2753
- if (isset($caption['attribs']['']['lang']))
2754
- {
2755
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2756
- }
2757
- if (isset($caption['attribs']['']['start']))
2758
- {
2759
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
2760
- }
2761
- if (isset($caption['attribs']['']['end']))
2762
- {
2763
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
2764
- }
2765
- if (isset($caption['data']))
2766
- {
2767
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2768
- }
2769
- $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
2770
- }
2771
- }
2772
- elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
2773
- {
2774
- foreach ($captions as $caption)
2775
- {
2776
- $caption_type = null;
2777
- $caption_lang = null;
2778
- $caption_startTime = null;
2779
- $caption_endTime = null;
2780
- $caption_text = null;
2781
- if (isset($caption['attribs']['']['type']))
2782
- {
2783
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2784
- }
2785
- if (isset($caption['attribs']['']['lang']))
2786
- {
2787
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2788
- }
2789
- if (isset($caption['attribs']['']['start']))
2790
- {
2791
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
2792
- }
2793
- if (isset($caption['attribs']['']['end']))
2794
- {
2795
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
2796
- }
2797
- if (isset($caption['data']))
2798
- {
2799
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2800
- }
2801
- $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
2802
- }
2803
- }
2804
- if (is_array($captions_parent))
2805
- {
2806
- $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent));
2807
- }
2808
-
2809
- // CATEGORIES
2810
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
2811
- {
2812
- $term = null;
2813
- $scheme = null;
2814
- $label = null;
2815
- if (isset($category['data']))
2816
- {
2817
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2818
- }
2819
- if (isset($category['attribs']['']['scheme']))
2820
- {
2821
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2822
- }
2823
- else
2824
- {
2825
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
2826
- }
2827
- if (isset($category['attribs']['']['label']))
2828
- {
2829
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2830
- }
2831
- $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
2832
- }
2833
- foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
2834
- {
2835
- $term = null;
2836
- $scheme = null;
2837
- $label = null;
2838
- if (isset($category['data']))
2839
- {
2840
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2841
- }
2842
- if (isset($category['attribs']['']['scheme']))
2843
- {
2844
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2845
- }
2846
- else
2847
- {
2848
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
2849
- }
2850
- if (isset($category['attribs']['']['label']))
2851
- {
2852
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2853
- }
2854
- $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
2855
- }
2856
- foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
2857
- {
2858
- $term = null;
2859
- $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
2860
- $label = null;
2861
- if (isset($category['attribs']['']['text']))
2862
- {
2863
- $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
2864
- }
2865
- $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
2866
-
2867
- if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
2868
- {
2869
- foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
2870
- {
2871
- if (isset($subcategory['attribs']['']['text']))
2872
- {
2873
- $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
2874
- }
2875
- $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
2876
- }
2877
- }
2878
- }
2879
- if (is_array($categories_parent))
2880
- {
2881
- $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent));
2882
- }
2883
-
2884
- // COPYRIGHT
2885
- if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
2886
- {
2887
- $copyright_url = null;
2888
- $copyright_label = null;
2889
- if (isset($copyright[0]['attribs']['']['url']))
2890
- {
2891
- $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
2892
- }
2893
- if (isset($copyright[0]['data']))
2894
- {
2895
- $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2896
- }
2897
- $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label);
2898
- }
2899
- elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
2900
- {
2901
- $copyright_url = null;
2902
- $copyright_label = null;
2903
- if (isset($copyright[0]['attribs']['']['url']))
2904
- {
2905
- $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
2906
- }
2907
- if (isset($copyright[0]['data']))
2908
- {
2909
- $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2910
- }
2911
- $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label);
2912
- }
2913
-
2914
- // CREDITS
2915
- if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
2916
- {
2917
- foreach ($credits as $credit)
2918
- {
2919
- $credit_role = null;
2920
- $credit_scheme = null;
2921
- $credit_name = null;
2922
- if (isset($credit['attribs']['']['role']))
2923
- {
2924
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
2925
- }
2926
- if (isset($credit['attribs']['']['scheme']))
2927
- {
2928
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2929
- }
2930
- else
2931
- {
2932
- $credit_scheme = 'urn:ebu';
2933
- }
2934
- if (isset($credit['data']))
2935
- {
2936
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2937
- }
2938
- $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
2939
- }
2940
- }
2941
- elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
2942
- {
2943
- foreach ($credits as $credit)
2944
- {
2945
- $credit_role = null;
2946
- $credit_scheme = null;
2947
- $credit_name = null;
2948
- if (isset($credit['attribs']['']['role']))
2949
- {
2950
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
2951
- }
2952
- if (isset($credit['attribs']['']['scheme']))
2953
- {
2954
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2955
- }
2956
- else
2957
- {
2958
- $credit_scheme = 'urn:ebu';
2959
- }
2960
- if (isset($credit['data']))
2961
- {
2962
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2963
- }
2964
- $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
2965
- }
2966
- }
2967
- if (is_array($credits_parent))
2968
- {
2969
- $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent));
2970
- }
2971
-
2972
- // DESCRIPTION
2973
- if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
2974
- {
2975
- if (isset($description_parent[0]['data']))
2976
- {
2977
- $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2978
- }
2979
- }
2980
- elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
2981
- {
2982
- if (isset($description_parent[0]['data']))
2983
- {
2984
- $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2985
- }
2986
- }
2987
-
2988
- // DURATION
2989
- if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
2990
- {
2991
- $seconds = null;
2992
- $minutes = null;
2993
- $hours = null;
2994
- if (isset($duration_parent[0]['data']))
2995
- {
2996
- $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
2997
- if (sizeof($temp) > 0)
2998
- {
2999
- (int) $seconds = array_pop($temp);
3000
- }
3001
- if (sizeof($temp) > 0)
3002
- {
3003
- (int) $minutes = array_pop($temp);
3004
- $seconds += $minutes * 60;
3005
- }
3006
- if (sizeof($temp) > 0)
3007
- {
3008
- (int) $hours = array_pop($temp);
3009
- $seconds += $hours * 3600;
3010
- }
3011
- unset($temp);
3012
- $duration_parent = $seconds;
3013
- }
3014
- }
3015
-
3016
- // HASHES
3017
- if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
3018
- {
3019
- foreach ($hashes_iterator as $hash)
3020
- {
3021
- $value = null;
3022
- $algo = null;
3023
- if (isset($hash['data']))
3024
- {
3025
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3026
- }
3027
- if (isset($hash['attribs']['']['algo']))
3028
- {
3029
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
3030
- }
3031
- else
3032
- {
3033
- $algo = 'md5';
3034
- }
3035
- $hashes_parent[] = $algo.':'.$value;
3036
- }
3037
- }
3038
- elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
3039
- {
3040
- foreach ($hashes_iterator as $hash)
3041
- {
3042
- $value = null;
3043
- $algo = null;
3044
- if (isset($hash['data']))
3045
- {
3046
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3047
- }
3048
- if (isset($hash['attribs']['']['algo']))
3049
- {
3050
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
3051
- }
3052
- else
3053
- {
3054
- $algo = 'md5';
3055
- }
3056
- $hashes_parent[] = $algo.':'.$value;
3057
- }
3058
- }
3059
- if (is_array($hashes_parent))
3060
- {
3061
- $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent));
3062
- }
3063
-
3064
- // KEYWORDS
3065
- if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
3066
- {
3067
- if (isset($keywords[0]['data']))
3068
- {
3069
- $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3070
- foreach ($temp as $word)
3071
- {
3072
- $keywords_parent[] = trim($word);
3073
- }
3074
- }
3075
- unset($temp);
3076
- }
3077
- elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
3078
- {
3079
- if (isset($keywords[0]['data']))
3080
- {
3081
- $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3082
- foreach ($temp as $word)
3083
- {
3084
- $keywords_parent[] = trim($word);
3085
- }
3086
- }
3087
- unset($temp);
3088
- }
3089
- elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
3090
- {
3091
- if (isset($keywords[0]['data']))
3092
- {
3093
- $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3094
- foreach ($temp as $word)
3095
- {
3096
- $keywords_parent[] = trim($word);
3097
- }
3098
- }
3099
- unset($temp);
3100
- }
3101
- elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
3102
- {
3103
- if (isset($keywords[0]['data']))
3104
- {
3105
- $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3106
- foreach ($temp as $word)
3107
- {
3108
- $keywords_parent[] = trim($word);
3109
- }
3110
- }
3111
- unset($temp);
3112
- }
3113
- if (is_array($keywords_parent))
3114
- {
3115
- $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent));
3116
- }
3117
-
3118
- // PLAYER
3119
- if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
3120
- {
3121
- if (isset($player_parent[0]['attribs']['']['url']))
3122
- {
3123
- $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3124
- }
3125
- }
3126
- elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
3127
- {
3128
- if (isset($player_parent[0]['attribs']['']['url']))
3129
- {
3130
- $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3131
- }
3132
- }
3133
-
3134
- // RATINGS
3135
- if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
3136
- {
3137
- foreach ($ratings as $rating)
3138
- {
3139
- $rating_scheme = null;
3140
- $rating_value = null;
3141
- if (isset($rating['attribs']['']['scheme']))
3142
- {
3143
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3144
- }
3145
- else
3146
- {
3147
- $rating_scheme = 'urn:simple';
3148
- }
3149
- if (isset($rating['data']))
3150
- {
3151
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3152
- }
3153
- $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3154
- }
3155
- }
3156
- elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
3157
- {
3158
- foreach ($ratings as $rating)
3159
- {
3160
- $rating_scheme = 'urn:itunes';
3161
- $rating_value = null;
3162
- if (isset($rating['data']))
3163
- {
3164
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3165
- }
3166
- $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3167
- }
3168
- }
3169
- elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
3170
- {
3171
- foreach ($ratings as $rating)
3172
- {
3173
- $rating_scheme = null;
3174
- $rating_value = null;
3175
- if (isset($rating['attribs']['']['scheme']))
3176
- {
3177
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3178
- }
3179
- else
3180
- {
3181
- $rating_scheme = 'urn:simple';
3182
- }
3183
- if (isset($rating['data']))
3184
- {
3185
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3186
- }
3187
- $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3188
- }
3189
- }
3190
- elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
3191
- {
3192
- foreach ($ratings as $rating)
3193
- {
3194
- $rating_scheme = 'urn:itunes';
3195
- $rating_value = null;
3196
- if (isset($rating['data']))
3197
- {
3198
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3199
- }
3200
- $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3201
- }
3202
- }
3203
- if (is_array($ratings_parent))
3204
- {
3205
- $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent));
3206
- }
3207
-
3208
- // RESTRICTIONS
3209
- if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
3210
- {
3211
- foreach ($restrictions as $restriction)
3212
- {
3213
- $restriction_relationship = null;
3214
- $restriction_type = null;
3215
- $restriction_value = null;
3216
- if (isset($restriction['attribs']['']['relationship']))
3217
- {
3218
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
3219
- }
3220
- if (isset($restriction['attribs']['']['type']))
3221
- {
3222
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3223
- }
3224
- if (isset($restriction['data']))
3225
- {
3226
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3227
- }
3228
- $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3229
- }
3230
- }
3231
- elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
3232
- {
3233
- foreach ($restrictions as $restriction)
3234
- {
3235
- $restriction_relationship = 'allow';
3236
- $restriction_type = null;
3237
- $restriction_value = 'itunes';
3238
- if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
3239
- {
3240
- $restriction_relationship = 'deny';
3241
- }
3242
- $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3243
- }
3244
- }
3245
- elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
3246
- {
3247
- foreach ($restrictions as $restriction)
3248
- {
3249
- $restriction_relationship = null;
3250
- $restriction_type = null;
3251
- $restriction_value = null;
3252
- if (isset($restriction['attribs']['']['relationship']))
3253
- {
3254
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
3255
- }
3256
- if (isset($restriction['attribs']['']['type']))
3257
- {
3258
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3259
- }
3260
- if (isset($restriction['data']))
3261
- {
3262
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3263
- }
3264
- $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3265
- }
3266
- }
3267
- elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
3268
- {
3269
- foreach ($restrictions as $restriction)
3270
- {
3271
- $restriction_relationship = 'allow';
3272
- $restriction_type = null;
3273
- $restriction_value = 'itunes';
3274
- if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
3275
- {
3276
- $restriction_relationship = 'deny';
3277
- }
3278
- $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3279
- }
3280
- }
3281
- if (is_array($restrictions_parent))
3282
- {
3283
- $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent));
3284
- }
3285
-
3286
- // THUMBNAILS
3287
- if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
3288
- {
3289
- foreach ($thumbnails as $thumbnail)
3290
- {
3291
- if (isset($thumbnail['attribs']['']['url']))
3292
- {
3293
- $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3294
- }
3295
- }
3296
- }
3297
- elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
3298
- {
3299
- foreach ($thumbnails as $thumbnail)
3300
- {
3301
- if (isset($thumbnail['attribs']['']['url']))
3302
- {
3303
- $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3304
- }
3305
- }
3306
- }
3307
-
3308
- // TITLES
3309
- if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
3310
- {
3311
- if (isset($title_parent[0]['data']))
3312
- {
3313
- $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3314
- }
3315
- }
3316
- elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
3317
- {
3318
- if (isset($title_parent[0]['data']))
3319
- {
3320
- $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3321
- }
3322
- }
3323
-
3324
- // Clear the memory
3325
- unset($parent);
3326
-
3327
- // Attributes
3328
- $bitrate = null;
3329
- $channels = null;
3330
- $duration = null;
3331
- $expression = null;
3332
- $framerate = null;
3333
- $height = null;
3334
- $javascript = null;
3335
- $lang = null;
3336
- $length = null;
3337
- $medium = null;
3338
- $samplingrate = null;
3339
- $type = null;
3340
- $url = null;
3341
- $width = null;
3342
-
3343
- // Elements
3344
- $captions = null;
3345
- $categories = null;
3346
- $copyrights = null;
3347
- $credits = null;
3348
- $description = null;
3349
- $hashes = null;
3350
- $keywords = null;
3351
- $player = null;
3352
- $ratings = null;
3353
- $restrictions = null;
3354
- $thumbnails = null;
3355
- $title = null;
3356
-
3357
- // If we have media:group tags, loop through them.
3358
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
3359
- {
3360
- // If we have media:content tags, loop through them.
3361
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
3362
- {
3363
- if (isset($content['attribs']['']['url']))
3364
- {
3365
- // Attributes
3366
- $bitrate = null;
3367
- $channels = null;
3368
- $duration = null;
3369
- $expression = null;
3370
- $framerate = null;
3371
- $height = null;
3372
- $javascript = null;
3373
- $lang = null;
3374
- $length = null;
3375
- $medium = null;
3376
- $samplingrate = null;
3377
- $type = null;
3378
- $url = null;
3379
- $width = null;
3380
-
3381
- // Elements
3382
- $captions = null;
3383
- $categories = null;
3384
- $copyrights = null;
3385
- $credits = null;
3386
- $description = null;
3387
- $hashes = null;
3388
- $keywords = null;
3389
- $player = null;
3390
- $ratings = null;
3391
- $restrictions = null;
3392
- $thumbnails = null;
3393
- $title = null;
3394
-
3395
- // Start checking the attributes of media:content
3396
- if (isset($content['attribs']['']['bitrate']))
3397
- {
3398
- $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
3399
- }
3400
- if (isset($content['attribs']['']['channels']))
3401
- {
3402
- $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
3403
- }
3404
- if (isset($content['attribs']['']['duration']))
3405
- {
3406
- $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
3407
- }
3408
- else
3409
- {
3410
- $duration = $duration_parent;
3411
- }
3412
- if (isset($content['attribs']['']['expression']))
3413
- {
3414
- $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
3415
- }
3416
- if (isset($content['attribs']['']['framerate']))
3417
- {
3418
- $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
3419
- }
3420
- if (isset($content['attribs']['']['height']))
3421
- {
3422
- $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
3423
- }
3424
- if (isset($content['attribs']['']['lang']))
3425
- {
3426
- $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3427
- }
3428
- if (isset($content['attribs']['']['fileSize']))
3429
- {
3430
- $length = ceil($content['attribs']['']['fileSize']);
3431
- }
3432
- if (isset($content['attribs']['']['medium']))
3433
- {
3434
- $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
3435
- }
3436
- if (isset($content['attribs']['']['samplingrate']))
3437
- {
3438
- $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
3439
- }
3440
- if (isset($content['attribs']['']['type']))
3441
- {
3442
- $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3443
- }
3444
- if (isset($content['attribs']['']['width']))
3445
- {
3446
- $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
3447
- }
3448
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3449
-
3450
- // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
3451
-
3452
- // CAPTIONS
3453
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
3454
- {
3455
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
3456
- {
3457
- $caption_type = null;
3458
- $caption_lang = null;
3459
- $caption_startTime = null;
3460
- $caption_endTime = null;
3461
- $caption_text = null;
3462
- if (isset($caption['attribs']['']['type']))
3463
- {
3464
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3465
- }
3466
- if (isset($caption['attribs']['']['lang']))
3467
- {
3468
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3469
- }
3470
- if (isset($caption['attribs']['']['start']))
3471
- {
3472
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3473
- }
3474
- if (isset($caption['attribs']['']['end']))
3475
- {
3476
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3477
- }
3478
- if (isset($caption['data']))
3479
- {
3480
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3481
- }
3482
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3483
- }
3484
- if (is_array($captions))
3485
- {
3486
- $captions = array_values(SimplePie_Misc::array_unique($captions));
3487
- }
3488
- }
3489
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
3490
- {
3491
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
3492
- {
3493
- $caption_type = null;
3494
- $caption_lang = null;
3495
- $caption_startTime = null;
3496
- $caption_endTime = null;
3497
- $caption_text = null;
3498
- if (isset($caption['attribs']['']['type']))
3499
- {
3500
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3501
- }
3502
- if (isset($caption['attribs']['']['lang']))
3503
- {
3504
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3505
- }
3506
- if (isset($caption['attribs']['']['start']))
3507
- {
3508
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3509
- }
3510
- if (isset($caption['attribs']['']['end']))
3511
- {
3512
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3513
- }
3514
- if (isset($caption['data']))
3515
- {
3516
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3517
- }
3518
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3519
- }
3520
- if (is_array($captions))
3521
- {
3522
- $captions = array_values(SimplePie_Misc::array_unique($captions));
3523
- }
3524
- }
3525
- else
3526
- {
3527
- $captions = $captions_parent;
3528
- }
3529
-
3530
- // CATEGORIES
3531
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
3532
- {
3533
- foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
3534
- {
3535
- $term = null;
3536
- $scheme = null;
3537
- $label = null;
3538
- if (isset($category['data']))
3539
- {
3540
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3541
- }
3542
- if (isset($category['attribs']['']['scheme']))
3543
- {
3544
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3545
- }
3546
- else
3547
- {
3548
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
3549
- }
3550
- if (isset($category['attribs']['']['label']))
3551
- {
3552
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3553
- }
3554
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
3555
- }
3556
- }
3557
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
3558
- {
3559
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
3560
- {
3561
- $term = null;
3562
- $scheme = null;
3563
- $label = null;
3564
- if (isset($category['data']))
3565
- {
3566
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3567
- }
3568
- if (isset($category['attribs']['']['scheme']))
3569
- {
3570
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3571
- }
3572
- else
3573
- {
3574
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
3575
- }
3576
- if (isset($category['attribs']['']['label']))
3577
- {
3578
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3579
- }
3580
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
3581
- }
3582
- }
3583
- if (is_array($categories) && is_array($categories_parent))
3584
- {
3585
- $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
3586
- }
3587
- elseif (is_array($categories))
3588
- {
3589
- $categories = array_values(SimplePie_Misc::array_unique($categories));
3590
- }
3591
- elseif (is_array($categories_parent))
3592
- {
3593
- $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
3594
- }
3595
-
3596
- // COPYRIGHTS
3597
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
3598
- {
3599
- $copyright_url = null;
3600
- $copyright_label = null;
3601
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
3602
- {
3603
- $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3604
- }
3605
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
3606
- {
3607
- $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3608
- }
3609
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
3610
- }
3611
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
3612
- {
3613
- $copyright_url = null;
3614
- $copyright_label = null;
3615
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
3616
- {
3617
- $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3618
- }
3619
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
3620
- {
3621
- $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3622
- }
3623
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
3624
- }
3625
- else
3626
- {
3627
- $copyrights = $copyrights_parent;
3628
- }
3629
-
3630
- // CREDITS
3631
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
3632
- {
3633
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
3634
- {
3635
- $credit_role = null;
3636
- $credit_scheme = null;
3637
- $credit_name = null;
3638
- if (isset($credit['attribs']['']['role']))
3639
- {
3640
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
3641
- }
3642
- if (isset($credit['attribs']['']['scheme']))
3643
- {
3644
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3645
- }
3646
- else
3647
- {
3648
- $credit_scheme = 'urn:ebu';
3649
- }
3650
- if (isset($credit['data']))
3651
- {
3652
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3653
- }
3654
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
3655
- }
3656
- if (is_array($credits))
3657
- {
3658
- $credits = array_values(SimplePie_Misc::array_unique($credits));
3659
- }
3660
- }
3661
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
3662
- {
3663
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
3664
- {
3665
- $credit_role = null;
3666
- $credit_scheme = null;
3667
- $credit_name = null;
3668
- if (isset($credit['attribs']['']['role']))
3669
- {
3670
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
3671
- }
3672
- if (isset($credit['attribs']['']['scheme']))
3673
- {
3674
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3675
- }
3676
- else
3677
- {
3678
- $credit_scheme = 'urn:ebu';
3679
- }
3680
- if (isset($credit['data']))
3681
- {
3682
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3683
- }
3684
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
3685
- }
3686
- if (is_array($credits))
3687
- {
3688
- $credits = array_values(SimplePie_Misc::array_unique($credits));
3689
- }
3690
- }
3691
- else
3692
- {
3693
- $credits = $credits_parent;
3694
- }
3695
-
3696
- // DESCRIPTION
3697
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
3698
- {
3699
- $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3700
- }
3701
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
3702
- {
3703
- $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3704
- }
3705
- else
3706
- {
3707
- $description = $description_parent;
3708
- }
3709
-
3710
- // HASHES
3711
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
3712
- {
3713
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
3714
- {
3715
- $value = null;
3716
- $algo = null;
3717
- if (isset($hash['data']))
3718
- {
3719
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3720
- }
3721
- if (isset($hash['attribs']['']['algo']))
3722
- {
3723
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
3724
- }
3725
- else
3726
- {
3727
- $algo = 'md5';
3728
- }
3729
- $hashes[] = $algo.':'.$value;
3730
- }
3731
- if (is_array($hashes))
3732
- {
3733
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
3734
- }
3735
- }
3736
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
3737
- {
3738
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
3739
- {
3740
- $value = null;
3741
- $algo = null;
3742
- if (isset($hash['data']))
3743
- {
3744
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3745
- }
3746
- if (isset($hash['attribs']['']['algo']))
3747
- {
3748
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
3749
- }
3750
- else
3751
- {
3752
- $algo = 'md5';
3753
- }
3754
- $hashes[] = $algo.':'.$value;
3755
- }
3756
- if (is_array($hashes))
3757
- {
3758
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
3759
- }
3760
- }
3761
- else
3762
- {
3763
- $hashes = $hashes_parent;
3764
- }
3765
-
3766
- // KEYWORDS
3767
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
3768
- {
3769
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
3770
- {
3771
- $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3772
- foreach ($temp as $word)
3773
- {
3774
- $keywords[] = trim($word);
3775
- }
3776
- unset($temp);
3777
- }
3778
- if (is_array($keywords))
3779
- {
3780
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
3781
- }
3782
- }
3783
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
3784
- {
3785
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
3786
- {
3787
- $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3788
- foreach ($temp as $word)
3789
- {
3790
- $keywords[] = trim($word);
3791
- }
3792
- unset($temp);
3793
- }
3794
- if (is_array($keywords))
3795
- {
3796
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
3797
- }
3798
- }
3799
- else
3800
- {
3801
- $keywords = $keywords_parent;
3802
- }
3803
-
3804
- // PLAYER
3805
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
3806
- {
3807
- $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3808
- }
3809
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
3810
- {
3811
- $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3812
- }
3813
- else
3814
- {
3815
- $player = $player_parent;
3816
- }
3817
-
3818
- // RATINGS
3819
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
3820
- {
3821
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
3822
- {
3823
- $rating_scheme = null;
3824
- $rating_value = null;
3825
- if (isset($rating['attribs']['']['scheme']))
3826
- {
3827
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3828
- }
3829
- else
3830
- {
3831
- $rating_scheme = 'urn:simple';
3832
- }
3833
- if (isset($rating['data']))
3834
- {
3835
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3836
- }
3837
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3838
- }
3839
- if (is_array($ratings))
3840
- {
3841
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
3842
- }
3843
- }
3844
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
3845
- {
3846
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
3847
- {
3848
- $rating_scheme = null;
3849
- $rating_value = null;
3850
- if (isset($rating['attribs']['']['scheme']))
3851
- {
3852
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3853
- }
3854
- else
3855
- {
3856
- $rating_scheme = 'urn:simple';
3857
- }
3858
- if (isset($rating['data']))
3859
- {
3860
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3861
- }
3862
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
3863
- }
3864
- if (is_array($ratings))
3865
- {
3866
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
3867
- }
3868
- }
3869
- else
3870
- {
3871
- $ratings = $ratings_parent;
3872
- }
3873
-
3874
- // RESTRICTIONS
3875
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
3876
- {
3877
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
3878
- {
3879
- $restriction_relationship = null;
3880
- $restriction_type = null;
3881
- $restriction_value = null;
3882
- if (isset($restriction['attribs']['']['relationship']))
3883
- {
3884
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
3885
- }
3886
- if (isset($restriction['attribs']['']['type']))
3887
- {
3888
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3889
- }
3890
- if (isset($restriction['data']))
3891
- {
3892
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3893
- }
3894
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3895
- }
3896
- if (is_array($restrictions))
3897
- {
3898
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
3899
- }
3900
- }
3901
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
3902
- {
3903
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
3904
- {
3905
- $restriction_relationship = null;
3906
- $restriction_type = null;
3907
- $restriction_value = null;
3908
- if (isset($restriction['attribs']['']['relationship']))
3909
- {
3910
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
3911
- }
3912
- if (isset($restriction['attribs']['']['type']))
3913
- {
3914
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3915
- }
3916
- if (isset($restriction['data']))
3917
- {
3918
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3919
- }
3920
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
3921
- }
3922
- if (is_array($restrictions))
3923
- {
3924
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
3925
- }
3926
- }
3927
- else
3928
- {
3929
- $restrictions = $restrictions_parent;
3930
- }
3931
-
3932
- // THUMBNAILS
3933
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
3934
- {
3935
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
3936
- {
3937
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3938
- }
3939
- if (is_array($thumbnails))
3940
- {
3941
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
3942
- }
3943
- }
3944
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
3945
- {
3946
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
3947
- {
3948
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
3949
- }
3950
- if (is_array($thumbnails))
3951
- {
3952
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
3953
- }
3954
- }
3955
- else
3956
- {
3957
- $thumbnails = $thumbnails_parent;
3958
- }
3959
-
3960
- // TITLES
3961
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
3962
- {
3963
- $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3964
- }
3965
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
3966
- {
3967
- $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3968
- }
3969
- else
3970
- {
3971
- $title = $title_parent;
3972
- }
3973
-
3974
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
3975
- }
3976
- }
3977
- }
3978
-
3979
- // If we have standalone media:content tags, loop through them.
3980
- if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
3981
- {
3982
- foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
3983
- {
3984
- if (isset($content['attribs']['']['url']))
3985
- {
3986
- // Attributes
3987
- $bitrate = null;
3988
- $channels = null;
3989
- $duration = null;
3990
- $expression = null;
3991
- $framerate = null;
3992
- $height = null;
3993
- $javascript = null;
3994
- $lang = null;
3995
- $length = null;
3996
- $medium = null;
3997
- $samplingrate = null;
3998
- $type = null;
3999
- $url = null;
4000
- $width = null;
4001
-
4002
- // Elements
4003
- $captions = null;
4004
- $categories = null;
4005
- $copyrights = null;
4006
- $credits = null;
4007
- $description = null;
4008
- $hashes = null;
4009
- $keywords = null;
4010
- $player = null;
4011
- $ratings = null;
4012
- $restrictions = null;
4013
- $thumbnails = null;
4014
- $title = null;
4015
-
4016
- // Start checking the attributes of media:content
4017
- if (isset($content['attribs']['']['bitrate']))
4018
- {
4019
- $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4020
- }
4021
- if (isset($content['attribs']['']['channels']))
4022
- {
4023
- $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
4024
- }
4025
- if (isset($content['attribs']['']['duration']))
4026
- {
4027
- $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
4028
- }
4029
- else
4030
- {
4031
- $duration = $duration_parent;
4032
- }
4033
- if (isset($content['attribs']['']['expression']))
4034
- {
4035
- $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
4036
- }
4037
- if (isset($content['attribs']['']['framerate']))
4038
- {
4039
- $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
4040
- }
4041
- if (isset($content['attribs']['']['height']))
4042
- {
4043
- $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
4044
- }
4045
- if (isset($content['attribs']['']['lang']))
4046
- {
4047
- $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4048
- }
4049
- if (isset($content['attribs']['']['fileSize']))
4050
- {
4051
- $length = ceil($content['attribs']['']['fileSize']);
4052
- }
4053
- if (isset($content['attribs']['']['medium']))
4054
- {
4055
- $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
4056
- }
4057
- if (isset($content['attribs']['']['samplingrate']))
4058
- {
4059
- $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4060
- }
4061
- if (isset($content['attribs']['']['type']))
4062
- {
4063
- $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4064
- }
4065
- if (isset($content['attribs']['']['width']))
4066
- {
4067
- $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
4068
- }
4069
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4070
-
4071
- // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
4072
-
4073
- // CAPTIONS
4074
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
4075
- {
4076
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
4077
- {
4078
- $caption_type = null;
4079
- $caption_lang = null;
4080
- $caption_startTime = null;
4081
- $caption_endTime = null;
4082
- $caption_text = null;
4083
- if (isset($caption['attribs']['']['type']))
4084
- {
4085
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4086
- }
4087
- if (isset($caption['attribs']['']['lang']))
4088
- {
4089
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4090
- }
4091
- if (isset($caption['attribs']['']['start']))
4092
- {
4093
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
4094
- }
4095
- if (isset($caption['attribs']['']['end']))
4096
- {
4097
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
4098
- }
4099
- if (isset($caption['data']))
4100
- {
4101
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4102
- }
4103
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
4104
- }
4105
- if (is_array($captions))
4106
- {
4107
- $captions = array_values(SimplePie_Misc::array_unique($captions));
4108
- }
4109
- }
4110
- else
4111
- {
4112
- $captions = $captions_parent;
4113
- }
4114
-
4115
- // CATEGORIES
4116
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
4117
- {
4118
- foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
4119
- {
4120
- $term = null;
4121
- $scheme = null;
4122
- $label = null;
4123
- if (isset($category['data']))
4124
- {
4125
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4126
- }
4127
- if (isset($category['attribs']['']['scheme']))
4128
- {
4129
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4130
- }
4131
- else
4132
- {
4133
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
4134
- }
4135
- if (isset($category['attribs']['']['label']))
4136
- {
4137
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4138
- }
4139
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
4140
- }
4141
- }
4142
- if (is_array($categories) && is_array($categories_parent))
4143
- {
4144
- $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
4145
- }
4146
- elseif (is_array($categories))
4147
- {
4148
- $categories = array_values(SimplePie_Misc::array_unique($categories));
4149
- }
4150
- elseif (is_array($categories_parent))
4151
- {
4152
- $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
4153
- }
4154
- else
4155
- {
4156
- $categories = null;
4157
- }
4158
-
4159
- // COPYRIGHTS
4160
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
4161
- {
4162
- $copyright_url = null;
4163
- $copyright_label = null;
4164
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
4165
- {
4166
- $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
4167
- }
4168
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
4169
- {
4170
- $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4171
- }
4172
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
4173
- }
4174
- else
4175
- {
4176
- $copyrights = $copyrights_parent;
4177
- }
4178
-
4179
- // CREDITS
4180
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
4181
- {
4182
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
4183
- {
4184
- $credit_role = null;
4185
- $credit_scheme = null;
4186
- $credit_name = null;
4187
- if (isset($credit['attribs']['']['role']))
4188
- {
4189
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4190
- }
4191
- if (isset($credit['attribs']['']['scheme']))
4192
- {
4193
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4194
- }
4195
- else
4196
- {
4197
- $credit_scheme = 'urn:ebu';
4198
- }
4199
- if (isset($credit['data']))
4200
- {
4201
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4202
- }
4203
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4204
- }
4205
- if (is_array($credits))
4206
- {
4207
- $credits = array_values(SimplePie_Misc::array_unique($credits));
4208
- }
4209
- }
4210
- else
4211
- {
4212
- $credits = $credits_parent;
4213
- }
4214
-
4215
- // DESCRIPTION
4216
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
4217
- {
4218
- $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4219
- }
4220
- else
4221
- {
4222
- $description = $description_parent;
4223
- }
4224
-
4225
- // HASHES
4226
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
4227
- {
4228
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
4229
- {
4230
- $value = null;
4231
- $algo = null;
4232
- if (isset($hash['data']))
4233
- {
4234
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4235
- }
4236
- if (isset($hash['attribs']['']['algo']))
4237
- {
4238
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4239
- }
4240
- else
4241
- {
4242
- $algo = 'md5';
4243
- }
4244
- $hashes[] = $algo.':'.$value;
4245
- }
4246
- if (is_array($hashes))
4247
- {
4248
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
4249
- }
4250
- }
4251
- else
4252
- {
4253
- $hashes = $hashes_parent;
4254
- }
4255
-
4256
- // KEYWORDS
4257
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
4258
- {
4259
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
4260
- {
4261
- $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4262
- foreach ($temp as $word)
4263
- {
4264
- $keywords[] = trim($word);
4265
- }
4266
- unset($temp);
4267
- }
4268
- if (is_array($keywords))
4269
- {
4270
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
4271
- }
4272
- }
4273
- else
4274
- {
4275
- $keywords = $keywords_parent;
4276
- }
4277
-
4278
- // PLAYER
4279
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
4280
- {
4281
- $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4282
- }
4283
- else
4284
- {
4285
- $player = $player_parent;
4286
- }
4287
-
4288
- // RATINGS
4289
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
4290
- {
4291
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
4292
- {
4293
- $rating_scheme = null;
4294
- $rating_value = null;
4295
- if (isset($rating['attribs']['']['scheme']))
4296
- {
4297
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4298
- }
4299
- else
4300
- {
4301
- $rating_scheme = 'urn:simple';
4302
- }
4303
- if (isset($rating['data']))
4304
- {
4305
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4306
- }
4307
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
4308
- }
4309
- if (is_array($ratings))
4310
- {
4311
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
4312
- }
4313
- }
4314
- else
4315
- {
4316
- $ratings = $ratings_parent;
4317
- }
4318
-
4319
- // RESTRICTIONS
4320
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
4321
- {
4322
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
4323
- {
4324
- $restriction_relationship = null;
4325
- $restriction_type = null;
4326
- $restriction_value = null;
4327
- if (isset($restriction['attribs']['']['relationship']))
4328
- {
4329
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4330
- }
4331
- if (isset($restriction['attribs']['']['type']))
4332
- {
4333
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4334
- }
4335
- if (isset($restriction['data']))
4336
- {
4337
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4338
- }
4339
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4340
- }
4341
- if (is_array($restrictions))
4342
- {
4343
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
4344
- }
4345
- }
4346
- else
4347
- {
4348
- $restrictions = $restrictions_parent;
4349
- }
4350
-
4351
- // THUMBNAILS
4352
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
4353
- {
4354
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
4355
- {
4356
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4357
- }
4358
- if (is_array($thumbnails))
4359
- {
4360
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
4361
- }
4362
- }
4363
- else
4364
- {
4365
- $thumbnails = $thumbnails_parent;
4366
- }
4367
-
4368
- // TITLES
4369
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
4370
- {
4371
- $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4372
- }
4373
- else
4374
- {
4375
- $title = $title_parent;
4376
- }
4377
-
4378
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
4379
- }
4380
- }
4381
- }
4382
-
4383
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
4384
- {
4385
- if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
4386
- {
4387
- // Attributes
4388
- $bitrate = null;
4389
- $channels = null;
4390
- $duration = null;
4391
- $expression = null;
4392
- $framerate = null;
4393
- $height = null;
4394
- $javascript = null;
4395
- $lang = null;
4396
- $length = null;
4397
- $medium = null;
4398
- $samplingrate = null;
4399
- $type = null;
4400
- $url = null;
4401
- $width = null;
4402
-
4403
- $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
4404
- if (isset($link['attribs']['']['type']))
4405
- {
4406
- $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4407
- }
4408
- if (isset($link['attribs']['']['length']))
4409
- {
4410
- $length = ceil($link['attribs']['']['length']);
4411
- }
4412
-
4413
- // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
4414
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
4415
- }
4416
- }
4417
-
4418
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
4419
- {
4420
- if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
4421
- {
4422
- // Attributes
4423
- $bitrate = null;
4424
- $channels = null;
4425
- $duration = null;
4426
- $expression = null;
4427
- $framerate = null;
4428
- $height = null;
4429
- $javascript = null;
4430
- $lang = null;
4431
- $length = null;
4432
- $medium = null;
4433
- $samplingrate = null;
4434
- $type = null;
4435
- $url = null;
4436
- $width = null;
4437
-
4438
- $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
4439
- if (isset($link['attribs']['']['type']))
4440
- {
4441
- $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4442
- }
4443
- if (isset($link['attribs']['']['length']))
4444
- {
4445
- $length = ceil($link['attribs']['']['length']);
4446
- }
4447
-
4448
- // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
4449
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
4450
- }
4451
- }
4452
-
4453
- if ($enclosure = $this->get_item_tags('', 'enclosure'))
4454
- {
4455
- if (isset($enclosure[0]['attribs']['']['url']))
4456
- {
4457
- // Attributes
4458
- $bitrate = null;
4459
- $channels = null;
4460
- $duration = null;
4461
- $expression = null;
4462
- $framerate = null;
4463
- $height = null;
4464
- $javascript = null;
4465
- $lang = null;
4466
- $length = null;
4467
- $medium = null;
4468
- $samplingrate = null;
4469
- $type = null;
4470
- $url = null;
4471
- $width = null;
4472
-
4473
- $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
4474
- if (isset($enclosure[0]['attribs']['']['type']))
4475
- {
4476
- $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4477
- }
4478
- if (isset($enclosure[0]['attribs']['']['length']))
4479
- {
4480
- $length = ceil($enclosure[0]['attribs']['']['length']);
4481
- }
4482
-
4483
- // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
4484
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
4485
- }
4486
- }
4487
-
4488
- if (sizeof($this->data['enclosures']) == 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
4489
- {
4490
- // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
4491
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
4492
- }
4493
-
4494
- $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
4495
- }
4496
- if (!empty($this->data['enclosures']))
4497
- {
4498
- return $this->data['enclosures'];
4499
- }
4500
- else
4501
- {
4502
- return null;
4503
- }
4504
- }
4505
-
4506
- function get_latitude()
4507
- {
4508
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
4509
- {
4510
- return (float) $return[0]['data'];
4511
- }
4512
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
4513
- {
4514
- return (float) $match[1];
4515
- }
4516
- else
4517
- {
4518
- return null;
4519
- }
4520
- }
4521
-
4522
- function get_longitude()
4523
- {
4524
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
4525
- {
4526
- return (float) $return[0]['data'];
4527
- }
4528
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
4529
- {
4530
- return (float) $return[0]['data'];
4531
- }
4532
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
4533
- {
4534
- return (float) $match[2];
4535
- }
4536
- else
4537
- {
4538
- return null;
4539
- }
4540
- }
4541
-
4542
- function get_source()
4543
- {
4544
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
4545
- {
4546
- return new $this->feed->source_class($this, $return[0]);
4547
- }
4548
- else
4549
- {
4550
- return null;
4551
- }
4552
- }
4553
-
4554
- /**
4555
- * Creates the add_to_* methods' return data
4556
- *
4557
- * @access private
4558
- * @param string $item_url String to prefix to the item permalink
4559
- * @param string $title_url String to prefix to the item title
4560
- * (and suffix to the item permalink)
4561
- * @return mixed URL if feed exists, false otherwise
4562
- */
4563
- function add_to_service($item_url, $title_url = null, $summary_url = null)
4564
- {
4565
- if ($this->get_permalink() !== null)
4566
- {
4567
- $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink());
4568
- if ($title_url !== null && $this->get_title() !== null)
4569
- {
4570
- $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title());
4571
- }
4572
- if ($summary_url !== null && $this->get_description() !== null)
4573
- {
4574
- $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description());
4575
- }
4576
- return $return;
4577
- }
4578
- else
4579
- {
4580
- return null;
4581
- }
4582
- }
4583
-
4584
- function add_to_blinklist()
4585
- {
4586
- return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title=');
4587
- }
4588
-
4589
- function add_to_blogmarks()
4590
- {
4591
- return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title=');
4592
- }
4593
-
4594
- function add_to_delicious()
4595
- {
4596
- return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title=');
4597
- }
4598
-
4599
- function add_to_digg()
4600
- {
4601
- return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext=');
4602
- }
4603
-
4604
- function add_to_furl()
4605
- {
4606
- return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t=');
4607
- }
4608
-
4609
- function add_to_magnolia()
4610
- {
4611
- return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title=');
4612
- }
4613
-
4614
- function add_to_myweb20()
4615
- {
4616
- return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t=');
4617
- }
4618
-
4619
- function add_to_newsvine()
4620
- {
4621
- return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h=');
4622
- }
4623
-
4624
- function add_to_reddit()
4625
- {
4626
- return $this->add_to_service('http://reddit.com/submit?url=', '&title=');
4627
- }
4628
-
4629
- function add_to_segnalo()
4630
- {
4631
- return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title=');
4632
- }
4633
-
4634
- function add_to_simpy()
4635
- {
4636
- return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title=');
4637
- }
4638
-
4639
- function add_to_spurl()
4640
- {
4641
- return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title=');
4642
- }
4643
-
4644
- function add_to_wists()
4645
- {
4646
- return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title=');
4647
- }
4648
-
4649
- function search_technorati()
4650
- {
4651
- return $this->add_to_service('http://www.technorati.com/search/');
4652
- }
4653
- }
4654
-
4655
- class SimplePie_Source
4656
- {
4657
- var $item;
4658
- var $data = array();
4659
-
4660
- function SimplePie_Source($item, $data)
4661
- {
4662
- $this->item = $item;
4663
- $this->data = $data;
4664
- }
4665
-
4666
- function __toString()
4667
- {
4668
- return md5(serialize($this->data));
4669
- }
4670
-
4671
- /**
4672
- * Remove items that link back to this before destroying this object
4673
- */
4674
- function __destruct()
4675
- {
4676
- unset($this->item);
4677
- }
4678
-
4679
- function get_source_tags($namespace, $tag)
4680
- {
4681
- if (isset($this->data['child'][$namespace][$tag]))
4682
- {
4683
- return $this->data['child'][$namespace][$tag];
4684
- }
4685
- else
4686
- {
4687
- return null;
4688
- }
4689
- }
4690
-
4691
- function get_base($element = array())
4692
- {
4693
- return $this->item->get_base($element);
4694
- }
4695
-
4696
- function sanitize($data, $type, $base = '')
4697
- {
4698
- return $this->item->sanitize($data, $type, $base);
4699
- }
4700
-
4701
- function get_item()
4702
- {
4703
- return $this->item;
4704
- }
4705
-
4706
- function get_title()
4707
- {
4708
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
4709
- {
4710
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
4711
- }
4712
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
4713
- {
4714
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
4715
- }
4716
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
4717
- {
4718
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
4719
- }
4720
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
4721
- {
4722
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
4723
- }
4724
- elseif ($return = $this->get_source_tags('', 'title'))
4725
- {
4726
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
4727
- }
4728
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
4729
- {
4730
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4731
- }
4732
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
4733
- {
4734
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4735
- }
4736
- else
4737
- {
4738
- return null;
4739
- }
4740
- }
4741
-
4742
- function get_category($key = 0)
4743
- {
4744
- $categories = $this->get_categories();
4745
- if (isset($categories[$key]))
4746
- {
4747
- return $categories[$key];
4748
- }
4749
- else
4750
- {
4751
- return null;
4752
- }
4753
- }
4754
-
4755
- function get_categories()
4756
- {
4757
- $categories = array();
4758
-
4759
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
4760
- {
4761
- $term = null;
4762
- $scheme = null;
4763
- $label = null;
4764
- if (isset($category['attribs']['']['term']))
4765
- {
4766
- $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
4767
- }
4768
- if (isset($category['attribs']['']['scheme']))
4769
- {
4770
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4771
- }
4772
- if (isset($category['attribs']['']['label']))
4773
- {
4774
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4775
- }
4776
- $categories[] =& new $this->item->feed->category_class($term, $scheme, $label);
4777
- }
4778
- foreach ((array) $this->get_source_tags('', 'category') as $category)
4779
- {
4780
- $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4781
- }
4782
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
4783
- {
4784
- $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4785
- }
4786
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
4787
- {
4788
- $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4789
- }
4790
-
4791
- if (!empty($categories))
4792
- {
4793
- return SimplePie_Misc::array_unique($categories);
4794
- }
4795
- else
4796
- {
4797
- return null;
4798
- }
4799
- }
4800
-
4801
- function get_author($key = 0)
4802
- {
4803
- $authors = $this->get_authors();
4804
- if (isset($authors[$key]))
4805
- {
4806
- return $authors[$key];
4807
- }
4808
- else
4809
- {
4810
- return null;
4811
- }
4812
- }
4813
-
4814
- function get_authors()
4815
- {
4816
- $authors = array();
4817
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
4818
- {
4819
- $name = null;
4820
- $uri = null;
4821
- $email = null;
4822
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
4823
- {
4824
- $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4825
- }
4826
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
4827
- {
4828
- $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
4829
- }
4830
- if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
4831
- {
4832
- $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4833
- }
4834
- if ($name !== null || $email !== null || $uri !== null)
4835
- {
4836
- $authors[] =& new $this->item->feed->author_class($name, $uri, $email);
4837
- }
4838
- }
4839
- if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
4840
- {
4841
- $name = null;
4842
- $url = null;
4843
- $email = null;
4844
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
4845
- {
4846
- $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4847
- }
4848
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
4849
- {
4850
- $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
4851
- }
4852
- if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
4853
- {
4854
- $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4855
- }
4856
- if ($name !== null || $email !== null || $url !== null)
4857
- {
4858
- $authors[] =& new $this->item->feed->author_class($name, $url, $email);
4859
- }
4860
- }
4861
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
4862
- {
4863
- $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4864
- }
4865
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
4866
- {
4867
- $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4868
- }
4869
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
4870
- {
4871
- $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
4872
- }
4873
-
4874
- if (!empty($authors))
4875
- {
4876
- return SimplePie_Misc::array_unique($authors);
4877
- }
4878
- else
4879
- {
4880
- return null;
4881
- }
4882
- }
4883
-
4884
- function get_contributor($key = 0)
4885
- {
4886
- $contributors = $this->get_contributors();
4887
- if (isset($contributors[$key]))
4888
- {
4889
- return $contributors[$key];
4890
- }
4891
- else
4892
- {
4893
- return null;
4894
- }
4895
- }
4896
-
4897
- function get_contributors()
4898
- {
4899
- $contributors = array();
4900
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
4901
- {
4902
- $name = null;
4903
- $uri = null;
4904
- $email = null;
4905
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
4906
- {
4907
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4908
- }
4909
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
4910
- {
4911
- $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
4912
- }
4913
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
4914
- {
4915
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4916
- }
4917
- if ($name !== null || $email !== null || $uri !== null)
4918
- {
4919
- $contributors[] =& new $this->item->feed->author_class($name, $uri, $email);
4920
- }
4921
- }
4922
- foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
4923
- {
4924
- $name = null;
4925
- $url = null;
4926
- $email = null;
4927
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
4928
- {
4929
- $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4930
- }
4931
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
4932
- {
4933
- $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
4934
- }
4935
- if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
4936
- {
4937
- $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4938
- }
4939
- if ($name !== null || $email !== null || $url !== null)
4940
- {
4941
- $contributors[] =& new $this->item->feed->author_class($name, $url, $email);
4942
- }
4943
- }
4944
-
4945
- if (!empty($contributors))
4946
- {
4947
- return SimplePie_Misc::array_unique($contributors);
4948
- }
4949
- else
4950
- {
4951
- return null;
4952
- }
4953
- }
4954
-
4955
- function get_link($key = 0, $rel = 'alternate')
4956
- {
4957
- $links = $this->get_links($rel);
4958
- if (isset($links[$key]))
4959
- {
4960
- return $links[$key];
4961
- }
4962
- else
4963
- {
4964
- return null;
4965
- }
4966
- }
4967
-
4968
- /**
4969
- * Added for parity between the parent-level and the item/entry-level.
4970
- */
4971
- function get_permalink()
4972
- {
4973
- return $this->get_link(0);
4974
- }
4975
-
4976
- function get_links($rel = 'alternate')
4977
- {
4978
- if (!isset($this->data['links']))
4979
- {
4980
- $this->data['links'] = array();
4981
- if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
4982
- {
4983
- foreach ($links as $link)
4984
- {
4985
- if (isset($link['attribs']['']['href']))
4986
- {
4987
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
4988
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
4989
- }
4990
- }
4991
- }
4992
- if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
4993
- {
4994
- foreach ($links as $link)
4995
- {
4996
- if (isset($link['attribs']['']['href']))
4997
- {
4998
- $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
4999
- $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
5000
-
5001
- }
5002
- }
5003
- }
5004
- if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
5005
- {
5006
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
5007
- }
5008
- if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
5009
- {
5010
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
5011
- }
5012
- if ($links = $this->get_source_tags('', 'link'))
5013
- {
5014
- $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
5015
- }
5016
-
5017
- $keys = array_keys($this->data['links']);
5018
- foreach ($keys as $key)
5019
- {
5020
- if (SimplePie_Misc::is_isegment_nz_nc($key))
5021
- {
5022
- if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
5023
- {
5024
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
5025
- $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
5026
- }
5027
- else
5028
- {
5029
- $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
5030
- }
5031
- }
5032
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
5033
- {
5034
- $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
5035
- }
5036
- $this->data['links'][$key] = array_unique($this->data['links'][$key]);
5037
- }
5038
- }
5039
-
5040
- if (isset($this->data['links'][$rel]))
5041
- {
5042
- return $this->data['links'][$rel];
5043
- }
5044
- else
5045
- {
5046
- return null;
5047
- }
5048
- }
5049
-
5050
- function get_description()
5051
- {
5052
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
5053
- {
5054
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5055
- }
5056
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
5057
- {
5058
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5059
- }
5060
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
5061
- {
5062
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5063
- }
5064
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
5065
- {
5066
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5067
- }
5068
- elseif ($return = $this->get_source_tags('', 'description'))
5069
- {
5070
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5071
- }
5072
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
5073
- {
5074
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5075
- }
5076
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
5077
- {
5078
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5079
- }
5080
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
5081
- {
5082
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
5083
- }
5084
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
5085
- {
5086
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
5087
- }
5088
- else
5089
- {
5090
- return null;
5091
- }
5092
- }
5093
-
5094
- function get_copyright()
5095
- {
5096
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
5097
- {
5098
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5099
- }
5100
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
5101
- {
5102
- return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5103
- }
5104
- elseif ($return = $this->get_source_tags('', 'copyright'))
5105
- {
5106
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5107
- }
5108
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
5109
- {
5110
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5111
- }
5112
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
5113
- {
5114
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5115
- }
5116
- else
5117
- {
5118
- return null;
5119
- }
5120
- }
5121
-
5122
- function get_language()
5123
- {
5124
- if ($return = $this->get_source_tags('', 'language'))
5125
- {
5126
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5127
- }
5128
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
5129
- {
5130
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5131
- }
5132
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
5133
- {
5134
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5135
- }
5136
- elseif (isset($this->data['xml_lang']))
5137
- {
5138
- return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
5139
- }
5140
- else
5141
- {
5142
- return null;
5143
- }
5144
- }
5145
-
5146
- function get_latitude()
5147
- {
5148
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
5149
- {
5150
- return (float) $return[0]['data'];
5151
- }
5152
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
5153
- {
5154
- return (float) $match[1];
5155
- }
5156
- else
5157
- {
5158
- return null;
5159
- }
5160
- }
5161
-
5162
- function get_longitude()
5163
- {
5164
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
5165
- {
5166
- return (float) $return[0]['data'];
5167
- }
5168
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
5169
- {
5170
- return (float) $return[0]['data'];
5171
- }
5172
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
5173
- {
5174
- return (float) $match[2];
5175
- }
5176
- else
5177
- {
5178
- return null;
5179
- }
5180
- }
5181
-
5182
- function get_image_url()
5183
- {
5184
- if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
5185
- {
5186
- return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
5187
- }
5188
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
5189
- {
5190
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
5191
- }
5192
- elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
5193
- {
5194
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
5195
- }
5196
- else
5197
- {
5198
- return null;
5199
- }
5200
- }
5201
- }
5202
-
5203
- class SimplePie_Author
5204
- {
5205
- var $name;
5206
- var $link;
5207
- var $email;
5208
-
5209
- // Constructor, used to input the data
5210
- function SimplePie_Author($name = null, $link = null, $email = null)
5211
- {
5212
- $this->name = $name;
5213
- $this->link = $link;
5214
- $this->email = $email;
5215
- }
5216
-
5217
- function __toString()
5218
- {
5219
- // There is no $this->data here
5220
- return md5(serialize($this));
5221
- }
5222
-
5223
- function get_name()
5224
- {
5225
- if ($this->name !== null)
5226
- {
5227
- return $this->name;
5228
- }
5229
- else
5230
- {
5231
- return null;
5232
- }
5233
- }
5234
-
5235
- function get_link()
5236
- {
5237
- if ($this->link !== null)
5238
- {
5239
- return $this->link;
5240
- }
5241
- else
5242
- {
5243
- return null;
5244
- }
5245
- }
5246
-
5247
- function get_email()
5248
- {
5249
- if ($this->email !== null)
5250
- {
5251
- return $this->email;
5252
- }
5253
- else
5254
- {
5255
- return null;
5256
- }
5257
- }
5258
- }
5259
-
5260
- class SimplePie_Category
5261
- {
5262
- var $term;
5263
- var $scheme;
5264
- var $label;
5265
-
5266
- // Constructor, used to input the data
5267
- function SimplePie_Category($term = null, $scheme = null, $label = null)
5268
- {
5269
- $this->term = $term;
5270
- $this->scheme = $scheme;
5271
- $this->label = $label;
5272
- }
5273
-
5274
- function __toString()
5275
- {
5276
- // There is no $this->data here
5277
- return md5(serialize($this));
5278
- }
5279
-
5280
- function get_term()
5281
- {
5282
- if ($this->term !== null)
5283
- {
5284
- return $this->term;
5285
- }
5286
- else
5287
- {
5288
- return null;
5289
- }
5290
- }
5291
-
5292
- function get_scheme()
5293
- {
5294
- if ($this->scheme !== null)
5295
- {
5296
- return $this->scheme;
5297
- }
5298
- else
5299
- {
5300
- return null;
5301
- }
5302
- }
5303
-
5304
- function get_label()
5305
- {
5306
- if ($this->label !== null)
5307
- {
5308
- return $this->label;
5309
- }
5310
- else
5311
- {
5312
- return $this->get_term();
5313
- }
5314
- }
5315
- }
5316
-
5317
- class SimplePie_Enclosure
5318
- {
5319
- var $bitrate;
5320
- var $captions;
5321
- var $categories;
5322
- var $channels;
5323
- var $copyright;
5324
- var $credits;
5325
- var $description;
5326
- var $duration;
5327
- var $expression;
5328
- var $framerate;
5329
- var $handler;
5330
- var $hashes;
5331
- var $height;
5332
- var $javascript;
5333
- var $keywords;
5334
- var $lang;
5335
- var $length;
5336
- var $link;
5337
- var $medium;
5338
- var $player;
5339
- var $ratings;
5340
- var $restrictions;
5341
- var $samplingrate;
5342
- var $thumbnails;
5343
- var $title;
5344
- var $type;
5345
- var $width;
5346
-
5347
- // Constructor, used to input the data
5348
- function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
5349
- {
5350
- $this->bitrate = $bitrate;
5351
- $this->captions = $captions;
5352
- $this->categories = $categories;
5353
- $this->channels = $channels;
5354
- $this->copyright = $copyright;
5355
- $this->credits = $credits;
5356
- $this->description = $description;
5357
- $this->duration = $duration;
5358
- $this->expression = $expression;
5359
- $this->framerate = $framerate;
5360
- $this->hashes = $hashes;
5361
- $this->height = $height;
5362
- $this->javascript = $javascript;
5363
- $this->keywords = $keywords;
5364
- $this->lang = $lang;
5365
- $this->length = $length;
5366
- $this->link = $link;
5367
- $this->medium = $medium;
5368
- $this->player = $player;
5369
- $this->ratings = $ratings;
5370
- $this->restrictions = $restrictions;
5371
- $this->samplingrate = $samplingrate;
5372
- $this->thumbnails = $thumbnails;
5373
- $this->title = $title;
5374
- $this->type = $type;
5375
- $this->width = $width;
5376
- if (class_exists('idna_convert'))
5377
- {
5378
- $idn =& new idna_convert;
5379
- $parsed = SimplePie_Misc::parse_url($link);
5380
- $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
5381
- }
5382
- $this->handler = $this->get_handler(); // Needs to load last
5383
- }
5384
-
5385
- function __toString()
5386
- {
5387
- // There is no $this->data here
5388
- return md5(serialize($this));
5389
- }
5390
-
5391
- function get_bitrate()
5392
- {
5393
- if ($this->bitrate !== null)
5394
- {
5395
- return $this->bitrate;
5396
- }
5397
- else
5398
- {
5399
- return null;
5400
- }
5401
- }
5402
-
5403
- function get_caption($key = 0)
5404
- {
5405
- $captions = $this->get_captions();
5406
- if (isset($captions[$key]))
5407
- {
5408
- return $captions[$key];
5409
- }
5410
- else
5411
- {
5412
- return null;
5413
- }
5414
- }
5415
-
5416
- function get_captions()
5417
- {
5418
- if ($this->captions !== null)
5419
- {
5420
- return $this->captions;
5421
- }
5422
- else
5423
- {
5424
- return null;
5425
- }
5426
- }
5427
-
5428
- function get_category($key = 0)
5429
- {
5430
- $categories = $this->get_categories();
5431
- if (isset($categories[$key]))
5432
- {
5433
- return $categories[$key];
5434
- }
5435
- else
5436
- {
5437
- return null;
5438
- }
5439
- }
5440
-
5441
- function get_categories()
5442
- {
5443
- if ($this->categories !== null)
5444
- {
5445
- return $this->categories;
5446
- }
5447
- else
5448
- {
5449
- return null;
5450
- }
5451
- }
5452
-
5453
- function get_channels()
5454
- {
5455
- if ($this->channels !== null)
5456
- {
5457
- return $this->channels;
5458
- }
5459
- else
5460
- {
5461
- return null;
5462
- }
5463
- }
5464
-
5465
- function get_copyright()
5466
- {
5467
- if ($this->copyright !== null)
5468
- {
5469
- return $this->copyright;
5470
- }
5471
- else
5472
- {
5473
- return null;
5474
- }
5475
- }
5476
-
5477
- function get_credit($key = 0)
5478
- {
5479
- $credits = $this->get_credits();
5480
- if (isset($credits[$key]))
5481
- {
5482
- return $credits[$key];
5483
- }
5484
- else
5485
- {
5486
- return null;
5487
- }
5488
- }
5489
-
5490
- function get_credits()
5491
- {
5492
- if ($this->credits !== null)
5493
- {
5494
- return $this->credits;
5495
- }
5496
- else
5497
- {
5498
- return null;
5499
- }
5500
- }
5501
-
5502
- function get_description()
5503
- {
5504
- if ($this->description !== null)
5505
- {
5506
- return $this->description;
5507
- }
5508
- else
5509
- {
5510
- return null;
5511
- }
5512
- }
5513
-
5514
- function get_duration($convert = false)
5515
- {
5516
- if ($this->duration !== null)
5517
- {
5518
- if ($convert)
5519
- {
5520
- $time = SimplePie_Misc::time_hms($this->duration);
5521
- return $time;
5522
- }
5523
- else
5524
- {
5525
- return $this->duration;
5526
- }
5527
- }
5528
- else
5529
- {
5530
- return null;
5531
- }
5532
- }
5533
-
5534
- function get_expression()
5535
- {
5536
- if ($this->expression !== null)
5537
- {
5538
- return $this->expression;
5539
- }
5540
- else
5541
- {
5542
- return 'full';
5543
- }
5544
- }
5545
-
5546
- function get_extension()
5547
- {
5548
- if ($this->link !== null)
5549
- {
5550
- $url = SimplePie_Misc::parse_url($this->link);
5551
- if ($url['path'] !== '')
5552
- {
5553
- return pathinfo($url['path'], PATHINFO_EXTENSION);
5554
- }
5555
- }
5556
- return null;
5557
- }
5558
-
5559
- function get_framerate()
5560
- {
5561
- if ($this->framerate !== null)
5562
- {
5563
- return $this->framerate;
5564
- }
5565
- else
5566
- {
5567
- return null;
5568
- }
5569
- }
5570
-
5571
- function get_handler()
5572
- {
5573
- return $this->get_real_type(true);
5574
- }
5575
-
5576
- function get_hash($key = 0)
5577
- {
5578
- $hashes = $this->get_hashes();
5579
- if (isset($hashes[$key]))
5580
- {
5581
- return $hashes[$key];
5582
- }
5583
- else
5584
- {
5585
- return null;
5586
- }
5587
- }
5588
-
5589
- function get_hashes()
5590
- {
5591
- if ($this->hashes !== null)
5592
- {
5593
- return $this->hashes;
5594
- }
5595
- else
5596
- {
5597
- return null;
5598
- }
5599
- }
5600
-
5601
- function get_height()
5602
- {
5603
- if ($this->height !== null)
5604
- {
5605
- return $this->height;
5606
- }
5607
- else
5608
- {
5609
- return null;
5610
- }
5611
- }
5612
-
5613
- function get_language()
5614
- {
5615
- if ($this->lang !== null)
5616
- {
5617
- return $this->lang;
5618
- }
5619
- else
5620
- {
5621
- return null;
5622
- }
5623
- }
5624
-
5625
- function get_keyword($key = 0)
5626
- {
5627
- $keywords = $this->get_keywords();
5628
- if (isset($keywords[$key]))
5629
- {
5630
- return $keywords[$key];
5631
- }
5632
- else
5633
- {
5634
- return null;
5635
- }
5636
- }
5637
-
5638
- function get_keywords()
5639
- {
5640
- if ($this->keywords !== null)
5641
- {
5642
- return $this->keywords;
5643
- }
5644
- else
5645
- {
5646
- return null;
5647
- }
5648
- }
5649
-
5650
- function get_length()
5651
- {
5652
- if ($this->length !== null)
5653
- {
5654
- return $this->length;
5655
- }
5656
- else
5657
- {
5658
- return null;
5659
- }
5660
- }
5661
-
5662
- function get_link()
5663
- {
5664
- if ($this->link !== null)
5665
- {
5666
- return urldecode($this->link);
5667
- }
5668
- else
5669
- {
5670
- return null;
5671
- }
5672
- }
5673
-
5674
- function get_medium()
5675
- {
5676
- if ($this->medium !== null)
5677
- {
5678
- return $this->medium;
5679
- }
5680
- else
5681
- {
5682
- return null;
5683
- }
5684
- }
5685
-
5686
- function get_player()
5687
- {
5688
- if ($this->player !== null)
5689
- {
5690
- return $this->player;
5691
- }
5692
- else
5693
- {
5694
- return null;
5695
- }
5696
- }
5697
-
5698
- function get_rating($key = 0)
5699
- {
5700
- $ratings = $this->get_ratings();
5701
- if (isset($ratings[$key]))
5702
- {
5703
- return $ratings[$key];
5704
- }
5705
- else
5706
- {
5707
- return null;
5708
- }
5709
- }
5710
-
5711
- function get_ratings()
5712
- {
5713
- if ($this->ratings !== null)
5714
- {
5715
- return $this->ratings;
5716
- }
5717
- else
5718
- {
5719
- return null;
5720
- }
5721
- }
5722
-
5723
- function get_restriction($key = 0)
5724
- {
5725
- $restrictions = $this->get_restrictions();
5726
- if (isset($restrictions[$key]))
5727
- {
5728
- return $restrictions[$key];
5729
- }
5730
- else
5731
- {
5732
- return null;
5733
- }
5734
- }
5735
-
5736
- function get_restrictions()
5737
- {
5738
- if ($this->restrictions !== null)
5739
- {
5740
- return $this->restrictions;
5741
- }
5742
- else
5743
- {
5744
- return null;
5745
- }
5746
- }
5747
-
5748
- function get_sampling_rate()
5749
- {
5750
- if ($this->samplingrate !== null)
5751
- {
5752
- return $this->samplingrate;
5753
- }
5754
- else
5755
- {
5756
- return null;
5757
- }
5758
- }
5759
-
5760
- function get_size()
5761
- {
5762
- $length = $this->get_length();
5763
- if ($length !== null)
5764
- {
5765
- return round($length/1048576, 2);
5766
- }
5767
- else
5768
- {
5769
- return null;
5770
- }
5771
- }
5772
-
5773
- function get_thumbnail($key = 0)
5774
- {
5775
- $thumbnails = $this->get_thumbnails();
5776
- if (isset($thumbnails[$key]))
5777
- {
5778
- return $thumbnails[$key];
5779
- }
5780
- else
5781
- {
5782
- return null;
5783
- }
5784
- }
5785
-
5786
- function get_thumbnails()
5787
- {
5788
- if ($this->thumbnails !== null)
5789
- {
5790
- return $this->thumbnails;
5791
- }
5792
- else
5793
- {
5794
- return null;
5795
- }
5796
- }
5797
-
5798
- function get_title()
5799
- {
5800
- if ($this->title !== null)
5801
- {
5802
- return $this->title;
5803
- }
5804
- else
5805
- {
5806
- return null;
5807
- }
5808
- }
5809
-
5810
- function get_type()
5811
- {
5812
- if ($this->type !== null)
5813
- {
5814
- return $this->type;
5815
- }
5816
- else
5817
- {
5818
- return null;
5819
- }
5820
- }
5821
-
5822
- function get_width()
5823
- {
5824
- if ($this->width !== null)
5825
- {
5826
- return $this->width;
5827
- }
5828
- else
5829
- {
5830
- return null;
5831
- }
5832
- }
5833
-
5834
- function native_embed($options='')
5835
- {
5836
- return $this->embed($options, true);
5837
- }
5838
-
5839
- /**
5840
- * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
5841
- */
5842
- function embed($options = '', $native = false)
5843
- {
5844
- // Set up defaults
5845
- $audio = '';
5846
- $video = '';
5847
- $alt = '';
5848
- $altclass = '';
5849
- $loop = 'false';
5850
- $width = 'auto';
5851
- $height = 'auto';
5852
- $bgcolor = '#ffffff';
5853
- $mediaplayer = '';
5854
- $widescreen = false;
5855
- $handler = $this->get_handler();
5856
- $type = $this->get_real_type();
5857
-
5858
- // Process options and reassign values as necessary
5859
- if (is_array($options))
5860
- {
5861
- extract($options);
5862
- }
5863
- else
5864
- {
5865
- $options = explode(',', $options);
5866
- foreach($options as $option)
5867
- {
5868
- $opt = explode(':', $option, 2);
5869
- if (isset($opt[0], $opt[1]))
5870
- {
5871
- $opt[0] = trim($opt[0]);
5872
- $opt[1] = trim($opt[1]);
5873
- switch ($opt[0])
5874
- {
5875
- case 'audio':
5876
- $audio = $opt[1];
5877
- break;
5878
-
5879
- case 'video':
5880
- $video = $opt[1];
5881
- break;
5882
-
5883
- case 'alt':
5884
- $alt = $opt[1];
5885
- break;
5886
-
5887
- case 'altclass':
5888
- $altclass = $opt[1];
5889
- break;
5890
-
5891
- case 'loop':
5892
- $loop = $opt[1];
5893
- break;
5894
-
5895
- case 'width':
5896
- $width = $opt[1];
5897
- break;
5898
-
5899
- case 'height':
5900
- $height = $opt[1];
5901
- break;
5902
-
5903
- case 'bgcolor':
5904
- $bgcolor = $opt[1];
5905
- break;
5906
-
5907
- case 'mediaplayer':
5908
- $mediaplayer = $opt[1];
5909
- break;
5910
-
5911
- case 'widescreen':
5912
- $widescreen = $opt[1];
5913
- break;
5914
- }
5915
- }
5916
- }
5917
- }
5918
-
5919
- $mime = explode('/', $type, 2);
5920
- $mime = $mime[0];
5921
-
5922
- // Process values for 'auto'
5923
- if ($width == 'auto')
5924
- {
5925
- if ($mime == 'video')
5926
- {
5927
- if ($height == 'auto')
5928
- {
5929
- $width = 480;
5930
- }
5931
- elseif ($widescreen)
5932
- {
5933
- $width = round((intval($height)/9)*16);
5934
- }
5935
- else
5936
- {
5937
- $width = round((intval($height)/3)*4);
5938
- }
5939
- }
5940
- else
5941
- {
5942
- $width = '100%';
5943
- }
5944
- }
5945
-
5946
- if ($height == 'auto')
5947
- {
5948
- if ($mime == 'audio')
5949
- {
5950
- $height = 0;
5951
- }
5952
- elseif ($mime == 'video')
5953
- {
5954
- if ($width == 'auto')
5955
- {
5956
- if ($widescreen)
5957
- {
5958
- $height = 270;
5959
- }
5960
- else
5961
- {
5962
- $height = 360;
5963
- }
5964
- }
5965
- elseif ($widescreen)
5966
- {
5967
- $height = round((intval($width)/16)*9);
5968
- }
5969
- else
5970
- {
5971
- $height = round((intval($width)/4)*3);
5972
- }
5973
- }
5974
- else
5975
- {
5976
- $height = 376;
5977
- }
5978
- }
5979
- elseif ($mime == 'audio')
5980
- {
5981
- $height = 0;
5982
- }
5983
-
5984
- // Set proper placeholder value
5985
- if ($mime == 'audio')
5986
- {
5987
- $placeholder = $audio;
5988
- }
5989
- elseif ($mime == 'video')
5990
- {
5991
- $placeholder = $video;
5992
- }
5993
-
5994
- $embed = '';
5995
-
5996
- // Make sure the JS library is included
5997
- if (!$native)
5998
- {
5999
- static $javascript_outputted = null;
6000
- if (!$javascript_outputted && $this->javascript)
6001
- {
6002
- $embed .= '<script type="text/javascript" src="?' . htmlspecialchars($this->javascript) . '"></script>';
6003
- $javascript_outputted = true;
6004
- }
6005
- }
6006
-
6007
- // Odeo Feed MP3's
6008
- if ($handler == 'odeo')
6009
- {
6010
- if ($native)
6011
- {
6012
- $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url=' . $this->get_link() . '"></embed>';
6013
- }
6014
- else
6015
- {
6016
- $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>';
6017
- }
6018
- }
6019
-
6020
- // Flash
6021
- elseif ($handler == 'flash')
6022
- {
6023
- if ($native)
6024
- {
6025
- $embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
6026
- }
6027
- else
6028
- {
6029
- $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
6030
- }
6031
- }
6032
-
6033
- // Flash Media Player file types.
6034
- // Preferred handler for MP3 file types.
6035
- elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
6036
- {
6037
- $height += 20;
6038
- if ($native)
6039
- {
6040
- $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
6041
- }
6042
- else
6043
- {
6044
- $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>";
6045
- }
6046
- }
6047
-
6048
- // QuickTime 7 file types. Need to test with QuickTime 6.
6049
- // Only handle MP3's if the Flash Media Player is not present.
6050
- elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == ''))
6051
- {
6052
- $height += 16;
6053
- if ($native)
6054
- {
6055
- if ($placeholder != ""){
6056
- $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
6057
- }
6058
- else {
6059
- $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
6060
- }
6061
- }
6062
- else
6063
- {
6064
- $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
6065
- }
6066
- }
6067
-
6068
- // Windows Media
6069
- elseif ($handler == 'wmedia')
6070
- {
6071
- $height += 45;
6072
- if ($native)
6073
- {
6074
- $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
6075
- }
6076
- else
6077
- {
6078
- $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
6079
- }
6080
- }
6081
-
6082
- // Everything else
6083
- else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
6084
-
6085
- return $embed;
6086
- }
6087
-
6088
- function get_real_type($find_handler = false)
6089
- {
6090
- // If it's Odeo, let's get it out of the way.
6091
- if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com')
6092
- {
6093
- return 'odeo';
6094
- }
6095
-
6096
- // Mime-types by handler.
6097
- $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
6098
- $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
6099
- $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
6100
- $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
6101
- $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3
6102
-
6103
- if ($this->get_type() !== null)
6104
- {
6105
- $type = strtolower($this->type);
6106
- }
6107
- else
6108
- {
6109
- $type = null;
6110
- }
6111
-
6112
- // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
6113
- if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
6114
- {
6115
- switch (strtolower($this->get_extension()))
6116
- {
6117
- // Audio mime-types
6118
- case 'aac':
6119
- case 'adts':
6120
- $type = 'audio/acc';
6121
- break;
6122
-
6123
- case 'aif':
6124
- case 'aifc':
6125
- case 'aiff':
6126
- case 'cdda':
6127
- $type = 'audio/aiff';
6128
- break;
6129
-
6130
- case 'bwf':
6131
- $type = 'audio/wav';
6132
- break;
6133
-
6134
- case 'kar':
6135
- case 'mid':
6136
- case 'midi':
6137
- case 'smf':
6138
- $type = 'audio/midi';
6139
- break;
6140
-
6141
- case 'm4a':
6142
- $type = 'audio/x-m4a';
6143
- break;
6144
-
6145
- case 'mp3':
6146
- case 'swa':
6147
- $type = 'audio/mp3';
6148
- break;
6149
-
6150
- case 'wav':
6151
- $type = 'audio/wav';
6152
- break;
6153
-
6154
- case 'wax':
6155
- $type = 'audio/x-ms-wax';
6156
- break;
6157
-
6158
- case 'wma':
6159
- $type = 'audio/x-ms-wma';
6160
- break;
6161
-
6162
- // Video mime-types
6163
- case '3gp':
6164
- case '3gpp':
6165
- $type = 'video/3gpp';
6166
- break;
6167
-
6168
- case '3g2':
6169
- case '3gp2':
6170
- $type = 'video/3gpp2';
6171
- break;
6172
-
6173
- case 'asf':
6174
- $type = 'video/x-ms-asf';
6175
- break;
6176
-
6177
- case 'flv':
6178
- $type = 'video/x-flv';
6179
- break;
6180
-
6181
- case 'm1a':
6182
- case 'm1s':
6183
- case 'm1v':
6184
- case 'm15':
6185
- case 'm75':
6186
- case 'mp2':
6187
- case 'mpa':
6188
- case 'mpeg':
6189
- case 'mpg':
6190
- case 'mpm':
6191
- case 'mpv':
6192
- $type = 'video/mpeg';
6193
- break;
6194
-
6195
- case 'm4v':
6196
- $type = 'video/x-m4v';
6197
- break;
6198
-
6199
- case 'mov':
6200
- case 'qt':
6201
- $type = 'video/quicktime';
6202
- break;
6203
-
6204
- case 'mp4':
6205
- case 'mpg4':
6206
- $type = 'video/mp4';
6207
- break;
6208
-
6209
- case 'sdv':
6210
- $type = 'video/sd-video';
6211
- break;
6212
-
6213
- case 'wm':
6214
- $type = 'video/x-ms-wm';
6215
- break;
6216
-
6217
- case 'wmv':
6218
- $type = 'video/x-ms-wmv';
6219
- break;
6220
-
6221
- case 'wvx':
6222
- $type = 'video/x-ms-wvx';
6223
- break;
6224
-
6225
- // Flash mime-types
6226
- case 'spl':
6227
- $type = 'application/futuresplash';
6228
- break;
6229
-
6230
- case 'swf':
6231
- $type = 'application/x-shockwave-flash';
6232
- break;
6233
- }
6234
- }
6235
-
6236
- if ($find_handler)
6237
- {
6238
- if (in_array($type, $types_flash))
6239
- {
6240
- return 'flash';
6241
- }
6242
- elseif (in_array($type, $types_fmedia))
6243
- {
6244
- return 'fmedia';
6245
- }
6246
- elseif (in_array($type, $types_quicktime))
6247
- {
6248
- return 'quicktime';
6249
- }
6250
- elseif (in_array($type, $types_wmedia))
6251
- {
6252
- return 'wmedia';
6253
- }
6254
- elseif (in_array($type, $types_mp3))
6255
- {
6256
- return 'mp3';
6257
- }
6258
- else
6259
- {
6260
- return null;
6261
- }
6262
- }
6263
- else
6264
- {
6265
- return $type;
6266
- }
6267
- }
6268
- }
6269
-
6270
- class SimplePie_Caption
6271
- {
6272
- var $type;
6273
- var $lang;
6274
- var $startTime;
6275
- var $endTime;
6276
- var $text;
6277
-
6278
- // Constructor, used to input the data
6279
- function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
6280
- {
6281
- $this->type = $type;
6282
- $this->lang = $lang;
6283
- $this->startTime = $startTime;
6284
- $this->endTime = $endTime;
6285
- $this->text = $text;
6286
- }
6287
-
6288
- function __toString()
6289
- {
6290
- // There is no $this->data here
6291
- return md5(serialize($this));
6292
- }
6293
-
6294
- function get_endtime()
6295
- {
6296
- if ($this->endTime !== null)
6297
- {
6298
- return $this->endTime;
6299
- }
6300
- else
6301
- {
6302
- return null;
6303
- }
6304
- }
6305
-
6306
- function get_language()
6307
- {
6308
- if ($this->lang !== null)
6309
- {
6310
- return $this->lang;
6311
- }
6312
- else
6313
- {
6314
- return null;
6315
- }
6316
- }
6317
-
6318
- function get_starttime()
6319
- {
6320
- if ($this->startTime !== null)
6321
- {
6322
- return $this->startTime;
6323
- }
6324
- else
6325
- {
6326
- return null;
6327
- }
6328
- }
6329
-
6330
- function get_text()
6331
- {
6332
- if ($this->text !== null)
6333
- {
6334
- return $this->text;
6335
- }
6336
- else
6337
- {
6338
- return null;
6339
- }
6340
- }
6341
-
6342
- function get_type()
6343
- {
6344
- if ($this->type !== null)
6345
- {
6346
- return $this->type;
6347
- }
6348
- else
6349
- {
6350
- return null;
6351
- }
6352
- }
6353
- }
6354
-
6355
- class SimplePie_Credit
6356
- {
6357
- var $role;
6358
- var $scheme;
6359
- var $name;
6360
-
6361
- // Constructor, used to input the data
6362
- function SimplePie_Credit($role = null, $scheme = null, $name = null)
6363
- {
6364
- $this->role = $role;
6365
- $this->scheme = $scheme;
6366
- $this->name = $name;
6367
- }
6368
-
6369
- function __toString()
6370
- {
6371
- // There is no $this->data here
6372
- return md5(serialize($this));
6373
- }
6374
-
6375
- function get_role()
6376
- {
6377
- if ($this->role !== null)
6378
- {
6379
- return $this->role;
6380
- }
6381
- else
6382
- {
6383
- return null;
6384
- }
6385
- }
6386
-
6387
- function get_scheme()
6388
- {
6389
- if ($this->scheme !== null)
6390
- {
6391
- return $this->scheme;
6392
- }
6393
- else
6394
- {
6395
- return null;
6396
- }
6397
- }
6398
-
6399
- function get_name()
6400
- {
6401
- if ($this->name !== null)
6402
- {
6403
- return $this->name;
6404
- }
6405
- else
6406
- {
6407
- return null;
6408
- }
6409
- }
6410
- }
6411
-
6412
- class SimplePie_Copyright
6413
- {
6414
- var $url;
6415
- var $label;
6416
-
6417
- // Constructor, used to input the data
6418
- function SimplePie_Copyright($url = null, $label = null)
6419
- {
6420
- $this->url = $url;
6421
- $this->label = $label;
6422
- }
6423
-
6424
- function __toString()
6425
- {
6426
- // There is no $this->data here
6427
- return md5(serialize($this));
6428
- }
6429
-
6430
- function get_url()
6431
- {
6432
- if ($this->url !== null)
6433
- {
6434
- return $this->url;
6435
- }
6436
- else
6437
- {
6438
- return null;
6439
- }
6440
- }
6441
-
6442
- function get_attribution()
6443
- {
6444
- if ($this->label !== null)
6445
- {
6446
- return $this->label;
6447
- }
6448
- else
6449
- {
6450
- return null;
6451
- }
6452
- }
6453
- }
6454
-
6455
- class SimplePie_Rating
6456
- {
6457
- var $scheme;
6458
- var $value;
6459
-
6460
- // Constructor, used to input the data
6461
- function SimplePie_Rating($scheme = null, $value = null)
6462
- {
6463
- $this->scheme = $scheme;
6464
- $this->value = $value;
6465
- }
6466
-
6467
- function __toString()
6468
- {
6469
- // There is no $this->data here
6470
- return md5(serialize($this));
6471
- }
6472
-
6473
- function get_scheme()
6474
- {
6475
- if ($this->scheme !== null)
6476
- {
6477
- return $this->scheme;
6478
- }
6479
- else
6480
- {
6481
- return null;
6482
- }
6483
- }
6484
-
6485
- function get_value()
6486
- {
6487
- if ($this->value !== null)
6488
- {
6489
- return $this->value;
6490
- }
6491
- else
6492
- {
6493
- return null;
6494
- }
6495
- }
6496
- }
6497
-
6498
- class SimplePie_Restriction
6499
- {
6500
- var $relationship;
6501
- var $type;
6502
- var $value;
6503
-
6504
- // Constructor, used to input the data
6505
- function SimplePie_Restriction($relationship = null, $type = null, $value = null)
6506
- {
6507
- $this->relationship = $relationship;
6508
- $this->type = $type;
6509
- $this->value = $value;
6510
- }
6511
-
6512
- function __toString()
6513
- {
6514
- // There is no $this->data here
6515
- return md5(serialize($this));
6516
- }
6517
-
6518
- function get_relationship()
6519
- {
6520
- if ($this->relationship !== null)
6521
- {
6522
- return $this->relationship;
6523
- }
6524
- else
6525
- {
6526
- return null;
6527
- }
6528
- }
6529
-
6530
- function get_type()
6531
- {
6532
- if ($this->type !== null)
6533
- {
6534
- return $this->type;
6535
- }
6536
- else
6537
- {
6538
- return null;
6539
- }
6540
- }
6541
-
6542
- function get_value()
6543
- {
6544
- if ($this->value !== null)
6545
- {
6546
- return $this->value;
6547
- }
6548
- else
6549
- {
6550
- return null;
6551
- }
6552
- }
6553
- }
6554
-
6555
- /**
6556
- * @todo Move to properly supporting RFC2616 (HTTP/1.1)
6557
- */
6558
- class SimplePie_File
6559
- {
6560
- var $url;
6561
- var $useragent;
6562
- var $success = true;
6563
- var $headers = array();
6564
- var $body;
6565
- var $status_code;
6566
- var $redirects = 0;
6567
- var $error;
6568
- var $method = SIMPLEPIE_FILE_SOURCE_NONE;
6569
-
6570
- function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
6571
- {
6572
- if (class_exists('idna_convert'))
6573
- {
6574
- $idn =& new idna_convert;
6575
- $parsed = SimplePie_Misc::parse_url($url);
6576
- $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
6577
- }
6578
- $this->url = $url;
6579
- $this->useragent = $useragent;
6580
- if (preg_match('/^http(s)?:\/\//i', $url))
6581
- {
6582
- if ($useragent === null)
6583
- {
6584
- $useragent = ini_get('user_agent');
6585
- $this->useragent = $useragent;
6586
- }
6587
- if (!is_array($headers))
6588
- {
6589
- $headers = array();
6590
- }
6591
- if (!$force_fsockopen && function_exists('curl_exec'))
6592
- {
6593
- $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
6594
- $fp = curl_init();
6595
- $headers2 = array();
6596
- foreach ($headers as $key => $value)
6597
- {
6598
- $headers2[] = "$key: $value";
6599
- }
6600
- if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
6601
- {
6602
- curl_setopt($fp, CURLOPT_ENCODING, '');
6603
- }
6604
- curl_setopt($fp, CURLOPT_URL, $url);
6605
- curl_setopt($fp, CURLOPT_HEADER, 1);
6606
- curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
6607
- curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
6608
- curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
6609
- curl_setopt($fp, CURLOPT_REFERER, $url);
6610
- curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
6611
- curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
6612
- if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
6613
- {
6614
- curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
6615
- curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
6616
- }
6617
-
6618
- $this->headers = curl_exec($fp);
6619
- if (curl_errno($fp) == 23 || curl_errno($fp) == 61)
6620
- {
6621
- curl_setopt($fp, CURLOPT_ENCODING, 'none');
6622
- $this->headers = curl_exec($fp);
6623
- }
6624
- if (curl_errno($fp))
6625
- {
6626
- $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
6627
- $this->success = false;
6628
- }
6629
- else
6630
- {
6631
- $info = curl_getinfo($fp);
6632
- curl_close($fp);
6633
- $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
6634
- $this->headers = array_pop($this->headers);
6635
- $parser =& new SimplePie_HTTP_Parser($this->headers);
6636
- if ($parser->parse())
6637
- {
6638
- $this->headers = $parser->headers;
6639
- $this->body = $parser->body;
6640
- $this->status_code = $parser->status_code;
6641
- if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
6642
- {
6643
- $this->redirects++;
6644
- $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
6645
- return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
6646
- }
6647
- }
6648
- }
6649
- }
6650
- else
6651
- {
6652
- $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
6653
- $url_parts = parse_url($url);
6654
- if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
6655
- {
6656
- $url_parts['host'] = "ssl://$url_parts[host]";
6657
- $url_parts['port'] = 443;
6658
- }
6659
- if (!isset($url_parts['port']))
6660
- {
6661
- $url_parts['port'] = 80;
6662
- }
6663
- $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
6664
- if (!$fp)
6665
- {
6666
- $this->error = 'fsockopen error: ' . $errstr;
6667
- $this->success = false;
6668
- }
6669
- else
6670
- {
6671
- stream_set_timeout($fp, $timeout);
6672
- if (isset($url_parts['path']))
6673
- {
6674
- if (isset($url_parts['query']))
6675
- {
6676
- $get = "$url_parts[path]?$url_parts[query]";
6677
- }
6678
- else
6679
- {
6680
- $get = $url_parts['path'];
6681
- }
6682
- }
6683
- else
6684
- {
6685
- $get = '/';
6686
- }
6687
- $out = "GET $get HTTP/1.0\r\n";
6688
- $out .= "Host: $url_parts[host]\r\n";
6689
- $out .= "User-Agent: $useragent\r\n";
6690
- if (extension_loaded('zlib'))
6691
- {
6692
- $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
6693
- }
6694
-
6695
- if (isset($url_parts['user']) && isset($url_parts['pass']))
6696
- {
6697
- $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
6698
- }
6699
- foreach ($headers as $key => $value)
6700
- {
6701
- $out .= "$key: $value\r\n";
6702
- }
6703
- $out .= "Connection: Close\r\n\r\n";
6704
- fwrite($fp, $out);
6705
-
6706
- $info = stream_get_meta_data($fp);
6707
-
6708
- $this->headers = '';
6709
- while (!$info['eof'] && !$info['timed_out'])
6710
- {
6711
- $this->headers .= fread($fp, 1160);
6712
- $info = stream_get_meta_data($fp);
6713
- }
6714
- if (!$info['timed_out'])
6715
- {
6716
- $parser =& new SimplePie_HTTP_Parser($this->headers);
6717
- if ($parser->parse())
6718
- {
6719
- $this->headers = $parser->headers;
6720
- $this->body = $parser->body;
6721
- $this->status_code = $parser->status_code;
6722
- if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
6723
- {
6724
- $this->redirects++;
6725
- $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
6726
- return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
6727
- }
6728
- if (isset($this->headers['content-encoding']))
6729
- {
6730
- // Hey, we act dumb elsewhere, so let's do that here too
6731
- switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
6732
- {
6733
- case 'gzip':
6734
- case 'x-gzip':
6735
- $decoder = new SimplePie_gzdecode($this->body);
6736
- if (!$decoder->parse())
6737
- {
6738
- $this->error = 'Unable to decode HTTP "gzip" stream';
6739
- $this->success = false;
6740
- }
6741
- else
6742
- {
6743
- $this->body = $decoder->data;
6744
- }
6745
- break;
6746
-
6747
- case 'deflate':
6748
- if (($body = gzuncompress($this->body)) === false)
6749
- {
6750
- if (($body = gzinflate($this->body)) === false)
6751
- {
6752
- $this->error = 'Unable to decode HTTP "deflate" stream';
6753
- $this->success = false;
6754
- }
6755
- }
6756
- $this->body = $body;
6757
- break;
6758
-
6759
- default:
6760
- $this->error = 'Unknown content coding';
6761
- $this->success = false;
6762
- }
6763
- }
6764
- }
6765
- }
6766
- else
6767
- {
6768
- $this->error = 'fsocket timed out';
6769
- $this->success = false;
6770
- }
6771
- fclose($fp);
6772
- }
6773
- }
6774
- }
6775
- else
6776
- {
6777
- $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
6778
- if (!$this->body = file_get_contents($url))
6779
- {
6780
- $this->error = 'file_get_contents could not read the file';
6781
- $this->success = false;
6782
- }
6783
- }
6784
- }
6785
- }
6786
-
6787
- /**
6788
- * HTTP Response Parser
6789
- *
6790
- * @package SimplePie
6791
- */
6792
- class SimplePie_HTTP_Parser
6793
- {
6794
- /**
6795
- * HTTP Version
6796
- *
6797
- * @access public
6798
- * @var float
6799
- */
6800
- var $http_version = 0.0;
6801
-
6802
- /**
6803
- * Status code
6804
- *
6805
- * @access public
6806
- * @var int
6807
- */
6808
- var $status_code = 0;
6809
-
6810
- /**
6811
- * Reason phrase
6812
- *
6813
- * @access public
6814
- * @var string
6815
- */
6816
- var $reason = '';
6817
-
6818
- /**
6819
- * Key/value pairs of the headers
6820
- *
6821
- * @access public
6822
- * @var array
6823
- */
6824
- var $headers = array();
6825
-
6826
- /**
6827
- * Body of the response
6828
- *
6829
- * @access public
6830
- * @var string
6831
- */
6832
- var $body = '';
6833
-
6834
- /**
6835
- * Current state of the state machine
6836
- *
6837
- * @access private
6838
- * @var string
6839
- */
6840
- var $state = 'http_version';
6841
-
6842
- /**
6843
- * Input data
6844
- *
6845
- * @access private
6846
- * @var string
6847
- */
6848
- var $data = '';
6849
-
6850
- /**
6851
- * Input data length (to avoid calling strlen() everytime this is needed)
6852
- *
6853
- * @access private
6854
- * @var int
6855
- */
6856
- var $data_length = 0;
6857
-
6858
- /**
6859
- * Current position of the pointer
6860
- *
6861
- * @var int
6862
- * @access private
6863
- */
6864
- var $position = 0;
6865
-
6866
- /**
6867
- * Name of the hedaer currently being parsed
6868
- *
6869
- * @access private
6870
- * @var string
6871
- */
6872
- var $name = '';
6873
-
6874
- /**
6875
- * Value of the hedaer currently being parsed
6876
- *
6877
- * @access private
6878
- * @var string
6879
- */
6880
- var $value = '';
6881
-
6882
- /**
6883
- * Create an instance of the class with the input data
6884
- *
6885
- * @access public
6886
- * @param string $data Input data
6887
- */
6888
- function SimplePie_HTTP_Parser($data)
6889
- {
6890
- $this->data = $data;
6891
- $this->data_length = strlen($this->data);
6892
- }
6893
-
6894
- /**
6895
- * Parse the input data
6896
- *
6897
- * @access public
6898
- * @return bool true on success, false on failure
6899
- */
6900
- function parse()
6901
- {
6902
- while ($this->state && $this->state !== 'emit' && $this->has_data())
6903
- {
6904
- $state = $this->state;
6905
- $this->$state();
6906
- }
6907
- $this->data = '';
6908
- if ($this->state === 'emit' || $this->state === 'body')
6909
- {
6910
- return true;
6911
- }
6912
- else
6913
- {
6914
- $this->http_version = '';
6915
- $this->status_code = '';
6916
- $this->reason = '';
6917
- $this->headers = array();
6918
- $this->body = '';
6919
- return false;
6920
- }
6921
- }
6922
-
6923
- /**
6924
- * Check whether there is data beyond the pointer
6925
- *
6926
- * @access private
6927
- * @return bool true if there is further data, false if not
6928
- */
6929
- function has_data()
6930
- {
6931
- return (bool) ($this->position < $this->data_length);
6932
- }
6933
-
6934
- /**
6935
- * See if the next character is LWS
6936
- *
6937
- * @access private
6938
- * @return bool true if the next character is LWS, false if not
6939
- */
6940
- function is_linear_whitespace()
6941
- {
6942
- return (bool) ($this->data[$this->position] === "\x09"
6943
- || $this->data[$this->position] === "\x20"
6944
- || ($this->data[$this->position] === "\x0A"
6945
- && isset($this->data[$this->position + 1])
6946
- && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20")));
6947
- }
6948
-
6949
- /**
6950
- * Parse the HTTP version
6951
- *
6952
- * @access private
6953
- */
6954
- function http_version()
6955
- {
6956
- if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/')
6957
- {
6958
- $len = strspn($this->data, '0123456789.', 5);
6959
- $this->http_version = substr($this->data, 5, $len);
6960
- $this->position += 5 + $len;
6961
- if (substr_count($this->http_version, '.') <= 1)
6962
- {
6963
- $this->http_version = (float) $this->http_version;
6964
- $this->position += strspn($this->data, "\x09\x20", $this->position);
6965
- $this->state = 'status';
6966
- }
6967
- else
6968
- {
6969
- $this->state = false;
6970
- }
6971
- }
6972
- else
6973
- {
6974
- $this->state = false;
6975
- }
6976
- }
6977
-
6978
- /**
6979
- * Parse the status code
6980
- *
6981
- * @access private
6982
- */
6983
- function status()
6984
- {
6985
- if ($len = strspn($this->data, '0123456789', $this->position))
6986
- {
6987
- $this->status_code = (int) substr($this->data, $this->position, $len);
6988
- $this->position += $len;
6989
- $this->state = 'reason';
6990
- }
6991
- else
6992
- {
6993
- $this->state = false;
6994
- }
6995
- }
6996
-
6997
- /**
6998
- * Parse the reason phrase
6999
- *
7000
- * @access private
7001
- */
7002
- function reason()
7003
- {
7004
- $len = strcspn($this->data, "\x0A", $this->position);
7005
- $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20");
7006
- $this->position += $len + 1;
7007
- $this->state = 'new_line';
7008
- }
7009
-
7010
- /**
7011
- * Deal with a new line, shifting data around as needed
7012
- *
7013
- * @access private
7014
- */
7015
- function new_line()
7016
- {
7017
- $this->value = trim($this->value, "\x0D\x20");
7018
- if ($this->name !== '' && $this->value !== '')
7019
- {
7020
- $this->name = strtolower($this->name);
7021
- if (isset($this->headers[$this->name]))
7022
- {
7023
- $this->headers[$this->name] .= ', ' . $this->value;
7024
- }
7025
- else
7026
- {
7027
- $this->headers[$this->name] = $this->value;
7028
- }
7029
- }
7030
- $this->name = '';
7031
- $this->value = '';
7032
- if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A")
7033
- {
7034
- $this->position += 2;
7035
- $this->state = 'body';
7036
- }
7037
- elseif ($this->data[$this->position] === "\x0A")
7038
- {
7039
- $this->position++;
7040
- $this->state = 'body';
7041
- }
7042
- else
7043
- {
7044
- $this->state = 'name';
7045
- }
7046
- }
7047
-
7048
- /**
7049
- * Parse a header name
7050
- *
7051
- * @access private
7052
- */
7053
- function name()
7054
- {
7055
- $len = strcspn($this->data, "\x0A:", $this->position);
7056
- if (isset($this->data[$this->position + $len]))
7057
- {
7058
- if ($this->data[$this->position + $len] === "\x0A")
7059
- {
7060
- $this->position += $len;
7061
- $this->state = 'new_line';
7062
- }
7063
- else
7064
- {
7065
- $this->name = substr($this->data, $this->position, $len);
7066
- $this->position += $len + 1;
7067
- $this->state = 'value';
7068
- }
7069
- }
7070
- else
7071
- {
7072
- $this->state = false;
7073
- }
7074
- }
7075
-
7076
- /**
7077
- * Parse LWS, replacing consecutive LWS characters with a single space
7078
- *
7079
- * @access private
7080
- */
7081
- function linear_whitespace()
7082
- {
7083
- do
7084
- {
7085
- if (substr($this->data, $this->position, 2) === "\x0D\x0A")
7086
- {
7087
- $this->position += 2;
7088
- }
7089
- elseif ($this->data[$this->position] === "\x0A")
7090
- {
7091
- $this->position++;
7092
- }
7093
- $this->position += strspn($this->data, "\x09\x20", $this->position);
7094
- } while ($this->has_data() && $this->is_linear_whitespace());
7095
- $this->value .= "\x20";
7096
- }
7097
-
7098
- /**
7099
- * See what state to move to while within non-quoted header values
7100
- *
7101
- * @access private
7102
- */
7103
- function value()
7104
- {
7105
- if ($this->is_linear_whitespace())
7106
- {
7107
- $this->linear_whitespace();
7108
- }
7109
- else
7110
- {
7111
- switch ($this->data[$this->position])
7112
- {
7113
- case '"':
7114
- $this->position++;
7115
- $this->state = 'quote';
7116
- break;
7117
-
7118
- case "\x0A":
7119
- $this->position++;
7120
- $this->state = 'new_line';
7121
- break;
7122
-
7123
- default:
7124
- $this->state = 'value_char';
7125
- break;
7126
- }
7127
- }
7128
- }
7129
-
7130
- /**
7131
- * Parse a header value while outside quotes
7132
- *
7133
- * @access private
7134
- */
7135
- function value_char()
7136
- {
7137
- $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position);
7138
- $this->value .= substr($this->data, $this->position, $len);
7139
- $this->position += $len;
7140
- $this->state = 'value';
7141
- }
7142
-
7143
- /**
7144
- * See what state to move to while within quoted header values
7145
- *
7146
- * @access private
7147
- */
7148
- function quote()
7149
- {
7150
- if ($this->is_linear_whitespace())
7151
- {
7152
- $this->linear_whitespace();
7153
- }
7154
- else
7155
- {
7156
- switch ($this->data[$this->position])
7157
- {
7158
- case '"':
7159
- $this->position++;
7160
- $this->state = 'value';
7161
- break;
7162
-
7163
- case "\x0A":
7164
- $this->position++;
7165
- $this->state = 'new_line';
7166
- break;
7167
-
7168
- case '\\':
7169
- $this->position++;
7170
- $this->state = 'quote_escaped';
7171
- break;
7172
-
7173
- default:
7174
- $this->state = 'quote_char';
7175
- break;
7176
- }
7177
- }
7178
- }
7179
-
7180
- /**
7181
- * Parse a header value while within quotes
7182
- *
7183
- * @access private
7184
- */
7185
- function quote_char()
7186
- {
7187
- $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position);
7188
- $this->value .= substr($this->data, $this->position, $len);
7189
- $this->position += $len;
7190
- $this->state = 'value';
7191
- }
7192
-
7193
- /**
7194
- * Parse an escaped character within quotes
7195
- *
7196
- * @access private
7197
- */
7198
- function quote_escaped()
7199
- {
7200
- $this->value .= $this->data[$this->position];
7201
- $this->position++;
7202
- $this->state = 'quote';
7203
- }
7204
-
7205
- /**
7206
- * Parse the body
7207
- *
7208
- * @access private
7209
- */
7210
- function body()
7211
- {
7212
- $this->body = substr($this->data, $this->position);
7213
- $this->state = 'emit';
7214
- }
7215
- }
7216
-
7217
- /**
7218
- * gzdecode
7219
- *
7220
- * @package SimplePie
7221
- */
7222
- class SimplePie_gzdecode
7223
- {
7224
- /**
7225
- * Compressed data
7226
- *
7227
- * @access private
7228
- * @see gzdecode::$data
7229
- */
7230
- var $compressed_data;
7231
-
7232
- /**
7233
- * Size of compressed data
7234
- *
7235
- * @access private
7236
- */
7237
- var $compressed_size;
7238
-
7239
- /**
7240
- * Minimum size of a valid gzip string
7241
- *
7242
- * @access private
7243
- */
7244
- var $min_compressed_size = 18;
7245
-
7246
- /**
7247
- * Current position of pointer
7248
- *
7249
- * @access private
7250
- */
7251
- var $position = 0;
7252
-
7253
- /**
7254
- * Flags (FLG)
7255
- *
7256
- * @access private
7257
- */
7258
- var $flags;
7259
-
7260
- /**
7261
- * Uncompressed data
7262
- *
7263
- * @access public
7264
- * @see gzdecode::$compressed_data
7265
- */
7266
- var $data;
7267
-
7268
- /**
7269
- * Modified time
7270
- *
7271
- * @access public
7272
- */
7273
- var $MTIME;
7274
-
7275
- /**
7276
- * Extra Flags
7277
- *
7278
- * @access public
7279
- */
7280
- var $XFL;
7281
-
7282
- /**
7283
- * Operating System
7284
- *
7285
- * @access public
7286
- */
7287
- var $OS;
7288
-
7289
- /**
7290
- * Subfield ID 1
7291
- *
7292
- * @access public
7293
- * @see gzdecode::$extra_field
7294
- * @see gzdecode::$SI2
7295
- */
7296
- var $SI1;
7297
-
7298
- /**
7299
- * Subfield ID 2
7300
- *
7301
- * @access public
7302
- * @see gzdecode::$extra_field
7303
- * @see gzdecode::$SI1
7304
- */
7305
- var $SI2;
7306
-
7307
- /**
7308
- * Extra field content
7309
- *
7310
- * @access public
7311
- * @see gzdecode::$SI1
7312
- * @see gzdecode::$SI2
7313
- */
7314
- var $extra_field;
7315
-
7316
- /**
7317
- * Original filename
7318
- *
7319
- * @access public
7320
- */
7321
- var $filename;
7322
-
7323
- /**
7324
- * Human readable comment
7325
- *
7326
- * @access public
7327
- */
7328
- var $comment;
7329
-
7330
- /**
7331
- * Don't allow anything to be set
7332
- *
7333
- * @access public
7334
- */
7335
- function __set($name, $value)
7336
- {
7337
- trigger_error("Cannot write property $name", E_USER_ERROR);
7338
- }
7339
-
7340
- /**
7341
- * Set the compressed string and related properties
7342
- *
7343
- * @access public
7344
- */
7345
- function SimplePie_gzdecode($data)
7346
- {
7347
- $this->compressed_data = $data;
7348
- $this->compressed_size = strlen($data);
7349
- }
7350
-
7351
- /**
7352
- * Decode the GZIP stream
7353
- *
7354
- * @access public
7355
- */
7356
- function parse()
7357
- {
7358
- if ($this->compressed_size >= $this->min_compressed_size)
7359
- {
7360
- // Check ID1, ID2, and CM
7361
- if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
7362
- {
7363
- return false;
7364
- }
7365
-
7366
- // Get the FLG (FLaGs)
7367
- $this->flags = ord($this->compressed_data[3]);
7368
-
7369
- // FLG bits above (1 << 4) are reserved
7370
- if ($this->flags > 0x1F)
7371
- {
7372
- return false;
7373
- }
7374
-
7375
- // Advance the pointer after the above
7376
- $this->position += 4;
7377
-
7378
- // MTIME
7379
- $mtime = substr($this->compressed_data, $this->position, 4);
7380
- // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
7381
- if (current(unpack('S', "\x00\x01")) === 1)
7382
- {
7383
- $mtime = strrev($mtime);
7384
- }
7385
- $this->MTIME = current(unpack('l', $mtime));
7386
- $this->position += 4;
7387
-
7388
- // Get the XFL (eXtra FLags)
7389
- $this->XFL = ord($this->compressed_data[$this->position++]);
7390
-
7391
- // Get the OS (Operating System)
7392
- $this->OS = ord($this->compressed_data[$this->position++]);
7393
-
7394
- // Parse the FEXTRA
7395
- if ($this->flags & 4)
7396
- {
7397
- // Read subfield IDs
7398
- $this->SI1 = $this->compressed_data[$this->position++];
7399
- $this->SI2 = $this->compressed_data[$this->position++];
7400
-
7401
- // SI2 set to zero is reserved for future use
7402
- if ($this->SI2 === "\x00")
7403
- {
7404
- return false;
7405
- }
7406
-
7407
- // Get the length of the extra field
7408
- $len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
7409
- $position += 2;
7410
-
7411
- // Check the length of the string is still valid
7412
- $this->min_compressed_size += $len + 4;
7413
- if ($this->compressed_size >= $this->min_compressed_size)
7414
- {
7415
- // Set the extra field to the given data
7416
- $this->extra_field = substr($this->compressed_data, $this->position, $len);
7417
- $this->position += $len;
7418
- }
7419
- else
7420
- {
7421
- return false;
7422
- }
7423
- }
7424
-
7425
- // Parse the FNAME
7426
- if ($this->flags & 8)
7427
- {
7428
- // Get the length of the filename
7429
- $len = strspn($this->compressed_data, "\x00", $this->position);
7430
-
7431
- // Check the length of the string is still valid
7432
- $this->min_compressed_size += $len + 1;
7433
- if ($this->compressed_size >= $this->min_compressed_size)
7434
- {
7435
- // Set the original filename to the given string
7436
- $this->filename = substr($this->compressed_data, $this->position, $len);
7437
- $this->position += $len + 1;
7438
- }
7439
- else
7440
- {
7441
- return false;
7442
- }
7443
- }
7444
-
7445
- // Parse the FCOMMENT
7446
- if ($this->flags & 16)
7447
- {
7448
- // Get the length of the comment
7449
- $len = strspn($this->compressed_data, "\x00", $this->position);
7450
-
7451
- // Check the length of the string is still valid
7452
- $this->min_compressed_size += $len + 1;
7453
- if ($this->compressed_size >= $this->min_compressed_size)
7454
- {
7455
- // Set the original comment to the given string
7456
- $this->comment = substr($this->compressed_data, $this->position, $len);
7457
- $this->position += $len + 1;
7458
- }
7459
- else
7460
- {
7461
- return false;
7462
- }
7463
- }
7464
-
7465
- // Parse the FHCRC
7466
- if ($this->flags & 2)
7467
- {
7468
- // Check the length of the string is still valid
7469
- $this->min_compressed_size += $len + 2;
7470
- if ($this->compressed_size >= $this->min_compressed_size)
7471
- {
7472
- // Read the CRC
7473
- $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
7474
-
7475
- // Check the CRC matches
7476
- if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
7477
- {
7478
- $this->position += 2;
7479
- }
7480
- else
7481
- {
7482
- return false;
7483
- }
7484
- }
7485
- else
7486
- {
7487
- return false;
7488
- }
7489
- }
7490
-
7491
- // Decompress the actual data
7492
- if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
7493
- {
7494
- return false;
7495
- }
7496
- else
7497
- {
7498
- $this->position = $this->compressed_size - 8;
7499
- }
7500
-
7501
- // Check CRC of data
7502
- $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
7503
- $this->position += 4;
7504
- /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
7505
- {
7506
- return false;
7507
- }*/
7508
-
7509
- // Check ISIZE of data
7510
- $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
7511
- $this->position += 4;
7512
- if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
7513
- {
7514
- return false;
7515
- }
7516
-
7517
- // Wow, against all odds, we've actually got a valid gzip string
7518
- return true;
7519
- }
7520
- else
7521
- {
7522
- return false;
7523
- }
7524
- }
7525
- }
7526
-
7527
- class SimplePie_Cache
7528
- {
7529
- /**
7530
- * Don't call the constructor. Please.
7531
- *
7532
- * @access private
7533
- */
7534
- function SimplePie_Cache()
7535
- {
7536
- trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
7537
- }
7538
-
7539
- /**
7540
- * Create a new SimplePie_Cache object
7541
- *
7542
- * @static
7543
- * @access public
7544
- */
7545
- function create($location, $filename, $extension)
7546
- {
7547
- return new SimplePie_Cache_File($location, $filename, $extension);
7548
- }
7549
- }
7550
-
7551
- class SimplePie_Cache_File
7552
- {
7553
- var $location;
7554
- var $filename;
7555
- var $extension;
7556
- var $name;
7557
-
7558
- function SimplePie_Cache_File($location, $filename, $extension)
7559
- {
7560
- $this->location = $location;
7561
- $this->filename = rawurlencode($filename);
7562
- $this->extension = rawurlencode($extension);
7563
- $this->name = "$location/$this->filename.$this->extension";
7564
- }
7565
-
7566
- function save($data)
7567
- {
7568
- if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
7569
- {
7570
- if (is_a($data, 'SimplePie'))
7571
- {
7572
- $data = $data->data;
7573
- }
7574
-
7575
- $data = serialize($data);
7576
-
7577
- if (function_exists('file_put_contents'))
7578
- {
7579
- return (bool) file_put_contents($this->name, $data);
7580
- }
7581
- else
7582
- {
7583
- $fp = fopen($this->name, 'wb');
7584
- if ($fp)
7585
- {
7586
- fwrite($fp, $data);
7587
- fclose($fp);
7588
- return true;
7589
- }
7590
- }
7591
- }
7592
- return false;
7593
- }
7594
-
7595
- function load()
7596
- {
7597
- if (file_exists($this->name) && is_readable($this->name))
7598
- {
7599
- return unserialize(file_get_contents($this->name));
7600
- }
7601
- return false;
7602
- }
7603
-
7604
- function mtime()
7605
- {
7606
- if (file_exists($this->name))
7607
- {
7608
- return filemtime($this->name);
7609
- }
7610
- return false;
7611
- }
7612
-
7613
- function touch()
7614
- {
7615
- if (file_exists($this->name))
7616
- {
7617
- return touch($this->name);
7618
- }
7619
- return false;
7620
- }
7621
-
7622
- function unlink()
7623
- {
7624
- if (file_exists($this->name))
7625
- {
7626
- return unlink($this->name);
7627
- }
7628
- return false;
7629
- }
7630
- }
7631
-
7632
- class SimplePie_Misc
7633
- {
7634
- function time_hms($seconds)
7635
- {
7636
- $time = '';
7637
-
7638
- $hours = floor($seconds / 3600);
7639
- $remainder = $seconds % 3600;
7640
- if ($hours > 0)
7641
- {
7642
- $time .= $hours.':';
7643
- }
7644
-
7645
- $minutes = floor($remainder / 60);
7646
- $seconds = $remainder % 60;
7647
- if ($minutes < 10 && $hours > 0)
7648
- {
7649
- $minutes = '0' . $minutes;
7650
- }
7651
- if ($seconds < 10)
7652
- {
7653
- $seconds = '0' . $seconds;
7654
- }
7655
-
7656
- $time .= $minutes.':';
7657
- $time .= $seconds;
7658
-
7659
- return $time;
7660
- }
7661
-
7662
- function absolutize_url($relative, $base)
7663
- {
7664
- if ($relative !== '')
7665
- {
7666
- $relative = SimplePie_Misc::parse_url($relative);
7667
- if ($relative['scheme'] !== '')
7668
- {
7669
- $target = $relative;
7670
- }
7671
- elseif ($base !== '')
7672
- {
7673
- $base = SimplePie_Misc::parse_url($base);
7674
- $target = SimplePie_Misc::parse_url('');
7675
- if ($relative['authority'] !== '')
7676
- {
7677
- $target = $relative;
7678
- $target['scheme'] = $base['scheme'];
7679
- }
7680
- else
7681
- {
7682
- $target['scheme'] = $base['scheme'];
7683
- $target['authority'] = $base['authority'];
7684
- if ($relative['path'] !== '')
7685
- {
7686
- if (strpos($relative['path'], '/') === 0)
7687
- {
7688
- $target['path'] = $relative['path'];
7689
- }
7690
- elseif ($base['authority'] !== '' && $base['path'] === '')
7691
- {
7692
- $target['path'] = '/' . $relative['path'];
7693
- }
7694
- elseif (($last_segment = strrpos($base['path'], '/')) !== false)
7695
- {
7696
- $target['path'] = substr($base['path'], 0, $last_segment + 1) . $relative['path'];
7697
- }
7698
- else
7699
- {
7700
- $target['path'] = $relative['path'];
7701
- }
7702
- $target['query'] = $relative['query'];
7703
- }
7704
- else
7705
- {
7706
- $target['path'] = $base['path'];
7707
- if ($relative['query'] !== '')
7708
- {
7709
- $target['query'] = $relative['query'];
7710
- }
7711
- elseif ($base['query'] !== '')
7712
- {
7713
- $target['query'] = $base['query'];
7714
- }
7715
- }
7716
- }
7717
- $target['fragment'] = $relative['fragment'];
7718
- }
7719
- else
7720
- {
7721
- // No base URL, just return the relative URL
7722
- $target = $relative;
7723
- }
7724
- $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']);
7725
- }
7726
- else
7727
- {
7728
- $return = $base;
7729
- }
7730
- $return = SimplePie_Misc::normalize_url($return);
7731
- return $return;
7732
- }
7733
-
7734
- function remove_dot_segments($input)
7735
- {
7736
- $output = '';
7737
- while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..')
7738
- {
7739
- // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
7740
- if (strpos($input, '../') === 0)
7741
- {
7742
- $input = substr($input, 3);
7743
- }
7744
- elseif (strpos($input, './') === 0)
7745
- {
7746
- $input = substr($input, 2);
7747
- }
7748
- // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
7749
- elseif (strpos($input, '/./') === 0)
7750
- {
7751
- $input = substr_replace($input, '/', 0, 3);
7752
- }
7753
- elseif ($input == '/.')
7754
- {
7755
- $input = '/';
7756
- }
7757
- // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
7758
- elseif (strpos($input, '/../') === 0)
7759
- {
7760
- $input = substr_replace($input, '/', 0, 4);
7761
- $output = substr_replace($output, '', strrpos($output, '/'));
7762
- }
7763
- elseif ($input == '/..')
7764
- {
7765
- $input = '/';
7766
- $output = substr_replace($output, '', strrpos($output, '/'));
7767
- }
7768
- // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
7769
- elseif ($input == '.' || $input == '..')
7770
- {
7771
- $input = '';
7772
- }
7773
- // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
7774
- elseif (($pos = strpos($input, '/', 1)) !== false)
7775
- {
7776
- $output .= substr($input, 0, $pos);
7777
- $input = substr_replace($input, '', 0, $pos);
7778
- }
7779
- else
7780
- {
7781
- $output .= $input;
7782
- $input = '';
7783
- }
7784
- }
7785
- return $output . $input;
7786
- }
7787
-
7788
- function get_element($realname, $string)
7789
- {
7790
- $return = array();
7791
- $name = preg_quote($realname, '/');
7792
- if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
7793
- {
7794
- for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
7795
- {
7796
- $return[$i]['tag'] = $realname;
7797
- $return[$i]['full'] = $matches[$i][0][0];
7798
- $return[$i]['offset'] = $matches[$i][0][1];
7799
- if (strlen($matches[$i][3][0]) <= 2)
7800
- {
7801
- $return[$i]['self_closing'] = true;
7802
- }
7803
- else
7804
- {
7805
- $return[$i]['self_closing'] = false;
7806
- $return[$i]['content'] = $matches[$i][4][0];
7807
- }
7808
- $return[$i]['attribs'] = array();
7809
- if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
7810
- {
7811
- for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
7812
- {
7813
- if (count($attribs[$j]) == 2)
7814
- {
7815
- $attribs[$j][2] = $attribs[$j][1];
7816
- }
7817
- $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
7818
- }
7819
- }
7820
- }
7821
- }
7822
- return $return;
7823
- }
7824
-
7825
- function element_implode($element)
7826
- {
7827
- $full = "<$element[tag]";
7828
- foreach ($element['attribs'] as $key => $value)
7829
- {
7830
- $key = strtolower($key);
7831
- $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
7832
- }
7833
- if ($element['self_closing'])
7834
- {
7835
- $full .= ' />';
7836
- }
7837
- else
7838
- {
7839
- $full .= ">$element[content]</$element[tag]>";
7840
- }
7841
- return $full;
7842
- }
7843
-
7844
- function error($message, $level, $file, $line)
7845
- {
7846
- switch ($level)
7847
- {
7848
- case E_USER_ERROR:
7849
- $note = 'PHP Error';
7850
- break;
7851
- case E_USER_WARNING:
7852
- $note = 'PHP Warning';
7853
- break;
7854
- case E_USER_NOTICE:
7855
- $note = 'PHP Notice';
7856
- break;
7857
- default:
7858
- $note = 'Unknown Error';
7859
- break;
7860
- }
7861
- error_log("$note: $message in $file on line $line", 0);
7862
- return $message;
7863
- }
7864
-
7865
- /**
7866
- * If a file has been cached, retrieve and display it.
7867
- *
7868
- * This is most useful for caching images (get_favicon(), etc.),
7869
- * however it works for all cached files. This WILL NOT display ANY
7870
- * file/image/page/whatever, but rather only display what has already
7871
- * been cached by SimplePie.
7872
- *
7873
- * @access public
7874
- * @see SimplePie::get_favicon()
7875
- * @param str $identifier_url URL that is used to identify the content.
7876
- * This may or may not be the actual URL of the live content.
7877
- * @param str $cache_location Location of SimplePie's cache. Defaults
7878
- * to './cache'.
7879
- * @param str $cache_extension The file extension that the file was
7880
- * cached with. Defaults to 'spc'.
7881
- * @param str $cache_class Name of the cache-handling class being used
7882
- * in SimplePie. Defaults to 'SimplePie_Cache', and should be left
7883
- * as-is unless you've overloaded the class.
7884
- * @param str $cache_name_function Obsolete. Exists for backwards
7885
- * compatibility reasons only.
7886
- */
7887
- function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5')
7888
- {
7889
- $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension);
7890
-
7891
- if ($file = $cache->load())
7892
- {
7893
- if (isset($file['headers']['content-type']))
7894
- {
7895
- header('Content-type:' . $file['headers']['content-type']);
7896
- }
7897
- else
7898
- {
7899
- header('Content-type: application/octet-stream');
7900
- }
7901
- header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
7902
- echo $file['body'];
7903
- exit;
7904
- }
7905
-
7906
- die('Cached file for ' . $identifier_url . ' cannot be found.');
7907
- }
7908
-
7909
- function fix_protocol($url, $http = 1)
7910
- {
7911
- $url = SimplePie_Misc::normalize_url($url);
7912
- $parsed = SimplePie_Misc::parse_url($url);
7913
- if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https')
7914
- {
7915
- return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
7916
- }
7917
-
7918
- if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
7919
- {
7920
- return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
7921
- }
7922
-
7923
- if ($http == 2 && $parsed['scheme'] !== '')
7924
- {
7925
- return "feed:$url";
7926
- }
7927
- elseif ($http == 3 && strtolower($parsed['scheme']) == 'http')
7928
- {
7929
- return substr_replace($url, 'podcast', 0, 4);
7930
- }
7931
- elseif ($http == 4 && strtolower($parsed['scheme']) == 'http')
7932
- {
7933
- return substr_replace($url, 'itpc', 0, 4);
7934
- }
7935
- else
7936
- {
7937
- return $url;
7938
- }
7939
- }
7940
-
7941
- function parse_url($url)
7942
- {
7943
- static $cache = array();
7944
- if (isset($cache[$url]))
7945
- {
7946
- return $cache[$url];
7947
- }
7948
- elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match))
7949
- {
7950
- for ($i = count($match); $i <= 9; $i++)
7951
- {
7952
- $match[$i] = '';
7953
- }
7954
- return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
7955
- }
7956
- else
7957
- {
7958
- return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => '');
7959
- }
7960
- }
7961
-
7962
- function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
7963
- {
7964
- $return = '';
7965
- if ($scheme !== '')
7966
- {
7967
- $return .= "$scheme:";
7968
- }
7969
- if ($authority !== '')
7970
- {
7971
- $return .= "//$authority";
7972
- }
7973
- if ($path !== '')
7974
- {
7975
- $return .= $path;
7976
- }
7977
- if ($query !== '')
7978
- {
7979
- $return .= "?$query";
7980
- }
7981
- if ($fragment !== '')
7982
- {
7983
- $return .= "#$fragment";
7984
- }
7985
- return $return;
7986
- }
7987
-
7988
- function normalize_url($url)
7989
- {
7990
- $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url);
7991
- $url = SimplePie_Misc::parse_url($url);
7992
- $url['scheme'] = strtolower($url['scheme']);
7993
- if ($url['authority'] !== '')
7994
- {
7995
- $url['authority'] = strtolower($url['authority']);
7996
- $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']);
7997
- }
7998
- return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']);
7999
- }
8000
-
8001
- function percent_encoding_normalization($match)
8002
- {
8003
- $integer = hexdec($match[1]);
8004
- if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E)
8005
- {
8006
- return chr($integer);
8007
- }
8008
- else
8009
- {
8010
- return strtoupper($match[0]);
8011
- }
8012
- }
8013
-
8014
- /**
8015
- * Remove bad UTF-8 bytes
8016
- *
8017
- * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
8018
- * FAQ: Multilingual Forms (modified to include full ASCII range)
8019
- *
8020
- * @author Geoffrey Sneddon
8021
- * @see http://www.w3.org/International/questions/qa-forms-utf-8
8022
- * @param string $str String to remove bad UTF-8 bytes from
8023
- * @return string UTF-8 string
8024
- */
8025
- function utf8_bad_replace($str)
8026
- {
8027
- if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str)))
8028
- {
8029
- return $return;
8030
- }
8031
- elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8')))
8032
- {
8033
- return $return;
8034
- }
8035
- elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches))
8036
- {
8037
- return implode("\xEF\xBF\xBD", $matches[0]);
8038
- }
8039
- elseif ($str !== '')
8040
- {
8041
- return "\xEF\xBF\xBD";
8042
- }
8043
- else
8044
- {
8045
- return '';
8046
- }
8047
- }
8048
-
8049
- /**
8050
- * Converts a Windows-1252 encoded string to a UTF-8 encoded string
8051
- *
8052
- * @static
8053
- * @access public
8054
- * @param string $string Windows-1252 encoded string
8055
- * @return string UTF-8 encoded string
8056
- */
8057
- function windows_1252_to_utf8($string)
8058
- {
8059
- static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
8060
-
8061
- return strtr($string, $convert_table);
8062
- }
8063
-
8064
- function change_encoding($data, $input, $output)
8065
- {
8066
- $input = SimplePie_Misc::encoding($input);
8067
- $output = SimplePie_Misc::encoding($output);
8068
-
8069
- // We fail to fail on non US-ASCII bytes
8070
- if ($input === 'US-ASCII')
8071
- {
8072
- static $non_ascii_octects = '';
8073
- if (!$non_ascii_octects)
8074
- {
8075
- for ($i = 0x80; $i <= 0xFF; $i++)
8076
- {
8077
- $non_ascii_octects .= chr($i);
8078
- }
8079
- }
8080
- $data = substr($data, 0, strcspn($data, $non_ascii_octects));
8081
- }
8082
-
8083
- // This is first, as behaviour of this is completely predictable
8084
- if ($input === 'Windows-1252' && $output === 'UTF-8')
8085
- {
8086
- return SimplePie_Misc::windows_1252_to_utf8($data);
8087
- }
8088
- // This is second, as behaviour of this varies only with PHP version
8089
- elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input)))
8090
- {
8091
- return $return;
8092
- }
8093
- // This is last, as behaviour of this varies with OS userland and PHP version
8094
- elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
8095
- {
8096
- return $return;
8097
- }
8098
- // If we can't do anything, just fail
8099
- else
8100
- {
8101
- return false;
8102
- }
8103
- }
8104
-
8105
- function encoding($charset)
8106
- {
8107
- /* Character sets are case-insensitive, and also need some further
8108
- normalization in the real world (though we'll return them in the form given
8109
- in their registration). */
8110
- switch (strtolower(preg_replace('/[\x09-\x0D\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]/', '', $charset)))
8111
- {
8112
- case 'adobestandardencoding':
8113
- case 'csadobestandardencoding':
8114
- return 'Adobe-Standard-Encoding';
8115
-
8116
- case 'adobesymbolencoding':
8117
- case 'cshppsmath':
8118
- return 'Adobe-Symbol-Encoding';
8119
-
8120
- case 'ami1251':
8121
- case 'ami1251':
8122
- case 'amiga1251':
8123
- case 'amiga1251':
8124
- return 'Amiga-1251';
8125
-
8126
- case 'ansix31101983':
8127
- case 'csat5001983':
8128
- case 'csiso99naplps':
8129
- case 'isoir99':
8130
- case 'naplps':
8131
- return 'ANSI_X3.110-1983';
8132
-
8133
- case 'arabic7':
8134
- case 'asmo449':
8135
- case 'csiso89asmo449':
8136
- case 'isoir89':
8137
- case 'iso9036':
8138
- return 'ASMO_449';
8139
-
8140
- case 'big5':
8141
- case 'csbig5':
8142
- case 'xxbig5':
8143
- return 'Big5';
8144
-
8145
- case 'big5hkscs':
8146
- return 'Big5-HKSCS';
8147
-
8148
- case 'bocu1':
8149
- case 'csbocu1':
8150
- return 'BOCU-1';
8151
-
8152
- case 'brf':
8153
- case 'csbrf':
8154
- return 'BRF';
8155
-
8156
- case 'bs4730':
8157
- case 'csiso4unitedkingdom':
8158
- case 'gb':
8159
- case 'isoir4':
8160
- case 'iso646gb':
8161
- case 'uk':
8162
- return 'BS_4730';
8163
-
8164
- case 'bsviewdata':
8165
- case 'csiso47bsviewdata':
8166
- case 'isoir47':
8167
- return 'BS_viewdata';
8168
-
8169
- case 'cesu8':
8170
- case 'cscesu8':
8171
- return 'CESU-8';
8172
-
8173
- case 'ca':
8174
- case 'csa71':
8175
- case 'csaz243419851':
8176
- case 'csiso121canadian1':
8177
- case 'isoir121':
8178
- case 'iso646ca':
8179
- return 'CSA_Z243.4-1985-1';
8180
-
8181
- case 'csa72':
8182
- case 'csaz243419852':
8183
- case 'csiso122canadian2':
8184
- case 'isoir122':
8185
- case 'iso646ca2':
8186
- return 'CSA_Z243.4-1985-2';
8187
-
8188
- case 'csaz24341985gr':
8189
- case 'csiso123csaz24341985gr':
8190
- case 'isoir123':
8191
- return 'CSA_Z243.4-1985-gr';
8192
-
8193
- case 'csiso139csn369103':
8194
- case 'csn369103':
8195
- case 'isoir139':
8196
- return 'CSN_369103';
8197
-
8198
- case 'csdecmcs':
8199
- case 'dec':
8200
- case 'decmcs':
8201
- return 'DEC-MCS';
8202
-
8203
- case 'csiso21german':
8204
- case 'de':
8205
- case 'din66003':
8206
- case 'isoir21':
8207
- case 'iso646de':
8208
- return 'DIN_66003';
8209
-
8210
- case 'csdkus':
8211
- case 'dkus':
8212
- return 'dk-us';
8213
-
8214
- case 'csiso646danish':
8215
- case 'dk':
8216
- case 'ds2089':
8217
- case 'ds2089':
8218
- case 'iso646dk':
8219
- return 'DS_2089';
8220
-
8221
- case 'csibmebcdicatde':
8222
- case 'ebcdicatde':
8223
- return 'EBCDIC-AT-DE';
8224
-
8225
- case 'csebcdicatdea':
8226
- case 'ebcdicatdea':
8227
- return 'EBCDIC-AT-DE-A';
8228
-
8229
- case 'csebcdiccafr':
8230
- case 'ebcdiccafr':
8231
- return 'EBCDIC-CA-FR';
8232
-
8233
- case 'csebcdicdkno':
8234
- case 'ebcdicdkno':
8235
- return 'EBCDIC-DK-NO';
8236
-
8237
- case 'csebcdicdknoa':
8238
- case 'ebcdicdknoa':
8239
- return 'EBCDIC-DK-NO-A';
8240
-
8241
- case 'csebcdices':
8242
- case 'ebcdices':
8243
- return 'EBCDIC-ES';
8244
-
8245
- case 'csebcdicesa':
8246
- case 'ebcdicesa':
8247
- return 'EBCDIC-ES-A';
8248
-
8249
- case 'csebcdicess':
8250
- case 'ebcdicess':
8251
- return 'EBCDIC-ES-S';
8252
-
8253
- case 'csebcdicfise':
8254
- case 'ebcdicfise':
8255
- return 'EBCDIC-FI-SE';
8256
-
8257
- case 'csebcdicfisea':
8258
- case 'ebcdicfisea':
8259
- return 'EBCDIC-FI-SE-A';
8260
-
8261
- case 'csebcdicfr':
8262
- case 'ebcdicfr':
8263
- return 'EBCDIC-FR';
8264
-
8265
- case 'csebcdicit':
8266
- case 'ebcdicit':
8267
- return 'EBCDIC-IT';
8268
-
8269
- case 'csebcdicpt':
8270
- case 'ebcdicpt':
8271
- return 'EBCDIC-PT';
8272
-
8273
- case 'csebcdicuk':
8274
- case 'ebcdicuk':
8275
- return 'EBCDIC-UK';
8276
-
8277
- case 'csebcdicus':
8278
- case 'ebcdicus':
8279
- return 'EBCDIC-US';
8280
-
8281
- case 'csiso111ecmacyrillic':
8282
- case 'ecmacyrillic':
8283
- case 'isoir111':
8284
- case 'koi8e':
8285
- return 'ECMA-cyrillic';
8286
-
8287
- case 'csiso17spanish':
8288
- case 'es':
8289
- case 'isoir17':
8290
- case 'iso646es':
8291
- return 'ES';
8292
-
8293
- case 'csiso85spanish2':
8294
- case 'es2':
8295
- case 'isoir85':
8296
- case 'iso646es2':
8297
- return 'ES2';
8298
-
8299
- case 'cseucfixwidjapanese':
8300
- case 'extendedunixcodefixedwidthforjapanese':
8301
- return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
8302
-
8303
- case 'cseucpkdfmtjapanese':
8304
- case 'eucjp':
8305
- case 'extendedunixcodepackedformatforjapanese':
8306
- return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
8307
-
8308
- case 'gb18030':
8309
- return 'GB18030';
8310
-
8311
- case 'cp936':
8312
- case 'gbk':
8313
- case 'ms936':
8314
- case 'windows936':
8315
- case 'csgb2312':
8316
- case 'gb2312':
8317
- case 'chinese':
8318
- case 'csiso58gb231280':
8319
- case 'gb231280':
8320
- case 'isoir58':
8321
- return 'GBK';
8322
-
8323
- case 'cn':
8324
- case 'csiso57gb1988':
8325
- case 'gb198880':
8326
- case 'isoir57':
8327
- case 'iso646cn':
8328
- return 'GB_1988-80';
8329
-
8330
- case 'csiso153gost1976874':
8331
- case 'gost1976874':
8332
- case 'isoir153':
8333
- case 'stsev35888':
8334
- return 'GOST_19768-74';
8335
-
8336
- case 'csiso150':
8337
- case 'csiso150greekccitt':
8338
- case 'greekccitt':
8339
- case 'isoir150':
8340
- return 'greek-ccitt';
8341
-
8342
- case 'csiso88greek7':
8343
- case 'greek7':
8344
- case 'isoir88':
8345
- return 'greek7';
8346
-
8347
- case 'csiso18greek7old':
8348
- case 'greek7old':
8349
- case 'isoir18':
8350
- return 'greek7-old';
8351
-
8352
- case 'cshpdesktop':
8353
- case 'hpdesktop':
8354
- return 'HP-DeskTop';
8355
-
8356
- case 'cshplegal':
8357
- case 'hplegal':
8358
- return 'HP-Legal';
8359
-
8360
- case 'cshpmath8':
8361
- case 'hpmath8':
8362
- return 'HP-Math8';
8363
-
8364
- case 'cshppifont':
8365
- case 'hppifont':
8366
- return 'HP-Pi-font';
8367
-
8368
- case 'cshproman8':
8369
- case 'hproman8':
8370
- case 'r8':
8371
- case 'roman8':
8372
- return 'hp-roman8';
8373
-
8374
- case 'hzgb2312':
8375
- return 'HZ-GB-2312';
8376
-
8377
- case 'csibmsymbols':
8378
- case 'ibmsymbols':
8379
- return 'IBM-Symbols';
8380
-
8381
- case 'csibmthai':
8382
- case 'ibmthai':
8383
- return 'IBM-Thai';
8384
-
8385
- case 'ccsid00858':
8386
- case 'cp00858':
8387
- case 'ibm00858':
8388
- case 'pcmultilingual850euro':
8389
- return 'IBM00858';
8390
-
8391
- case 'ccsid00924':
8392
- case 'cp00924':
8393
- case 'ebcdiclatin9euro':
8394
- case 'ibm00924':
8395
- return 'IBM00924';
8396
-
8397
- case 'ccsid01140':
8398
- case 'cp01140':
8399
- case 'ebcdicus37euro':
8400
- case 'ibm01140':
8401
- return 'IBM01140';
8402
-
8403
- case 'ccsid01141':
8404
- case 'cp01141':
8405
- case 'ebcdicde273euro':
8406
- case 'ibm01141':
8407
- return 'IBM01141';
8408
-
8409
- case 'ccsid01142':
8410
- case 'cp01142':
8411
- case 'ebcdicdk277euro':
8412
- case 'ebcdicno277euro':
8413
- case 'ibm01142':
8414
- return 'IBM01142';
8415
-
8416
- case 'ccsid01143':
8417
- case 'cp01143':
8418
- case 'ebcdicfi278euro':
8419
- case 'ebcdicse278euro':
8420
- case 'ibm01143':
8421
- return 'IBM01143';
8422
-
8423
- case 'ccsid01144':
8424
- case 'cp01144':
8425
- case 'ebcdicit280euro':
8426
- case 'ibm01144':
8427
- return 'IBM01144';
8428
-
8429
- case 'ccsid01145':
8430
- case 'cp01145':
8431
- case 'ebcdices284euro':
8432
- case 'ibm01145':
8433
- return 'IBM01145';
8434
-
8435
- case 'ccsid01146':
8436
- case 'cp01146':
8437
- case 'ebcdicgb285euro':
8438
- case 'ibm01146':
8439
- return 'IBM01146';
8440
-
8441
- case 'ccsid01147':
8442
- case 'cp01147':
8443
- case 'ebcdicfr297euro':
8444
- case 'ibm01147':
8445
- return 'IBM01147';
8446
-
8447
- case 'ccsid01148':
8448
- case 'cp01148':
8449
- case 'ebcdicinternational500euro':
8450
- case 'ibm01148':
8451
- return 'IBM01148';
8452
-
8453
- case 'ccsid01149':
8454
- case 'cp01149':
8455
- case 'ebcdicis871euro':
8456
- case 'ibm01149':
8457
- return 'IBM01149';
8458
-
8459
- case 'cp037':
8460
- case 'csibm037':
8461
- case 'ebcdiccpca':
8462
- case 'ebcdiccpnl':
8463
- case 'ebcdiccpus':
8464
- case 'ebcdiccpwt':
8465
- case 'ibm037':
8466
- return 'IBM037';
8467
-
8468
- case 'cp038':
8469
- case 'csibm038':
8470
- case 'ebcdicint':
8471
- case 'ibm038':
8472
- return 'IBM038';
8473
-
8474
- case 'cp273':
8475
- case 'csibm273':
8476
- case 'ibm273':
8477
- return 'IBM273';
8478
-
8479
- case 'cp274':
8480
- case 'csibm274':
8481
- case 'ebcdicbe':
8482
- case 'ibm274':
8483
- return 'IBM274';
8484
-
8485
- case 'cp275':
8486
- case 'csibm275':
8487
- case 'ebcdicbr':
8488
- case 'ibm275':
8489
- return 'IBM275';
8490
-
8491
- case 'csibm277':
8492
- case 'ebcdiccpdk':
8493
- case 'ebcdiccpno':
8494
- case 'ibm277':
8495
- return 'IBM277';
8496
-
8497
- case 'cp278':
8498
- case 'csibm278':
8499
- case 'ebcdiccpfi':
8500
- case 'ebcdiccpse':
8501
- case 'ibm278':
8502
- return 'IBM278';
8503
-
8504
- case 'cp280':
8505
- case 'csibm280':
8506
- case 'ebcdiccpit':
8507
- case 'ibm280':
8508
- return 'IBM280';
8509
-
8510
- case 'cp281':
8511
- case 'csibm281':
8512
- case 'ebcdicjpe':
8513
- case 'ibm281':
8514
- return 'IBM281';
8515
-
8516
- case 'cp284':
8517
- case 'csibm284':
8518
- case 'ebcdiccpes':
8519
- case 'ibm284':
8520
- return 'IBM284';
8521
-
8522
- case 'cp285':
8523
- case 'csibm285':
8524
- case 'ebcdiccpgb':
8525
- case 'ibm285':
8526
- return 'IBM285';
8527
-
8528
- case 'cp290':
8529
- case 'csibm290':
8530
- case 'ebcdicjpkana':
8531
- case 'ibm290':
8532
- return 'IBM290';
8533
-
8534
- case 'cp297':
8535
- case 'csibm297':
8536
- case 'ebcdiccpfr':
8537
- case 'ibm297':
8538
- return 'IBM297';
8539
-
8540
- case 'cp420':
8541
- case 'csibm420':
8542
- case 'ebcdiccpar1':
8543
- case 'ibm420':
8544
- return 'IBM420';
8545
-
8546
- case 'cp423':
8547
- case 'csibm423':
8548
- case 'ebcdiccpgr':
8549
- case 'ibm423':
8550
- return 'IBM423';
8551
-
8552
- case 'cp424':
8553
- case 'csibm424':
8554
- case 'ebcdiccphe':
8555
- case 'ibm424':
8556
- return 'IBM424';
8557
-
8558
- case '437':
8559
- case 'cp437':
8560
- case 'cspc8codepage437':
8561
- case 'ibm437':
8562
- return 'IBM437';
8563
-
8564
- case 'cp500':
8565
- case 'csibm500':
8566
- case 'ebcdiccpbe':
8567
- case 'ebcdiccpch':
8568
- case 'ibm500':
8569
- return 'IBM500';
8570
-
8571
- case 'cp775':
8572
- case 'cspc775baltic':
8573
- case 'ibm775':
8574
- return 'IBM775';
8575
-
8576
- case '850':
8577
- case 'cp850':
8578
- case 'cspc850multilingual':
8579
- case 'ibm850':
8580
- return 'IBM850';
8581
-
8582
- case '851':
8583
- case 'cp851':
8584
- case 'csibm851':
8585
- case 'ibm851':
8586
- return 'IBM851';
8587
-
8588
- case '852':
8589
- case 'cp852':
8590
- case 'cspcp852':
8591
- case 'ibm852':
8592
- return 'IBM852';
8593
-
8594
- case '855':
8595
- case 'cp855':
8596
- case 'csibm855':
8597
- case 'ibm855':
8598
- return 'IBM855';
8599
-
8600
- case '857':
8601
- case 'cp857':
8602
- case 'csibm857':
8603
- case 'ibm857':
8604
- return 'IBM857';
8605
-
8606
- case '860':
8607
- case 'cp860':
8608
- case 'csibm860':
8609
- case 'ibm860':
8610
- return 'IBM860';
8611
-
8612
- case '861':
8613
- case 'cpis':
8614
- case 'cp861':
8615
- case 'csibm861':
8616
- case 'ibm861':
8617
- return 'IBM861';
8618
-
8619
- case '862':
8620
- case 'cp862':
8621
- case 'cspc862latinhebrew':
8622
- case 'ibm862':
8623
- return 'IBM862';
8624
-
8625
- case '863':
8626
- case 'cp863':
8627
- case 'csibm863':
8628
- case 'ibm863':
8629
- return 'IBM863';
8630
-
8631
- case 'cp864':
8632
- case 'csibm864':
8633
- case 'ibm864':
8634
- return 'IBM864';
8635
-
8636
- case '865':
8637
- case 'cp865':
8638
- case 'csibm865':
8639
- case 'ibm865':
8640
- return 'IBM865';
8641
-
8642
- case '866':
8643
- case 'cp866':
8644
- case 'csibm866':
8645
- case 'ibm866':
8646
- return 'IBM866';
8647
-
8648
- case 'cpar':
8649
- case 'cp868':
8650
- case 'csibm868':
8651
- case 'ibm868':
8652
- return 'IBM868';
8653
-
8654
- case '869':
8655
- case 'cpgr':
8656
- case 'cp869':
8657
- case 'csibm869':
8658
- case 'ibm869':
8659
- return 'IBM869';
8660
-
8661
- case 'cp870':
8662
- case 'csibm870':
8663
- case 'ebcdiccproece':
8664
- case 'ebcdiccpyu':
8665
- case 'ibm870':
8666
- return 'IBM870';
8667
-
8668
- case 'cp871':
8669
- case 'csibm871':
8670
- case 'ebcdiccpis':
8671
- case 'ibm871':
8672
- return 'IBM871';
8673
-
8674
- case 'cp880':
8675
- case 'csibm880':
8676
- case 'ebcdiccyrillic':
8677
- case 'ibm880':
8678
- return 'IBM880';
8679
-
8680
- case 'cp891':
8681
- case 'csibm891':
8682
- case 'ibm891':
8683
- return 'IBM891';
8684
-
8685
- case 'cp903':
8686
- case 'csibm903':
8687
- case 'ibm903':
8688
- return 'IBM903';
8689
-
8690
- case '904':
8691
- case 'cp904':
8692
- case 'csibbm904':
8693
- case 'ibm904':
8694
- return 'IBM904';
8695
-
8696
- case 'cp905':
8697
- case 'csibm905':
8698
- case 'ebcdiccptr':
8699
- case 'ibm905':
8700
- return 'IBM905';
8701
-
8702
- case 'cp918':
8703
- case 'csibm918':
8704
- case 'ebcdiccpar2':
8705
- case 'ibm918':
8706
- return 'IBM918';
8707
-
8708
- case 'cp1026':
8709
- case 'csibm1026':
8710
- case 'ibm1026':
8711
- return 'IBM1026';
8712
-
8713
- case 'ibm1047':
8714
- case 'ibm1047':
8715
- return 'IBM1047';
8716
-
8717
- case 'csiso143iecp271':
8718
- case 'iecp271':
8719
- case 'isoir143':
8720
- return 'IEC_P27-1';
8721
-
8722
- case 'csiso49inis':
8723
- case 'inis':
8724
- case 'isoir49':
8725
- return 'INIS';
8726
-
8727
- case 'csiso50inis8':
8728
- case 'inis8':
8729
- case 'isoir50':
8730
- return 'INIS-8';
8731
-
8732
- case 'csiso51iniscyrillic':
8733
- case 'iniscyrillic':
8734
- case 'isoir51':
8735
- return 'INIS-cyrillic';
8736
-
8737
- case 'csinvariant':
8738
- case 'invariant':
8739
- return 'INVARIANT';
8740
-
8741
- case 'iso2022cn':
8742
- return 'ISO-2022-CN';
8743
-
8744
- case 'iso2022cnext':
8745
- return 'ISO-2022-CN-EXT';
8746
-
8747
- case 'csiso2022jp':
8748
- case 'iso2022jp':
8749
- return 'ISO-2022-JP';
8750
-
8751
- case 'csiso2022jp2':
8752
- case 'iso2022jp2':
8753
- return 'ISO-2022-JP-2';
8754
-
8755
- case 'csiso2022kr':
8756
- case 'iso2022kr':
8757
- return 'ISO-2022-KR';
8758
-
8759
- case 'cswindows30latin1':
8760
- case 'iso88591windows30latin1':
8761
- return 'ISO-8859-1-Windows-3.0-Latin-1';
8762
-
8763
- case 'cswindows31latin1':
8764
- case 'iso88591windows31latin1':
8765
- return 'ISO-8859-1-Windows-3.1-Latin-1';
8766
-
8767
- case 'csisolatin2':
8768
- case 'iso88592':
8769
- case 'isoir101':
8770
- case 'iso88592':
8771
- case 'iso885921987':
8772
- case 'l2':
8773
- case 'latin2':
8774
- return 'ISO-8859-2';
8775
-
8776
- case 'cswindows31latin2':
8777
- case 'iso88592windowslatin2':
8778
- return 'ISO-8859-2-Windows-Latin-2';
8779
-
8780
- case 'csisolatin3':
8781
- case 'iso88593':
8782
- case 'isoir109':
8783
- case 'iso88593':
8784
- case 'iso885931988':
8785
- case 'l3':
8786
- case 'latin3':
8787
- return 'ISO-8859-3';
8788
-
8789
- case 'csisolatin4':
8790
- case 'iso88594':
8791
- case 'isoir110':
8792
- case 'iso88594':
8793
- case 'iso885941988':
8794
- case 'l4':
8795
- case 'latin4':
8796
- return 'ISO-8859-4';
8797
-
8798
- case 'csisolatincyrillic':
8799
- case 'cyrillic':
8800
- case 'iso88595':
8801
- case 'isoir144':
8802
- case 'iso88595':
8803
- case 'iso885951988':
8804
- return 'ISO-8859-5';
8805
-
8806
- case 'arabic':
8807
- case 'asmo708':
8808
- case 'csisolatinarabic':
8809
- case 'ecma114':
8810
- case 'iso88596':
8811
- case 'isoir127':
8812
- case 'iso88596':
8813
- case 'iso885961987':
8814
- return 'ISO-8859-6';
8815
-
8816
- case 'csiso88596e':
8817
- case 'iso88596e':
8818
- case 'iso88596e':
8819
- return 'ISO-8859-6-E';
8820
-
8821
- case 'csiso88596i':
8822
- case 'iso88596i':
8823
- case 'iso88596i':
8824
- return 'ISO-8859-6-I';
8825
-
8826
- case 'csisolatingreek':
8827
- case 'ecma118':
8828
- case 'elot928':
8829
- case 'greek':
8830
- case 'greek8':
8831
- case 'iso88597':
8832
- case 'isoir126':
8833
- case 'iso88597':
8834
- case 'iso885971987':
8835
- return 'ISO-8859-7';
8836
-
8837
- case 'csisolatinhebrew':
8838
- case 'hebrew':
8839
- case 'iso88598':
8840
- case 'isoir138':
8841
- case 'iso88598':
8842
- case 'iso885981988':
8843
- return 'ISO-8859-8';
8844
-
8845
- case 'csiso88598e':
8846
- case 'iso88598e':
8847
- case 'iso88598e':
8848
- return 'ISO-8859-8-E';
8849
-
8850
- case 'csiso88598i':
8851
- case 'iso88598i':
8852
- case 'iso88598i':
8853
- return 'ISO-8859-8-I';
8854
-
8855
- case 'cswindows31latin5':
8856
- case 'iso88599windowslatin5':
8857
- return 'ISO-8859-9-Windows-Latin-5';
8858
-
8859
- case 'csisolatin6':
8860
- case 'iso885910':
8861
- case 'isoir157':
8862
- case 'iso8859101992':
8863
- case 'l6':
8864
- case 'latin6':
8865
- return 'ISO-8859-10';
8866
-
8867
- case 'iso885913':
8868
- return 'ISO-8859-13';
8869
-
8870
- case 'iso885914':
8871
- case 'isoceltic':
8872
- case 'isoir199':
8873
- case 'iso885914':
8874
- case 'iso8859141998':
8875
- case 'l8':
8876
- case 'latin8':
8877
- return 'ISO-8859-14';
8878
-
8879
- case 'iso885915':
8880
- case 'iso885915':
8881
- case 'latin9':
8882
- return 'ISO-8859-15';
8883
-
8884
- case 'iso885916':
8885
- case 'isoir226':
8886
- case 'iso885916':
8887
- case 'iso8859162001':
8888
- case 'l10':
8889
- case 'latin10':
8890
- return 'ISO-8859-16';
8891
-
8892
- case 'iso10646j1':
8893
- return 'ISO-10646-J-1';
8894
-
8895
- case 'csunicode':
8896
- case 'iso10646ucs2':
8897
- return 'ISO-10646-UCS-2';
8898
-
8899
- case 'csucs4':
8900
- case 'iso10646ucs4':
8901
- return 'ISO-10646-UCS-4';
8902
-
8903
- case 'csunicodeascii':
8904
- case 'iso10646ucsbasic':
8905
- return 'ISO-10646-UCS-Basic';
8906
-
8907
- case 'csunicodelatin1':
8908
- case 'iso10646':
8909
- case 'iso10646unicodelatin1':
8910
- return 'ISO-10646-Unicode-Latin1';
8911
-
8912
- case 'csiso10646utf1':
8913
- case 'iso10646utf1':
8914
- return 'ISO-10646-UTF-1';
8915
-
8916
- case 'csiso115481':
8917
- case 'iso115481':
8918
- case 'iso115481':
8919
- case 'isotr115481':
8920
- return 'ISO-11548-1';
8921
-
8922
- case 'csiso90':
8923
- case 'isoir90':
8924
- return 'iso-ir-90';
8925
-
8926
- case 'csunicodeibm1261':
8927
- case 'isounicodeibm1261':
8928
- return 'ISO-Unicode-IBM-1261';
8929
-
8930
- case 'csunicodeibm1264':
8931
- case 'isounicodeibm1264':
8932
- return 'ISO-Unicode-IBM-1264';
8933
-
8934
- case 'csunicodeibm1265':
8935
- case 'isounicodeibm1265':
8936
- return 'ISO-Unicode-IBM-1265';
8937
-
8938
- case 'csunicodeibm1268':
8939
- case 'isounicodeibm1268':
8940
- return 'ISO-Unicode-IBM-1268';
8941
-
8942
- case 'csunicodeibm1276':
8943
- case 'isounicodeibm1276':
8944
- return 'ISO-Unicode-IBM-1276';
8945
-
8946
- case 'csiso646basic1983':
8947
- case 'iso646basic1983':
8948
- case 'ref':
8949
- return 'ISO_646.basic:1983';
8950
-
8951
- case 'csiso2intlrefversion':
8952
- case 'irv':
8953
- case 'isoir2':
8954
- case 'iso646irv1983':
8955
- return 'ISO_646.irv:1983';
8956
-
8957
- case 'csiso2033':
8958
- case 'e13b':
8959
- case 'isoir98':
8960
- case 'iso20331983':
8961
- return 'ISO_2033-1983';
8962
-
8963
- case 'csiso5427cyrillic':
8964
- case 'isoir37':
8965
- case 'iso5427':
8966
- return 'ISO_5427';
8967
-
8968
- case 'isoir54':
8969
- case 'iso5427cyrillic1981':
8970
- case 'iso54271981':
8971
- return 'ISO_5427:1981';
8972
-
8973
- case 'csiso5428greek':
8974
- case 'isoir55':
8975
- case 'iso54281980':
8976
- return 'ISO_5428:1980';
8977
-
8978
- case 'csiso6937add':
8979
- case 'isoir152':
8980
- case 'iso6937225':
8981
- return 'ISO_6937-2-25';
8982
-
8983
- case 'csisotextcomm':
8984
- case 'isoir142':
8985
- case 'iso69372add':
8986
- return 'ISO_6937-2-add';
8987
-
8988
- case 'csiso8859supp':
8989
- case 'isoir154':
8990
- case 'iso8859supp':
8991
- case 'latin125':
8992
- return 'ISO_8859-supp';
8993
-
8994
- case 'csiso10367box':
8995
- case 'isoir155':
8996
- case 'iso10367box':
8997
- return 'ISO_10367-box';
8998
-
8999
- case 'csiso15italian':
9000
- case 'isoir15':
9001
- case 'iso646it':
9002
- case 'it':
9003
- return 'IT';
9004
-
9005
- case 'csiso13jisc6220jp':
9006
- case 'isoir13':
9007
- case 'jisc62201969':
9008
- case 'jisc62201969jp':
9009
- case 'katakana':
9010
- case 'x02017':
9011
- return 'JIS_C6220-1969-jp';
9012
-
9013
- case 'csiso14jisc6220ro':
9014
- case 'isoir14':
9015
- case 'iso646jp':
9016
- case 'jisc62201969ro':
9017
- case 'jp':
9018
- return 'JIS_C6220-1969-ro';
9019
-
9020
- case 'csiso42jisc62261978':
9021
- case 'isoir42':
9022
- case 'jisc62261978':
9023
- return 'JIS_C6226-1978';
9024
-
9025
- case 'csiso87jisx0208':
9026
- case 'isoir87':
9027
- case 'jisc62261983':
9028
- case 'jisx02081983':
9029
- case 'x0208':
9030
- return 'JIS_C6226-1983';
9031
-
9032
- case 'csiso91jisc62291984a':
9033
- case 'isoir91':
9034
- case 'jisc62291984a':
9035
- case 'jpocra':
9036
- return 'JIS_C6229-1984-a';
9037
-
9038
- case 'csiso92jisc62991984b':
9039
- case 'isoir92':
9040
- case 'iso646jpocrb':
9041
- case 'jisc62291984b':
9042
- case 'jpocrb':
9043
- return 'JIS_C6229-1984-b';
9044
-
9045
- case 'csiso93jis62291984badd':
9046
- case 'isoir93':
9047
- case 'jisc62291984badd':
9048
- case 'jpocrbadd':
9049
- return 'JIS_C6229-1984-b-add';
9050
-
9051
- case 'csiso94jis62291984hand':
9052
- case 'isoir94':
9053
- case 'jisc62291984hand':
9054
- case 'jpocrhand':
9055
- return 'JIS_C6229-1984-hand';
9056
-
9057
- case 'csiso95jis62291984handadd':
9058
- case 'isoir95':
9059
- case 'jisc62291984handadd':
9060
- case 'jpocrhandadd':
9061
- return 'JIS_C6229-1984-hand-add';
9062
-
9063
- case 'csiso96jisc62291984kana':
9064
- case 'isoir96':
9065
- case 'jisc62291984kana':
9066
- return 'JIS_C6229-1984-kana';
9067
-
9068
- case 'csjisencoding':
9069
- case 'jisencoding':
9070
- return 'JIS_Encoding';
9071
-
9072
- case 'cshalfwidthkatakana':
9073
- case 'jisx0201':
9074
- case 'x0201':
9075
- return 'JIS_X0201';
9076
-
9077
- case 'csiso159jisx02121990':
9078
- case 'isoir159':
9079
- case 'jisx02121990':
9080
- case 'x0212':
9081
- return 'JIS_X0212-1990';
9082
-
9083
- case 'csiso141jusib1002':
9084
- case 'isoir141':
9085
- case 'iso646yu':
9086
- case 'js':
9087
- case 'jusib1002':
9088
- case 'yu':
9089
- return 'JUS_I.B1.002';
9090
-
9091
- case 'csiso147macedonian':
9092
- case 'isoir147':
9093
- case 'jusib1003mac':
9094
- case 'macedonian':
9095
- return 'JUS_I.B1.003-mac';
9096
-
9097
- case 'csiso146serbian':
9098
- case 'isoir146':
9099
- case 'jusib1003serb':
9100
- case 'serbian':
9101
- return 'JUS_I.B1.003-serb';
9102
-
9103
- case 'koi7switched':
9104
- return 'KOI7-switched';
9105
-
9106
- case 'cskoi8r':
9107
- case 'koi8r':
9108
- return 'KOI8-R';
9109
-
9110
- case 'koi8u':
9111
- return 'KOI8-U';
9112
-
9113
- case 'csksc5636':
9114
- case 'iso646kr':
9115
- case 'ksc5636':
9116
- return 'KSC5636';
9117
-
9118
- case 'cskz1048':
9119
- case 'kz1048':
9120
- case 'rk1048':
9121
- case 'strk10482002':
9122
- return 'KZ-1048';
9123
-
9124
- case 'csiso19latingreek':
9125
- case 'isoir19':
9126
- case 'latingreek':
9127
- return 'latin-greek';
9128
-
9129
- case 'csiso27latingreek1':
9130
- case 'isoir27':
9131
- case 'latingreek1':
9132
- return 'Latin-greek-1';
9133
-
9134
- case 'csiso158lap':
9135
- case 'isoir158':
9136
- case 'lap':
9137
- case 'latinlap':
9138
- return 'latin-lap';
9139
-
9140
- case 'csmacintosh':
9141
- case 'mac':
9142
- case 'macintosh':
9143
- return 'macintosh';
9144
-
9145
- case 'csmicrosoftpublishing':
9146
- case 'microsoftpublishing':
9147
- return 'Microsoft-Publishing';
9148
-
9149
- case 'csmnem':
9150
- case 'mnem':
9151
- return 'MNEM';
9152
-
9153
- case 'csmnemonic':
9154
- case 'mnemonic':
9155
- return 'MNEMONIC';
9156
-
9157
- case 'csiso86hungarian':
9158
- case 'hu':
9159
- case 'isoir86':
9160
- case 'iso646hu':
9161
- case 'msz77953':
9162
- return 'MSZ_7795.3';
9163
-
9164
- case 'csnatsdano':
9165
- case 'isoir91':
9166
- case 'natsdano':
9167
- return 'NATS-DANO';
9168
-
9169
- case 'csnatsdanoadd':
9170
- case 'isoir92':
9171
- case 'natsdanoadd':
9172
- return 'NATS-DANO-ADD';
9173
-
9174
- case 'csnatssefi':
9175
- case 'isoir81':
9176
- case 'natssefi':
9177
- return 'NATS-SEFI';
9178
-
9179
- case 'csnatssefiadd':
9180
- case 'isoir82':
9181
- case 'natssefiadd':
9182
- return 'NATS-SEFI-ADD';
9183
-
9184
- case 'csiso151cuba':
9185
- case 'cuba':
9186
- case 'isoir151':
9187
- case 'iso646cu':
9188
- case 'ncnc001081':
9189
- return 'NC_NC00-10:81';
9190
-
9191
- case 'csiso69french':
9192
- case 'fr':
9193
- case 'isoir69':
9194
- case 'iso646fr':
9195
- case 'nfz62010':
9196
- return 'NF_Z_62-010';
9197
-
9198
- case 'csiso25french':
9199
- case 'isoir25':
9200
- case 'iso646fr1':
9201
- case 'nfz620101973':
9202
- return 'NF_Z_62-010_(1973)';
9203
-
9204
- case 'csiso60danishnorwegian':
9205
- case 'csiso60norwegian1':
9206
- case 'isoir60':
9207
- case 'iso646no':
9208
- case 'no':
9209
- case 'ns45511':
9210
- return 'NS_4551-1';
9211
-
9212
- case 'csiso61norwegian2':
9213
- case 'isoir61':
9214
- case 'iso646no2':
9215
- case 'no2':
9216
- case 'ns45512':
9217
- return 'NS_4551-2';
9218
-
9219
- case 'osdebcdicdf03irv':
9220
- return 'OSD_EBCDIC_DF03_IRV';
9221
-
9222
- case 'osdebcdicdf041':
9223
- return 'OSD_EBCDIC_DF04_1';
9224
-
9225
- case 'osdebcdicdf0415':
9226
- return 'OSD_EBCDIC_DF04_15';
9227
-
9228
- case 'cspc8danishnorwegian':
9229
- case 'pc8danishnorwegian':
9230
- return 'PC8-Danish-Norwegian';
9231
-
9232
- case 'cspc8turkish':
9233
- case 'pc8turkish':
9234
- return 'PC8-Turkish';
9235
-
9236
- case 'csiso16portuguese':
9237
- case 'isoir16':
9238
- case 'iso646pt':
9239
- case 'pt':
9240
- return 'PT';
9241
-
9242
- case 'csiso84portuguese2':
9243
- case 'isoir84':
9244
- case 'iso646pt2':
9245
- case 'pt2':
9246
- return 'PT2';
9247
-
9248
- case 'cp154':
9249
- case 'csptcp154':
9250
- case 'cyrillicasian':
9251
- case 'pt154':
9252
- case 'ptcp154':
9253
- return 'PTCP154';
9254
-
9255
- case 'scsu':
9256
- return 'SCSU';
9257
-
9258
- case 'csiso10swedish':
9259
- case 'fi':
9260
- case 'isoir10':
9261
- case 'iso646fi':
9262
- case 'iso646se':
9263
- case 'se':
9264
- case 'sen850200b':
9265
- return 'SEN_850200_B';
9266
-
9267
- case 'csiso11swedishfornames':
9268
- case 'isoir11':
9269
- case 'iso646se2':
9270
- case 'se2':
9271
- case 'sen850200c':
9272
- return 'SEN_850200_C';
9273
-
9274
- case 'csshiftjis':
9275
- case 'mskanji':
9276
- case 'shiftjis':
9277
- return 'Shift_JIS';
9278
-
9279
- case 'csiso102t617bit':
9280
- case 'isoir102':
9281
- case 't617bit':
9282
- return 'T.61-7bit';
9283
-
9284
- case 'csiso103t618bit':
9285
- case 'isoir103':
9286
- case 't61':
9287
- case 't618bit':
9288
- return 'T.61-8bit';
9289
-
9290
- case 'csiso128t101g2':
9291
- case 'isoir128':
9292
- case 't101g2':
9293
- return 'T.101-G2';
9294
-
9295
- case 'cstscii':
9296
- case 'tscii':
9297
- return 'TSCII';
9298
-
9299
- case 'csunicode11':
9300
- case 'unicode11':
9301
- return 'UNICODE-1-1';
9302
-
9303
- case 'csunicode11utf7':
9304
- case 'unicode11utf7':
9305
- return 'UNICODE-1-1-UTF-7';
9306
-
9307
- case 'csunknown8bit':
9308
- case 'unknown8bit':
9309
- return 'UNKNOWN-8BIT';
9310
-
9311
- case 'ansix341968':
9312
- case 'ansix341986':
9313
- case 'ascii':
9314
- case 'cp367':
9315
- case 'csascii':
9316
- case 'ibm367':
9317
- case 'isoir6':
9318
- case 'iso646us':
9319
- case 'iso646irv1991':
9320
- case 'us':
9321
- case 'usascii':
9322
- return 'US-ASCII';
9323
-
9324
- case 'csusdk':
9325
- case 'usdk':
9326
- return 'us-dk';
9327
-
9328
- case 'utf7':
9329
- return 'UTF-7';
9330
-
9331
- case 'utf8':
9332
- return 'UTF-8';
9333
-
9334
- case 'utf16':
9335
- return 'UTF-16';
9336
-
9337
- case 'utf16be':
9338
- return 'UTF-16BE';
9339
-
9340
- case 'utf16le':
9341
- return 'UTF-16LE';
9342
-
9343
- case 'utf32':
9344
- return 'UTF-32';
9345
-
9346
- case 'utf32be':
9347
- return 'UTF-32BE';
9348
-
9349
- case 'utf32le':
9350
- return 'UTF-32LE';
9351
-
9352
- case 'csventurainternational':
9353
- case 'venturainternational':
9354
- return 'Ventura-International';
9355
-
9356
- case 'csventuramath':
9357
- case 'venturamath':
9358
- return 'Ventura-Math';
9359
-
9360
- case 'csventuraus':
9361
- case 'venturaus':
9362
- return 'Ventura-US';
9363
-
9364
- case 'csiso70videotexsupp1':
9365
- case 'isoir70':
9366
- case 'videotexsuppl':
9367
- return 'videotex-suppl';
9368
-
9369
- case 'csviqr':
9370
- case 'viqr':
9371
- return 'VIQR';
9372
-
9373
- case 'csviscii':
9374
- case 'viscii':
9375
- return 'VISCII';
9376
-
9377
- case 'cswindows31j':
9378
- case 'windows31j':
9379
- return 'Windows-31J';
9380
-
9381
- case 'iso885911':
9382
- case 'tis620':
9383
- return 'Windows-874';
9384
-
9385
- case 'cseuckr':
9386
- case 'euckr':
9387
- case 'windows949':
9388
- case 'csksc56011987':
9389
- case 'isoir149':
9390
- case 'korean':
9391
- case 'ksc5601':
9392
- case 'ksc56011987':
9393
- case 'ksc56011989':
9394
- return 'Windows-949';
9395
-
9396
- case 'windows1250':
9397
- return 'windows-1250';
9398
-
9399
- case 'windows1251':
9400
- return 'windows-1251';
9401
-
9402
- case 'cp819':
9403
- case 'csisolatin1':
9404
- case 'ibm819':
9405
- case 'iso88591':
9406
- case 'isoir100':
9407
- case 'iso885911987':
9408
- case 'l1':
9409
- case 'latin1':
9410
- case 'windows1252':
9411
- return 'Windows-1252';
9412
-
9413
- case 'windows1252':
9414
- return 'windows-1252';
9415
-
9416
- case 'windows1253':
9417
- return 'windows-1253';
9418
-
9419
- case 'csisolatin5':
9420
- case 'iso88599':
9421
- case 'isoir148':
9422
- case 'iso885991989':
9423
- case 'l5':
9424
- case 'latin5':
9425
- case 'windows1254':
9426
- return 'Windows-1254';
9427
-
9428
- case 'windows1254':
9429
- return 'windows-1254';
9430
-
9431
- case 'windows1255':
9432
- return 'windows-1255';
9433
-
9434
- case 'windows1256':
9435
- return 'windows-1256';
9436
-
9437
- case 'windows1257':
9438
- return 'windows-1257';
9439
-
9440
- case 'windows1258':
9441
- return 'windows-1258';
9442
-
9443
- default:
9444
- return $charset;
9445
- }
9446
- }
9447
-
9448
- function get_curl_version()
9449
- {
9450
- if (is_array($curl = curl_version()))
9451
- {
9452
- $curl = $curl['version'];
9453
- }
9454
- elseif (substr($curl, 0, 5) == 'curl/')
9455
- {
9456
- $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
9457
- }
9458
- elseif (substr($curl, 0, 8) == 'libcurl/')
9459
- {
9460
- $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
9461
- }
9462
- else
9463
- {
9464
- $curl = 0;
9465
- }
9466
- return $curl;
9467
- }
9468
-
9469
- function is_subclass_of($class1, $class2)
9470
- {
9471
- if (func_num_args() != 2)
9472
- {
9473
- trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
9474
- }
9475
- elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1))
9476
- {
9477
- return is_subclass_of($class1, $class2);
9478
- }
9479
- elseif (is_string($class1) && is_string($class2))
9480
- {
9481
- if (class_exists($class1))
9482
- {
9483
- if (class_exists($class2))
9484
- {
9485
- $class2 = strtolower($class2);
9486
- while ($class1 = strtolower(get_parent_class($class1)))
9487
- {
9488
- if ($class1 == $class2)
9489
- {
9490
- return true;
9491
- }
9492
- }
9493
- }
9494
- }
9495
- else
9496
- {
9497
- trigger_error('Unknown class passed as parameter', E_USER_WARNNG);
9498
- }
9499
- }
9500
- return false;
9501
- }
9502
-
9503
- /**
9504
- * Strip HTML comments
9505
- *
9506
- * @access public
9507
- * @param string $data Data to strip comments from
9508
- * @return string Comment stripped string
9509
- */
9510
- function strip_comments($data)
9511
- {
9512
- $output = '';
9513
- while (($start = strpos($data, '<!--')) !== false)
9514
- {
9515
- $output .= substr($data, 0, $start);
9516
- if (($end = strpos($data, '-->', $start)) !== false)
9517
- {
9518
- $data = substr_replace($data, '', 0, $end + 3);
9519
- }
9520
- else
9521
- {
9522
- $data = '';
9523
- }
9524
- }
9525
- return $output . $data;
9526
- }
9527
-
9528
- function parse_date($dt)
9529
- {
9530
- $parser = SimplePie_Parse_Date::get();
9531
- return $parser->parse($dt);
9532
- }
9533
-
9534
- /**
9535
- * Decode HTML entities
9536
- *
9537
- * @static
9538
- * @access public
9539
- * @param string $data Input data
9540
- * @return string Output data
9541
- */
9542
- function entities_decode($data)
9543
- {
9544
- $decoder = new SimplePie_Decode_HTML_Entities($data);
9545
- return $decoder->parse();
9546
- }
9547
-
9548
- /**
9549
- * Remove RFC822 comments
9550
- *
9551
- * @access public
9552
- * @param string $data Data to strip comments from
9553
- * @return string Comment stripped string
9554
- */
9555
- function uncomment_rfc822($string)
9556
- {
9557
- $string = (string) $string;
9558
- $position = 0;
9559
- $length = strlen($string);
9560
- $depth = 0;
9561
-
9562
- $output = '';
9563
-
9564
- while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
9565
- {
9566
- $output .= substr($string, $position, $pos - $position);
9567
- $position = $pos + 1;
9568
- if ($string[$pos - 1] !== '\\')
9569
- {
9570
- $depth++;
9571
- while ($depth && $position < $length)
9572
- {
9573
- $position += strcspn($string, '()', $position);
9574
- if ($string[$position - 1] === '\\')
9575
- {
9576
- $position++;
9577
- continue;
9578
- }
9579
- elseif (isset($string[$position]))
9580
- {
9581
- switch ($string[$position])
9582
- {
9583
- case '(':
9584
- $depth++;
9585
- break;
9586
-
9587
- case ')':
9588
- $depth--;
9589
- break;
9590
- }
9591
- $position++;
9592
- }
9593
- else
9594
- {
9595
- break;
9596
- }
9597
- }
9598
- }
9599
- else
9600
- {
9601
- $output .= '(';
9602
- }
9603
- }
9604
- $output .= substr($string, $position);
9605
-
9606
- return $output;
9607
- }
9608
-
9609
- function parse_mime($mime)
9610
- {
9611
- if (($pos = strpos($mime, ';')) === false)
9612
- {
9613
- return trim($mime);
9614
- }
9615
- else
9616
- {
9617
- return trim(substr($mime, 0, $pos));
9618
- }
9619
- }
9620
-
9621
- function htmlspecialchars_decode($string, $quote_style)
9622
- {
9623
- if (function_exists('htmlspecialchars_decode'))
9624
- {
9625
- return htmlspecialchars_decode($string, $quote_style);
9626
- }
9627
- else
9628
- {
9629
- return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
9630
- }
9631
- }
9632
-
9633
- function atom_03_construct_type($attribs)
9634
- {
9635
- if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) == 'base64'))
9636
- {
9637
- $mode = SIMPLEPIE_CONSTRUCT_BASE64;
9638
- }
9639
- else
9640
- {
9641
- $mode = SIMPLEPIE_CONSTRUCT_NONE;
9642
- }
9643
- if (isset($attribs['']['type']))
9644
- {
9645
- switch (strtolower(trim($attribs['']['type'])))
9646
- {
9647
- case 'text':
9648
- case 'text/plain':
9649
- return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
9650
-
9651
- case 'html':
9652
- case 'text/html':
9653
- return SIMPLEPIE_CONSTRUCT_HTML | $mode;
9654
-
9655
- case 'xhtml':
9656
- case 'application/xhtml+xml':
9657
- return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
9658
-
9659
- default:
9660
- return SIMPLEPIE_CONSTRUCT_NONE | $mode;
9661
- }
9662
- }
9663
- else
9664
- {
9665
- return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
9666
- }
9667
- }
9668
-
9669
- function atom_10_construct_type($attribs)
9670
- {
9671
- if (isset($attribs['']['type']))
9672
- {
9673
- switch (strtolower(trim($attribs['']['type'])))
9674
- {
9675
- case 'text':
9676
- return SIMPLEPIE_CONSTRUCT_TEXT;
9677
-
9678
- case 'html':
9679
- return SIMPLEPIE_CONSTRUCT_HTML;
9680
-
9681
- case 'xhtml':
9682
- return SIMPLEPIE_CONSTRUCT_XHTML;
9683
-
9684
- default:
9685
- return SIMPLEPIE_CONSTRUCT_NONE;
9686
- }
9687
- }
9688
- return SIMPLEPIE_CONSTRUCT_TEXT;
9689
- }
9690
-
9691
- function atom_10_content_construct_type($attribs)
9692
- {
9693
- if (isset($attribs['']['type']))
9694
- {
9695
- $type = strtolower(trim($attribs['']['type']));
9696
- switch ($type)
9697
- {
9698
- case 'text':
9699
- return SIMPLEPIE_CONSTRUCT_TEXT;
9700
-
9701
- case 'html':
9702
- return SIMPLEPIE_CONSTRUCT_HTML;
9703
-
9704
- case 'xhtml':
9705
- return SIMPLEPIE_CONSTRUCT_XHTML;
9706
- }
9707
- if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) == 'text/')
9708
- {
9709
- return SIMPLEPIE_CONSTRUCT_NONE;
9710
- }
9711
- else
9712
- {
9713
- return SIMPLEPIE_CONSTRUCT_BASE64;
9714
- }
9715
- }
9716
- else
9717
- {
9718
- return SIMPLEPIE_CONSTRUCT_TEXT;
9719
- }
9720
- }
9721
-
9722
- function is_isegment_nz_nc($string)
9723
- {
9724
- return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
9725
- }
9726
-
9727
- function space_seperated_tokens($string)
9728
- {
9729
- $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
9730
- $string_length = strlen($string);
9731
-
9732
- $position = strspn($string, $space_characters);
9733
- $tokens = array();
9734
-
9735
- while ($position < $string_length)
9736
- {
9737
- $len = strcspn($string, $space_characters, $position);
9738
- $tokens[] = substr($string, $position, $len);
9739
- $position += $len;
9740
- $position += strspn($string, $space_characters, $position);
9741
- }
9742
-
9743
- return $tokens;
9744
- }
9745
-
9746
- function array_unique($array)
9747
- {
9748
- if (version_compare(PHP_VERSION, '5.2', '>='))
9749
- {
9750
- return array_unique($array);
9751
- }
9752
- else
9753
- {
9754
- $array = (array) $array;
9755
- $new_array = array();
9756
- $new_array_strings = array();
9757
- foreach ($array as $key => $value)
9758
- {
9759
- if (is_object($value))
9760
- {
9761
- if (method_exists($value, '__toString'))
9762
- {
9763
- $cmp = $value->__toString();
9764
- }
9765
- else
9766
- {
9767
- trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR);
9768
- }
9769
- }
9770
- elseif (is_array($value))
9771
- {
9772
- $cmp = (string) reset($value);
9773
- }
9774
- else
9775
- {
9776
- $cmp = (string) $value;
9777
- }
9778
- if (!in_array($cmp, $new_array_strings))
9779
- {
9780
- $new_array[$key] = $value;
9781
- $new_array_strings[] = $cmp;
9782
- }
9783
- }
9784
- return $new_array;
9785
- }
9786
- }
9787
-
9788
- /**
9789
- * Converts a unicode codepoint to a UTF-8 character
9790
- *
9791
- * @static
9792
- * @access public
9793
- * @param int $codepoint Unicode codepoint
9794
- * @return string UTF-8 character
9795
- */
9796
- function codepoint_to_utf8($codepoint)
9797
- {
9798
- static $cache = array();
9799
- $codepoint = (int) $codepoint;
9800
- if (isset($cache[$codepoint]))
9801
- {
9802
- return $cache[$codepoint];
9803
- }
9804
- elseif ($codepoint < 0)
9805
- {
9806
- return $cache[$codepoint] = false;
9807
- }
9808
- else if ($codepoint <= 0x7f)
9809
- {
9810
- return $cache[$codepoint] = chr($codepoint);
9811
- }
9812
- else if ($codepoint <= 0x7ff)
9813
- {
9814
- return $cache[$codepoint] = chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
9815
- }
9816
- else if ($codepoint <= 0xffff)
9817
- {
9818
- return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
9819
- }
9820
- else if ($codepoint <= 0x10ffff)
9821
- {
9822
- return $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
9823
- }
9824
- else
9825
- {
9826
- // U+FFFD REPLACEMENT CHARACTER
9827
- return $cache[$codepoint] = "\xEF\xBF\xBD";
9828
- }
9829
- }
9830
-
9831
- /**
9832
- * Re-implementation of PHP 5's stripos()
9833
- *
9834
- * Returns the numeric position of the first occurrence of needle in the
9835
- * haystack string.
9836
- *
9837
- * @static
9838
- * @access string
9839
- * @param object $haystack
9840
- * @param string $needle Note that the needle may be a string of one or more
9841
- * characters. If needle is not a string, it is converted to an integer
9842
- * and applied as the ordinal value of a character.
9843
- * @param int $offset The optional offset parameter allows you to specify which
9844
- * character in haystack to start searching. The position returned is still
9845
- * relative to the beginning of haystack.
9846
- * @return bool If needle is not found, stripos() will return boolean false.
9847
- */
9848
- function stripos($haystack, $needle, $offset = 0)
9849
- {
9850
- if (function_exists('stripos'))
9851
- {
9852
- return stripos($haystack, $needle, $offset);
9853
- }
9854
- else
9855
- {
9856
- if (is_string($needle))
9857
- {
9858
- $needle = strtolower($needle);
9859
- }
9860
- elseif (is_int($needle) || is_bool($needle) || is_double($needle))
9861
- {
9862
- $needle = strtolower(chr($needle));
9863
- }
9864
- else
9865
- {
9866
- trigger_error('needle is not a string or an integer', E_USER_WARNING);
9867
- return false;
9868
- }
9869
-
9870
- return strpos(strtolower($haystack), $needle, $offset);
9871
- }
9872
- }
9873
-
9874
- /**
9875
- * Similar to parse_str()
9876
- *
9877
- * Returns an associative array of name/value pairs, where the value is an
9878
- * array of values that have used the same name
9879
- *
9880
- * @static
9881
- * @access string
9882
- * @param string $str The input string.
9883
- * @return array
9884
- */
9885
- function parse_str($str)
9886
- {
9887
- $return = array();
9888
- $str = explode('&', $str);
9889
-
9890
- foreach ($str as $section)
9891
- {
9892
- if (strpos($section, '=') !== false)
9893
- {
9894
- list($name, $value) = explode('=', $section, 2);
9895
- $return[urldecode($name)][] = urldecode($value);
9896
- }
9897
- else
9898
- {
9899
- $return[urldecode($section)][] = null;
9900
- }
9901
- }
9902
-
9903
- return $return;
9904
- }
9905
-
9906
- /**
9907
- * Detect XML encoding, as per XML 1.0 Appendix F.1
9908
- *
9909
- * @todo Add support for EBCDIC
9910
- * @param string $data XML data
9911
- * @return array Possible encodings
9912
- */
9913
- function xml_encoding($data)
9914
- {
9915
- // UTF-32 Big Endian BOM
9916
- if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
9917
- {
9918
- $encoding[] = 'UTF-32BE';
9919
- }
9920
- // UTF-32 Little Endian BOM
9921
- elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
9922
- {
9923
- $encoding[] = 'UTF-32LE';
9924
- }
9925
- // UTF-16 Big Endian BOM
9926
- elseif (substr($data, 0, 2) === "\xFE\xFF")
9927
- {
9928
- $encoding[] = 'UTF-16BE';
9929
- }
9930
- // UTF-16 Little Endian BOM
9931
- elseif (substr($data, 0, 2) === "\xFF\xFE")
9932
- {
9933
- $encoding[] = 'UTF-16LE';
9934
- }
9935
- // UTF-8 BOM
9936
- elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
9937
- {
9938
- $encoding[] = 'UTF-8';
9939
- }
9940
- // UTF-32 Big Endian Without BOM
9941
- elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
9942
- {
9943
- if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
9944
- {
9945
- $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'));
9946
- if ($parser->parse())
9947
- {
9948
- $encoding[] = $parser->encoding;
9949
- }
9950
- }
9951
- $encoding[] = 'UTF-32BE';
9952
- }
9953
- // UTF-32 Little Endian Without BOM
9954
- elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
9955
- {
9956
- if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
9957
- {
9958
- $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'));
9959
- if ($parser->parse())
9960
- {
9961
- $encoding[] = $parser->encoding;
9962
- }
9963
- }
9964
- $encoding[] = 'UTF-32LE';
9965
- }
9966
- // UTF-16 Big Endian Without BOM
9967
- elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
9968
- {
9969
- if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
9970
- {
9971
- $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'));
9972
- if ($parser->parse())
9973
- {
9974
- $encoding[] = $parser->encoding;
9975
- }
9976
- }
9977
- $encoding[] = 'UTF-16BE';
9978
- }
9979
- // UTF-16 Little Endian Without BOM
9980
- elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
9981
- {
9982
- if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
9983
- {
9984
- $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'));
9985
- if ($parser->parse())
9986
- {
9987
- $encoding[] = $parser->encoding;
9988
- }
9989
- }
9990
- $encoding[] = 'UTF-16LE';
9991
- }
9992
- // US-ASCII (or superset)
9993
- elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
9994
- {
9995
- if ($pos = strpos($data, "\x3F\x3E"))
9996
- {
9997
- $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
9998
- if ($parser->parse())
9999
- {
10000
- $encoding[] = $parser->encoding;
10001
- }
10002
- }
10003
- $encoding[] = 'UTF-8';
10004
- }
10005
- // Fallback to UTF-8
10006
- else
10007
- {
10008
- $encoding[] = 'UTF-8';
10009
- }
10010
- return $encoding;
10011
- }
10012
- }
10013
-
10014
- /**
10015
- * Decode HTML Entities
10016
- *
10017
- * This implements HTML5 as of revision 967 (2007-06-28)
10018
- *
10019
- * @package SimplePie
10020
- */
10021
- class SimplePie_Decode_HTML_Entities
10022
- {
10023
- /**
10024
- * Data to be parsed
10025
- *
10026
- * @access private
10027
- * @var string
10028
- */
10029
- var $data = '';
10030
-
10031
- /**
10032
- * Currently consumed bytes
10033
- *
10034
- * @access private
10035
- * @var string
10036
- */
10037
- var $consumed = '';
10038
-
10039
- /**
10040
- * Position of the current byte being parsed
10041
- *
10042
- * @access private
10043
- * @var int
10044
- */
10045
- var $position = 0;
10046
-
10047
- /**
10048
- * Create an instance of the class with the input data
10049
- *
10050
- * @access public
10051
- * @param string $data Input data
10052
- */
10053
- function SimplePie_Decode_HTML_Entities($data)
10054
- {
10055
- $this->data = $data;
10056
- }
10057
-
10058
- /**
10059
- * Parse the input data
10060
- *
10061
- * @access public
10062
- * @return string Output data
10063
- */
10064
- function parse()
10065
- {
10066
- while (($this->position = strpos($this->data, '&', $this->position)) !== false)
10067
- {
10068
- $this->consume();
10069
- $this->entity();
10070
- $this->consumed = '';
10071
- }
10072
- return $this->data;
10073
- }
10074
-
10075
- /**
10076
- * Consume the next byte
10077
- *
10078
- * @access private
10079
- * @return mixed The next byte, or false, if there is no more data
10080
- */
10081
- function consume()
10082
- {
10083
- if (isset($this->data[$this->position]))
10084
- {
10085
- $this->consumed .= $this->data[$this->position];
10086
- return $this->data[$this->position++];
10087
- }
10088
- else
10089
- {
10090
- $this->consumed = false;
10091
- return false;
10092
- }
10093
- }
10094
-
10095
- /**
10096
- * Consume a range of characters
10097
- *
10098
- * @access private
10099
- * @param string $chars Characters to consume
10100
- * @return mixed A series of characters that match the range, or false
10101
- */
10102
- function consume_range($chars)
10103
- {
10104
- if ($len = strspn($this->data, $chars, $this->position))
10105
- {
10106
- $data = substr($this->data, $this->position, $len);
10107
- $this->consumed .= $data;
10108
- $this->position += $len;
10109
- return $data;
10110
- }
10111
- else
10112
- {
10113
- $this->consumed = false;
10114
- return false;
10115
- }
10116
- }
10117
-
10118
- /**
10119
- * Unconsume one byte
10120
- *
10121
- * @access private
10122
- */
10123
- function unconsume()
10124
- {
10125
- $this->consumed = substr($this->consumed, 0, -1);
10126
- $this->position--;
10127
- }
10128
-
10129
- /**
10130
- * Decode an entity
10131
- *
10132
- * @access private
10133
- */
10134
- function entity()
10135
- {
10136
- switch ($this->consume())
10137
- {
10138
- case "\x09":
10139
- case "\x0A":
10140
- case "\x0B":
10141
- case "\x0B":
10142
- case "\x0C":
10143
- case "\x20":
10144
- case "\x3C":
10145
- case "\x26":
10146
- case false:
10147
- break;
10148
-
10149
- case "\x23":
10150
- switch ($this->consume())
10151
- {
10152
- case "\x78":
10153
- case "\x58":
10154
- $range = '0123456789ABCDEFabcdef';
10155
- $hex = true;
10156
- break;
10157
-
10158
- default:
10159
- $range = '0123456789';
10160
- $hex = false;
10161
- $this->unconsume();
10162
- break;
10163
- }
10164
-
10165
- if ($codepoint = $this->consume_range($range))
10166
- {
10167
- static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
10168
-
10169
- if ($hex)
10170
- {
10171
- $codepoint = hexdec($codepoint);
10172
- }
10173
- else
10174
- {
10175
- $codepoint = intval($codepoint);
10176
- }
10177
-
10178
- if (isset($windows_1252_specials[$codepoint]))
10179
- {
10180
- $replacement = $windows_1252_specials[$codepoint];
10181
- }
10182
- else
10183
- {
10184
- $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
10185
- }
10186
-
10187
- if ($this->consume() != ';')
10188
- {
10189
- $this->unconsume();
10190
- }
10191
-
10192
- $consumed_length = strlen($this->consumed);
10193
- $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
10194
- $this->position += strlen($replacement) - $consumed_length;
10195
- }
10196
- break;
10197
-
10198
- default:
10199
- static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C");
10200
-
10201
- for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
10202
- {
10203
- $consumed = substr($this->consumed, 1);
10204
- if (isset($entities[$consumed]))
10205
- {
10206
- $match = $consumed;
10207
- }
10208
- }
10209
-
10210
- if ($match !== null)
10211
- {
10212
- $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
10213
- $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
10214
- }
10215
- break;
10216
- }
10217
- }
10218
- }
10219
-
10220
- /**
10221
- * Date Parser
10222
- *
10223
- * @package SimplePie
10224
- */
10225
- class SimplePie_Parse_Date
10226
- {
10227
- /**
10228
- * Input data
10229
- *
10230
- * @access protected
10231
- * @var string
10232
- */
10233
- var $date;
10234
-
10235
- /**
10236
- * List of days, calendar day name => ordinal day number in the week
10237
- *
10238
- * @access protected
10239
- * @var array
10240
- */
10241
- var $day = array(
10242
- // English
10243
- 'mon' => 1,
10244
- 'monday' => 1,
10245
- 'tue' => 2,
10246
- 'tuesday' => 2,
10247
- 'wed' => 3,
10248
- 'wednesday' => 3,
10249
- 'thu' => 4,
10250
- 'thursday' => 4,
10251
- 'fri' => 5,
10252
- 'friday' => 5,
10253
- 'sat' => 6,
10254
- 'saturday' => 6,
10255
- 'sun' => 7,
10256
- 'sunday' => 7,
10257
- // Dutch
10258
- 'maandag' => 1,
10259
- 'dinsdag' => 2,
10260
- 'woensdag' => 3,
10261
- 'donderdag' => 4,
10262
- 'vrijdag' => 5,
10263
- 'zaterdag' => 6,
10264
- 'zondag' => 7,
10265
- // French
10266
- 'lundi' => 1,
10267
- 'mardi' => 2,
10268
- 'mercredi' => 3,
10269
- 'jeudi' => 4,
10270
- 'vendredi' => 5,
10271
- 'samedi' => 6,
10272
- 'dimanche' => 7,
10273
- // German
10274
- 'montag' => 1,
10275
- 'dienstag' => 2,
10276
- 'mittwoch' => 3,
10277
- 'donnerstag' => 4,
10278
- 'freitag' => 5,
10279
- 'samstag' => 6,
10280
- 'sonnabend' => 6,
10281
- 'sonntag' => 7,
10282
- // Italian
10283
- 'lunedì' => 1,
10284
- 'martedì' => 2,
10285
- 'mercoledì' => 3,
10286
- 'giovedì' => 4,
10287
- 'venerdì' => 5,
10288
- 'sabato' => 6,
10289
- 'domenica' => 7,
10290
- // Spanish
10291
- 'lunes' => 1,
10292
- 'martes' => 2,
10293
- 'miércoles' => 3,
10294
- 'jueves' => 4,
10295
- 'viernes' => 5,
10296
- 'sábado' => 6,
10297
- 'domingo' => 7,
10298
- // Finnish
10299
- 'maanantai' => 1,
10300
- 'tiistai' => 2,
10301
- 'keskiviikko' => 3,
10302
- 'torstai' => 4,
10303
- 'perjantai' => 5,
10304
- 'lauantai' => 6,
10305
- 'sunnuntai' => 7,
10306
- // Hungarian
10307
- 'hétfő' => 1,
10308
- 'kedd' => 2,
10309
- 'szerda' => 3,
10310
- 'csütörtok' => 4,
10311
- 'péntek' => 5,
10312
- 'szombat' => 6,
10313
- 'vasárnap' => 7,
10314
- // Greek
10315
- 'Δευ' => 1,
10316
- 'Τρι' => 2,
10317
- 'Τετ' => 3,
10318
- 'Πεμ' => 4,
10319
- 'Παρ' => 5,
10320
- 'Σαβ' => 6,
10321
- 'Κυρ' => 7,
10322
- );
10323
-
10324
- /**
10325
- * List of months, calendar month name => calendar month number
10326
- *
10327
- * @access protected
10328
- * @var array
10329
- */
10330
- var $month = array(
10331
- // English
10332
- 'jan' => 1,
10333
- 'january' => 1,
10334
- 'feb' => 2,
10335
- 'february' => 2,
10336
- 'mar' => 3,
10337
- 'march' => 3,
10338
- 'apr' => 4,
10339
- 'april' => 4,
10340
- 'may' => 5,
10341
- // No long form of May
10342
- 'jun' => 6,
10343
- 'june' => 6,
10344
- 'jul' => 7,
10345
- 'july' => 7,
10346
- 'aug' => 8,
10347
- 'august' => 8,
10348
- 'sep' => 9,
10349
- 'september' => 8,
10350
- 'oct' => 10,
10351
- 'october' => 10,
10352
- 'nov' => 11,
10353
- 'november' => 11,
10354
- 'dec' => 12,
10355
- 'december' => 12,
10356
- // Dutch
10357
- 'januari' => 1,
10358
- 'februari' => 2,
10359
- 'maart' => 3,
10360
- 'april' => 4,
10361
- 'mei' => 5,
10362
- 'juni' => 6,
10363
- 'juli' => 7,
10364
- 'augustus' => 8,
10365
- 'september' => 9,
10366
- 'oktober' => 10,
10367
- 'november' => 11,
10368
- 'december' => 12,
10369
- // French
10370
- 'janvier' => 1,
10371
- 'février' => 2,
10372
- 'mars' => 3,
10373
- 'avril' => 4,
10374
- 'mai' => 5,
10375
- 'juin' => 6,
10376
- 'juillet' => 7,
10377
- 'août' => 8,
10378
- 'septembre' => 9,
10379
- 'octobre' => 10,
10380
- 'novembre' => 11,
10381
- 'décembre' => 12,
10382
- // German
10383
- 'januar' => 1,
10384
- 'februar' => 2,
10385
- 'märz' => 3,
10386
- 'april' => 4,
10387
- 'mai' => 5,
10388
- 'juni' => 6,
10389
- 'juli' => 7,
10390
- 'august' => 8,
10391
- 'september' => 9,
10392
- 'oktober' => 10,
10393
- 'november' => 11,
10394
- 'dezember' => 12,
10395
- // Italian
10396
- 'gennaio' => 1,
10397
- 'febbraio' => 2,
10398
- 'marzo' => 3,
10399
- 'aprile' => 4,
10400
- 'maggio' => 5,
10401
- 'giugno' => 6,
10402
- 'luglio' => 7,
10403
- 'agosto' => 8,
10404
- 'settembre' => 9,
10405
- 'ottobre' => 10,
10406
- 'novembre' => 11,
10407
- 'dicembre' => 12,
10408
- // Spanish
10409
- 'enero' => 1,
10410
- 'febrero' => 2,
10411
- 'marzo' => 3,
10412
- 'abril' => 4,
10413
- 'mayo' => 5,
10414
- 'junio' => 6,
10415
- 'julio' => 7,
10416
- 'agosto' => 8,
10417
- 'septiembre' => 9,
10418
- 'setiembre' => 9,
10419
- 'octubre' => 10,
10420
- 'noviembre' => 11,
10421
- 'diciembre' => 12,
10422
- // Finnish
10423
- 'tammikuu' => 1,
10424
- 'helmikuu' => 2,
10425
- 'maaliskuu' => 3,
10426
- 'huhtikuu' => 4,
10427
- 'toukokuu' => 5,
10428
- 'kesäkuu' => 6,
10429
- 'heinäkuu' => 7,
10430
- 'elokuu' => 8,
10431
- 'suuskuu' => 9,
10432
- 'lokakuu' => 10,
10433
- 'marras' => 11,
10434
- 'joulukuu' => 12,
10435
- // Hungarian
10436
- 'január' => 1,
10437
- 'február' => 2,
10438
- 'március' => 3,
10439
- 'április' => 4,
10440
- 'május' => 5,
10441
- 'június' => 6,
10442
- 'július' => 7,
10443
- 'augusztus' => 8,
10444
- 'szeptember' => 9,
10445
- 'október' => 10,
10446
- 'november' => 11,
10447
- 'december' => 12,
10448
- // Greek
10449
- 'Ιαν' => 1,
10450
- 'Φεβ' => 2,
10451
- 'Μάώ' => 3,
10452
- 'Μαώ' => 3,
10453
- 'Απρ' => 4,
10454
- 'Μάι' => 5,
10455
- 'Μαϊ' => 5,
10456
- 'Μαι' => 5,
10457
- 'Ιούν' => 6,
10458
- 'Ιον' => 6,
10459
- 'Ιούλ' => 7,
10460
- 'Ιολ' => 7,
10461
- 'Αύγ' => 8,
10462
- 'Αυγ' => 8,
10463
- 'Σεπ' => 9,
10464
- 'Οκτ' => 10,
10465
- 'Νοέ' => 11,
10466
- 'Δεκ' => 12,
10467
- );
10468
-
10469
- /**
10470
- * List of timezones, abbreviation => offset from UTC
10471
- *
10472
- * @access protected
10473
- * @var array
10474
- */
10475
- var $timezone = array(
10476
- 'ACDT' => 37800,
10477
- 'ACIT' => 28800,
10478
- 'ACST' => 34200,
10479
- 'ACT' => -18000,
10480
- 'ACWDT' => 35100,
10481
- 'ACWST' => 31500,
10482
- 'AEDT' => 39600,
10483
- 'AEST' => 36000,
10484
- 'AFT' => 16200,
10485
- 'AKDT' => -28800,
10486
- 'AKST' => -32400,
10487
- 'AMDT' => 18000,
10488
- 'AMT' => -14400,
10489
- 'ANAST' => 46800,
10490
- 'ANAT' => 43200,
10491
- 'ART' => -10800,
10492
- 'AZOST' => -3600,
10493
- 'AZST' => 18000,
10494
- 'AZT' => 14400,
10495
- 'BIOT' => 21600,
10496
- 'BIT' => -43200,
10497
- 'BOT' => -14400,
10498
- 'BRST' => -7200,
10499
- 'BRT' => -10800,
10500
- 'BST' => 3600,
10501
- 'BTT' => 21600,
10502
- 'CAST' => 18000,
10503
- 'CAT' => 7200,
10504
- 'CCT' => 23400,
10505
- 'CDT' => -18000,
10506
- 'CEDT' => 7200,
10507
- 'CET' => 3600,
10508
- 'CGST' => -7200,
10509
- 'CGT' => -10800,
10510
- 'CHADT' => 49500,
10511
- 'CHAST' => 45900,
10512
- 'CIST' => -28800,
10513
- 'CKT' => -36000,
10514
- 'CLDT' => -10800,
10515
- 'CLST' => -14400,
10516
- 'COT' => -18000,
10517
- 'CST' => -21600,
10518
- 'CVT' => -3600,
10519
- 'CXT' => 25200,
10520
- 'DAVT' => 25200,
10521
- 'DTAT' => 36000,
10522
- 'EADT' => -18000,
10523
- 'EAST' => -21600,
10524
- 'EAT' => 10800,
10525
- 'ECT' => -18000,
10526
- 'EDT' => -14400,
10527
- 'EEST' => 10800,
10528
- 'EET' => 7200,
10529
- 'EGT' => -3600,
10530
- 'EKST' => 21600,
10531
- 'EST' => -18000,
10532
- 'FJT' => 43200,
10533
- 'FKDT' => -10800,
10534
- 'FKST' => -14400,
10535
- 'FNT' => -7200,
10536
- 'GALT' => -21600,
10537
- 'GEDT' => 14400,
10538
- 'GEST' => 10800,
10539
- 'GFT' => -10800,
10540
- 'GILT' => 43200,
10541
- 'GIT' => -32400,
10542
- 'GST' => 14400,
10543
- 'GST' => -7200,
10544
- 'GYT' => -14400,
10545
- 'HAA' => -10800,
10546
- 'HAC' => -18000,
10547
- 'HADT' => -32400,
10548
- 'HAE' => -14400,
10549
- 'HAP' => -25200,
10550
- 'HAR' => -21600,
10551
- 'HAST' => -36000,
10552
- 'HAT' => -9000,
10553
- 'HAY' => -28800,
10554
- 'HKST' => 28800,
10555
- 'HMT' => 18000,
10556
- 'HNA' => -14400,
10557
- 'HNC' => -21600,
10558
- 'HNE' => -18000,
10559
- 'HNP' => -28800,
10560
- 'HNR' => -25200,
10561
- 'HNT' => -12600,
10562
- 'HNY' => -32400,
10563
- 'IRDT' => 16200,
10564
- 'IRKST' => 32400,
10565
- 'IRKT' => 28800,
10566
- 'IRST' => 12600,
10567
- 'JFDT' => -10800,
10568
- 'JFST' => -14400,
10569
- 'JST' => 32400,
10570
- 'KGST' => 21600,
10571
- 'KGT' => 18000,
10572
- 'KOST' => 39600,
10573
- 'KOVST' => 28800,
10574
- 'KOVT' => 25200,
10575
- 'KRAST' => 28800,
10576
- 'KRAT' => 25200,
10577
- 'KST' => 32400,
10578
- 'LHDT' => 39600,
10579
- 'LHST' => 37800,
10580
- 'LINT' => 50400,
10581
- 'LKT' => 21600,
10582
- 'MAGST' => 43200,
10583
- 'MAGT' => 39600,
10584
- 'MAWT' => 21600,
10585
- 'MDT' => -21600,
10586
- 'MESZ' => 7200,
10587
- 'MEZ' => 3600,
10588
- 'MHT' => 43200,
10589
- 'MIT' => -34200,
10590
- 'MNST' => 32400,
10591
- 'MSDT' => 14400,
10592
- 'MSST' => 10800,
10593
- 'MST' => -25200,
10594
- 'MUT' => 14400,
10595
- 'MVT' => 18000,
10596
- 'MYT' => 28800,
10597
- 'NCT' => 39600,
10598
- 'NDT' => -9000,
10599
- 'NFT' => 41400,
10600
- 'NMIT' => 36000,
10601
- 'NOVST' => 25200,
10602
- 'NOVT' => 21600,
10603
- 'NPT' => 20700,
10604
- 'NRT' => 43200,
10605
- 'NST' => -12600,
10606
- 'NUT' => -39600,
10607
- 'NZDT' => 46800,
10608
- 'NZST' => 43200,
10609
- 'OMSST' => 25200,
10610
- 'OMST' => 21600,
10611
- 'PDT' => -25200,
10612
- 'PET' => -18000,
10613
- 'PETST' => 46800,
10614
- 'PETT' => 43200,
10615
- 'PGT' => 36000,
10616
- 'PHOT' => 46800,
10617
- 'PHT' => 28800,
10618
- 'PKT' => 18000,
10619
- 'PMDT' => -7200,
10620
- 'PMST' => -10800,
10621
- 'PONT' => 39600,
10622
- 'PST' => -28800,
10623
- 'PWT' => 32400,
10624
- 'PYST' => -10800,
10625
- 'PYT' => -14400,
10626
- 'RET' => 14400,
10627
- 'ROTT' => -10800,
10628
- 'SAMST' => 18000,
10629
- 'SAMT' => 14400,
10630
- 'SAST' => 7200,
10631
- 'SBT' => 39600,
10632
- 'SCDT' => 46800,
10633
- 'SCST' => 43200,
10634
- 'SCT' => 14400,
10635
- 'SEST' => 3600,
10636
- 'SGT' => 28800,
10637
- 'SIT' => 28800,
10638
- 'SRT' => -10800,
10639
- 'SST' => -39600,
10640
- 'SYST' => 10800,
10641
- 'SYT' => 7200,
10642
- 'TFT' => 18000,
10643
- 'THAT' => -36000,
10644
- 'TJT' => 18000,
10645
- 'TKT' => -36000,
10646
- 'TMT' => 18000,
10647
- 'TOT' => 46800,
10648
- 'TPT' => 32400,
10649
- 'TRUT' => 36000,
10650
- 'TVT' => 43200,
10651
- 'TWT' => 28800,
10652
- 'UYST' => -7200,
10653
- 'UYT' => -10800,
10654
- 'UZT' => 18000,
10655
- 'VET' => -14400,
10656
- 'VLAST' => 39600,
10657
- 'VLAT' => 36000,
10658
- 'VOST' => 21600,
10659
- 'VUT' => 39600,
10660
- 'WAST' => 7200,
10661
- 'WAT' => 3600,
10662
- 'WDT' => 32400,
10663
- 'WEST' => 3600,
10664
- 'WFT' => 43200,
10665
- 'WIB' => 25200,
10666
- 'WIT' => 32400,
10667
- 'WITA' => 28800,
10668
- 'WKST' => 18000,
10669
- 'WST' => 28800,
10670
- 'YAKST' => 36000,
10671
- 'YAKT' => 32400,
10672
- 'YAPT' => 36000,
10673
- 'YEKST' => 21600,
10674
- 'YEKT' => 18000,
10675
- );
10676
-
10677
- /**
10678
- * Cached PCRE for SimplePie_Parse_Date::$day
10679
- *
10680
- * @access protected
10681
- * @var string
10682
- */
10683
- var $day_pcre;
10684
-
10685
- /**
10686
- * Cached PCRE for SimplePie_Parse_Date::$month
10687
- *
10688
- * @access protected
10689
- * @var string
10690
- */
10691
- var $month_pcre;
10692
-
10693
- /**
10694
- * Array of user-added callback methods
10695
- *
10696
- * @access private
10697
- * @var array
10698
- */
10699
- var $built_in = array();
10700
-
10701
- /**
10702
- * Array of user-added callback methods
10703
- *
10704
- * @access private
10705
- * @var array
10706
- */
10707
- var $user = array();
10708
-
10709
- /**
10710
- * Create new SimplePie_Parse_Date object, and set self::day_pcre,
10711
- * self::month_pcre, and self::built_in
10712
- *
10713
- * @access private
10714
- */
10715
- function SimplePie_Parse_Date()
10716
- {
10717
- $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
10718
- $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
10719
-
10720
- static $cache;
10721
- if (!isset($cache[get_class($this)]))
10722
- {
10723
- if (extension_loaded('Reflection'))
10724
- {
10725
- $class = new ReflectionClass(get_class($this));
10726
- $methods = $class->getMethods();
10727
- $all_methods = array();
10728
- foreach ($methods as $method)
10729
- {
10730
- $all_methods[] = $method->getName();
10731
- }
10732
- }
10733
- else
10734
- {
10735
- $all_methods = get_class_methods($this);
10736
- }
10737
-
10738
- foreach ($all_methods as $method)
10739
- {
10740
- if (strtolower(substr($method, 0, 5)) === 'date_')
10741
- {
10742
- $cache[get_class($this)][] = $method;
10743
- }
10744
- }
10745
- }
10746
-
10747
- foreach ($cache[get_class($this)] as $method)
10748
- {
10749
- $this->built_in[] = $method;
10750
- }
10751
- }
10752
-
10753
- /**
10754
- * Get the object
10755
- *
10756
- * @access public
10757
- */
10758
- function get()
10759
- {
10760
- static $object;
10761
- if (!$object)
10762
- {
10763
- $object = new SimplePie_Parse_Date;
10764
- }
10765
- return $object;
10766
- }
10767
-
10768
- /**
10769
- * Parse a date
10770
- *
10771
- * @final
10772
- * @access public
10773
- * @param string $date Date to parse
10774
- * @return int Timestamp corresponding to date string, or false on failure
10775
- */
10776
- function parse($date)
10777
- {
10778
- foreach ($this->user as $method)
10779
- {
10780
- if (($returned = call_user_func($method, $date)) !== false)
10781
- {
10782
- return $returned;
10783
- }
10784
- }
10785
-
10786
- foreach ($this->built_in as $method)
10787
- {
10788
- if (($returned = call_user_func(array(&$this, $method), $date)) !== false)
10789
- {
10790
- return $returned;
10791
- }
10792
- }
10793
-
10794
- return false;
10795
- }
10796
-
10797
- /**
10798
- * Add a callback method to parse a date
10799
- *
10800
- * @final
10801
- * @access public
10802
- * @param callback $callback
10803
- */
10804
- function add_callback($callback)
10805
- {
10806
- if (is_callable($callback))
10807
- {
10808
- $this->user[] = $callback;
10809
- }
10810
- else
10811
- {
10812
- trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
10813
- }
10814
- }
10815
-
10816
- /**
10817
- * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
10818
- * well as allowing any of upper or lower case "T", horizontal tabs, or
10819
- * spaces to be used as the time seperator (including more than one))
10820
- *
10821
- * @access protected
10822
- * @return int Timestamp
10823
- */
10824
- function date_w3cdtf($date)
10825
- {
10826
- static $pcre;
10827
- if (!$pcre)
10828
- {
10829
- $year = '([0-9]{4})';
10830
- $month = $day = $hour = $minute = $second = '([0-9]{2})';
10831
- $decimal = '([0-9]*)';
10832
- $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
10833
- $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
10834
- }
10835
- if (preg_match($pcre, $date, $match))
10836
- {
10837
- /*
10838
- Capturing subpatterns:
10839
- 1: Year
10840
- 2: Month
10841
- 3: Day
10842
- 4: Hour
10843
- 5: Minute
10844
- 6: Second
10845
- 7: Decimal fraction of a second
10846
- 8: Zulu
10847
- 9: Timezone ±
10848
- 10: Timezone hours
10849
- 11: Timezone minutes
10850
- */
10851
-
10852
- // Fill in empty matches
10853
- for ($i = count($match); $i <= 3; $i++)
10854
- {
10855
- $match[$i] = '1';
10856
- }
10857
-
10858
- for ($i = count($match); $i <= 7; $i++)
10859
- {
10860
- $match[$i] = '0';
10861
- }
10862
-
10863
- // Numeric timezone
10864
- if (isset($match[9]) && $match[9] !== '')
10865
- {
10866
- $timezone = $match[10] * 3600;
10867
- $timezone += $match[11] * 60;
10868
- if ($match[9] === '-')
10869
- {
10870
- $timezone = 0 - $timezone;
10871
- }
10872
- }
10873
- else
10874
- {
10875
- $timezone = 0;
10876
- }
10877
-
10878
- // Convert the number of seconds to an integer, taking decimals into account
10879
- $second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
10880
-
10881
- return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
10882
- }
10883
- else
10884
- {
10885
- return false;
10886
- }
10887
- }
10888
-
10889
- /**
10890
- * Remove RFC822 comments
10891
- *
10892
- * @access protected
10893
- * @param string $data Data to strip comments from
10894
- * @return string Comment stripped string
10895
- */
10896
- function remove_rfc2822_comments($string)
10897
- {
10898
- $string = (string) $string;
10899
- $position = 0;
10900
- $length = strlen($string);
10901
- $depth = 0;
10902
-
10903
- $output = '';
10904
-
10905
- while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
10906
- {
10907
- $output .= substr($string, $position, $pos - $position);
10908
- $position = $pos + 1;
10909
- if ($string[$pos - 1] !== '\\')
10910
- {
10911
- $depth++;
10912
- while ($depth && $position < $length)
10913
- {
10914
- $position += strcspn($string, '()', $position);
10915
- if ($string[$position - 1] === '\\')
10916
- {
10917
- $position++;
10918
- continue;
10919
- }
10920
- elseif (isset($string[$position]))
10921
- {
10922
- switch ($string[$position])
10923
- {
10924
- case '(':
10925
- $depth++;
10926
- break;
10927
-
10928
- case ')':
10929
- $depth--;
10930
- break;
10931
- }
10932
- $position++;
10933
- }
10934
- else
10935
- {
10936
- break;
10937
- }
10938
- }
10939
- }
10940
- else
10941
- {
10942
- $output .= '(';
10943
- }
10944
- }
10945
- $output .= substr($string, $position);
10946
-
10947
- return $output;
10948
- }
10949
-
10950
- /**
10951
- * Parse RFC2822's date format
10952
- *
10953
- * @access protected
10954
- * @return int Timestamp
10955
- */
10956
- function date_rfc2822($date)
10957
- {
10958
- static $pcre;
10959
- if (!$pcre)
10960
- {
10961
- $wsp = '[\x09\x20]';
10962
- $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
10963
- $optional_fws = $fws . '?';
10964
- $day_name = $this->day_pcre;
10965
- $month = $this->month_pcre;
10966
- $day = '([0-9]{1,2})';
10967
- $hour = $minute = $second = '([0-9]{2})';
10968
- $year = '([0-9]{2,4})';
10969
- $num_zone = '([+\-])([0-9]{2})([0-9]{2})';
10970
- $character_zone = '([A-Z]{1,5})';
10971
- $zone = '(?:' . $num_zone . '|' . $character_zone . ')';
10972
- $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
10973
- }
10974
- if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
10975
- {
10976
- /*
10977
- Capturing subpatterns:
10978
- 1: Day name
10979
- 2: Day
10980
- 3: Month
10981
- 4: Year
10982
- 5: Hour
10983
- 6: Minute
10984
- 7: Second
10985
- 8: Timezone ±
10986
- 9: Timezone hours
10987
- 10: Timezone minutes
10988
- 11: Alphabetic timezone
10989
- */
10990
-
10991
- // Find the month number
10992
- $month = $this->month[strtolower($match[3])];
10993
-
10994
- // Numeric timezone
10995
- if ($match[8] !== '')
10996
- {
10997
- $timezone = $match[9] * 3600;
10998
- $timezone += $match[10] * 60;
10999
- if ($match[8] === '-')
11000
- {
11001
- $timezone = 0 - $timezone;
11002
- }
11003
- }
11004
- // Character timezone
11005
- elseif (isset($this->timezone[strtoupper($match[11])]))
11006
- {
11007
- $timezone = $this->timezone[strtoupper($match[11])];
11008
- }
11009
- // Assume everything else to be -0000
11010
- else
11011
- {
11012
- $timezone = 0;
11013
- }
11014
-
11015
- // Deal with 2/3 digit years
11016
- if ($match[4] < 50)
11017
- {
11018
- $match[4] += 2000;
11019
- }
11020
- elseif ($match[4] < 1000)
11021
- {
11022
- $match[4] += 1900;
11023
- }
11024
-
11025
- // Second is optional, if it is empty set it to zero
11026
- if ($match[7] !== '')
11027
- {
11028
- $second = $match[7];
11029
- }
11030
- else
11031
- {
11032
- $second = 0;
11033
- }
11034
-
11035
- return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
11036
- }
11037
- else
11038
- {
11039
- return false;
11040
- }
11041
- }
11042
-
11043
- /**
11044
- * Parse RFC850's date format
11045
- *
11046
- * @access protected
11047
- * @return int Timestamp
11048
- */
11049
- function date_rfc850($date)
11050
- {
11051
- static $pcre;
11052
- if (!$pcre)
11053
- {
11054
- $space = '[\x09\x20]+';
11055
- $day_name = $this->day_pcre;
11056
- $month = $this->month_pcre;
11057
- $day = '([0-9]{1,2})';
11058
- $year = $hour = $minute = $second = '([0-9]{2})';
11059
- $zone = '([A-Z]{1,5})';
11060
- $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
11061
- }
11062
- if (preg_match($pcre, $date, $match))
11063
- {
11064
- /*
11065
- Capturing subpatterns:
11066
- 1: Day name
11067
- 2: Day
11068
- 3: Month
11069
- 4: Year
11070
- 5: Hour
11071
- 6: Minute
11072
- 7: Second
11073
- 8: Timezone
11074
- */
11075
-
11076
- // Month
11077
- $month = $this->month[strtolower($match[3])];
11078
-
11079
- // Character timezone
11080
- if (isset($this->timezone[strtoupper($match[8])]))
11081
- {
11082
- $timezone = $this->timezone[strtoupper($match[8])];
11083
- }
11084
- // Assume everything else to be -0000
11085
- else
11086
- {
11087
- $timezone = 0;
11088
- }
11089
-
11090
- // Deal with 2 digit year
11091
- if ($match[4] < 50)
11092
- {
11093
- $match[4] += 2000;
11094
- }
11095
- else
11096
- {
11097
- $match[4] += 1900;
11098
- }
11099
-
11100
- return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
11101
- }
11102
- else
11103
- {
11104
- return false;
11105
- }
11106
- }
11107
-
11108
- /**
11109
- * Parse C99's asctime()'s date format
11110
- *
11111
- * @access protected
11112
- * @return int Timestamp
11113
- */
11114
- function date_asctime($date)
11115
- {
11116
- static $pcre;
11117
- if (!$pcre)
11118
- {
11119
- $space = '[\x09\x20]+';
11120
- $wday_name = $this->day_pcre;
11121
- $mon_name = $this->month_pcre;
11122
- $day = '([0-9]{1,2})';
11123
- $hour = $sec = $min = '([0-9]{2})';
11124
- $year = '([0-9]{4})';
11125
- $terminator = '\x0A?\x00?';
11126
- $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
11127
- }
11128
- if (preg_match($pcre, $date, $match))
11129
- {
11130
- /*
11131
- Capturing subpatterns:
11132
- 1: Day name
11133
- 2: Month
11134
- 3: Day
11135
- 4: Hour
11136
- 5: Minute
11137
- 6: Second
11138
- 7: Year
11139
- */
11140
-
11141
- $month = $this->month[strtolower($match[2])];
11142
- return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
11143
- }
11144
- else
11145
- {
11146
- return false;
11147
- }
11148
- }
11149
-
11150
- /**
11151
- * Parse dates using strtotime()
11152
- *
11153
- * @access protected
11154
- * @return int Timestamp
11155
- */
11156
- function date_strtotime($date)
11157
- {
11158
- $strtotime = strtotime($date);
11159
- if ($strtotime === -1 || $strtotime === false)
11160
- {
11161
- return false;
11162
- }
11163
- else
11164
- {
11165
- return $strtotime;
11166
- }
11167
- }
11168
- }
11169
-
11170
- /**
11171
- * Content-type sniffing
11172
- *
11173
- * @package SimplePie
11174
- */
11175
- class SimplePie_Content_Type_Sniffer
11176
- {
11177
- /**
11178
- * File object
11179
- *
11180
- * @var SimplePie_File
11181
- * @access private
11182
- */
11183
- var $file;
11184
-
11185
- /**
11186
- * Create an instance of the class with the input file
11187
- *
11188
- * @access public
11189
- * @param SimplePie_Content_Type_Sniffer $file Input file
11190
- */
11191
- function SimplePie_Content_Type_Sniffer($file)
11192
- {
11193
- $this->file = $file;
11194
- }
11195
-
11196
- /**
11197
- * Get the Content-Type of the specified file
11198
- *
11199
- * @access public
11200
- * @return string Actual Content-Type
11201
- */
11202
- function get_type()
11203
- {
11204
- if (isset($this->file->headers['content-type']))
11205
- {
11206
- if (!isset($this->file->headers['content-encoding'])
11207
- && ($this->file->headers['content-type'] === 'text/plain'
11208
- || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
11209
- || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'))
11210
- {
11211
- return $this->text_or_binary();
11212
- }
11213
-
11214
- if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
11215
- {
11216
- $official = substr($this->file->headers['content-type'], 0, $pos);
11217
- }
11218
- else
11219
- {
11220
- $official = $this->file->headers['content-type'];
11221
- }
11222
- $official = strtolower($official);
11223
-
11224
- if ($official === 'unknown/unknown'
11225
- || $official === 'application/unknown')
11226
- {
11227
- return $this->unknown();
11228
- }
11229
- elseif (substr($official, -4) === '+xml'
11230
- || $official === 'text/xml'
11231
- || $official === 'application/xml')
11232
- {
11233
- return $official;
11234
- }
11235
- elseif (substr($official, 0, 6) === 'image/')
11236
- {
11237
- if ($return = $this->image())
11238
- {
11239
- return $return;
11240
- }
11241
- else
11242
- {
11243
- return $official;
11244
- }
11245
- }
11246
- elseif ($official === 'text/html')
11247
- {
11248
- return $this->feed_or_html();
11249
- }
11250
- else
11251
- {
11252
- return $official;
11253
- }
11254
- }
11255
- else
11256
- {
11257
- return $this->unknown();
11258
- }
11259
- }
11260
-
11261
- /**
11262
- * Sniff text or binary
11263
- *
11264
- * @access private
11265
- * @return string Actual Content-Type
11266
- */
11267
- function text_or_binary()
11268
- {
11269
- if (substr($this->file->body, 0, 2) === "\xFE\xFF"
11270
- || substr($this->file->body, 0, 2) === "\xFF\xFE"
11271
- || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
11272
- || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF")
11273
- {
11274
- return 'text/plain';
11275
- }
11276
- elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
11277
- {
11278
- return 'application/octect-stream';
11279
- }
11280
- else
11281
- {
11282
- return 'text/plain';
11283
- }
11284
- }
11285
-
11286
- /**
11287
- * Sniff unknown
11288
- *
11289
- * @access private
11290
- * @return string Actual Content-Type
11291
- */
11292
- function unknown()
11293
- {
11294
- $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
11295
- if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
11296
- || strtolower(substr($this->file->body, $ws, 5)) === '<html'
11297
- || strtolower(substr($this->file->body, $ws, 7)) === '<script')
11298
- {
11299
- return 'text/html';
11300
- }
11301
- elseif (substr($this->file->body, 0, 5) === '%PDF-')
11302
- {
11303
- return 'application/pdf';
11304
- }
11305
- elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-')
11306
- {
11307
- return 'application/postscript';
11308
- }
11309
- elseif (substr($this->file->body, 0, 6) === 'GIF87a'
11310
- || substr($this->file->body, 0, 6) === 'GIF89a')
11311
- {
11312
- return 'image/gif';
11313
- }
11314
- elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
11315
- {
11316
- return 'image/png';
11317
- }
11318
- elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
11319
- {
11320
- return 'image/jpeg';
11321
- }
11322
- elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
11323
- {
11324
- return 'image/bmp';
11325
- }
11326
- else
11327
- {
11328
- return $this->text_or_binary();
11329
- }
11330
- }
11331
-
11332
- /**
11333
- * Sniff images
11334
- *
11335
- * @access private
11336
- * @return string Actual Content-Type
11337
- */
11338
- function image()
11339
- {
11340
- if (substr($this->file->body, 0, 6) === 'GIF87a'
11341
- || substr($this->file->body, 0, 6) === 'GIF89a')
11342
- {
11343
- return 'image/gif';
11344
- }
11345
- elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
11346
- {
11347
- return 'image/png';
11348
- }
11349
- elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
11350
- {
11351
- return 'image/jpeg';
11352
- }
11353
- elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
11354
- {
11355
- return 'image/bmp';
11356
- }
11357
- else
11358
- {
11359
- return false;
11360
- }
11361
- }
11362
-
11363
- /**
11364
- * Sniff HTML
11365
- *
11366
- * @access private
11367
- * @return string Actual Content-Type
11368
- */
11369
- function feed_or_html()
11370
- {
11371
- $len = strlen($this->file->body);
11372
- $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
11373
-
11374
- while ($pos < $len)
11375
- {
11376
- switch ($this->file->body[$pos])
11377
- {
11378
- case "\x09":
11379
- case "\x0A":
11380
- case "\x0D":
11381
- case "\x20":
11382
- $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
11383
- continue 2;
11384
-
11385
- case '<':
11386
- $pos++;
11387
- break;
11388
-
11389
- default:
11390
- return 'text/html';
11391
- }
11392
-
11393
- if (substr($this->file->body, $pos, 3) === '!--')
11394
- {
11395
- $pos += 3;
11396
- if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false)
11397
- {
11398
- $pos += 3;
11399
- }
11400
- else
11401
- {
11402
- return 'text/html';
11403
- }
11404
- }
11405
- elseif (substr($this->file->body, $pos, 1) === '!')
11406
- {
11407
- if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false)
11408
- {
11409
- $pos++;
11410
- }
11411
- else
11412
- {
11413
- return 'text/html';
11414
- }
11415
- }
11416
- elseif (substr($this->file->body, $pos, 1) === '?')
11417
- {
11418
- if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false)
11419
- {
11420
- $pos += 2;
11421
- }
11422
- else
11423
- {
11424
- return 'text/html';
11425
- }
11426
- }
11427
- elseif (substr($this->file->body, $pos, 3) === 'rss'
11428
- || substr($this->file->body, $pos, 7) === 'rdf:RDF')
11429
- {
11430
- return 'application/rss+xml';
11431
- }
11432
- elseif (substr($this->file->body, $pos, 4) === 'feed')
11433
- {
11434
- return 'application/atom+xml';
11435
- }
11436
- else
11437
- {
11438
- return 'text/html';
11439
- }
11440
- }
11441
-
11442
- return 'text/html';
11443
- }
11444
- }
11445
-
11446
- /**
11447
- * Parses the XML Declaration
11448
- *
11449
- * @package SimplePie
11450
- */
11451
- class SimplePie_XML_Declaration_Parser
11452
- {
11453
- /**
11454
- * XML Version
11455
- *
11456
- * @access public
11457
- * @var string
11458
- */
11459
- var $version = '1.0';
11460
-
11461
- /**
11462
- * Encoding
11463
- *
11464
- * @access public
11465
- * @var string
11466
- */
11467
- var $encoding = 'UTF-8';
11468
-
11469
- /**
11470
- * Standalone
11471
- *
11472
- * @access public
11473
- * @var bool
11474
- */
11475
- var $standalone = false;
11476
-
11477
- /**
11478
- * Current state of the state machine
11479
- *
11480
- * @access private
11481
- * @var string
11482
- */
11483
- var $state = 'before_version_name';
11484
-
11485
- /**
11486
- * Input data
11487
- *
11488
- * @access private
11489
- * @var string
11490
- */
11491
- var $data = '';
11492
-
11493
- /**
11494
- * Input data length (to avoid calling strlen() everytime this is needed)
11495
- *
11496
- * @access private
11497
- * @var int
11498
- */
11499
- var $data_length = 0;
11500
-
11501
- /**
11502
- * Current position of the pointer
11503
- *
11504
- * @var int
11505
- * @access private
11506
- */
11507
- var $position = 0;
11508
-
11509
- /**
11510
- * Create an instance of the class with the input data
11511
- *
11512
- * @access public
11513
- * @param string $data Input data
11514
- */
11515
- function SimplePie_XML_Declaration_Parser($data)
11516
- {
11517
- $this->data = $data;
11518
- $this->data_length = strlen($this->data);
11519
- }
11520
-
11521
- /**
11522
- * Parse the input data
11523
- *
11524
- * @access public
11525
- * @return bool true on success, false on failure
11526
- */
11527
- function parse()
11528
- {
11529
- while ($this->state && $this->state !== 'emit' && $this->has_data())
11530
- {
11531
- $state = $this->state;
11532
- $this->$state();
11533
- }
11534
- $this->data = '';
11535
- if ($this->state === 'emit')
11536
- {
11537
- return true;
11538
- }
11539
- else
11540
- {
11541
- $this->version = '';
11542
- $this->encoding = '';
11543
- $this->standalone = '';
11544
- return false;
11545
- }
11546
- }
11547
-
11548
- /**
11549
- * Check whether there is data beyond the pointer
11550
- *
11551
- * @access private
11552
- * @return bool true if there is further data, false if not
11553
- */
11554
- function has_data()
11555
- {
11556
- return (bool) ($this->position < $this->data_length);
11557
- }
11558
-
11559
- /**
11560
- * Advance past any whitespace
11561
- *
11562
- * @return int Number of whitespace characters passed
11563
- */
11564
- function skip_whitespace()
11565
- {
11566
- $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position);
11567
- $this->position += $whitespace;
11568
- return $whitespace;
11569
- }
11570
-
11571
- /**
11572
- * Read value
11573
- */
11574
- function get_value()
11575
- {
11576
- $quote = substr($this->data, $this->position, 1);
11577
- if ($quote === '"' || $quote === "'")
11578
- {
11579
- $this->position++;
11580
- $len = strcspn($this->data, $quote, $this->position);
11581
- if ($this->has_data())
11582
- {
11583
- $value = substr($this->data, $this->position, $len);
11584
- $this->position += $len + 1;
11585
- return $value;
11586
- }
11587
- }
11588
- return false;
11589
- }
11590
-
11591
- function before_version_name()
11592
- {
11593
- if ($this->skip_whitespace())
11594
- {
11595
- $this->state = 'version_name';
11596
- }
11597
- else
11598
- {
11599
- $this->state = false;
11600
- }
11601
- }
11602
-
11603
- function version_name()
11604
- {
11605
- if (substr($this->data, $this->position, 7) === 'version')
11606
- {
11607
- $this->position += 7;
11608
- $this->skip_whitespace();
11609
- $this->state = 'version_equals';
11610
- }
11611
- else
11612
- {
11613
- $this->state = false;
11614
- }
11615
- }
11616
-
11617
- function version_equals()
11618
- {
11619
- if (substr($this->data, $this->position, 1) === '=')
11620
- {
11621
- $this->position++;
11622
- $this->skip_whitespace();
11623
- $this->state = 'version_value';
11624
- }
11625
- else
11626
- {
11627
- $this->state = false;
11628
- }
11629
- }
11630
-
11631
- function version_value()
11632
- {
11633
- if ($this->version = $this->get_value())
11634
- {
11635
- $this->skip_whitespace();
11636
- if ($this->has_data())
11637
- {
11638
- $this->state = 'encoding_name';
11639
- }
11640
- else
11641
- {
11642
- $this->state = 'emit';
11643
- }
11644
- }
11645
- else
11646
- {
11647
- $this->state = 'standalone_name';
11648
- }
11649
- }
11650
-
11651
- function encoding_name()
11652
- {
11653
- if (substr($this->data, $this->position, 8) === 'encoding')
11654
- {
11655
- $this->position += 8;
11656
- $this->skip_whitespace();
11657
- $this->state = 'encoding_equals';
11658
- }
11659
- else
11660
- {
11661
- $this->state = false;
11662
- }
11663
- }
11664
-
11665
- function encoding_equals()
11666
- {
11667
- if (substr($this->data, $this->position, 1) === '=')
11668
- {
11669
- $this->position++;
11670
- $this->skip_whitespace();
11671
- $this->state = 'encoding_value';
11672
- }
11673
- else
11674
- {
11675
- $this->state = false;
11676
- }
11677
- }
11678
-
11679
- function encoding_value()
11680
- {
11681
- if ($this->encoding = $this->get_value())
11682
- {
11683
- $this->skip_whitespace();
11684
- if ($this->has_data())
11685
- {
11686
- $this->state = 'standalone_name';
11687
- }
11688
- else
11689
- {
11690
- $this->state = 'emit';
11691
- }
11692
- }
11693
- else
11694
- {
11695
- $this->state = false;
11696
- }
11697
- }
11698
-
11699
- function standalone_name()
11700
- {
11701
- if (substr($this->data, $this->position, 10) === 'standalone')
11702
- {
11703
- $this->position += 10;
11704
- $this->skip_whitespace();
11705
- $this->state = 'standalone_equals';
11706
- }
11707
- else
11708
- {
11709
- $this->state = false;
11710
- }
11711
- }
11712
-
11713
- function standalone_equals()
11714
- {
11715
- if (substr($this->data, $this->position, 1) === '=')
11716
- {
11717
- $this->position++;
11718
- $this->skip_whitespace();
11719
- $this->state = 'standalone_value';
11720
- }
11721
- else
11722
- {
11723
- $this->state = false;
11724
- }
11725
- }
11726
-
11727
- function standalone_value()
11728
- {
11729
- if ($standalone = $this->get_value())
11730
- {
11731
- switch ($standalone)
11732
- {
11733
- case 'yes':
11734
- $this->standalone = true;
11735
- break;
11736
-
11737
- case 'no':
11738
- $this->standalone = false;
11739
- break;
11740
-
11741
- default:
11742
- $this->state = false;
11743
- return;
11744
- }
11745
-
11746
- $this->skip_whitespace();
11747
- if ($this->has_data())
11748
- {
11749
- $this->state = false;
11750
- }
11751
- else
11752
- {
11753
- $this->state = 'emit';
11754
- }
11755
- }
11756
- else
11757
- {
11758
- $this->state = false;
11759
- }
11760
- }
11761
- }
11762
-
11763
- class SimplePie_Locator
11764
- {
11765
- var $useragent;
11766
- var $timeout;
11767
- var $file;
11768
- var $local = array();
11769
- var $elsewhere = array();
11770
- var $file_class = 'SimplePie_File';
11771
- var $cached_entities = array();
11772
- var $http_base;
11773
- var $base;
11774
- var $base_location = 0;
11775
- var $checked_feeds = 0;
11776
- var $max_checked_feeds = 10;
11777
- var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
11778
-
11779
- function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer')
11780
- {
11781
- $this->file =& $file;
11782
- $this->file_class = $file_class;
11783
- $this->useragent = $useragent;
11784
- $this->timeout = $timeout;
11785
- $this->max_checked_feeds = $max_checked_feeds;
11786
- $this->content_type_sniffer_class = $content_type_sniffer_class;
11787
- }
11788
-
11789
- function find($type = SIMPLEPIE_LOCATOR_ALL)
11790
- {
11791
- if ($this->is_feed($this->file))
11792
- {
11793
- return $this->file;
11794
- }
11795
-
11796
- if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
11797
- {
11798
- $sniffer = new $this->content_type_sniffer_class($this->file);
11799
- if ($sniffer->get_type() !== 'text/html')
11800
- {
11801
- return null;
11802
- }
11803
- }
11804
-
11805
- if ($type & ~SIMPLEPIE_LOCATOR_NONE)
11806
- {
11807
- $this->get_base();
11808
- }
11809
-
11810
- if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
11811
- {
11812
- return $working;
11813
- }
11814
-
11815
- if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
11816
- {
11817
- if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
11818
- {
11819
- return $working;
11820
- }
11821
-
11822
- if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
11823
- {
11824
- return $working;
11825
- }
11826
-
11827
- if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
11828
- {
11829
- return $working;
11830
- }
11831
-
11832
- if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
11833
- {
11834
- return $working;
11835
- }
11836
- }
11837
- return null;
11838
- }
11839
-
11840
- function is_feed(&$file)
11841
- {
11842
- if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
11843
- {
11844
- $sniffer = new $this->content_type_sniffer_class($file);
11845
- $sniffed = $sniffer->get_type();
11846
- if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
11847
- {
11848
- return true;
11849
- }
11850
- else
11851
- {
11852
- return false;
11853
- }
11854
- }
11855
- elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
11856
- {
11857
- return true;
11858
- }
11859
- else
11860
- {
11861
- return false;
11862
- }
11863
- }
11864
-
11865
- function get_base()
11866
- {
11867
- $this->http_base = $this->file->url;
11868
- $this->base = $this->http_base;
11869
- $elements = SimplePie_Misc::get_element('base', $this->file->body);
11870
- foreach ($elements as $element)
11871
- {
11872
- if ($element['attribs']['href']['data'] !== '')
11873
- {
11874
- $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base);
11875
- $this->base_location = $element['offset'];
11876
- break;
11877
- }
11878
- }
11879
- }
11880
-
11881
- function autodiscovery()
11882
- {
11883
- $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
11884
- $done = array();
11885
- foreach ($links as $link)
11886
- {
11887
- if ($this->checked_feeds == $this->max_checked_feeds)
11888
- {
11889
- break;
11890
- }
11891
- if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data']))
11892
- {
11893
- $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
11894
-
11895
- if ($this->base_location < $link['offset'])
11896
- {
11897
- $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
11898
- }
11899
- else
11900
- {
11901
- $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
11902
- }
11903
-
11904
- if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))))
11905
- {
11906
- $this->checked_feeds++;
11907
- $feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
11908
- if ($this->is_feed($feed))
11909
- {
11910
- return $feed;
11911
- }
11912
- }
11913
- $done[] = $href;
11914
- }
11915
- }
11916
- return null;
11917
- }
11918
-
11919
- function get_links()
11920
- {
11921
- $links = SimplePie_Misc::get_element('a', $this->file->body);
11922
- foreach ($links as $link)
11923
- {
11924
- if (isset($link['attribs']['href']['data']))
11925
- {
11926
- $href = trim($link['attribs']['href']['data']);
11927
- $parsed = SimplePie_Misc::parse_url($href);
11928
- if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
11929
- {
11930
- if ($this->base_location < $link['offset'])
11931
- {
11932
- $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
11933
- }
11934
- else
11935
- {
11936
- $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
11937
- }
11938
-
11939
- $current = SimplePie_Misc::parse_url($this->file->url);
11940
-
11941
- if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority'])
11942
- {
11943
- $this->local[] = $href;
11944
- }
11945
- else
11946
- {
11947
- $this->elsewhere[] = $href;
11948
- }
11949
- }
11950
- }
11951
- }
11952
- $this->local = array_unique($this->local);
11953
- $this->elsewhere = array_unique($this->elsewhere);
11954
- if (!empty($this->local) || !empty($this->elsewhere))
11955
- {
11956
- return true;
11957
- }
11958
- return null;
11959
- }
11960
-
11961
- function extension(&$array)
11962
- {
11963
- foreach ($array as $key => $value)
11964
- {
11965
- if ($this->checked_feeds == $this->max_checked_feeds)
11966
- {
11967
- break;
11968
- }
11969
- if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
11970
- {
11971
- $this->checked_feeds++;
11972
- $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
11973
- if ($this->is_feed($feed))
11974
- {
11975
- return $feed;
11976
- }
11977
- else
11978
- {
11979
- unset($array[$key]);
11980
- }
11981
- }
11982
- }
11983
- return null;
11984
- }
11985
-
11986
- function body(&$array)
11987
- {
11988
- foreach ($array as $key => $value)
11989
- {
11990
- if ($this->checked_feeds == $this->max_checked_feeds)
11991
- {
11992
- break;
11993
- }
11994
- if (preg_match('/(rss|rdf|atom|xml)/i', $value))
11995
- {
11996
- $this->checked_feeds++;
11997
- $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
11998
- if ($this->is_feed($feed))
11999
- {
12000
- return $feed;
12001
- }
12002
- else
12003
- {
12004
- unset($array[$key]);
12005
- }
12006
- }
12007
- }
12008
- return null;
12009
- }
12010
- }
12011
-
12012
- class SimplePie_Parser
12013
- {
12014
- var $error_code;
12015
- var $error_string;
12016
- var $current_line;
12017
- var $current_column;
12018
- var $current_byte;
12019
- var $separator = ' ';
12020
- var $feed = false;
12021
- var $namespace = array('');
12022
- var $element = array('');
12023
- var $xml_base = array('');
12024
- var $xml_base_explicit = array(false);
12025
- var $xml_lang = array('');
12026
- var $data = array();
12027
- var $datas = array(array());
12028
- var $current_xhtml_construct = -1;
12029
- var $encoding;
12030
-
12031
- function parse(&$data, $encoding)
12032
- {
12033
- // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
12034
- if (strtoupper($encoding) == 'US-ASCII')
12035
- {
12036
- $this->encoding = 'UTF-8';
12037
- }
12038
- else
12039
- {
12040
- $this->encoding = $encoding;
12041
- }
12042
-
12043
- // Strip BOM:
12044
- // UTF-32 Big Endian BOM
12045
- if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
12046
- {
12047
- $data = substr($data, 4);
12048
- }
12049
- // UTF-32 Little Endian BOM
12050
- elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
12051
- {
12052
- $data = substr($data, 4);
12053
- }
12054
- // UTF-16 Big Endian BOM
12055
- elseif (substr($data, 0, 2) === "\xFE\xFF")
12056
- {
12057
- $data = substr($data, 2);
12058
- }
12059
- // UTF-16 Little Endian BOM
12060
- elseif (substr($data, 0, 2) === "\xFF\xFE")
12061
- {
12062
- $data = substr($data, 2);
12063
- }
12064
- // UTF-8 BOM
12065
- elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
12066
- {
12067
- $data = substr($data, 3);
12068
- }
12069
-
12070
- if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false)
12071
- {
12072
- $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
12073
- if ($declaration->parse())
12074
- {
12075
- $data = substr($data, $pos + 2);
12076
- $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
12077
- }
12078
- else
12079
- {
12080
- $this->error_string = 'SimplePie bug! Please report this!';
12081
- return false;
12082
- }
12083
- }
12084
-
12085
- // Work around libxml bug
12086
- $data = str_replace('&lt;', '&#60;', $data);
12087
- $data = str_replace('&gt;', '&#62;', $data);
12088
- $data = str_replace('&amp;', '&#38;', $data);
12089
- $data = str_replace('&apos;', '&#39;', $data);
12090
- $data = str_replace('&quot;', '&#34;', $data);
12091
-
12092
- $return = true;
12093
-
12094
- // Create the parser
12095
- $xml = xml_parser_create_ns($this->encoding, $this->separator);
12096
- xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
12097
- xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
12098
- xml_set_object($xml, $this);
12099
- xml_set_character_data_handler($xml, 'cdata');
12100
- xml_set_element_handler($xml, 'tag_open', 'tag_close');
12101
-
12102
- // Parse!
12103
- if (!xml_parse($xml, $data, true))
12104
- {
12105
- $this->error_code = xml_get_error_code($xml);
12106
- $this->error_string = xml_error_string($this->error_code);
12107
- $return = false;
12108
- }
12109
- $this->current_line = xml_get_current_line_number($xml);
12110
- $this->current_column = xml_get_current_column_number($xml);
12111
- $this->current_byte = xml_get_current_byte_index($xml);
12112
- xml_parser_free($xml);
12113
- return $return;
12114
- }
12115
-
12116
- function get_error_code()
12117
- {
12118
- return $this->error_code;
12119
- }
12120
-
12121
- function get_error_string()
12122
- {
12123
- return $this->error_string;
12124
- }
12125
-
12126
- function get_current_line()
12127
- {
12128
- return $this->current_line;
12129
- }
12130
-
12131
- function get_current_column()
12132
- {
12133
- return $this->current_column;
12134
- }
12135
-
12136
- function get_current_byte()
12137
- {
12138
- return $this->current_byte;
12139
- }
12140
-
12141
- function get_data()
12142
- {
12143
- return $this->data;
12144
- }
12145
-
12146
- function tag_open($parser, $tag, $attributes)
12147
- {
12148
- if ($this->feed === 0)
12149
- {
12150
- return;
12151
- }
12152
- elseif ($this->feed == false)
12153
- {
12154
- if (in_array($tag, array(
12155
- SIMPLEPIE_NAMESPACE_ATOM_10 . $this->separator . 'feed',
12156
- SIMPLEPIE_NAMESPACE_ATOM_03 . $this->separator . 'feed',
12157
- 'rss',
12158
- SIMPLEPIE_NAMESPACE_RDF . $this->separator . 'RDF'
12159
- )))
12160
- {
12161
- $this->feed = 1;
12162
- }
12163
- }
12164
- else
12165
- {
12166
- $this->feed++;
12167
- }
12168
-
12169
- list($this->namespace[], $this->element[]) = $this->split_ns($tag);
12170
-
12171
- $attribs = array();
12172
- foreach ($attributes as $name => $value)
12173
- {
12174
- list($attrib_namespace, $attribute) = $this->split_ns($name);
12175
- $attribs[$attrib_namespace][$attribute] = $value;
12176
- }
12177
-
12178
- if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
12179
- {
12180
- $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base));
12181
- $this->xml_base_explicit[] = true;
12182
- }
12183
- else
12184
- {
12185
- $this->xml_base[] = end($this->xml_base);
12186
- $this->xml_base_explicit[] = end($this->xml_base_explicit);
12187
- }
12188
-
12189
- if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
12190
- {
12191
- $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
12192
- }
12193
- else
12194
- {
12195
- $this->xml_lang[] = end($this->xml_lang);
12196
- }
12197
-
12198
- if ($this->current_xhtml_construct >= 0)
12199
- {
12200
- $this->current_xhtml_construct++;
12201
- if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML)
12202
- {
12203
- $this->data['data'] .= '<' . end($this->element);
12204
- if (isset($attribs['']))
12205
- {
12206
- foreach ($attribs[''] as $name => $value)
12207
- {
12208
- $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
12209
- }
12210
- }
12211
- $this->data['data'] .= '>';
12212
- }
12213
- }
12214
- else
12215
- {
12216
- $this->datas[] =& $this->data;
12217
- $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
12218
- $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
12219
- if ((end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] == 'xml')
12220
- || (end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] == 'xhtml'))
12221
- {
12222
- $this->current_xhtml_construct = 0;
12223
- }
12224
- }
12225
- }
12226
-
12227
- function cdata($parser, $cdata)
12228
- {
12229
- if ($this->current_xhtml_construct >= 0)
12230
- {
12231
- $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
12232
- }
12233
- elseif ($this->feed > 1)
12234
- {
12235
- $this->data['data'] .= $cdata;
12236
- }
12237
- }
12238
-
12239
- function tag_close($parser, $tag)
12240
- {
12241
- if (!$this->feed)
12242
- {
12243
- return;
12244
- }
12245
-
12246
- if ($this->current_xhtml_construct >= 0)
12247
- {
12248
- $this->current_xhtml_construct--;
12249
- if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
12250
- {
12251
- $this->data['data'] .= '</' . end($this->element) . '>';
12252
- }
12253
- }
12254
- if ($this->current_xhtml_construct == -1)
12255
- {
12256
- $this->data =& $this->datas[$this->feed];
12257
- array_pop($this->datas);
12258
- }
12259
-
12260
- array_pop($this->element);
12261
- array_pop($this->namespace);
12262
- array_pop($this->xml_base);
12263
- array_pop($this->xml_base_explicit);
12264
- array_pop($this->xml_lang);
12265
- $this->feed--;
12266
- }
12267
-
12268
- function split_ns($string)
12269
- {
12270
- static $cache = array();
12271
- if (!isset($cache[$string]))
12272
- {
12273
- if ($pos = strpos($string, $this->separator))
12274
- {
12275
- static $separator_length;
12276
- if (!$separator_length)
12277
- {
12278
- $separator_length = strlen($this->separator);
12279
- }
12280
- $namespace = substr($string, 0, $pos);
12281
- $local_name = substr($string, $pos + $separator_length);
12282
- if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES)
12283
- {
12284
- $namespace = SIMPLEPIE_NAMESPACE_ITUNES;
12285
- }
12286
-
12287
- // Normalize the Media RSS namespaces
12288
- if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG)
12289
- {
12290
- $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
12291
- }
12292
- $cache[$string] = array($namespace, $local_name);
12293
- }
12294
- else
12295
- {
12296
- $cache[$string] = array('', $string);
12297
- }
12298
- }
12299
- return $cache[$string];
12300
- }
12301
- }
12302
-
12303
- /**
12304
- * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags
12305
- */
12306
- class SimplePie_Sanitize
12307
- {
12308
- // Private vars
12309
- var $base;
12310
-
12311
- // Options
12312
- var $remove_div = true;
12313
- var $image_handler = '';
12314
- var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
12315
- var $encode_instead_of_strip = false;
12316
- var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
12317
- var $strip_comments = false;
12318
- var $output_encoding = 'UTF-8';
12319
- var $enable_cache = true;
12320
- var $cache_location = './cache';
12321
- var $cache_name_function = 'md5';
12322
- var $cache_class = 'SimplePie_Cache';
12323
- var $file_class = 'SimplePie_File';
12324
- var $timeout = 10;
12325
- var $useragent = '';
12326
- var $force_fsockopen = false;
12327
-
12328
- var $replace_url_attributes = array(
12329
- 'a' => 'href',
12330
- 'area' => 'href',
12331
- 'blockquote' => 'cite',
12332
- 'del' => 'cite',
12333
- 'form' => 'action',
12334
- 'img' => array('longdesc', 'src'),
12335
- 'input' => 'src',
12336
- 'ins' => 'cite',
12337
- 'q' => 'cite'
12338
- );
12339
-
12340
- function remove_div($enable = true)
12341
- {
12342
- $this->remove_div = (bool) $enable;
12343
- }
12344
-
12345
- function set_image_handler($page = false)
12346
- {
12347
- if ($page)
12348
- {
12349
- $this->image_handler = (string) $page;
12350
- }
12351
- else
12352
- {
12353
- $this->image_handler = false;
12354
- }
12355
- }
12356
-
12357
- function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache')
12358
- {
12359
- if (isset($enable_cache))
12360
- {
12361
- $this->enable_cache = (bool) $enable_cache;
12362
- }
12363
-
12364
- if ($cache_location)
12365
- {
12366
- $this->cache_location = (string) $cache_location;
12367
- }
12368
-
12369
- if ($cache_name_function)
12370
- {
12371
- $this->cache_name_function = (string) $cache_name_function;
12372
- }
12373
-
12374
- if ($cache_class)
12375
- {
12376
- $this->cache_class = (string) $cache_class;
12377
- }
12378
- }
12379
-
12380
- function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false)
12381
- {
12382
- if ($file_class)
12383
- {
12384
- $this->file_class = (string) $file_class;
12385
- }
12386
-
12387
- if ($timeout)
12388
- {
12389
- $this->timeout = (string) $timeout;
12390
- }
12391
-
12392
- if ($useragent)
12393
- {
12394
- $this->useragent = (string) $useragent;
12395
- }
12396
-
12397
- if ($force_fsockopen)
12398
- {
12399
- $this->force_fsockopen = (string) $force_fsockopen;
12400
- }
12401
- }
12402
-
12403
- function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
12404
- {
12405
- if ($tags)
12406
- {
12407
- if (is_array($tags))
12408
- {
12409
- $this->strip_htmltags = $tags;
12410
- }
12411
- else
12412
- {
12413
- $this->strip_htmltags = explode(',', $tags);
12414
- }
12415
- }
12416
- else
12417
- {
12418
- $this->strip_htmltags = false;
12419
- }
12420
- }
12421
-
12422
- function encode_instead_of_strip($encode = false)
12423
- {
12424
- $this->encode_instead_of_strip = (bool) $encode;
12425
- }
12426
-
12427
- function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
12428
- {
12429
- if ($attribs)
12430
- {
12431
- if (is_array($attribs))
12432
- {
12433
- $this->strip_attributes = $attribs;
12434
- }
12435
- else
12436
- {
12437
- $this->strip_attributes = explode(',', $attribs);
12438
- }
12439
- }
12440
- else
12441
- {
12442
- $this->strip_attributes = false;
12443
- }
12444
- }
12445
-
12446
- function strip_comments($strip = false)
12447
- {
12448
- $this->strip_comments = (bool) $strip;
12449
- }
12450
-
12451
- function set_output_encoding($encoding = 'UTF-8')
12452
- {
12453
- $this->output_encoding = (string) $encoding;
12454
- }
12455
-
12456
- /**
12457
- * Set element/attribute key/value pairs of HTML attributes
12458
- * containing URLs that need to be resolved relative to the feed
12459
- *
12460
- * @access public
12461
- * @since 1.0
12462
- * @param array $element_attribute Element/attribute key/value pairs
12463
- */
12464
- function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
12465
- {
12466
- $this->replace_url_attributes = (array) $element_attribute;
12467
- }
12468
-
12469
- function sanitize($data, $type, $base = '')
12470
- {
12471
- $data = trim($data);
12472
- if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
12473
- {
12474
- if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
12475
- {
12476
- if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
12477
- {
12478
- $type |= SIMPLEPIE_CONSTRUCT_HTML;
12479
- }
12480
- else
12481
- {
12482
- $type |= SIMPLEPIE_CONSTRUCT_TEXT;
12483
- }
12484
- }
12485
-
12486
- if ($type & SIMPLEPIE_CONSTRUCT_BASE64)
12487
- {
12488
- $data = base64_decode($data);
12489
- }
12490
-
12491
- if ($type & SIMPLEPIE_CONSTRUCT_XHTML)
12492
- {
12493
- if ($this->remove_div)
12494
- {
12495
- $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
12496
- $data = preg_replace('/<\/div>$/', '', $data);
12497
- }
12498
- else
12499
- {
12500
- $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
12501
- }
12502
- }
12503
-
12504
- if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
12505
- {
12506
- // Strip comments
12507
- if ($this->strip_comments)
12508
- {
12509
- $data = SimplePie_Misc::strip_comments($data);
12510
- }
12511
-
12512
- // Strip out HTML tags and attributes that might cause various security problems.
12513
- // Based on recommendations by Mark Pilgrim at:
12514
- // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
12515
- if ($this->strip_htmltags)
12516
- {
12517
- foreach ($this->strip_htmltags as $tag)
12518
- {
12519
- $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU';
12520
- while (preg_match($pcre, $data))
12521
- {
12522
- $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data);
12523
- }
12524
- }
12525
- }
12526
-
12527
- if ($this->strip_attributes)
12528
- {
12529
- foreach ($this->strip_attributes as $attrib)
12530
- {
12531
- $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data);
12532
- }
12533
- }
12534
-
12535
- // Replace relative URLs
12536
- $this->base = $base;
12537
- foreach ($this->replace_url_attributes as $element => $attributes)
12538
- {
12539
- $data = $this->replace_urls($data, $element, $attributes);
12540
- }
12541
-
12542
- // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
12543
- if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache)
12544
- {
12545
- $images = SimplePie_Misc::get_element('img', $data);
12546
- foreach ($images as $img)
12547
- {
12548
- if (isset($img['attribs']['src']['data']))
12549
- {
12550
- $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']);
12551
- $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi');
12552
-
12553
- if ($cache->load())
12554
- {
12555
- $img['attribs']['src']['data'] = $this->image_handler . $image_url;
12556
- $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
12557
- }
12558
- else
12559
- {
12560
- $file =& new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
12561
- $headers = $file->headers;
12562
-
12563
- if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)))
12564
- {
12565
- if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
12566
- {
12567
- $img['attribs']['src']['data'] = $this->image_handler . $image_url;
12568
- $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
12569
- }
12570
- else
12571
- {
12572
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
12573
- }
12574
- }
12575
- }
12576
- }
12577
- }
12578
- }
12579
-
12580
- // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
12581
- $data = trim($data);
12582
- }
12583
-
12584
- if ($type & SIMPLEPIE_CONSTRUCT_IRI)
12585
- {
12586
- $data = SimplePie_Misc::absolutize_url($data, $base);
12587
- }
12588
-
12589
- if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI))
12590
- {
12591
- $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
12592
- }
12593
-
12594
- if ($this->output_encoding != 'UTF-8')
12595
- {
12596
- $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
12597
- }
12598
- }
12599
- return $data;
12600
- }
12601
-
12602
- function replace_urls($data, $tag, $attributes)
12603
- {
12604
- if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
12605
- {
12606
- $elements = SimplePie_Misc::get_element($tag, $data);
12607
- foreach ($elements as $element)
12608
- {
12609
- if (is_array($attributes))
12610
- {
12611
- foreach ($attributes as $attribute)
12612
- {
12613
- if (isset($element['attribs'][$attribute]['data']))
12614
- {
12615
- $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base);
12616
- $new_element = SimplePie_Misc::element_implode($element);
12617
- $data = str_replace($element['full'], $new_element, $data);
12618
- $element['full'] = $new_element;
12619
- }
12620
- }
12621
- }
12622
- elseif (isset($element['attribs'][$attributes]['data']))
12623
- {
12624
- $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base);
12625
- $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data);
12626
- }
12627
- }
12628
- }
12629
- return $data;
12630
- }
12631
-
12632
- function do_strip_htmltags($match)
12633
- {
12634
- if ($this->encode_instead_of_strip)
12635
- {
12636
- if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
12637
- {
12638
- $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
12639
- $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
12640
- return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
12641
- }
12642
- else
12643
- {
12644
- return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
12645
- }
12646
- }
12647
- elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
12648
- {
12649
- return $match[4];
12650
- }
12651
- else
12652
- {
12653
- return '';
12654
- }
12655
- }
12656
- }
12657
-
12658
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style.css DELETED
@@ -1,55 +0,0 @@
1
-
2
-
3
- #form_box {
4
- float: left;
5
- width: 290px;
6
- background: #f8f8f8;
7
- border: 1px solid #d6d6d6;
8
- border-left-color: #e4e4e4;
9
- border-top-color: #e4e4e4;
10
- font-size: 11px;
11
- font-weight: bold;
12
- padding: 0.5em;
13
- margin-top: 10px;
14
- margin-bottom: 2px;
15
- }
16
-
17
- #form_box div {
18
- height: 25px;
19
- padding: 0.2em 0.5em;
20
- }
21
-
22
- #form_box div.hr {
23
- border-bottom: 2px solid #e2e2e1;
24
- height: 0px;
25
- margin-top: 0pt;
26
- margin-bottom: 7px;
27
- }
28
-
29
- #form_box p {
30
- float: left;
31
- margin: 4px 0pt;
32
- width: 120px;
33
- }
34
-
35
-
36
- #log {
37
- float: left;
38
- padding: 0.5em;
39
- margin-left: 10px;
40
- width: 290px;
41
- border: 1px solid #d6d6d6;
42
- border-left-color: #e4e4e4;
43
- border-top-color: #e4e4e4;
44
- margin-top: 10px;
45
- }
46
-
47
- #log_res {
48
- overflow: auto;
49
- }
50
-
51
- #log_res.ajax-loading {
52
- padding: 20px 0;
53
- background: url(http://demos.mootools.net/demos/Group/spinner.gif) no-repeat center;
54
- }
55
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
support.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- function mrt_sub2(){
4
- ?>
5
- <div class=wrap>
6
- <h2><?php _e('WP - Security Support') ?></h2>
7
- <div style="height:299px">
8
- Under Construction...<br /><br />
9
- <ul>
10
- <li><a href='http://semperfiwebdesign.com/documentation/wp-security-scan/changelog/' target="_blank">Changelog</a></li>
11
- <li><a href='http://semperfiwebdesign.com/documentation/wp-security-scan/' target="_blank">Documentation</a></li>
12
- <li><a href='http://semperfiwebdesign.com/documentation/wp-security-scan/change-wordpress-database-table-name-prefix/' target="_blank">Change WordPress Databse Table Name Prefix</a></li>
13
-
14
- </ul>
15
- <br /><br /><strong>Backup early, backup often!</strong><br /><br /><br /><br /><br />
16
- <em>For comments, suggestions, bug reporting, etc please <a href="http://semperfiwebdesign.com/contact/">click here</a>.</em>
17
- </div>
18
- Plugin by <a href="http://semperfiwebdesign.com/" title="Semper Fi Web Design">Semper Fi Web Design</a>
19
- </div>
20
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uninstall.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('WP_UNINSTALL_PLUGIN')) {exit;}
2
+ /*
3
+ * Delete stored options from the options table
4
+ */
5
+ delete_option('WSD-COOKIE');
6
+ delete_option('WSD-TOKEN');
7
+ delete_option('WSD-TARGETID');
8
+ delete_option('WSD-USER');