Completed
Branch master (72d684)
by Christian
13:26
created
html/inc/forum_email.inc 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -196,6 +196,10 @@
 block discarded – undo
196 196
 
197 197
 //////////////////// a banishment vote has been started  ///////////
198 198
 //
199
+/**
200
+ * @param integer $duration
201
+ * @param integer $end_time
202
+ */
199 203
 function send_banish_vote_email($user, $duration, $reason, $end_time) {
200 204
 	global $master_url;
201 205
     $now=time();
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     $link = secure_url_base() . "forum_thread.php?id=" . $thread->id;
129 129
     $body = "Another " . PROJECT . " user has posted to the thread
130 130
 \"" . $thread->title . "\".\n"
131
-           ."To view the updated thread, visit:\n$link
131
+            ."To view the updated thread, visit:\n$link
132 132
 
133 133
 --------------------------
134 134
 To change email preferences, visit:
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 //////////////////// a user clicks the red "x" to report a post ///////////
142 142
 //
143 143
 function send_report_post_email($user, $forum, $thread,  $post, $message) {
144
-	global $master_url;
144
+    global $master_url;
145 145
 
146 146
     $body = "";
147 147
     $owner = BoincUser::lookup_id($post->user);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 //////////////////// a banishment vote has been started  ///////////
198 198
 //
199 199
 function send_banish_vote_email($user, $duration, $reason, $end_time) {
200
-	global $master_url;
200
+    global $master_url;
201 201
     $now=time();
202 202
     $subject = PROJECT." banishment vote underway";
203 203
     $vote_url = $master_url."forum_banishment_vote.php";
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
     pm_send_msg($user, $user, $subject, $body, false);
220 220
 
221 221
     $body .= "\n\n<a href=".$vote_url."?action=yes&userid="
222
-             .$user->id
223
-           .">[vote to banish author]</a>\n\n"
224
-           ."<a href=".$vote_url."?action=no&userid="
225
-             .$user->id
226
-           .">[vote not to banish author]</a>";
222
+                .$user->id
223
+            .">[vote to banish author]</a>\n\n"
224
+            ."<a href=".$vote_url."?action=no&userid="
225
+                .$user->id
226
+            .">[vote not to banish author]</a>";
227 227
 
228 228
     $forum = new BoincForum;
229 229
     $forum->parent_type = 0;
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 // - project forums: everyone in POST_REPORT_EMAILS
25 25
 // - team message board: team founder and admins
26 26
 //
27
-function mail_report_list($forum, $subject, $body, $must_send=false) {
27
+function mail_report_list($forum, $subject, $body, $must_send = false) {
28 28
     $success = true;
29 29
     switch ($forum->parent_type) {
30 30
     case 0:
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 function send_moderation_email($forum, $post, $thread, $explanation, $action) {
63 63
     global $master_url;
64 64
 
65
-    $moderator=get_logged_in_user();
65
+    $moderator = get_logged_in_user();
66 66
     $body = "";
67 67
     $user = BoincUser::lookup_id($post->user);
68 68
 
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 // If a user is subscribed to a thread that is replied to,
124 124
 // send them an email notifying them of the reply.
125 125
 //
126
-function send_reply_notification_email($thread, $user){
127
-    $title = PROJECT . ": A user has posted to '". $thread->title ."'";
128
-    $link = secure_url_base() . "forum_thread.php?id=" . $thread->id;
129
-    $body = "Another " . PROJECT . " user has posted to the thread
130
-\"" . $thread->title . "\".\n"
126
+function send_reply_notification_email($thread, $user) {
127
+    $title = PROJECT.": A user has posted to '".$thread->title."'";
128
+    $link = secure_url_base()."forum_thread.php?id=".$thread->id;
129
+    $body = "Another ".PROJECT." user has posted to the thread
130
+\"" . $thread->title."\".\n"
131 131
            ."To view the updated thread, visit:\n$link
132 132
 
133 133
 --------------------------
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 //////////////////// a user clicks the red "x" to report a post ///////////
142 142
 //
143
-function send_report_post_email($user, $forum, $thread,  $post, $message) {
143
+function send_report_post_email($user, $forum, $thread, $post, $message) {
144 144
 	global $master_url;
145 145
 
146 146
     $body = "";
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 //
199 199
 function send_banish_vote_email($user, $duration, $reason, $end_time) {
200 200
 	global $master_url;
201
-    $now=time();
201
+    $now = time();
202 202
     $subject = PROJECT." banishment vote underway";
203 203
     $vote_url = $master_url."forum_banishment_vote.php";
204 204
     $body = "
205 205
 A vote has been started to banish you
206 206
 from the ".PROJECT." message boards until ".date('M j,
207
-Y G:i', $duration+$now).",
207
+Y G:i', $duration + $now).",
208 208
 because your postings have not followed our guidelines.
209 209
 
210
-This vote will last until ".date('M j, Y G:i',$end_time)." or until a majority
210
+This vote will last until ".date('M j, Y G:i', $end_time)." or until a majority
211 211
 decision has been reached.  If the vote does not result in banishment, you will be
212 212
 able to resume posting at that time.
213 213
     ";
Please login to merge, or discard this patch.
html/inc/forum_rss.inc 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -29,6 +29,9 @@
 block discarded – undo
29 29
     return false;
30 30
 }
31 31
 
32
+/**
33
+ * @param boolean $no_images
34
+ */
32 35
 function show_forum_rss_item($thread, $userid, $threads_only, $no_images) {
33 36
     $unique_url=secure_url_base()."forum_thread.php?id=".$thread->id;
34 37
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 function show_forum_rss_item($thread, $userid, $threads_only, $no_images) {
33
-    $unique_url=secure_url_base()."forum_thread.php?id=".$thread->id;
33
+    $unique_url = secure_url_base()."forum_thread.php?id=".$thread->id;
34 34
 
35 35
     $clause2 = " and hidden=0 ";
36 36
     if ($userid) $clause2 .= "and user=$userid";
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     }
42 42
     if (!count($posts)) return;
43 43
     $post = $posts[0];
44
-    $post_date = gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
44
+    $post_date = gmdate('D, d M Y H:i:s', $post->timestamp).' GMT';
45 45
     $post_user = BOincUser::lookup_id($post->user);
46 46
     BoincForumPrefs::lookup($post_user);
47 47
     $options = new output_options();
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
 
85 85
     // Now construct header
86 86
     //
87
-    header ("Expires: " . gmdate('D, d M Y H:i:s', time()+86400) . " GMT");
87
+    header("Expires: ".gmdate('D, d M Y H:i:s', time() + 86400)." GMT");
88 88
     if (sizeof($threads)) {
89 89
         $t = $threads[0];
90
-        $last_mod_time = $threads_only?$t->create_time:$t->timestamp;
91
-        $create_date  = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT'; 
92
-        header ("Last-Modified: " . $create_date);
90
+        $last_mod_time = $threads_only ? $t->create_time : $t->timestamp;
91
+        $create_date  = gmdate('D, d M Y H:i:s', $last_mod_time).' GMT'; 
92
+        header("Last-Modified: ".$create_date);
93 93
     } else {
94
-        $create_date  = gmdate('D, d M Y H:i:s') . ' GMT'; 
94
+        $create_date  = gmdate('D, d M Y H:i:s').' GMT'; 
95 95
     }
96
-    header ("Content-Type: application/xml");
96
+    header("Content-Type: application/xml");
97 97
 
98
-    $forum=BoincForum::lookup_id($forumid);
98
+    $forum = BoincForum::lookup_id($forumid);
99 99
     // Create channel header and open XML content
100 100
     //
101 101
     $description = PROJECT.": $forum->title";
102 102
     if ($userid) {
103 103
         $description .= " (posts by $user->name)";
104 104
     }
105
-    $channel_image = secure_url_base() . "rss_image.gif";
105
+    $channel_image = secure_url_base()."rss_image.gif";
106 106
     $language = "en-us";
107 107
     echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
108 108
         <rss version=\"2.0\">
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,9 +23,15 @@  discard block
 block discarded – undo
23 23
 // return true if the given HTML may contain images or video
24 24
 //
25 25
 function contains_image_or_video($x) {
26
-    if (strstr($x, "<img ")) return true;
27
-    if (strstr($x, "<object ")) return true;
28
-    if (strstr($x, "<iframe ")) return true;
26
+    if (strstr($x, "<img ")) {
27
+        return true;
28
+    }
29
+    if (strstr($x, "<object ")) {
30
+        return true;
31
+    }
32
+    if (strstr($x, "<iframe ")) {
33
+        return true;
34
+    }
29 35
     return false;
30 36
 }
31 37
 
@@ -33,13 +39,17 @@  discard block
 block discarded – undo
33 39
     $unique_url=secure_url_base()."forum_thread.php?id=".$thread->id;
34 40
 
35 41
     $clause2 = " and hidden=0 ";
36
-    if ($userid) $clause2 .= "and user=$userid";
42
+    if ($userid) {
43
+        $clause2 .= "and user=$userid";
44
+    }
37 45
     if ($threads_only) {
38 46
         $posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
39 47
     } else {
40 48
         $posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
41 49
     }
42
-    if (!count($posts)) return;
50
+    if (!count($posts)) {
51
+        return;
52
+    }
43 53
     $post = $posts[0];
44 54
     $post_date = gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
45 55
     $post_user = BOincUser::lookup_id($post->user);
@@ -49,7 +59,9 @@  discard block
 block discarded – undo
49 59
         $options->htmlitems = false;
50 60
     }
51 61
     $t = output_transform($post->content, $options);
52
-    if ($no_images && contains_image_or_video($t)) return;
62
+    if ($no_images && contains_image_or_video($t)) {
63
+        return;
64
+    }
53 65
     echo "<item>
54 66
         <title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title>
55 67
         <link>$unique_url</link>
@@ -65,7 +77,9 @@  discard block
 block discarded – undo
65 77
 
66 78
     if ($userid) {
67 79
         $user = BoincUser::lookup_id($userid);
68
-        if (!$user) error_page("no such user");
80
+        if (!$user) {
81
+            error_page("no such user");
82
+        }
69 83
         $clause .= " and owner=$userid";
70 84
     }
71 85
 
Please login to merge, or discard this patch.
html/inc/geoip.inc 4 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -229,6 +229,9 @@  discard block
 block discarded – undo
229 229
   shmop_close ($shmid);
230 230
 }
231 231
 
232
+/**
233
+ * @param GeoIP $gi
234
+ */
232 235
 function _setup_segments($gi){
233 236
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 237
   $gi->record_length = STANDARD_RECORD_LENGTH;
@@ -311,6 +314,10 @@  discard block
 block discarded – undo
311 314
   return $gi;
312 315
 }
313 316
 
317
+/**
318
+ * @param string $filename
319
+ * @param integer $flags
320
+ */
314 321
 function geoip_open($filename, $flags) {
315 322
   $gi = new GeoIP;
316 323
   $gi->flags = $flags;
@@ -419,6 +426,9 @@  discard block
 block discarded – undo
419 426
   return false;
420 427
 }
421 428
 
429
+/**
430
+ * @param integer $ipnum
431
+ */
422 432
 function _get_org($gi,$ipnum){
423 433
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 434
   if ($seek_org == $gi->databaseSegments) {
@@ -443,6 +453,9 @@  discard block
 block discarded – undo
443 453
   return _get_org($gi, $ipnum);
444 454
 }
445 455
 
456
+/**
457
+ * @param integer $ipnum
458
+ */
446 459
 function _get_region($gi,$ipnum){
447 460
   if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448 461
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
Please login to merge, or discard this patch.
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 }
214 214
 function geoip_load_shared_mem ($file) {
215 215
 
216
-  $fp = fopen($file, "rb");
217
-  if (!$fp) {
216
+    $fp = fopen($file, "rb");
217
+    if (!$fp) {
218 218
     print "error opening $file: $php_errormsg\n";
219 219
     exit;
220
-  }
221
-  $s_array = fstat($fp);
222
-  $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
220
+    }
221
+    $s_array = fstat($fp);
222
+    $size = $s_array['size'];
223
+    if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224 224
     shmop_delete ($shmid);
225 225
     shmop_close ($shmid);
226
-  }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
226
+    }
227
+    $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
+    shmop_write ($shmid, fread($fp, $size), 0);
229
+    shmop_close ($shmid);
230 230
 }
231 231
 
232 232
 function _setup_segments($gi){
233
-  $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
-  $gi->record_length = STANDARD_RECORD_LENGTH;
235
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
233
+    $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
+    $gi->record_length = STANDARD_RECORD_LENGTH;
235
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
236 236
     $offset = @shmop_size ($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238 238
         $delim = @shmop_read ($gi->shmid, $offset, 3);
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246 246
             } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+        } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251
-		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
251
+            || ($gi->databaseType == GEOIP_ISP_EDITION)
252
+            || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
253 253
                 $gi->databaseSegments = 0;
254 254
                 $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255 255
                 for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256 256
                     $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
-			($gi->databaseType == GEOIP_ISP_EDITION)) {
260
-	                $gi->record_length = ORG_RECORD_LENGTH;
258
+                if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
+            ($gi->databaseType == GEOIP_ISP_EDITION)) {
260
+                    $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
262 262
             }
263 263
             break;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273
-  } else {
273
+    } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283 283
         else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
284
-	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
284
+        $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285 285
                 }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288
-		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
288
+         ($gi->databaseType == GEOIP_ISP_EDITION) || 
289 289
                  ($gi->databaseType == GEOIP_ASNUM_EDITION)){
290 290
             $gi->databaseSegments = 0;
291 291
             $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292 292
             for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293 293
             $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
294 294
             }
295
-	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
-	    $gi->record_length = ORG_RECORD_LENGTH;
295
+        if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
+        $gi->record_length = ORG_RECORD_LENGTH;
297 297
             }
298 298
         }
299 299
         break;
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305 305
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
306 306
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
307
-         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
307
+            $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309 309
     fseek($gi->filehandle,$filepos,SEEK_SET);
310
-  }
311
-  return $gi;
310
+    }
311
+    return $gi;
312 312
 }
313 313
 
314 314
 function geoip_open($filename, $flags) {
315
-  $gi = new GeoIP;
316
-  $gi->flags = $flags;
317
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
315
+    $gi = new GeoIP;
316
+    $gi->flags = $flags;
317
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
318 318
     $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320 320
     $gi->filehandle = fopen($filename,"rb");
@@ -322,174 +322,174 @@  discard block
 block discarded – undo
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
324 324
     }
325
-  }
325
+    }
326 326
 
327
-  $gi = _setup_segments($gi);
328
-  return $gi;
327
+    $gi = _setup_segments($gi);
328
+    return $gi;
329 329
 }
330 330
 
331 331
 function geoip_close($gi) {
332
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
332
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
333 333
     return true;
334
-  }
334
+    }
335 335
 
336
-  return fclose($gi->filehandle);
336
+    return fclose($gi->filehandle);
337 337
 }
338 338
 
339 339
 function geoip_country_id_by_name($gi, $name) {
340
-  $addr = gethostbyname($name);
341
-  if (!$addr || $addr == $name) {
340
+    $addr = gethostbyname($name);
341
+    if (!$addr || $addr == $name) {
342 342
     return false;
343
-  }
344
-  return geoip_country_id_by_addr($gi, $addr);
343
+    }
344
+    return geoip_country_id_by_addr($gi, $addr);
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
349
-  if ($country_id !== false) {
348
+    $country_id = geoip_country_id_by_name($gi,$name);
349
+    if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351
-  }
352
-  return false;
351
+    }
352
+    return false;
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
357
-  if ($country_id !== false) {
356
+    $country_id = geoip_country_id_by_name($gi,$name);
357
+    if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359
-  }
360
-  return false;
359
+    }
360
+    return false;
361 361
 }
362 362
 
363 363
 function geoip_country_id_by_addr($gi, $addr) {
364
-  $ipnum = ip2long($addr);
365
-  return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
364
+    $ipnum = ip2long($addr);
365
+    return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
370
-  if ($country_id !== false) {
369
+    $country_id = geoip_country_id_by_addr($gi,$addr);
370
+    if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372
-  }
373
-  return false;
372
+    }
373
+    return false;
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
378
-  if ($country_id !== false) {
377
+    $country_id = geoip_country_id_by_addr($gi,$addr);
378
+    if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380
-  }
381
-  return false;
380
+    }
381
+    return false;
382 382
 }
383 383
 
384 384
 function _geoip_seek_country($gi, $ipnum) {
385
-  $offset = 0;
386
-  for ($depth = 31; $depth >= 0; --$depth) {
385
+    $offset = 0;
386
+    for ($depth = 31; $depth >= 0; --$depth) {
387 387
     if ($gi->flags & GEOIP_MEMORY_CACHE) {
388
-      $buf = substr($gi->memory_buffer,
388
+        $buf = substr($gi->memory_buffer,
389 389
                             2 * $gi->record_length * $offset,
390 390
                             2 * $gi->record_length);
391 391
         } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
392
+        $buf = @shmop_read ($gi->shmid, 
393 393
                             2 * $gi->record_length * $offset,
394 394
                             2 * $gi->record_length );
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+        fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+        $buf = fread($gi->filehandle, 2 * $gi->record_length);
399 399
     }
400 400
     $x = array(0,0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402
-      for ($j = 0; $j < $gi->record_length; ++$j) {
402
+        for ($j = 0; $j < $gi->record_length; ++$j) {
403 403
         $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
404
-      }
404
+        }
405 405
     }
406 406
     if ($ipnum & (1 << $depth)) {
407
-      if ($x[1] >= $gi->databaseSegments) {
407
+        if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409
-      }
410
-      $offset = $x[1];
409
+        }
410
+        $offset = $x[1];
411 411
         } else {
412
-      if ($x[0] >= $gi->databaseSegments) {
412
+        if ($x[0] >= $gi->databaseSegments) {
413 413
         return $x[0];
414
-      }
415
-      $offset = $x[0];
414
+        }
415
+        $offset = $x[0];
416
+    }
416 417
     }
417
-  }
418
-  trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
-  return false;
418
+    trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
+    return false;
420 420
 }
421 421
 
422 422
 function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
424
-  if ($seek_org == $gi->databaseSegments) {
423
+    $seek_org = _geoip_seek_country($gi,$ipnum);
424
+    if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426
-  }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
426
+    }
427
+    $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
429 429
     $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432 432
     $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
433
-  }
434
-  $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
-  return $org_buf;
433
+    }
434
+    $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
+    return $org_buf;
436 436
 }
437 437
 
438 438
 function geoip_org_by_addr ($gi,$addr) {
439
-  if ($addr == NULL) {
439
+    if ($addr == NULL) {
440 440
     return 0;
441
-  }
442
-  $ipnum = ip2long($addr);
443
-  return _get_org($gi, $ipnum);
441
+    }
442
+    $ipnum = ip2long($addr);
443
+    return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446 446
 function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
447
+    if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448 448
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449 449
     if ($seek_region >= 1000){
450
-      $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
450
+        $country_code = "US";
451
+        $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454
-      $region = "";
454
+        $region = "";
455 455
     }
456
-  return array ($country_code,$region);
456
+    return array ($country_code,$region);
457 457
     }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 458
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460 460
     if ($seek_region < US_OFFSET){
461
-      $country_code = "";
462
-      $region = "";  
461
+        $country_code = "";
462
+        $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464
-      $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
464
+        $country_code = "US";
465
+        $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467
-      $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
467
+        $country_code = "CA";
468
+        $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470 470
             $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
471
-      $region = "";
471
+        $region = "";
472
+    }
473
+    return array ($country_code,$region);
472 474
     }
473
-  return array ($country_code,$region);
474
-  }
475 475
 }
476 476
 
477 477
 function geoip_region_by_addr ($gi,$addr) {
478
-  if ($addr == NULL) {
478
+    if ($addr == NULL) {
479 479
     return 0;
480
-  }
481
-  $ipnum = ip2long($addr);
482
-  return _get_region($gi, $ipnum);
480
+    }
481
+    $ipnum = ip2long($addr);
482
+    return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485 485
 function getdnsattributes ($l,$ip){
486
-  $r = new Net_DNS_Resolver();
487
-  $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
491
-  $str = $regs[1];
492
-  return $str;
486
+    $r = new Net_DNS_Resolver();
487
+    $r->nameservers = array("ws1.maxmind.com");
488
+    $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
+    $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
+    ereg("\"(.*)\"",$str,$regs);
491
+    $str = $regs[1];
492
+    return $str;
493 493
 }
494 494
 
495 495
 ?>
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
 "VU", "WF", "WS", "YE", "YT", "CS", "ZA", "ZM", "ZR", "ZW", "A1", "A2", "O1"
139 139
 );
140 140
     var $GEOIP_COUNTRY_CODES3 = array(
141
-"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG",
142
-"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
143
-"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC",
144
-"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
145
-"CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
146
-"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
147
-"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM",
148
-"GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO",
149
-"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
150
-"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
151
-"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
152
-"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
153
-"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
154
-"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
155
-"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
156
-"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF",
157
-"TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA",
158
-"UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
159
-        "WLF","WSM","YEM","YT","SCG","ZAF","ZMB","ZR","ZWE","A1","A2","O1"
141
+"", "AP", "EU", "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT", "AGO", "AQ", "ARG",
142
+"ASM", "AUT", "AUS", "ABW", "AZE", "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
143
+"BEN", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BV", "BWA", "BLR", "BLZ", "CAN", "CC",
144
+"COD", "CAF", "COG", "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", "CUB", "CPV",
145
+"CX", "CYP", "CZE", "DEU", "DJI", "DNK", "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH",
146
+"ERI", "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", "FX", "GAB", "GBR", "GRD",
147
+"GEO", "GUF", "GHA", "GIB", "GRL", "GMB", "GIN", "GLP", "GNQ", "GRC", "GS", "GTM", "GUM",
148
+"GNB", "GUY", "HKG", "HM", "HND", "HRV", "HTI", "HUN", "IDN", "IRL", "ISR", "IND", "IO",
149
+"IRQ", "IRN", "ISL", "ITA", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", "COM", "KNA",
150
+"PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU",
151
+"LUX", "LVA", "LBY", "MAR", "MCO", "MDA", "MDG", "MHL", "MKD", "MLI", "MMR", "MNG", "MAC",
152
+"MNP", "MTQ", "MRT", "MSR", "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", "NCL",
153
+"NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", "NRU", "NIU", "NZL", "OMN", "PAN", "PER",
154
+"PYF", "PNG", "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", "PLW", "PRY", "QAT",
155
+"REU", "ROU", "RUS", "RWA", "SAU", "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
156
+"SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV", "SYR", "SWZ", "TCA", "TCD", "TF",
157
+"TGO", "THA", "TJK", "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", "TWN", "TZA",
158
+"UKR", "UGA", "UM", "USA", "URY", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT",
159
+        "WLF", "WSM", "YEM", "YT", "SCG", "ZAF", "ZMB", "ZR", "ZWE", "A1", "A2", "O1"
160 160
     );
161 161
     var $GEOIP_COUNTRY_NAMES = array(
162 162
 "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
209 209
 "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
210 210
 "Serbia and Montenegro", "South Africa", "Zambia", "Zaire", "Zimbabwe",
211
-"Anonymous Proxy","Satellite Provider","Other"
211
+"Anonymous Proxy", "Satellite Provider", "Other"
212 212
 );
213 213
 }
214
-function geoip_load_shared_mem ($file) {
214
+function geoip_load_shared_mem($file) {
215 215
 
216 216
   $fp = fopen($file, "rb");
217 217
   if (!$fp) {
@@ -220,42 +220,42 @@  discard block
 block discarded – undo
220 220
   }
221 221
   $s_array = fstat($fp);
222 222
   $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224
-    shmop_delete ($shmid);
225
-    shmop_close ($shmid);
223
+  if ($shmid = @shmop_open(GEOIP_SHM_KEY, "w", 0, 0)) {
224
+    shmop_delete($shmid);
225
+    shmop_close($shmid);
226 226
   }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
227
+  $shmid = shmop_open(GEOIP_SHM_KEY, "c", 0644, $size);
228
+  shmop_write($shmid, fread($fp, $size), 0);
229
+  shmop_close($shmid);
230 230
 }
231 231
 
232
-function _setup_segments($gi){
232
+function _setup_segments($gi) {
233 233
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 234
   $gi->record_length = STANDARD_RECORD_LENGTH;
235
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
236
-    $offset = @shmop_size ($gi->shmid) - 3;
235
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
236
+    $offset = @shmop_size($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238
-        $delim = @shmop_read ($gi->shmid, $offset, 3);
238
+        $delim = @shmop_read($gi->shmid, $offset, 3);
239 239
         $offset += 3;
240 240
         if ($delim == (chr(255).chr(255).chr(255))) {
241
-            $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
241
+            $gi->databaseType = ord(@shmop_read($gi->shmid, $offset, 1));
242 242
             $offset++;
243 243
 
244
-            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
244
+            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246
-            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
246
+            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251 251
 		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
252
+		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
253 253
                 $gi->databaseSegments = 0;
254
-                $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
-                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256
-                    $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
254
+                $buf = @shmop_read($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
+                for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
256
+                    $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
258
+	            if (($gi->databaseType == GEOIP_ORG_EDITION) ||
259 259
 			($gi->databaseType == GEOIP_ISP_EDITION)) {
260 260
 	                $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
@@ -265,32 +265,32 @@  discard block
 block discarded – undo
265 265
             $offset -= 4;
266 266
         }
267 267
     }
268
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
269
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
270
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
268
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
269
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
270
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273 273
   } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
277
-        $delim = fread($gi->filehandle,3);
278
-        if ($delim == (chr(255).chr(255).chr(255))){
279
-        $gi->databaseType = ord(fread($gi->filehandle,1));
280
-        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
277
+        $delim = fread($gi->filehandle, 3);
278
+        if ($delim == (chr(255).chr(255).chr(255))) {
279
+        $gi->databaseType = ord(fread($gi->filehandle, 1));
280
+        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
283
+        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
284 284
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
285
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 288
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
289
-                 ($gi->databaseType == GEOIP_ASNUM_EDITION)){
289
+                 ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
290 290
             $gi->databaseSegments = 0;
291
-            $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292
-            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293
-            $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
291
+            $buf = fread($gi->filehandle, SEGMENT_RECORD_LENGTH);
292
+            for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
293
+            $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
294 294
             }
295 295
 	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296 296
 	    $gi->record_length = ORG_RECORD_LENGTH;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
         fseek($gi->filehandle, -4, SEEK_CUR);
302 302
         }
303 303
     }
304
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
306
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
304
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
305
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
306
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
307 307
          $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309
-    fseek($gi->filehandle,$filepos,SEEK_SET);
309
+    fseek($gi->filehandle, $filepos, SEEK_SET);
310 310
   }
311 311
   return $gi;
312 312
 }
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 function geoip_open($filename, $flags) {
315 315
   $gi = new GeoIP;
316 316
   $gi->flags = $flags;
317
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
318
-    $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
317
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
318
+    $gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320
-    $gi->filehandle = fopen($filename,"rb");
321
-    if ($gi->flags & GEOIP_MEMORY_CACHE) {
320
+    $gi->filehandle = fopen($filename, "rb");
321
+    if ($gi->flags&GEOIP_MEMORY_CACHE) {
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
324 324
     }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 }
330 330
 
331 331
 function geoip_close($gi) {
332
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
332
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
333 333
     return true;
334 334
   }
335 335
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
348
+  $country_id = geoip_country_id_by_name($gi, $name);
349 349
   if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351 351
   }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
356
+  $country_id = geoip_country_id_by_name($gi, $name);
357 357
   if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359 359
   }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
369
+  $country_id = geoip_country_id_by_addr($gi, $addr);
370 370
   if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372 372
   }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
377
+  $country_id = geoip_country_id_by_addr($gi, $addr);
378 378
   if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380 380
   }
@@ -384,26 +384,26 @@  discard block
 block discarded – undo
384 384
 function _geoip_seek_country($gi, $ipnum) {
385 385
   $offset = 0;
386 386
   for ($depth = 31; $depth >= 0; --$depth) {
387
-    if ($gi->flags & GEOIP_MEMORY_CACHE) {
387
+    if ($gi->flags&GEOIP_MEMORY_CACHE) {
388 388
       $buf = substr($gi->memory_buffer,
389
-                            2 * $gi->record_length * $offset,
390
-                            2 * $gi->record_length);
391
-        } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
393
-                            2 * $gi->record_length * $offset,
394
-                            2 * $gi->record_length );
389
+                            2*$gi->record_length*$offset,
390
+                            2*$gi->record_length);
391
+        } elseif ($gi->flags&GEOIP_SHARED_MEMORY) {
392
+      $buf = @shmop_read($gi->shmid, 
393
+                            2*$gi->record_length*$offset,
394
+                            2*$gi->record_length);
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+      fseek($gi->filehandle, 2*$gi->record_length*$offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+      $buf = fread($gi->filehandle, 2*$gi->record_length);
399 399
     }
400
-    $x = array(0,0);
400
+    $x = array(0, 0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402 402
       for ($j = 0; $j < $gi->record_length; ++$j) {
403
-        $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
403
+        $x[$i] += ord($buf[$gi->record_length*$i + $j]) << ($j*8);
404 404
       }
405 405
     }
406
-    if ($ipnum & (1 << $depth)) {
406
+    if ($ipnum&(1 << $depth)) {
407 407
       if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409 409
       }
@@ -419,23 +419,23 @@  discard block
 block discarded – undo
419 419
   return false;
420 420
 }
421 421
 
422
-function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
422
+function _get_org($gi, $ipnum) {
423
+  $seek_org = _geoip_seek_country($gi, $ipnum);
424 424
   if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426 426
   }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
429
-    $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
427
+  $record_pointer = $seek_org + (2*$gi->record_length - 1)*$gi->databaseSegments;
428
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
429
+    $org_buf = @shmop_read($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432
-    $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
432
+    $org_buf = fread($gi->filehandle, MAX_ORG_RECORD_LENGTH);
433 433
   }
434 434
   $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435 435
   return $org_buf;
436 436
 }
437 437
 
438
-function geoip_org_by_addr ($gi,$addr) {
438
+function geoip_org_by_addr($gi, $addr) {
439 439
   if ($addr == NULL) {
440 440
     return 0;
441 441
   }
@@ -443,38 +443,38 @@  discard block
 block discarded – undo
443 443
   return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446
-function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449
-    if ($seek_region >= 1000){
446
+function _get_region($gi, $ipnum) {
447
+  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
448
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0;
449
+    if ($seek_region >= 1000) {
450 450
       $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
451
+      $region = chr(($seek_region - 1000)/26 + 65).chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454 454
       $region = "";
455 455
     }
456
-  return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
456
+  return array($country_code, $region);
457
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460
-    if ($seek_region < US_OFFSET){
460
+    if ($seek_region < US_OFFSET) {
461 461
       $country_code = "";
462 462
       $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464 464
       $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
465
+      $region = chr(($seek_region - US_OFFSET)/26 + 65).chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467 467
       $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
468
+      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65).chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470
-            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
470
+            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET)/FIPS_RANGE];
471 471
       $region = "";
472 472
     }
473
-  return array ($country_code,$region);
473
+  return array($country_code, $region);
474 474
   }
475 475
 }
476 476
 
477
-function geoip_region_by_addr ($gi,$addr) {
477
+function geoip_region_by_addr($gi, $addr) {
478 478
   if ($addr == NULL) {
479 479
     return 0;
480 480
   }
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
   return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485
-function getdnsattributes ($l,$ip){
485
+function getdnsattributes($l, $ip) {
486 486
   $r = new Net_DNS_Resolver();
487 487
   $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
488
+  $p = $r->search($l.".".$ip.".s.maxmind.com", "TXT", "IN");
489
+  $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
490
+  ereg("\"(.*)\"", $str, $regs);
491 491
   $str = $regs[1];
492 492
   return $str;
493 493
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -279,10 +279,9 @@  discard block
 block discarded – undo
279 279
         $gi->databaseType = ord(fread($gi->filehandle,1));
280 280
         if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282
-        }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
282
+        } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
284 283
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
284
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 285
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 286
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 287
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
@@ -454,7 +453,7 @@  discard block
 block discarded – undo
454 453
       $region = "";
455 454
     }
456 455
   return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
456
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 457
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 458
     //print $seek_region;
460 459
     if ($seek_region < US_OFFSET){
Please login to merge, or discard this patch.
html/inc/host.inc 3 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -324,6 +324,11 @@  discard block
 block discarded – undo
324 324
 // so it's OK to show the domain name etc.
325 325
 // If private is false, show the owner's name only if they've given permission
326 326
 //
327
+/**
328
+ * @param integer $i
329
+ * @param boolean $show_owner
330
+ * @param boolean $any_product_name
331
+ */
327 332
 function show_host_row($host, $i, $private, $show_owner, $any_product_name) {
328 333
     $anonymous = false;
329 334
     if (!$private) {
@@ -503,6 +508,9 @@  discard block
 block discarded – undo
503 508
 // that their time intervals are disjoint.
504 509
 // So the CPU/OS checks don't have to be very strict.
505 510
 //
511
+/**
512
+ * @param boolean $show_detail
513
+ */
506 514
 function hosts_compatible($host1, $host2, $show_detail) {
507 515
     // A host is "new" if it has no credit and no results.
508 516
     // Skip disjoint-time check if one host or other is new
@@ -642,6 +650,9 @@  discard block
 block discarded – undo
642 650
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
643 651
 }
644 652
 
653
+/**
654
+ * @param string $sort
655
+ */
645 656
 function link_url_rev($actual_sort, $sort, $rev, $show_all) {
646 657
     if ($actual_sort == $sort) {
647 658
         $rev = 1 - $rev;
@@ -661,6 +672,9 @@  discard block
 block discarded – undo
661 672
     echo "<p>";
662 673
 }
663 674
 
675
+/**
676
+ * @param boolean $any_product_name
677
+ */
664 678
 function user_host_table_start(
665 679
     $private, $sort, $rev, $show_all, $any_product_name
666 680
 ) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 
33 33
 function sched_log_name($x) {
34 34
     if ($x == 0) return "NO_SUCH_LOG";
35
-    return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
35
+    return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt";
36 36
 }
37 37
 
38 38
 function sched_log_link($x) {
39 39
     if (file_exists("sched_logs")) {
40
-        return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>";
40
+        return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>";
41 41
     } else {
42 42
         return time_str($x);
43 43
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 function location_form($host) {
47 47
     $none = "selected";
48
-    $h=$w=$s=$m="";
48
+    $h = $w = $s = $m = "";
49 49
     if ($host->venue == "home") $h = "selected";
50 50
     if ($host->venue == "work") $w = "selected";
51 51
     if ($host->venue == "school") $s = "selected";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             row2(tra("Product name"), $host->product_name);
99 99
         }
100 100
         $x = $host->timezone/3600;
101
-        if ($x >= 0) $x="+$x";
101
+        if ($x >= 0) $x = "+$x";
102 102
         row2(tra("Local Standard Time"), tra("UTC %1 hours", $x));
103 103
     } else {
104 104
         $owner = BoincUser::lookup_id($host->userid);
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if ($d[0] == "BOINC") continue;
257 257
         if ($d[0] == "vbox") continue;
258 258
         if ($str) $str .= "<p>";
259
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
259
+        if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] ";
260 260
         if ($d[0] == "CUDA") {
261 261
             $str .= "NVIDIA";
262 262
         } else if ($d[0] == "CAL") {
@@ -449,14 +449,14 @@  discard block
 block discarded – undo
449 449
     if ($pos1 === false) return $x;
450 450
     $pos2 = strpos($model, ']');
451 451
     if ($pos2 === false) return $x;
452
-    $a = substr($model, $pos1+1, $pos2-$pos1-1);
452
+    $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1);
453 453
     $y = explode(" ", $a);
454 454
     if (count($y) == 0) return $x;
455 455
     if ($y[0] == "Family") {
456 456
         $x->info = $a;
457 457
     } else {
458 458
         $x->arch = $y[0];
459
-        $x->info = substr($a, strlen($y[0])+1);
459
+        $x->info = substr($a, strlen($y[0]) + 1);
460 460
     }
461 461
     return $x;
462 462
 }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
     $avg_time = 0;
546 546
 
547 547
     $results = BoincResult::enum("hostid=$hostid order by received_time");
548
-    foreach($results as $result) {
548
+    foreach ($results as $result) {
549 549
         if ($result->granted_credit <= 0) continue;
550 550
         $total += $result->granted_credit;
551 551
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 
639 639
 function link_url($sort, $rev, $show_all) {
640 640
     global $userid;
641
-    $x = $userid ? "&userid=$userid":"";
641
+    $x = $userid ? "&userid=$userid" : "";
642 642
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
643 643
 }
644 644
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 }
711 711
 
712 712
 function show_user_hosts($userid, $private, $show_all, $sort, $rev) {
713
-    $desc = false;  // whether the sort order's default is decreasing
713
+    $desc = false; // whether the sort order's default is decreasing
714 714
     switch ($sort) {
715 715
     case "total_credit": $sort_clause = "total_credit"; $desc = true; break;
716 716
     case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     more_or_less($sort, $rev, $show_all);
734 734
 
735 735
     $now = time();
736
-    $old_hosts=0;
736
+    $old_hosts = 0;
737 737
     $i = 1;
738 738
     $hosts = BoincHost::enum("userid=$userid order by $sort_clause");
739 739
     $any_product_name = false;
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
     }
746 746
     user_host_table_start($private, $sort, $rev, $show_all, $any_product_name);
747 747
     foreach ($hosts as $host) {
748
-        $is_old=false;
748
+        $is_old = false;
749 749
         if (($now - $host->rpc_time) > 30*86400) {
750
-            $is_old=true;
750
+            $is_old = true;
751 751
             $old_hosts++;
752 752
         }
753 753
         if (!$show_all && $is_old) continue;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     }
757 757
     end_table();
758 758
 
759
-    if ($old_hosts>0) {
759
+    if ($old_hosts > 0) {
760 760
         more_or_less($sort, $rev, $show_all);
761 761
     }
762 762
 
@@ -776,6 +776,6 @@  discard block
 block discarded – undo
776 776
     }
777 777
 }
778 778
 
779
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
779
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
780 780
 
781 781
 ?>
Please login to merge, or discard this patch.
Braces   +102 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,16 +22,24 @@  discard block
 block discarded – undo
22 22
 require_once("../inc/user.inc");
23 23
 
24 24
 function link_to_results($host) {
25
-    if (!$host) return tra("No host");
25
+    if (!$host) {
26
+        return tra("No host");
27
+    }
26 28
     $config = get_config();
27
-    if (!parse_bool($config, "show_results")) return tra("Unavailable");
29
+    if (!parse_bool($config, "show_results")) {
30
+        return tra("Unavailable");
31
+    }
28 32
     $nresults = host_nresults($host);
29
-    if (!$nresults) return "0";
33
+    if (!$nresults) {
34
+        return "0";
35
+    }
30 36
     return "<a href=results.php?hostid=$host->id>$nresults</a>";
31 37
 }
32 38
 
33 39
 function sched_log_name($x) {
34
-    if ($x == 0) return "NO_SUCH_LOG";
40
+    if ($x == 0) {
41
+        return "NO_SUCH_LOG";
42
+    }
35 43
     return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
36 44
 }
37 45
 
@@ -46,9 +54,15 @@  discard block
 block discarded – undo
46 54
 function location_form($host) {
47 55
     $none = "selected";
48 56
     $h=$w=$s=$m="";
49
-    if ($host->venue == "home") $h = "selected";
50
-    if ($host->venue == "work") $w = "selected";
51
-    if ($host->venue == "school") $s = "selected";
57
+    if ($host->venue == "home") {
58
+        $h = "selected";
59
+    }
60
+    if ($host->venue == "work") {
61
+        $w = "selected";
62
+    }
63
+    if ($host->venue == "school") {
64
+        $s = "selected";
65
+    }
52 66
     $x = "<form action=host_venue_action.php>
53 67
         <input type=hidden name=hostid value=$host->id>
54 68
         <select class=\"form-control\" name=venue>
@@ -98,7 +112,9 @@  discard block
 block discarded – undo
98 112
             row2(tra("Product name"), $host->product_name);
99 113
         }
100 114
         $x = $host->timezone/3600;
101
-        if ($x >= 0) $x="+$x";
115
+        if ($x >= 0) {
116
+            $x="+$x";
117
+        }
102 118
         row2(tra("Local Standard Time"), tra("UTC %1 hours", $x));
103 119
     } else {
104 120
         $owner = BoincUser::lookup_id($host->userid);
@@ -253,10 +269,18 @@  discard block
 block discarded – undo
253 269
         $desc = trim($desc, "[");
254 270
         $d = explode("|", $desc);
255 271
         //print_r($d);
256
-        if ($d[0] == "BOINC") continue;
257
-        if ($d[0] == "vbox") continue;
258
-        if ($str) $str .= "<p>";
259
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
272
+        if ($d[0] == "BOINC") {
273
+            continue;
274
+        }
275
+        if ($d[0] == "vbox") {
276
+            continue;
277
+        }
278
+        if ($str) {
279
+            $str .= "<p>";
280
+        }
281
+        if ($d[2]!="" && $d[2]!="1") {
282
+            $str .= "[".$d[2]."] ";
283
+        }
260 284
         if ($d[0] == "CUDA") {
261 285
             $str .= "NVIDIA";
262 286
         } else if ($d[0] == "CAL") {
@@ -297,7 +321,9 @@  discard block
 block discarded – undo
297 321
 
298 322
 
299 323
     }
300
-    if (!$str) $str = "---";
324
+    if (!$str) {
325
+        $str = "---";
326
+    }
301 327
     return $str;
302 328
 }
303 329
 
@@ -305,7 +331,9 @@  discard block
 block discarded – undo
305 331
 //
306 332
 function boinc_version($x) {
307 333
     $y = strstr($x, 'BOINC');
308
-    if (!$y) return '';
334
+    if (!$y) {
335
+        return '';
336
+    }
309 337
     $z = explode("]", $y, 2);
310 338
     $a = explode('|', $z[0]);
311 339
     $v = $a[1];
@@ -442,16 +470,26 @@  discard block
 block discarded – undo
442 470
     $x->arch = null;
443 471
     $x->info = null;
444 472
     foreach ($y as $z) {
445
-        if (strstr($z, "GHz")) $x->speed = $z;
446
-        if (strstr($z, "MHz")) $x->speed = $z;
473
+        if (strstr($z, "GHz")) {
474
+            $x->speed = $z;
475
+        }
476
+        if (strstr($z, "MHz")) {
477
+            $x->speed = $z;
478
+        }
447 479
     }
448 480
     $pos1 = strpos($model, '[');
449
-    if ($pos1 === false) return $x;
481
+    if ($pos1 === false) {
482
+        return $x;
483
+    }
450 484
     $pos2 = strpos($model, ']');
451
-    if ($pos2 === false) return $x;
485
+    if ($pos2 === false) {
486
+        return $x;
487
+    }
452 488
     $a = substr($model, $pos1+1, $pos2-$pos1-1);
453 489
     $y = explode(" ", $a);
454
-    if (count($y) == 0) return $x;
490
+    if (count($y) == 0) {
491
+        return $x;
492
+    }
455 493
     if ($y[0] == "Family") {
456 494
         $x->info = $a;
457 495
     } else {
@@ -462,38 +500,64 @@  discard block
 block discarded – undo
462 500
 }
463 501
 
464 502
 function cpus_compatible($host1, $host2) {
465
-    if ($host1->p_ncpus != $host2->p_ncpus) return false;
466
-    if ($host1->p_vendor != $host2->p_vendor) return false;
503
+    if ($host1->p_ncpus != $host2->p_ncpus) {
504
+        return false;
505
+    }
506
+    if ($host1->p_vendor != $host2->p_vendor) {
507
+        return false;
508
+    }
467 509
     $x1 = parse_model($host1->p_model);
468 510
     $x2 = parse_model($host2->p_model);
469 511
     if ($x1->info && $x2->info) {
470
-        if ($x1->info != $x2->info) return false;
512
+        if ($x1->info != $x2->info) {
513
+            return false;
514
+        }
471 515
         if ($x1->speed && $x2->speed) {
472
-            if ($x1->speed != $x2->speed) return false;
516
+            if ($x1->speed != $x2->speed) {
517
+                return false;
518
+            }
473 519
         }
474 520
         if ($x1->arch && $x2->arch) {
475
-            if ($x1->arch != $x2->arch) return false;
521
+            if ($x1->arch != $x2->arch) {
522
+                return false;
523
+            }
476 524
         }
477 525
         return true;
478 526
     }
479
-    if ($host1->p_model != $host2->p_model) return false;
527
+    if ($host1->p_model != $host2->p_model) {
528
+        return false;
529
+    }
480 530
     return true;
481 531
 }
482 532
 
483 533
 // does one host strictly precede the other?
484 534
 //
485 535
 function times_disjoint($host1, $host2) {
486
-    if ($host1->rpc_time < $host2->create_time) return true;
487
-    if ($host2->rpc_time < $host1->create_time) return true;
536
+    if ($host1->rpc_time < $host2->create_time) {
537
+        return true;
538
+    }
539
+    if ($host2->rpc_time < $host1->create_time) {
540
+        return true;
541
+    }
488 542
     return false;
489 543
 }
490 544
 
491 545
 function os_compatible($host1, $host2) {
492
-    if (strstr($host1->os_name, "Windows") && strstr($host2->os_name, "Windows")) return true;
493
-    if (strstr($host1->os_name, "Linux") && strstr($host2->os_name, "Linux")) return true;
494
-    if (strstr($host1->os_name, "Darwin") && strstr($host2->os_name, "Darwin")) return true;
495
-    if (strstr($host1->os_name, "SunOS") && strstr($host2->os_name, "SunOS")) return true;
496
-    if ($host1->os_name == $host2->os_name) return true;
546
+    if (strstr($host1->os_name, "Windows") && strstr($host2->os_name, "Windows")) {
547
+        return true;
548
+    }
549
+    if (strstr($host1->os_name, "Linux") && strstr($host2->os_name, "Linux")) {
550
+        return true;
551
+    }
552
+    if (strstr($host1->os_name, "Darwin") && strstr($host2->os_name, "Darwin")) {
553
+        return true;
554
+    }
555
+    if (strstr($host1->os_name, "SunOS") && strstr($host2->os_name, "SunOS")) {
556
+        return true;
557
+    }
558
+    if ($host1->os_name == $host2->os_name) {
559
+        return true;
560
+    }
497 561
     return false;
498 562
 }
499 563
 
@@ -546,7 +610,9 @@  discard block
 block discarded – undo
546 610
 
547 611
     $results = BoincResult::enum("hostid=$hostid order by received_time");
548 612
     foreach($results as $result) {
549
-        if ($result->granted_credit <= 0) continue;
613
+        if ($result->granted_credit <= 0) {
614
+            continue;
615
+        }
550 616
         $total += $result->granted_credit;
551 617
 
552 618
         update_average(
@@ -750,7 +816,9 @@  discard block
 block discarded – undo
750 816
             $is_old=true;
751 817
             $old_hosts++;
752 818
         }
753
-        if (!$show_all && $is_old) continue;
819
+        if (!$show_all && $is_old) {
820
+            continue;
821
+        }
754 822
         show_host_row($host, $i, $private, false, $any_product_name);
755 823
         $i++;
756 824
     }
Please login to merge, or discard this patch.
html/inc/htmLawed.php 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -616,6 +616,10 @@
 block discarded – undo
616 616
 // eof 
617 617
 } 
618 618
 
619
+/**
620
+ * @param string $e
621
+ * @param string $a
622
+ */
619 623
 function hl_tag2(&$e, &$a, $t=1){ 
620 624
 // transform tag 
621 625
 if($e == 'center'){$e = 'div'; return 'text-align: center;';} 
Please login to merge, or discard this patch.
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
 function htmLawed($t, $C=1, $S=array()){ 
13 13
 $C = is_array($C) ? $C : array(); 
14 14
 if(!empty($C['valid_xhtml'])){ 
15
- $C['elements'] = empty($C['elements']) ? '*-center-dir-font-isindex-menu-s-strike-u' : $C['elements']; 
16
- $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; 
17
- $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; 
15
+    $C['elements'] = empty($C['elements']) ? '*-center-dir-font-isindex-menu-s-strike-u' : $C['elements']; 
16
+    $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; 
17
+    $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; 
18 18
 } 
19 19
 // config eles 
20 20
 $e = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'applet'=>1, 'area'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'blockquote'=>1, 'br'=>1, 'button'=>1, 'caption'=>1, 'center'=>1, 'cite'=>1, 'code'=>1, 'col'=>1, 'colgroup'=>1, 'dd'=>1, 'del'=>1, 'dfn'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'dt'=>1, 'em'=>1, 'embed'=>1, 'fieldset'=>1, 'font'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'isindex'=>1, 'kbd'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'p'=>1, 'param'=>1, 'pre'=>1, 'q'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'script'=>1, 'select'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'table'=>1, 'tbody'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'tt'=>1, 'u'=>1, 'ul'=>1, 'var'=>1); // 86/deprecated+embed+ruby 
21 21
 if(!empty($C['safe'])){ 
22
- unset($e['applet'], $e['embed'], $e['iframe'], $e['object'], $e['script']); 
22
+    unset($e['applet'], $e['embed'], $e['iframe'], $e['object'], $e['script']); 
23 23
 } 
24 24
 $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; 
25 25
 if($x == '-*'){$e = array();} 
26 26
 elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} 
27 27
 else{ 
28
- if(isset($x[1])){ 
29
-  preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); 
30
-  for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} 
31
-  foreach($m as $v){ 
32
-   if($v[0] == '+'){$e[substr($v, 1)] = 1;} 
33
-   if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} 
34
-  } 
35
- } 
28
+    if(isset($x[1])){ 
29
+    preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); 
30
+    for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} 
31
+    foreach($m as $v){ 
32
+    if($v[0] == '+'){$e[substr($v, 1)] = 1;} 
33
+    if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} 
34
+    } 
35
+    } 
36 36
 } 
37 37
 $C['elements'] =& $e; 
38 38
 // config attrs 
39 39
 $x = !empty($C['deny_attribute']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['deny_attribute']) : ''; 
40 40
 $x = array_flip((isset($x[0]) && $x[0] == '*') ? explode('-', $x) : explode(',', $x. (!empty($C['safe']) ? ',on*' : ''))); 
41 41
 if(isset($x['on*'])){ 
42
- unset($x['on*']); 
43
- $x += array('onblur'=>1, 'onchange'=>1, 'onclick'=>1, 'ondblclick'=>1, 'onfocus'=>1, 'onkeydown'=>1, 'onkeypress'=>1, 'onkeyup'=>1, 'onmousedown'=>1, 'onmousemove'=>1, 'onmouseout'=>1, 'onmouseover'=>1, 'onmouseup'=>1, 'onreset'=>1, 'onselect'=>1, 'onsubmit'=>1); 
42
+    unset($x['on*']); 
43
+    $x += array('onblur'=>1, 'onchange'=>1, 'onclick'=>1, 'ondblclick'=>1, 'onfocus'=>1, 'onkeydown'=>1, 'onkeypress'=>1, 'onkeyup'=>1, 'onmousedown'=>1, 'onmousemove'=>1, 'onmouseout'=>1, 'onmouseover'=>1, 'onmouseup'=>1, 'onreset'=>1, 'onselect'=>1, 'onsubmit'=>1); 
44 44
 } 
45 45
 $C['deny_attribute'] = $x; 
46 46
 // config URL 
47 47
 $x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https'; 
48 48
 $C['schemes'] = array(); 
49 49
 foreach(explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v){ 
50
- $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); 
51
- if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} 
50
+    $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); 
51
+    if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} 
52 52
 } 
53 53
 if(!isset($C['schemes']['*'])){$C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1,);} 
54 54
 if(!empty($C['safe']) && empty($C['schemes']['style'])){$C['schemes']['style'] = array('!'=>1);} 
55 55
 $C['abs_url'] = isset($C['abs_url']) ? $C['abs_url'] : 0; 
56 56
 if(!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])){ 
57
- $C['base_url'] = $C['abs_url'] = 0; 
57
+    $C['base_url'] = $C['abs_url'] = 0; 
58 58
 } 
59 59
 // config rest 
60 60
 $C['and_mark'] = empty($C['and_mark']) ? 0 : 1; 
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
 
90 90
 $t = preg_replace('`[\x00-\x08\x0b-\x0c\x0e-\x1f]`', '', $t); 
91 91
 if($C['clean_ms_char']){ 
92
- $x = array("\x7f"=>'', "\x80"=>'&#8364;', "\x81"=>'', "\x83"=>'&#402;', "\x85"=>'&#8230;', "\x86"=>'&#8224;', "\x87"=>'&#8225;', "\x88"=>'&#710;', "\x89"=>'&#8240;', "\x8a"=>'&#352;', "\x8b"=>'&#8249;', "\x8c"=>'&#338;', "\x8d"=>'', "\x8e"=>'&#381;', "\x8f"=>'', "\x90"=>'', "\x95"=>'&#8226;', "\x96"=>'&#8211;', "\x97"=>'&#8212;', "\x98"=>'&#732;', "\x99"=>'&#8482;', "\x9a"=>'&#353;', "\x9b"=>'&#8250;', "\x9c"=>'&#339;', "\x9d"=>'', "\x9e"=>'&#382;', "\x9f"=>'&#376;'); 
93
- $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'&#8218;', "\x84"=>'&#8222;', "\x91"=>'&#8216;', "\x92"=>'&#8217;', "\x93"=>'&#8220;', "\x94"=>'&#8221;') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); 
94
- $t = strtr($t, $x); 
92
+    $x = array("\x7f"=>'', "\x80"=>'&#8364;', "\x81"=>'', "\x83"=>'&#402;', "\x85"=>'&#8230;', "\x86"=>'&#8224;', "\x87"=>'&#8225;', "\x88"=>'&#710;', "\x89"=>'&#8240;', "\x8a"=>'&#352;', "\x8b"=>'&#8249;', "\x8c"=>'&#338;', "\x8d"=>'', "\x8e"=>'&#381;', "\x8f"=>'', "\x90"=>'', "\x95"=>'&#8226;', "\x96"=>'&#8211;', "\x97"=>'&#8212;', "\x98"=>'&#732;', "\x99"=>'&#8482;', "\x9a"=>'&#353;', "\x9b"=>'&#8250;', "\x9c"=>'&#339;', "\x9d"=>'', "\x9e"=>'&#382;', "\x9f"=>'&#376;'); 
93
+    $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'&#8218;', "\x84"=>'&#8222;', "\x91"=>'&#8216;', "\x92"=>'&#8217;', "\x93"=>'&#8220;', "\x94"=>'&#8221;') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); 
94
+    $t = strtr($t, $x); 
95 95
 } 
96 96
 if($C['cdata'] or $C['comment']){$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'hl_cmtcd', $t);} 
97 97
 $t = preg_replace_callback('`&amp;([A-Za-z][A-Za-z0-9]{1,30}|#(?:[0-9]{1,8}|[Xx][0-9A-Fa-f]{1,7}));`', 'hl_ent', str_replace('&', '&amp;', $t)); 
98 98
 if($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])){$GLOBALS['hl_Ids'] = array();} 
99 99
 if($C['hook']){$t = $C['hook']($t, $C, $S);} 
100 100
 if($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])){ 
101
- $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); 
101
+    $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); 
102 102
 } 
103 103
 // main 
104 104
 $t = preg_replace_callback('`<(?:(?:\s|$)|(?:[^>]*(?:>|$)))|>`m', 'hl_tag', $t); 
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 // check attr val against $S 
117 117
 $o = 1; $l = strlen($t); 
118 118
 foreach($p as $k=>$v){ 
119
- switch($k){ 
120
-  case 'maxlen':if($l > $v){$o = 0;} 
121
-  break; case 'minlen': if($l < $v){$o = 0;} 
122
-  break; case 'maxval': if((float)($t) > $v){$o = 0;} 
123
-  break; case 'minval': if((float)($t) < $v){$o = 0;} 
124
-  break; case 'match': if(!preg_match($v, $t)){$o = 0;} 
125
-  break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} 
126
-  break; case 'oneof': 
119
+    switch($k){ 
120
+    case 'maxlen':if($l > $v){$o = 0;} 
121
+    break; case 'minlen': if($l < $v){$o = 0;} 
122
+    break; case 'maxval': if((float)($t) > $v){$o = 0;} 
123
+    break; case 'minval': if((float)($t) < $v){$o = 0;} 
124
+    break; case 'match': if(!preg_match($v, $t)){$o = 0;} 
125
+    break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} 
126
+    break; case 'oneof': 
127 127
    $m = 0; 
128
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} 
129
-   $o = $m; 
130
-  break; case 'noneof': 
128
+    foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} 
129
+    $o = $m; 
130
+    break; case 'noneof': 
131 131
    $m = 1; 
132
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} 
133
-   $o = $m; 
134
-  break; default: 
132
+    foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} 
133
+    $o = $m; 
134
+    break; default: 
135 135
   break; 
136
- } 
137
- if(!$o){break;} 
136
+    } 
137
+    if(!$o){break;} 
138 138
 } 
139 139
 return ($o ? $t : (isset($p['default']) ? $p['default'] : 0)); 
140 140
 // eof 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 // $in sets allowed child 
165 165
 $in = ((isset($eF[$in]) && $in != '#pcdata') or isset($eO[$in])) ? $in : 'div'; 
166 166
 if(isset($cE[$in])){ 
167
- return (!$do ? '' : str_replace(array('<', '>'), array('&lt;', '&gt;'), $t)); 
167
+    return (!$do ? '' : str_replace(array('<', '>'), array('&lt;', '&gt;'), $t)); 
168 168
 } 
169 169
 if(isset($cS[$in])){$inOk = $cS[$in];} 
170 170
 elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
@@ -178,116 +178,116 @@  discard block
 block discarded – undo
178 178
 ob_start(); 
179 179
 
180 180
 for($i=-1, $ci=count($t); ++$i<$ci;){ 
181
- // allowed $ok in parent $p 
182
- if($ql = count($q)){ 
183
-  $p = array_pop($q); 
184
-  $q[] = $p; 
185
-  if(isset($cS[$p])){$ok = $cS[$p];} 
186
-  elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
187
-  elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
188
-  elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
189
-  if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
190
-  if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
191
- }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
192
- // bad tags, & ele content 
193
- if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
194
-  echo '&lt;', $s, $e, $a, '&gt;'; 
195
- } 
196
- if(isset($x[0])){ 
197
-  if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
198
-   echo '<div>', $x, '</div>'; 
199
-  } 
200
-  elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
201
-  elseif(strpos($x, "\x02\x04")){ 
202
-   foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
181
+    // allowed $ok in parent $p 
182
+    if($ql = count($q)){ 
183
+    $p = array_pop($q); 
184
+    $q[] = $p; 
185
+    if(isset($cS[$p])){$ok = $cS[$p];} 
186
+    elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
187
+    elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
188
+    elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
189
+    if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
190
+    if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
191
+    }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
192
+    // bad tags, & ele content 
193
+    if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
194
+    echo '&lt;', $s, $e, $a, '&gt;'; 
195
+    } 
196
+    if(isset($x[0])){ 
197
+    if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
198
+    echo '<div>', $x, '</div>'; 
199
+    } 
200
+    elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
201
+    elseif(strpos($x, "\x02\x04")){ 
202
+    foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
203 203
     echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
204
-   } 
205
-  }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
206
- } 
207
- // get markup 
208
- if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} 
209
- $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; 
210
- // close tag 
211
- if($s){ 
212
-  if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen 
213
-  if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 
214
-  $add = ''; // Nesting - close open tags that need to be 
215
-  for($j=-1, $cj=count($q); ++$j<$cj;){   
216
-   if(($d = array_pop($q)) == $e){break;} 
217
-   else{$add .= "</{$d}>";} 
218
-  } 
219
-  echo $add, '</', $e, '>'; unset($e); continue; 
220
- } 
221
- // open tag 
222
- // $cB ele needs $eB ele as child 
223
- if(isset($cB[$e]) && strlen(trim($x))){ 
224
-  $t[$i] = "{$e}{$a}>"; 
225
-  array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; 
226
- } 
227
- if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ 
228
-  array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; 
229
- } 
230
- // if no open ele, $in = parent; mostly immediate parent-child relation should hold 
231
- if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ 
232
-  if(!isset($ok[$e])){ 
233
-   if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} 
234
-   continue; 
235
-  } 
236
-  if(!isset($cE[$e])){$q[] = $e;} 
237
-  echo '<', $e, $a, '>'; unset($e); continue; 
238
- } 
239
- // specific parent-child 
240
- if(isset($cS[$p][$e])){ 
241
-  if(!isset($cE[$e])){$q[] = $e;} 
242
-  echo '<', $e, $a, '>'; unset($e); continue; 
243
- } 
244
- // nesting 
245
- $add = ''; 
246
- $q2 = array(); 
247
- for($k=-1, $kc=count($q); ++$k<$kc;){ 
248
-  $d = $q[$k]; 
249
-  $ok2 = array(); 
250
-  if(isset($cS[$d])){$q2[] = $d; continue;} 
251
-  $ok2 = isset($cI[$d]) ? $eI : $eF; 
252
-  if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} 
253
-  if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} 
254
-  if(!isset($ok2[$e])){ 
255
-   if(!$k && !isset($inOk[$e])){continue 2;} 
256
-   $add = "</{$d}>"; 
257
-   for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} 
258
-   break; 
259
-  } 
260
-  else{$q2[] = $d;} 
261
- } 
262
- $q = $q2; 
263
- if(!isset($cE[$e])){$q[] = $e;} 
264
- echo $add, '<', $e, $a, '>'; unset($e); continue; 
204
+    } 
205
+    }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
206
+    } 
207
+    // get markup 
208
+    if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} 
209
+    $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; 
210
+    // close tag 
211
+    if($s){ 
212
+    if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen 
213
+    if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 
214
+    $add = ''; // Nesting - close open tags that need to be 
215
+    for($j=-1, $cj=count($q); ++$j<$cj;){   
216
+    if(($d = array_pop($q)) == $e){break;} 
217
+    else{$add .= "</{$d}>";} 
218
+    } 
219
+    echo $add, '</', $e, '>'; unset($e); continue; 
220
+    } 
221
+    // open tag 
222
+    // $cB ele needs $eB ele as child 
223
+    if(isset($cB[$e]) && strlen(trim($x))){ 
224
+    $t[$i] = "{$e}{$a}>"; 
225
+    array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; 
226
+    } 
227
+    if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ 
228
+    array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; 
229
+    } 
230
+    // if no open ele, $in = parent; mostly immediate parent-child relation should hold 
231
+    if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ 
232
+    if(!isset($ok[$e])){ 
233
+    if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} 
234
+    continue; 
235
+    } 
236
+    if(!isset($cE[$e])){$q[] = $e;} 
237
+    echo '<', $e, $a, '>'; unset($e); continue; 
238
+    } 
239
+    // specific parent-child 
240
+    if(isset($cS[$p][$e])){ 
241
+    if(!isset($cE[$e])){$q[] = $e;} 
242
+    echo '<', $e, $a, '>'; unset($e); continue; 
243
+    } 
244
+    // nesting 
245
+    $add = ''; 
246
+    $q2 = array(); 
247
+    for($k=-1, $kc=count($q); ++$k<$kc;){ 
248
+    $d = $q[$k]; 
249
+    $ok2 = array(); 
250
+    if(isset($cS[$d])){$q2[] = $d; continue;} 
251
+    $ok2 = isset($cI[$d]) ? $eI : $eF; 
252
+    if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} 
253
+    if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} 
254
+    if(!isset($ok2[$e])){ 
255
+    if(!$k && !isset($inOk[$e])){continue 2;} 
256
+    $add = "</{$d}>"; 
257
+    for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} 
258
+    break; 
259
+    } 
260
+    else{$q2[] = $d;} 
261
+    } 
262
+    $q = $q2; 
263
+    if(!isset($cE[$e])){$q[] = $e;} 
264
+    echo $add, '<', $e, $a, '>'; unset($e); continue; 
265 265
 } 
266 266
 
267 267
 // end 
268 268
 if($ql = count($q)){ 
269
- $p = array_pop($q); 
270
- $q[] = $p; 
271
- if(isset($cS[$p])){$ok = $cS[$p];} 
272
- elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
273
- elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
274
- elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
275
- if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
276
- if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
269
+    $p = array_pop($q); 
270
+    $q[] = $p; 
271
+    if(isset($cS[$p])){$ok = $cS[$p];} 
272
+    elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
273
+    elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
274
+    elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
275
+    if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
276
+    if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
277 277
 }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
278 278
 if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
279
- echo '&lt;', $s, $e, $a, '&gt;'; 
279
+    echo '&lt;', $s, $e, $a, '&gt;'; 
280 280
 } 
281 281
 if(isset($x[0])){ 
282
- if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
283
-  echo '<div>', $x, '</div>'; 
284
- } 
285
- elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
286
- elseif(strpos($x, "\x02\x04")){ 
287
-  foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
288
-   echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
289
-  } 
290
- }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
282
+    if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
283
+    echo '<div>', $x, '</div>'; 
284
+    } 
285
+    elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
286
+    elseif(strpos($x, "\x02\x04")){ 
287
+    foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
288
+    echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
289
+    } 
290
+    }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
291 291
 } 
292 292
 while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} 
293 293
 $o = ob_get_contents(); 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 if(!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])){return $t;} 
304 304
 if($v == 1){return '';} 
305 305
 if($n == 'comment'){ 
306
- if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} 
306
+    if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} 
307 307
 } 
308 308
 else{$t = substr($t, 1, -1);} 
309 309
 $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $t) : $t; 
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 static $U = array('quot'=>1,'amp'=>1,'lt'=>1,'gt'=>1); 
319 319
 static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39',  'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); 
320 320
 if($t[0] != '#'){ 
321
- return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; 
321
+    return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; 
322 322
 } 
323 323
 if(($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))){ 
324
- return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; 
324
+    return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; 
325 325
 } 
326 326
 return ($C['and_mark'] ? "\x06" : '&'). '#'. (((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'. dechex($n)). ';';
327 327
 // eof 
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 if(isset($c['!']) && substr($p, 0, 7) != $d){$p = "$d$p";} 
338 338
 if(isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)){return "{$b}{$p}{$a}";} // All ok, frag, query, param 
339 339
 if(preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])){ // Denied prot 
340
- return "{$b}{$d}{$p}{$a}"; 
340
+    return "{$b}{$d}{$p}{$a}"; 
341 341
 } 
342 342
 if($C['abs_url']){ 
343
- if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel 
344
-  $p = substr($p, strlen($C['base_url'])); 
345
- }elseif(empty($m[1])){ // Make URL abs 
346
-  if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} 
347
-  elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} 
348
-  elseif(strcspn($p, './')){$p = $C['base_url']. $p;} 
349
-  else{ 
350
-   preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); 
351
-   $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); 
352
-   while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ 
343
+    if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel 
344
+    $p = substr($p, strlen($C['base_url'])); 
345
+    }elseif(empty($m[1])){ // Make URL abs 
346
+    if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} 
347
+    elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} 
348
+    elseif(strcspn($p, './')){$p = $C['base_url']. $p;} 
349
+    else{ 
350
+    preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); 
351
+    $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); 
352
+    while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ 
353 353
     $p = preg_replace('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', '', $p); 
354
-   } 
355
-   $p = $m[1]. $p; 
356
-  } 
357
- } 
354
+    } 
355
+    $p = $m[1]. $p; 
356
+    } 
357
+    } 
358 358
 } 
359 359
 return "{$b}{$p}{$a}"; 
360 360
 // eof 
@@ -381,27 +381,27 @@  discard block
 block discarded – undo
381 381
 $s = array(); 
382 382
 $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace_callback('/"(?>(`.|[^"])*)"/sm', create_function('$m', 'return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), $m[0]), 1, -1);'), trim($t))); 
383 383
 for($i = count(($t = explode(';', $t))); --$i>=0;){ 
384
- $w = $t[$i]; 
385
- if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a =  substr($w, $e+1)))){continue;} 
386
- $y = $n = array(); 
387
- foreach(explode(',', $a) as $v){ 
388
-  if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} 
389
-  if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} 
390
-  if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} 
391
-  if(!isset($m[2])){$y[$x] = 1; continue;} 
392
-  foreach(explode('/', $m[2]) as $m){ 
393
-   if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} 
394
-   $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); 
395
-  } 
396
-  if(isset($y[$x]['match']) && !hl_regex($y[$x]['match'])){unset($y[$x]['match']);} 
397
-  if(isset($y[$x]['nomatch']) && !hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} 
398
- } 
399
- if(!count($y) && !count($n)){continue;} 
400
- foreach(explode(',', substr($w, 0, $e)) as $v){ 
401
-  if(!strlen(($v = strtolower($v)))){continue;} 
402
-  if(count($y)){$s[$v] = $y;} 
403
-  if(count($n)){$s[$v]['n'] = $n;} 
404
- } 
384
+    $w = $t[$i]; 
385
+    if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a =  substr($w, $e+1)))){continue;} 
386
+    $y = $n = array(); 
387
+    foreach(explode(',', $a) as $v){ 
388
+    if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} 
389
+    if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} 
390
+    if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} 
391
+    if(!isset($m[2])){$y[$x] = 1; continue;} 
392
+    foreach(explode('/', $m[2]) as $m){ 
393
+    if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} 
394
+    $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); 
395
+    } 
396
+    if(isset($y[$x]['match']) && !hl_regex($y[$x]['match'])){unset($y[$x]['match']);} 
397
+    if(isset($y[$x]['nomatch']) && !hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} 
398
+    } 
399
+    if(!count($y) && !count($n)){continue;} 
400
+    foreach(explode(',', substr($w, 0, $e)) as $v){ 
401
+    if(!strlen(($v = strtolower($v)))){continue;} 
402
+    if(count($y)){$s[$v] = $y;} 
403
+    if(count($n)){$s[$v]['n'] = $n;} 
404
+    } 
405 405
 } 
406 406
 return $s; 
407 407
 // eof 
@@ -415,22 +415,22 @@  discard block
 block discarded – undo
415 415
 if($t == '< '){return '&lt; ';} 
416 416
 if($t == '>'){return '&gt;';} 
417 417
 if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ 
418
- return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t); 
418
+    return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t); 
419 419
 }elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ 
420
- return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); 
420
+    return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); 
421 421
 } 
422 422
 // attr string 
423 423
 $a = str_replace(array("\n", "\r", "\t"), ' ', trim($m[3])); 
424 424
 // tag transform 
425 425
 static $eD = array('applet'=>1, 'center'=>1, 'dir'=>1, 'embed'=>1, 'font'=>1, 'isindex'=>1, 'menu'=>1, 's'=>1, 'strike'=>1, 'u'=>1); // Deprecated
426 426
 if($C['make_tag_strict'] && isset($eD[$e])){ 
427
- $trt = hl_tag2($e, $a, $C['make_tag_strict']); 
428
- if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '');} 
427
+    $trt = hl_tag2($e, $a, $C['make_tag_strict']); 
428
+    if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '');} 
429 429
 } 
430 430
 // close tag 
431 431
 static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1); // Empty ele 
432 432
 if(!empty($m[1])){ 
433
- return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '')); 
433
+    return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '')); 
434 434
 } 
435 435
 
436 436
 // open tag & attr 
@@ -440,49 +440,49 @@  discard block
 block discarded – undo
440 440
 static $aNU = array('class'=>array('param'=>1, 'script'=>1), 'dir'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'id'=>array('script'=>1), 'lang'=>array('applet'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'xml:lang'=>array('applet'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'onclick'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'ondblclick'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeydown'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeypress'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeyup'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmousedown'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmousemove'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseout'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseover'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseup'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'style'=>array('param'=>1, 'script'=>1), 'title'=>array('param'=>1, 'script'=>1)); // Univ & exceptions 
441 441
 
442 442
 if($C['lc_std_val']){ 
443
- // predef attr vals for $eAL & $aNE ele 
444
- static $aNL = array('all'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'center'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'cols'=>1, 'data'=>1, 'default'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'middle'=>1, 'none'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'submit'=>1, 'text'=>1, 'top'=>1); 
445
- static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'xml:space'=>1); 
446
- $lcase = isset($eAL[$e]) ? 1 : 0; 
443
+    // predef attr vals for $eAL & $aNE ele 
444
+    static $aNL = array('all'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'center'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'cols'=>1, 'data'=>1, 'default'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'middle'=>1, 'none'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'submit'=>1, 'text'=>1, 'top'=>1); 
445
+    static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'xml:space'=>1); 
446
+    $lcase = isset($eAL[$e]) ? 1 : 0; 
447 447
 } 
448 448
 
449 449
 $depTr = 0; 
450 450
 if($C['no_deprecated_attr']){ 
451
- // dep attr:applicable ele 
452
- static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('img'=>1, 'object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'start'=>array('ol'=>1), 'type'=>array('li'=>1, 'ol'=>1, 'ul'=>1), 'value'=>array('li'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'td'=>1, 'th'=>1)); 
453
- static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); 
454
- $depTr = isset($eAD[$e]) ? 1 : 0; 
451
+    // dep attr:applicable ele 
452
+    static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('img'=>1, 'object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'start'=>array('ol'=>1), 'type'=>array('li'=>1, 'ol'=>1, 'ul'=>1), 'value'=>array('li'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'td'=>1, 'th'=>1)); 
453
+    static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); 
454
+    $depTr = isset($eAD[$e]) ? 1 : 0; 
455 455
 } 
456 456
 
457 457
 // attr name-vals 
458 458
 if(strpos($a, "\x01") !== false){$a = preg_replace('`\x01[^\x01]*\x01`', '', $a);} // No comment/CDATA sec 
459 459
 $mode = 0; $a = trim($a, ' /'); $aA = array(); 
460 460
 while(strlen($a)){ 
461
- $w = 0; 
462
- switch($mode){ 
463
-  case 0: // Name 
461
+    $w = 0; 
462
+    switch($mode){ 
463
+    case 0: // Name 
464 464
    if(preg_match('`^[a-zA-Z][\-a-zA-Z:]+`', $a, $m)){ 
465 465
     $nm = strtolower($m[0]); 
466 466
     $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); 
467
-   } 
468
-  break; case 1: 
467
+    } 
468
+    break; case 1: 
469 469
    if($a[0] == '='){ // = 
470 470
     $w = 1; $mode = 2; $a = ltrim($a, '= '); 
471
-   }else{ // No val 
471
+    }else{ // No val 
472 472
     $w = 1; $mode = 0; $a = ltrim($a); 
473 473
     $aA[$nm] = ''; 
474
-   } 
475
-  break; case 2: // Val 
474
+    } 
475
+    break; case 2: // Val 
476 476
    if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ 
477 477
     $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; 
478 478
     $aA[$nm] = trim(str_replace('<', '&lt;', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); 
479
-   } 
480
-  break; 
481
- } 
482
- if($w == 0){ // Parse errs, deal with space, " & ' 
483
-  $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); 
484
-  $mode = 0; 
485
- } 
479
+    } 
480
+    break; 
481
+    } 
482
+    if($w == 0){ // Parse errs, deal with space, " & ' 
483
+    $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); 
484
+    $mode = 0; 
485
+    } 
486 486
 } 
487 487
 if($mode == 1){$aA[$nm] = '';} 
488 488
 
@@ -491,126 +491,126 @@  discard block
 block discarded – undo
491 491
 $rl = isset($S[$e]) ? $S[$e] : array(); 
492 492
 $a = array(); $nfr = 0; 
493 493
 foreach($aA as $k=>$v){ 
494
-  if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ 
495
-  if(isset($aNE[$k])){$v = $k;} 
496
-  elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues 
497
-   $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; 
498
-  } 
499
-  if($k == 'style' && !$C['style_pass']){ 
500
-   if(false !== strpos($v, '&#')){ 
494
+    if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ 
495
+    if(isset($aNE[$k])){$v = $k;} 
496
+    elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues 
497
+    $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; 
498
+    } 
499
+    if($k == 'style' && !$C['style_pass']){ 
500
+    if(false !== strpos($v, '&#')){ 
501 501
     static $sC = array('&#x20;'=>' ', '&#32;'=>' ', '&#x45;'=>'e', '&#69;'=>'e', '&#x65;'=>'e', '&#101;'=>'e', '&#x58;'=>'x', '&#88;'=>'x', '&#x78;'=>'x', '&#120;'=>'x', '&#x50;'=>'p', '&#80;'=>'p', '&#x70;'=>'p', '&#112;'=>'p', '&#x53;'=>'s', '&#83;'=>'s', '&#x73;'=>'s', '&#115;'=>'s', '&#x49;'=>'i', '&#73;'=>'i', '&#x69;'=>'i', '&#105;'=>'i', '&#x4f;'=>'o', '&#79;'=>'o', '&#x6f;'=>'o', '&#111;'=>'o', '&#x4e;'=>'n', '&#78;'=>'n', '&#x6e;'=>'n', '&#110;'=>'n', '&#x55;'=>'u', '&#85;'=>'u', '&#x75;'=>'u', '&#117;'=>'u', '&#x52;'=>'r', '&#82;'=>'r', '&#x72;'=>'r', '&#114;'=>'r', '&#x4c;'=>'l', '&#76;'=>'l', '&#x6c;'=>'l', '&#108;'=>'l', '&#x28;'=>'(', '&#40;'=>'(', '&#x29;'=>')', '&#41;'=>')', '&#x20;'=>':', '&#32;'=>':', '&#x22;'=>'"', '&#34;'=>'"', '&#x27;'=>"'", '&#39;'=>"'", '&#x2f;'=>'/', '&#47;'=>'/', '&#x2a;'=>'*', '&#42;'=>'*', '&#x5c;'=>'\\', '&#92;'=>'\\'); 
502 502
     $v = strtr($v, $sC); 
503
-   } 
504
-   $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'hl_prot', $v); 
505
-   $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; 
506
-  }elseif(isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o'){ 
507
-   $v = str_replace("\xad", ' ', (strpos($v, '&') !== false ? str_replace(array('&#xad;', '&#173;', '&shy;'), ' ', $v) : $v)); 
508
-   $v = hl_prot($v, $k); 
509
-   if($k == 'href'){ // X-spam 
503
+    } 
504
+    $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'hl_prot', $v); 
505
+    $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; 
506
+    }elseif(isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o'){ 
507
+    $v = str_replace("\xad", ' ', (strpos($v, '&') !== false ? str_replace(array('&#xad;', '&#173;', '&shy;'), ' ', $v) : $v)); 
508
+    $v = hl_prot($v, $k); 
509
+    if($k == 'href'){ // X-spam 
510 510
     if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ 
511
-     $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); 
511
+        $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); 
512 512
     }elseif($C['anti_link_spam']){ 
513
-     $r1 = $C['anti_link_spam'][1]; 
514
-     if(!empty($r1) && preg_match($r1, $v)){continue;} 
515
-     $r0 = $C['anti_link_spam'][0]; 
516
-     if(!empty($r0) && preg_match($r0, $v)){ 
517
-      if(isset($a['rel'])){ 
518
-       if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} 
519
-      }elseif(isset($aA['rel'])){ 
520
-       if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} 
521
-      }else{$a['rel'] = 'nofollow';} 
522
-     } 
523
-    } 
524
-   } 
525
-  } 
526
-  if(isset($rl[$k]) && is_array($rl[$k]) && ($v = hl_attrval($v, $rl[$k])) === 0){continue;} 
527
-  $a[$k] = str_replace('"', '&quot;', $v); 
528
- } 
513
+        $r1 = $C['anti_link_spam'][1]; 
514
+        if(!empty($r1) && preg_match($r1, $v)){continue;} 
515
+        $r0 = $C['anti_link_spam'][0]; 
516
+        if(!empty($r0) && preg_match($r0, $v)){ 
517
+        if(isset($a['rel'])){ 
518
+        if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} 
519
+        }elseif(isset($aA['rel'])){ 
520
+        if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} 
521
+        }else{$a['rel'] = 'nofollow';} 
522
+        } 
523
+    } 
524
+    } 
525
+    } 
526
+    if(isset($rl[$k]) && is_array($rl[$k]) && ($v = hl_attrval($v, $rl[$k])) === 0){continue;} 
527
+    $a[$k] = str_replace('"', '&quot;', $v); 
528
+    } 
529 529
 } 
530 530
 if($nfr){$a['rel'] = isset($a['rel']) ? $a['rel']. ' nofollow' : 'nofollow';} 
531 531
 
532 532
 // rqd attr 
533 533
 static $eAR = array('area'=>array('alt'=>'area'), 'bdo'=>array('dir'=>'ltr'), 'form'=>array('action'=>''), 'img'=>array('src'=>'', 'alt'=>'image'), 'map'=>array('name'=>''), 'optgroup'=>array('label'=>''), 'param'=>array('name'=>''), 'script'=>array('type'=>'text/javascript'), 'textarea'=>array('rows'=>'10', 'cols'=>'50')); 
534 534
 if(isset($eAR[$e])){ 
535
- foreach($eAR[$e] as $k=>$v){ 
536
-  if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} 
537
- } 
535
+    foreach($eAR[$e] as $k=>$v){ 
536
+    if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} 
537
+    } 
538 538
 } 
539 539
 
540 540
 // depr attrs 
541 541
 if($depTr){ 
542
- $c = array(); 
543
- foreach($a as $k=>$v){ 
544
-  if($k == 'style' or !isset($aND[$k][$e])){continue;} 
545
-  if($k == 'align'){ 
546
-   unset($a['align']); 
547
-   if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} 
548
-   elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} 
549
-   else{$c[] = 'text-align: '. $v;} 
550
-  }elseif($k == 'bgcolor'){ 
551
-   unset($a['bgcolor']); 
552
-   $c[] = 'background-color: '. $v; 
553
-  }elseif($k == 'border'){ 
554
-   unset($a['border']); $c[] = "border: {$v}px"; 
555
-  }elseif($k == 'bordercolor'){ 
556
-   unset($a['bordercolor']); $c[] = 'border-color: '. $v; 
557
-  }elseif($k == 'clear'){ 
558
-   unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); 
559
-  }elseif($k == 'compact'){ 
560
-   unset($a['compact']); $c[] = 'font-size: 85%'; 
561
-  }elseif($k == 'height' or $k == 'width'){ 
562
-   unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); 
563
-  }elseif($k == 'hspace'){ 
564
-   unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; 
565
-  }elseif($k == 'language' && !isset($a['type'])){ 
566
-   unset($a['language']); 
567
-   $a['type'] = 'text/'. strtolower($v); 
568
-  }elseif($k == 'name'){ 
569
-   if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} 
570
-   if(!isset($a['id']) && preg_match('`[a-zA-Z][a-zA-Z\d.:_\-]*`', $v)){$a['id'] = $v;} 
571
-  }elseif($k == 'noshade'){ 
572
-   unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; 
573
-  }elseif($k == 'nowrap'){ 
574
-   unset($a['nowrap']); $c[] = 'white-space: nowrap'; 
575
-  }elseif($k == 'size'){ 
576
-   unset($a['size']); $c[] = 'size: '. $v. 'px'; 
577
-  }elseif($k == 'start' or $k == 'value'){ 
578
-   unset($a[$k]); 
579
-  }elseif($k == 'type'){ 
580
-   unset($a['type']); 
581
-   static $ol_type = array('i'=>'lower-roman', 'I'=>'upper-roman', 'a'=>'lower-latin', 'A'=>'upper-latin', '1'=>'decimal'); 
582
-   $c[] = 'list-style-type: '. (isset($ol_type[$v]) ? $ol_type[$v] : 'decimal'); 
583
-  }elseif($k == 'vspace'){ 
584
-   unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; 
585
-  } 
586
- } 
587
- if(count($c)){ 
588
-  $c = implode('; ', $c); 
589
-  $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; 
590
- } 
542
+    $c = array(); 
543
+    foreach($a as $k=>$v){ 
544
+    if($k == 'style' or !isset($aND[$k][$e])){continue;} 
545
+    if($k == 'align'){ 
546
+    unset($a['align']); 
547
+    if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} 
548
+    elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} 
549
+    else{$c[] = 'text-align: '. $v;} 
550
+    }elseif($k == 'bgcolor'){ 
551
+    unset($a['bgcolor']); 
552
+    $c[] = 'background-color: '. $v; 
553
+    }elseif($k == 'border'){ 
554
+    unset($a['border']); $c[] = "border: {$v}px"; 
555
+    }elseif($k == 'bordercolor'){ 
556
+    unset($a['bordercolor']); $c[] = 'border-color: '. $v; 
557
+    }elseif($k == 'clear'){ 
558
+    unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); 
559
+    }elseif($k == 'compact'){ 
560
+    unset($a['compact']); $c[] = 'font-size: 85%'; 
561
+    }elseif($k == 'height' or $k == 'width'){ 
562
+    unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); 
563
+    }elseif($k == 'hspace'){ 
564
+    unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; 
565
+    }elseif($k == 'language' && !isset($a['type'])){ 
566
+    unset($a['language']); 
567
+    $a['type'] = 'text/'. strtolower($v); 
568
+    }elseif($k == 'name'){ 
569
+    if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} 
570
+    if(!isset($a['id']) && preg_match('`[a-zA-Z][a-zA-Z\d.:_\-]*`', $v)){$a['id'] = $v;} 
571
+    }elseif($k == 'noshade'){ 
572
+    unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; 
573
+    }elseif($k == 'nowrap'){ 
574
+    unset($a['nowrap']); $c[] = 'white-space: nowrap'; 
575
+    }elseif($k == 'size'){ 
576
+    unset($a['size']); $c[] = 'size: '. $v. 'px'; 
577
+    }elseif($k == 'start' or $k == 'value'){ 
578
+    unset($a[$k]); 
579
+    }elseif($k == 'type'){ 
580
+    unset($a['type']); 
581
+    static $ol_type = array('i'=>'lower-roman', 'I'=>'upper-roman', 'a'=>'lower-latin', 'A'=>'upper-latin', '1'=>'decimal'); 
582
+    $c[] = 'list-style-type: '. (isset($ol_type[$v]) ? $ol_type[$v] : 'decimal'); 
583
+    }elseif($k == 'vspace'){ 
584
+    unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; 
585
+    } 
586
+    } 
587
+    if(count($c)){ 
588
+    $c = implode('; ', $c); 
589
+    $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; 
590
+    } 
591 591
 } 
592 592
 // unique ID 
593 593
 if($C['unique_ids'] && isset($a['id'])){ 
594
- if(!preg_match('`^[A-Za-z][A-Za-z0-9_\-.:]*$`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); 
595
- }else{ 
596
-  while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} 
597
-  $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; 
598
- } 
594
+    if(!preg_match('`^[A-Za-z][A-Za-z0-9_\-.:]*$`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); 
595
+    }else{ 
596
+    while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} 
597
+    $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; 
598
+    } 
599 599
 } 
600 600
 // xml:lang 
601 601
 if($C['xml:lang'] && isset($a['lang'])){ 
602
- $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; 
603
- if($C['xml:lang'] == 2){unset($a['lang']);} 
602
+    $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; 
603
+    if($C['xml:lang'] == 2){unset($a['lang']);} 
604 604
 } 
605 605
 // for transformed tag 
606 606
 if(!empty($trt)){ 
607
- $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; 
607
+    $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; 
608 608
 } 
609 609
 // return with empty ele / 
610 610
 if(empty($C['hook_tag'])){ 
611
- $aA = ''; 
612
- foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} 
613
- return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; 
611
+    $aA = ''; 
612
+    foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} 
613
+    return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; 
614 614
 } 
615 615
 else{return $C['hook_tag']($e, $a);} 
616 616
 // eof 
@@ -624,17 +624,17 @@  discard block
 block discarded – undo
624 624
 if($e == 'u'){$e = 'span'; return 'text-decoration: underline;';} 
625 625
 static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%'); 
626 626
 if($e == 'font'){ 
627
- $a2 = ''; 
628
- if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)){ 
629
-  $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[2])). ';'; 
630
- } 
631
- if(preg_match('`color\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m)){ 
632
-  $a2 .= ' color: '. trim($m[2]). ';'; 
633
- } 
634
- if(preg_match('`size\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m) && isset($fs[($m = trim($m[2]))])){ 
635
-  $a2 .= ' font-size: '. $fs[$m]. ';'; 
636
- } 
637
- $e = 'span'; return ltrim($a2); 
627
+    $a2 = ''; 
628
+    if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)){ 
629
+    $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[2])). ';'; 
630
+    } 
631
+    if(preg_match('`color\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m)){ 
632
+    $a2 .= ' color: '. trim($m[2]). ';'; 
633
+    } 
634
+    if(preg_match('`size\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m) && isset($fs[($m = trim($m[2]))])){ 
635
+    $a2 .= ' font-size: '. $fs[$m]. ';'; 
636
+    } 
637
+    $e = 'span'; return ltrim($a2); 
638 638
 } 
639 639
 if($t == 2){$e = 0; return 0;} 
640 640
 return ''; 
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 if(strpos(' pre,script,textarea', "$p,")){return $t;} 
647 647
 $t = preg_replace('`\s+`', ' ', preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)(</\2>)`sm'), create_function('$m', 'return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", " "), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4];'), $t)); 
648 648
 if(($w = strtolower($w)) == -1){ 
649
- return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); 
649
+    return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); 
650 650
 } 
651 651
 $s = strpos(" $w", 't') ? "\t" : ' '; 
652 652
 $s = preg_match('`\d`', $w, $m) ? str_repeat($s, $m[0]) : str_repeat($s, ($s == "\t" ? 1 : 2)); 
@@ -658,39 +658,39 @@  discard block
 block discarded – undo
658 658
 $T = explode('<', $t); 
659 659
 $X = 1; 
660 660
 while($X){ 
661
- $n = $N; 
662
- $t = $T; 
663
- ob_start(); 
664
- if(isset($d[$p])){echo str_repeat($s, ++$n);} 
665
- echo ltrim(array_shift($t)); 
666
- for($i=-1, $j=count($t); ++$i<$j;){ 
667
-  $r = ''; list($e, $r) = explode('>', $t[$i]); 
668
-  $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); 
669
-  $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); 
670
-  $e = "<$e>"; 
671
-  if(isset($d[$y])){ 
672
-   if(!$x){ 
661
+    $n = $N; 
662
+    $t = $T; 
663
+    ob_start(); 
664
+    if(isset($d[$p])){echo str_repeat($s, ++$n);} 
665
+    echo ltrim(array_shift($t)); 
666
+    for($i=-1, $j=count($t); ++$i<$j;){ 
667
+    $r = ''; list($e, $r) = explode('>', $t[$i]); 
668
+    $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); 
669
+    $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); 
670
+    $e = "<$e>"; 
671
+    if(isset($d[$y])){ 
672
+    if(!$x){ 
673 673
     if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} 
674 674
     else{++$N; ob_end_clean(); continue 2;} 
675
-   } 
676
-   else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} 
677
-   echo $r; continue; 
678
-  } 
679
-  $f = "\n". str_repeat($s, $n); 
680
-  if(isset($c[$y])){ 
681
-   if(!$x){echo $e, $f, $r;} 
682
-   else{echo $f, $e, $r;} 
683
-  }elseif(isset($b[$y])){echo $f, $e, $r; 
684
-  }elseif(isset($a[$y])){echo $e, $f, $r; 
685
-  }elseif(!$y){echo $f, $e, $f, $r; 
686
-  }else{echo $e, $r;} 
687
- } 
688
- $X = 0; 
675
+    } 
676
+    else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} 
677
+    echo $r; continue; 
678
+    } 
679
+    $f = "\n". str_repeat($s, $n); 
680
+    if(isset($c[$y])){ 
681
+    if(!$x){echo $e, $f, $r;} 
682
+    else{echo $f, $e, $r;} 
683
+    }elseif(isset($b[$y])){echo $f, $e, $r; 
684
+    }elseif(isset($a[$y])){echo $e, $f, $r; 
685
+    }elseif(!$y){echo $f, $e, $f, $r; 
686
+    }else{echo $e, $r;} 
687
+    } 
688
+    $X = 0; 
689 689
 } 
690 690
 $t = str_replace(array("\n ", " \n"), "\n", preg_replace('`[\n]\s*?[\n]+`', "\n", ob_get_contents())); 
691 691
 ob_end_clean(); 
692 692
 if(($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)){ 
693
- $t = str_replace("\n", $l, $t); 
693
+    $t = str_replace("\n", $l, $t); 
694 694
 } 
695 695
 return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); 
696 696
 // eof 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 function kses($t, $h, $p=array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'mailto')){ 
706 706
 // kses compat 
707 707
 foreach($h as $k=>$v){ 
708
- $h[$k]['n']['*'] = 1; 
708
+    $h[$k]['n']['*'] = 1; 
709 709
 } 
710 710
 $C['cdata'] = $C['comment'] = $C['make_tag_strict'] = $C['no_deprecated_attr'] = $C['unique_ids'] = 0; 
711 711
 $C['keep_bad'] = 1; 
Please login to merge, or discard this patch.
Switch Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 $o = 1; $l = strlen($t); 
118 118
 foreach($p as $k=>$v){ 
119 119
  switch($k){ 
120
-  case 'maxlen':if($l > $v){$o = 0;} 
121
-  break; case 'minlen': if($l < $v){$o = 0;} 
122
-  break; case 'maxval': if((float)($t) > $v){$o = 0;} 
123
-  break; case 'minval': if((float)($t) < $v){$o = 0;} 
124
-  break; case 'match': if(!preg_match($v, $t)){$o = 0;} 
125
-  break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} 
126
-  break; case 'oneof': 
127
-   $m = 0; 
128
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} 
129
-   $o = $m; 
130
-  break; case 'noneof': 
131
-   $m = 1; 
132
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} 
133
-   $o = $m; 
134
-  break; default: 
135
-  break; 
120
+ case 'maxlen':if($l > $v){$o = 0;} 
121
+ break; case 'minlen': if($l < $v){$o = 0;} 
122
+ break; case 'maxval': if((float)($t) > $v){$o = 0;} 
123
+ break; case 'minval': if((float)($t) < $v){$o = 0;} 
124
+ break; case 'match': if(!preg_match($v, $t)){$o = 0;} 
125
+ break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} 
126
+ break; case 'oneof': 
127
+  $m = 0; 
128
+  foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} 
129
+  $o = $m; 
130
+ break; case 'noneof': 
131
+  $m = 1; 
132
+  foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} 
133
+  $o = $m; 
134
+ break; default: 
135
+ break; 
136 136
  } 
137 137
  if(!$o){break;} 
138 138
 } 
@@ -460,24 +460,24 @@  discard block
 block discarded – undo
460 460
 while(strlen($a)){ 
461 461
  $w = 0; 
462 462
  switch($mode){ 
463
-  case 0: // Name 
464
-   if(preg_match('`^[a-zA-Z][\-a-zA-Z:]+`', $a, $m)){ 
465
-    $nm = strtolower($m[0]); 
466
-    $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); 
467
-   } 
468
-  break; case 1: 
469
-   if($a[0] == '='){ // = 
470
-    $w = 1; $mode = 2; $a = ltrim($a, '= '); 
471
-   }else{ // No val 
472
-    $w = 1; $mode = 0; $a = ltrim($a); 
473
-    $aA[$nm] = ''; 
474
-   } 
475
-  break; case 2: // Val 
476
-   if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ 
477
-    $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; 
478
-    $aA[$nm] = trim(str_replace('<', '&lt;', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); 
479
-   } 
480
-  break; 
463
+ case 0: // Name 
464
+  if(preg_match('`^[a-zA-Z][\-a-zA-Z:]+`', $a, $m)){ 
465
+   $nm = strtolower($m[0]); 
466
+   $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); 
467
+  } 
468
+ break; case 1: 
469
+  if($a[0] == '='){ // = 
470
+   $w = 1; $mode = 2; $a = ltrim($a, '= '); 
471
+  }else{ // No val 
472
+   $w = 1; $mode = 0; $a = ltrim($a); 
473
+   $aA[$nm] = ''; 
474
+  } 
475
+ break; case 2: // Val 
476
+  if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ 
477
+   $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; 
478
+   $aA[$nm] = trim(str_replace('<', '&lt;', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); 
479
+  } 
480
+ break; 
481 481
  } 
482 482
  if($w == 0){ // Parse errs, deal with space, " & ' 
483 483
   $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); 
Please login to merge, or discard this patch.
Spacing   +285 added lines, -285 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@  discard block
 block discarded – undo
9 9
 See htmLawed_README.txt/htm 
10 10
 */ 
11 11
 
12
-function htmLawed($t, $C=1, $S=array()){ 
12
+function htmLawed($t, $C = 1, $S = array()) { 
13 13
 $C = is_array($C) ? $C : array(); 
14
-if(!empty($C['valid_xhtml'])){ 
14
+if (!empty($C['valid_xhtml'])) { 
15 15
  $C['elements'] = empty($C['elements']) ? '*-center-dir-font-isindex-menu-s-strike-u' : $C['elements']; 
16 16
  $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; 
17 17
  $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; 
18 18
 } 
19 19
 // config eles 
20 20
 $e = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'applet'=>1, 'area'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'blockquote'=>1, 'br'=>1, 'button'=>1, 'caption'=>1, 'center'=>1, 'cite'=>1, 'code'=>1, 'col'=>1, 'colgroup'=>1, 'dd'=>1, 'del'=>1, 'dfn'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'dt'=>1, 'em'=>1, 'embed'=>1, 'fieldset'=>1, 'font'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'isindex'=>1, 'kbd'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'p'=>1, 'param'=>1, 'pre'=>1, 'q'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'script'=>1, 'select'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'table'=>1, 'tbody'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'tt'=>1, 'u'=>1, 'ul'=>1, 'var'=>1); // 86/deprecated+embed+ruby 
21
-if(!empty($C['safe'])){ 
21
+if (!empty($C['safe'])) { 
22 22
  unset($e['applet'], $e['embed'], $e['iframe'], $e['object'], $e['script']); 
23 23
 } 
24 24
 $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; 
25
-if($x == '-*'){$e = array();} 
26
-elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} 
27
-else{ 
28
- if(isset($x[1])){ 
25
+if ($x == '-*') {$e = array(); } 
26
+elseif (strpos($x, '*') === false) {$e = array_flip(explode(',', $x)); } 
27
+else { 
28
+ if (isset($x[1])) { 
29 29
   preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); 
30
-  for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} 
31
-  foreach($m as $v){ 
32
-   if($v[0] == '+'){$e[substr($v, 1)] = 1;} 
33
-   if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} 
30
+  for ($i = count($m); --$i >= 0;) {$m[$i] = $m[$i][0]; } 
31
+  foreach ($m as $v) { 
32
+   if ($v[0] == '+') {$e[substr($v, 1)] = 1; } 
33
+   if ($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'.$v, $m)) {unset($e[$v]); } 
34 34
   } 
35 35
  } 
36 36
 } 
37
-$C['elements'] =& $e; 
37
+$C['elements'] = & $e; 
38 38
 // config attrs 
39 39
 $x = !empty($C['deny_attribute']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['deny_attribute']) : ''; 
40
-$x = array_flip((isset($x[0]) && $x[0] == '*') ? explode('-', $x) : explode(',', $x. (!empty($C['safe']) ? ',on*' : ''))); 
41
-if(isset($x['on*'])){ 
40
+$x = array_flip((isset($x[0]) && $x[0] == '*') ? explode('-', $x) : explode(',', $x.(!empty($C['safe']) ? ',on*' : ''))); 
41
+if (isset($x['on*'])) { 
42 42
  unset($x['on*']); 
43 43
  $x += array('onblur'=>1, 'onchange'=>1, 'onclick'=>1, 'ondblclick'=>1, 'onfocus'=>1, 'onkeydown'=>1, 'onkeypress'=>1, 'onkeyup'=>1, 'onmousedown'=>1, 'onmousemove'=>1, 'onmouseout'=>1, 'onmouseover'=>1, 'onmouseup'=>1, 'onreset'=>1, 'onselect'=>1, 'onsubmit'=>1); 
44 44
 } 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 // config URL 
47 47
 $x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https'; 
48 48
 $C['schemes'] = array(); 
49
-foreach(explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v){ 
49
+foreach (explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v) { 
50 50
  $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); 
51
- if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} 
51
+ if ($x2) {$C['schemes'][$x] = array_flip(explode(',', $x2)); } 
52 52
 } 
53
-if(!isset($C['schemes']['*'])){$C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1,);} 
54
-if(!empty($C['safe']) && empty($C['schemes']['style'])){$C['schemes']['style'] = array('!'=>1);} 
53
+if (!isset($C['schemes']['*'])) {$C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1,); } 
54
+if (!empty($C['safe']) && empty($C['schemes']['style'])) {$C['schemes']['style'] = array('!'=>1); } 
55 55
 $C['abs_url'] = isset($C['abs_url']) ? $C['abs_url'] : 0; 
56
-if(!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])){ 
56
+if (!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])) { 
57 57
  $C['base_url'] = $C['abs_url'] = 0; 
58 58
 } 
59 59
 // config rest 
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 $C['unique_ids'] = isset($C['unique_ids']) ? $C['unique_ids'] : 1; 
82 82
 $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 0; 
83 83
 
84
-if(isset($GLOBALS['C'])){$reC = $GLOBALS['C'];} 
84
+if (isset($GLOBALS['C'])) {$reC = $GLOBALS['C']; } 
85 85
 $GLOBALS['C'] = $C; 
86 86
 $S = is_array($S) ? $S : hl_spec($S); 
87
-if(isset($GLOBALS['S'])){$reS = $GLOBALS['S'];} 
87
+if (isset($GLOBALS['S'])) {$reS = $GLOBALS['S']; } 
88 88
 $GLOBALS['S'] = $S; 
89 89
 
90 90
 $t = preg_replace('`[\x00-\x08\x0b-\x0c\x0e-\x1f]`', '', $t); 
91
-if($C['clean_ms_char']){ 
91
+if ($C['clean_ms_char']) { 
92 92
  $x = array("\x7f"=>'', "\x80"=>'&#8364;', "\x81"=>'', "\x83"=>'&#402;', "\x85"=>'&#8230;', "\x86"=>'&#8224;', "\x87"=>'&#8225;', "\x88"=>'&#710;', "\x89"=>'&#8240;', "\x8a"=>'&#352;', "\x8b"=>'&#8249;', "\x8c"=>'&#338;', "\x8d"=>'', "\x8e"=>'&#381;', "\x8f"=>'', "\x90"=>'', "\x95"=>'&#8226;', "\x96"=>'&#8211;', "\x97"=>'&#8212;', "\x98"=>'&#732;', "\x99"=>'&#8482;', "\x9a"=>'&#353;', "\x9b"=>'&#8250;', "\x9c"=>'&#339;', "\x9d"=>'', "\x9e"=>'&#382;', "\x9f"=>'&#376;'); 
93 93
  $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'&#8218;', "\x84"=>'&#8222;', "\x91"=>'&#8216;', "\x92"=>'&#8217;', "\x93"=>'&#8220;', "\x94"=>'&#8221;') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); 
94 94
  $t = strtr($t, $x); 
95 95
 } 
96
-if($C['cdata'] or $C['comment']){$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'hl_cmtcd', $t);} 
96
+if ($C['cdata'] or $C['comment']) {$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'hl_cmtcd', $t); } 
97 97
 $t = preg_replace_callback('`&amp;([A-Za-z][A-Za-z0-9]{1,30}|#(?:[0-9]{1,8}|[Xx][0-9A-Fa-f]{1,7}));`', 'hl_ent', str_replace('&', '&amp;', $t)); 
98
-if($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])){$GLOBALS['hl_Ids'] = array();} 
99
-if($C['hook']){$t = $C['hook']($t, $C, $S);} 
100
-if($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])){ 
98
+if ($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])) {$GLOBALS['hl_Ids'] = array(); } 
99
+if ($C['hook']) {$t = $C['hook']($t, $C, $S); } 
100
+if ($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])) { 
101 101
  $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$S, 'time'=>microtime()); 
102 102
 } 
103 103
 // main 
@@ -106,41 +106,41 @@  discard block
 block discarded – undo
106 106
 $t = (($C['cdata'] or $C['comment']) && strpos($t, "\x01") !== false) ? str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05"), array('', '', '&', '<', '>'), $t) : $t; 
107 107
 $t = $C['tidy'] ? hl_tidy($t, $C['tidy'], $C['parent']) : $t; 
108 108
 unset($C, $e); 
109
-if(isset($reC)){$GLOBALS['C'] = $reC;} 
110
-if(isset($reS)){$GLOBALS['S'] = $reS;} 
109
+if (isset($reC)) {$GLOBALS['C'] = $reC; } 
110
+if (isset($reS)) {$GLOBALS['S'] = $reS; } 
111 111
 return $t; 
112 112
 // eof 
113 113
 } 
114 114
 
115
-function hl_attrval($t, $p){ 
115
+function hl_attrval($t, $p) { 
116 116
 // check attr val against $S 
117 117
 $o = 1; $l = strlen($t); 
118
-foreach($p as $k=>$v){ 
119
- switch($k){ 
120
-  case 'maxlen':if($l > $v){$o = 0;} 
121
-  break; case 'minlen': if($l < $v){$o = 0;} 
122
-  break; case 'maxval': if((float)($t) > $v){$o = 0;} 
123
-  break; case 'minval': if((float)($t) < $v){$o = 0;} 
124
-  break; case 'match': if(!preg_match($v, $t)){$o = 0;} 
125
-  break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} 
118
+foreach ($p as $k=>$v) { 
119
+ switch ($k) { 
120
+  case 'maxlen':if ($l > $v) {$o = 0; } 
121
+  break; case 'minlen': if ($l < $v) {$o = 0; } 
122
+  break; case 'maxval': if ((float)($t) > $v) {$o = 0; } 
123
+  break; case 'minval': if ((float)($t) < $v) {$o = 0; } 
124
+  break; case 'match': if (!preg_match($v, $t)) {$o = 0; } 
125
+  break; case 'nomatch': if (preg_match($v, $t)) {$o = 0; } 
126 126
   break; case 'oneof': 
127 127
    $m = 0; 
128
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} 
128
+   foreach (explode('|', $v) as $n) {if ($t == $n) {$m = 1; break; }} 
129 129
    $o = $m; 
130 130
   break; case 'noneof': 
131 131
    $m = 1; 
132
-   foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} 
132
+   foreach (explode('|', $v) as $n) {if ($t == $n) {$m = 0; break; }} 
133 133
    $o = $m; 
134 134
   break; default: 
135 135
   break; 
136 136
  } 
137
- if(!$o){break;} 
137
+ if (!$o) {break; } 
138 138
 } 
139 139
 return ($o ? $t : (isset($p['default']) ? $p['default'] : 0)); 
140 140
 // eof 
141 141
 } 
142 142
 
143
-function hl_bal($t, $do=1, $in='div'){ 
143
+function hl_bal($t, $do = 1, $in = 'div') { 
144 144
 // balance tags 
145 145
 // by content 
146 146
 $cB = array('blockquote'=>1, 'form'=>1, 'map'=>1, 'noscript'=>1); // Block 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 $cN2 = array_keys($cN); 
152 152
 $cR = array('blockquote'=>1, 'dir'=>1, 'dl'=>1, 'form'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1); 
153 153
 $cS = array('colgroup'=>array('col'=>1), 'dir'=>array('li'=>1), 'dl'=>array('dd'=>1, 'dt'=>1), 'menu'=>array('li'=>1), 'ol'=>array('li'=>1), 'optgroup'=>array('option'=>1), 'option'=>array('#pcdata'=>1), 'rbc'=>array('rb'=>1), 'rp'=>array('#pcdata'=>1), 'rtc'=>array('rt'=>1), 'ruby'=>array('rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1), 'select'=>array('optgroup'=>1, 'option'=>1), 'script'=>array('#pcdata'=>1), 'table'=>array('caption'=>1, 'col'=>1, 'colgroup'=>1, 'tfoot'=>1, 'tbody'=>1, 'tr'=>1, 'thead'=>1), 'tbody'=>array('tr'=>1), 'tfoot'=>array('tr'=>1), 'textarea'=>array('#pcdata'=>1), 'thead'=>array('tr'=>1), 'tr'=>array('td'=>1, 'th'=>1), 'ul'=>array('li'=>1)); // Specific - immediate parent-child 
154
-if($GLOBALS['C']['direct_list_nest']){$cS['ol'] = $cS['ul'] += array('ol'=>1, 'ul'=>1);} 
154
+if ($GLOBALS['C']['direct_list_nest']) {$cS['ol'] = $cS['ul'] += array('ol'=>1, 'ul'=>1); } 
155 155
 $cO = array('address'=>array('p'=>1), 'applet'=>array('param'=>1), 'blockquote'=>array('script'=>1), 'fieldset'=>array('legend'=>1, '#pcdata'=>1), 'form'=>array('script'=>1), 'map'=>array('area'=>1), 'object'=>array('param'=>1, 'embed'=>1)); // Other 
156 156
 $cT = array('colgroup'=>1, 'dd'=>1, 'dt'=>1, 'li'=>1, 'option'=>1, 'p'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1); // Omitable closing
157 157
 // block/inline type; ins & del both type; #pcdata: text 
@@ -163,196 +163,196 @@  discard block
 block discarded – undo
163 163
 
164 164
 // $in sets allowed child 
165 165
 $in = ((isset($eF[$in]) && $in != '#pcdata') or isset($eO[$in])) ? $in : 'div'; 
166
-if(isset($cE[$in])){ 
166
+if (isset($cE[$in])) { 
167 167
  return (!$do ? '' : str_replace(array('<', '>'), array('&lt;', '&gt;'), $t)); 
168 168
 } 
169
-if(isset($cS[$in])){$inOk = $cS[$in];} 
170
-elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
171
-elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} 
172
-elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} 
173
-if(isset($cO[$in])){$inOk = $inOk + $cO[$in];} 
174
-if(isset($cN[$in])){$inOk = array_diff_assoc($inOk, $cN[$in]);} 
169
+if (isset($cS[$in])) {$inOk = $cS[$in]; } 
170
+elseif (isset($cI[$in])) {$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1; } 
171
+elseif (isset($cF[$in])) {$inOk = $eF; unset($cI['del'], $cI['ins']); } 
172
+elseif (isset($cB[$in])) {$inOk = $eB; unset($cI['del'], $cI['ins']); } 
173
+if (isset($cO[$in])) {$inOk = $inOk + $cO[$in]; } 
174
+if (isset($cN[$in])) {$inOk = array_diff_assoc($inOk, $cN[$in]); } 
175 175
 
176 176
 $t = explode('<', $t); 
177 177
 $ok = $q = array(); // $q seq list of open non-empty ele 
178 178
 ob_start(); 
179 179
 
180
-for($i=-1, $ci=count($t); ++$i<$ci;){ 
180
+for ($i = -1, $ci = count($t); ++$i < $ci;) { 
181 181
  // allowed $ok in parent $p 
182
- if($ql = count($q)){ 
182
+ if ($ql = count($q)) { 
183 183
   $p = array_pop($q); 
184 184
   $q[] = $p; 
185
-  if(isset($cS[$p])){$ok = $cS[$p];} 
186
-  elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
187
-  elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
188
-  elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
189
-  if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
190
-  if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
191
- }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
185
+  if (isset($cS[$p])) {$ok = $cS[$p]; } 
186
+  elseif (isset($cI[$p])) {$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1; } 
187
+  elseif (isset($cF[$p])) {$ok = $eF; unset($cI['del'], $cI['ins']); } 
188
+  elseif (isset($cB[$p])) {$ok = $eB; unset($cI['del'], $cI['ins']); } 
189
+  if (isset($cO[$p])) {$ok = $ok + $cO[$p]; } 
190
+  if (isset($cN[$p])) {$ok = array_diff_assoc($ok, $cN[$p]); } 
191
+ } else {$ok = $inOk; unset($cI['del'], $cI['ins']); } 
192 192
  // bad tags, & ele content 
193
- if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
193
+ if (isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))) { 
194 194
   echo '&lt;', $s, $e, $a, '&gt;'; 
195 195
  } 
196
- if(isset($x[0])){ 
197
-  if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
196
+ if (isset($x[0])) { 
197
+  if (strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))) { 
198 198
    echo '<div>', $x, '</div>'; 
199 199
   } 
200
-  elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
201
-  elseif(strpos($x, "\x02\x04")){ 
202
-   foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
200
+  elseif ($do < 3 or isset($ok['#pcdata'])) {echo $x; } 
201
+  elseif (strpos($x, "\x02\x04")) { 
202
+   foreach (preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY) as $v) { 
203 203
     echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
204 204
    } 
205
-  }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
205
+  }elseif ($do > 4) {echo preg_replace('`\S`', '', $x); } 
206 206
  } 
207 207
  // get markup 
208
- if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} 
208
+ if (!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)) {$x = $t[$i]; continue; } 
209 209
  $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; 
210 210
  // close tag 
211
- if($s){ 
212
-  if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen 
213
-  if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 
211
+ if ($s) { 
212
+  if (isset($cE[$e]) or !in_array($e, $q)) {continue; } // Empty/unopen 
213
+  if ($p == $e) {array_pop($q); echo '</', $e, '>'; unset($e); continue; } // Last open 
214 214
   $add = ''; // Nesting - close open tags that need to be 
215
-  for($j=-1, $cj=count($q); ++$j<$cj;){   
216
-   if(($d = array_pop($q)) == $e){break;} 
217
-   else{$add .= "</{$d}>";} 
215
+  for ($j = -1, $cj = count($q); ++$j < $cj;) {   
216
+   if (($d = array_pop($q)) == $e) {break; } 
217
+   else {$add .= "</{$d}>"; } 
218 218
   } 
219 219
   echo $add, '</', $e, '>'; unset($e); continue; 
220 220
  } 
221 221
  // open tag 
222 222
  // $cB ele needs $eB ele as child 
223
- if(isset($cB[$e]) && strlen(trim($x))){ 
223
+ if (isset($cB[$e]) && strlen(trim($x))) { 
224 224
   $t[$i] = "{$e}{$a}>"; 
225
-  array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; 
225
+  array_splice($t, $i + 1, 0, 'div>'.$x); unset($e, $x); ++$ci; --$i; continue; 
226 226
  } 
227
- if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ 
227
+ if ((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])) { 
228 228
   array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; 
229 229
  } 
230 230
  // if no open ele, $in = parent; mostly immediate parent-child relation should hold 
231
- if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ 
232
-  if(!isset($ok[$e])){ 
233
-   if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} 
231
+ if (!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)) { 
232
+  if (!isset($ok[$e])) { 
233
+   if ($ql && isset($cT[$p])) {echo '</', array_pop($q), '>'; unset($e, $x); --$i; } 
234 234
    continue; 
235 235
   } 
236
-  if(!isset($cE[$e])){$q[] = $e;} 
236
+  if (!isset($cE[$e])) {$q[] = $e; } 
237 237
   echo '<', $e, $a, '>'; unset($e); continue; 
238 238
  } 
239 239
  // specific parent-child 
240
- if(isset($cS[$p][$e])){ 
241
-  if(!isset($cE[$e])){$q[] = $e;} 
240
+ if (isset($cS[$p][$e])) { 
241
+  if (!isset($cE[$e])) {$q[] = $e; } 
242 242
   echo '<', $e, $a, '>'; unset($e); continue; 
243 243
  } 
244 244
  // nesting 
245 245
  $add = ''; 
246 246
  $q2 = array(); 
247
- for($k=-1, $kc=count($q); ++$k<$kc;){ 
247
+ for ($k = -1, $kc = count($q); ++$k < $kc;) { 
248 248
   $d = $q[$k]; 
249 249
   $ok2 = array(); 
250
-  if(isset($cS[$d])){$q2[] = $d; continue;} 
250
+  if (isset($cS[$d])) {$q2[] = $d; continue; } 
251 251
   $ok2 = isset($cI[$d]) ? $eI : $eF; 
252
-  if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} 
253
-  if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} 
254
-  if(!isset($ok2[$e])){ 
255
-   if(!$k && !isset($inOk[$e])){continue 2;} 
252
+  if (isset($cO[$d])) {$ok2 = $ok2 + $cO[$d]; } 
253
+  if (isset($cN[$d])) {$ok2 = array_diff_assoc($ok2, $cN[$d]); } 
254
+  if (!isset($ok2[$e])) { 
255
+   if (!$k && !isset($inOk[$e])) {continue 2; } 
256 256
    $add = "</{$d}>"; 
257
-   for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} 
257
+   for (;++$k < $kc;) {$add = "</{$q[$k]}>{$add}"; } 
258 258
    break; 
259 259
   } 
260
-  else{$q2[] = $d;} 
260
+  else {$q2[] = $d; } 
261 261
  } 
262 262
  $q = $q2; 
263
- if(!isset($cE[$e])){$q[] = $e;} 
263
+ if (!isset($cE[$e])) {$q[] = $e; } 
264 264
  echo $add, '<', $e, $a, '>'; unset($e); continue; 
265 265
 } 
266 266
 
267 267
 // end 
268
-if($ql = count($q)){ 
268
+if ($ql = count($q)) { 
269 269
  $p = array_pop($q); 
270 270
  $q[] = $p; 
271
- if(isset($cS[$p])){$ok = $cS[$p];} 
272
- elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
273
- elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
274
- elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
275
- if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
276
- if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
277
-}else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
278
-if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
271
+ if (isset($cS[$p])) {$ok = $cS[$p]; } 
272
+ elseif (isset($cI[$p])) {$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1; } 
273
+ elseif (isset($cF[$p])) {$ok = $eF; unset($cI['del'], $cI['ins']); } 
274
+ elseif (isset($cB[$p])) {$ok = $eB; unset($cI['del'], $cI['ins']); } 
275
+ if (isset($cO[$p])) {$ok = $ok + $cO[$p]; } 
276
+ if (isset($cN[$p])) {$ok = array_diff_assoc($ok, $cN[$p]); } 
277
+} else {$ok = $inOk; unset($cI['del'], $cI['ins']); } 
278
+if (isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))) { 
279 279
  echo '&lt;', $s, $e, $a, '&gt;'; 
280 280
 } 
281
-if(isset($x[0])){ 
282
- if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
281
+if (isset($x[0])) { 
282
+ if (strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))) { 
283 283
   echo '<div>', $x, '</div>'; 
284 284
  } 
285
- elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
286
- elseif(strpos($x, "\x02\x04")){ 
287
-  foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
285
+ elseif ($do < 3 or isset($ok['#pcdata'])) {echo $x; } 
286
+ elseif (strpos($x, "\x02\x04")) { 
287
+  foreach (preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY) as $v) { 
288 288
    echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
289 289
   } 
290
- }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
290
+ }elseif ($do > 4) {echo preg_replace('`\S`', '', $x); } 
291 291
 } 
292
-while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} 
292
+while (!empty($q) && ($e = array_pop($q))) {echo '</', $e, '>'; } 
293 293
 $o = ob_get_contents(); 
294 294
 ob_end_clean(); 
295 295
 return $o; 
296 296
 // eof 
297 297
 } 
298 298
 
299
-function hl_cmtcd($t){ 
299
+function hl_cmtcd($t) { 
300 300
 // comment/CDATA sec handler 
301 301
 $t = $t[0]; 
302 302
 global $C; 
303
-if(!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])){return $t;} 
304
-if($v == 1){return '';} 
305
-if($n == 'comment'){ 
306
- if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} 
303
+if (!($v = $C[$n = $t[3] == '-' ? 'comment' : 'cdata'])) {return $t; } 
304
+if ($v == 1) {return ''; } 
305
+if ($n == 'comment') { 
306
+ if (substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' ') {$t .= ' '; } 
307 307
 } 
308
-else{$t = substr($t, 1, -1);} 
308
+else {$t = substr($t, 1, -1); } 
309 309
 $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $t) : $t; 
310 310
 return str_replace(array('&', '<', '>'), array("\x03", "\x04", "\x05"), ($n == 'comment' ? "\x01\x02\x04!--$t--\x05\x02\x01" : "\x01\x01\x04$t\x05\x01\x01")); 
311 311
 // eof 
312 312
 } 
313 313
 
314
-function hl_ent($t){ 
314
+function hl_ent($t) { 
315 315
 // entitity handler 
316 316
 global $C; 
317 317
 $t = $t[1]; 
318
-static $U = array('quot'=>1,'amp'=>1,'lt'=>1,'gt'=>1); 
319
-static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39',  'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); 
320
-if($t[0] != '#'){ 
321
- return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; 
318
+static $U = array('quot'=>1, 'amp'=>1, 'lt'=>1, 'gt'=>1); 
319
+static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39', 'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); 
320
+if ($t[0] != '#') { 
321
+ return ($C['and_mark'] ? "\x06" : '&').(isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'.($C['hexdec_entity'] > 1 ? 'x'.dechex($N[$t]) : $N[$t]) : $t) : 'amp;'.$t)).';'; 
322 322
 } 
323
-if(($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))){ 
324
- return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; 
323
+if (($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))) { 
324
+ return ($C['and_mark'] ? "\x06" : '&')."amp;#{$t};"; 
325 325
 } 
326
-return ($C['and_mark'] ? "\x06" : '&'). '#'. (((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'. dechex($n)). ';';
326
+return ($C['and_mark'] ? "\x06" : '&').'#'.(((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'.dechex($n)).';';
327 327
 // eof 
328 328
 } 
329 329
 
330
-function hl_prot($p, $c=null){ 
330
+function hl_prot($p, $c = null) { 
331 331
 // check URL scheme 
332 332
 global $C; 
333 333
 $b = $a = ''; 
334
-if($c == null){$c = 'style'; $b = $p[1]; $a = $p[3]; $p = trim($p[2]);} 
334
+if ($c == null) {$c = 'style'; $b = $p[1]; $a = $p[3]; $p = trim($p[2]); } 
335 335
 $c = isset($C['schemes'][$c]) ? $C['schemes'][$c] : $C['schemes']['*']; 
336 336
 static $d = 'denied:'; 
337
-if(isset($c['!']) && substr($p, 0, 7) != $d){$p = "$d$p";} 
338
-if(isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)){return "{$b}{$p}{$a}";} // All ok, frag, query, param 
339
-if(preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])){ // Denied prot 
337
+if (isset($c['!']) && substr($p, 0, 7) != $d) {$p = "$d$p"; } 
338
+if (isset($c['*']) or !strcspn($p, '#?;') or (substr($p, 0, 7) == $d)) {return "{$b}{$p}{$a}"; } // All ok, frag, query, param 
339
+if (preg_match('`^([^:?[@!$()*,=/\'\]]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])) { // Denied prot 
340 340
  return "{$b}{$d}{$p}{$a}"; 
341 341
 } 
342
-if($C['abs_url']){ 
343
- if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel 
342
+if ($C['abs_url']) { 
343
+ if ($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0) { // Make url rel 
344 344
   $p = substr($p, strlen($C['base_url'])); 
345
- }elseif(empty($m[1])){ // Make URL abs 
346
-  if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} 
347
-  elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} 
348
-  elseif(strcspn($p, './')){$p = $C['base_url']. $p;} 
349
-  else{ 
345
+ }elseif (empty($m[1])) { // Make URL abs 
346
+  if (substr($p, 0, 2) == '//') {$p = substr($C['base_url'], 0, strpos($C['base_url'], ':') + 1).$p; } 
347
+  elseif ($p[0] == '/') {$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']).$p; } 
348
+  elseif (strcspn($p, './')) {$p = $C['base_url'].$p; } 
349
+  else { 
350 350
    preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); 
351
-   $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); 
352
-   while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ 
351
+   $p = preg_replace('`(?<=/)\./`', '', $m[2].$p); 
352
+   while (preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)) { 
353 353
     $p = preg_replace('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', '', $p); 
354 354
    } 
355
-   $p = $m[1]. $p; 
355
+   $p = $m[1].$p; 
356 356
   } 
357 357
  } 
358 358
 } 
@@ -360,76 +360,76 @@  discard block
 block discarded – undo
360 360
 // eof 
361 361
 } 
362 362
 
363
-function hl_regex($p){ 
363
+function hl_regex($p) { 
364 364
 // ?regex 
365
-if(empty($p)){return 0;} 
366
-if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} 
367
-else{ini_set('track_errors', 1);} 
365
+if (empty($p)) {return 0; } 
366
+if ($t = ini_get('track_errors')) {$o = isset($php_errormsg) ? $php_errormsg : null; } 
367
+else {ini_set('track_errors', 1); } 
368 368
 unset($php_errormsg); 
369
-if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} 
369
+if (($d = ini_get('display_errors'))) {ini_set('display_errors', 0); } 
370 370
 preg_match($p, ''); 
371
-if($d){ini_set('display_errors', 1);} 
371
+if ($d) {ini_set('display_errors', 1); } 
372 372
 $r = isset($php_errormsg) ? 0 : 1; 
373
-if($t){$php_errormsg = isset($o) ? $o : null;} 
374
-else{ini_set('track_errors', 0);} 
373
+if ($t) {$php_errormsg = isset($o) ? $o : null; } 
374
+else {ini_set('track_errors', 0); } 
375 375
 return $r; 
376 376
 // eof 
377 377
 } 
378 378
 
379
-function hl_spec($t){ 
379
+function hl_spec($t) { 
380 380
 // final $spec 
381 381
 $s = array(); 
382 382
 $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace_callback('/"(?>(`.|[^"])*)"/sm', create_function('$m', 'return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), $m[0]), 1, -1);'), trim($t))); 
383
-for($i = count(($t = explode(';', $t))); --$i>=0;){ 
383
+for ($i = count(($t = explode(';', $t))); --$i >= 0;) { 
384 384
  $w = $t[$i]; 
385
- if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a =  substr($w, $e+1)))){continue;} 
385
+ if (empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e + 1)))) {continue; } 
386 386
  $y = $n = array(); 
387
- foreach(explode(',', $a) as $v){ 
388
-  if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} 
389
-  if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} 
390
-  if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} 
391
-  if(!isset($m[2])){$y[$x] = 1; continue;} 
392
-  foreach(explode('/', $m[2]) as $m){ 
393
-   if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} 
394
-   $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); 
387
+ foreach (explode(',', $a) as $v) { 
388
+  if (!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)) {continue; } 
389
+  if (($x = strtolower($m[1])) == '-*') {$n['*'] = 1; continue; } 
390
+  if ($x[0] == '-') {$n[substr($x, 1)] = 1; continue; } 
391
+  if (!isset($m[2])) {$y[$x] = 1; continue; } 
392
+  foreach (explode('/', $m[2]) as $m) { 
393
+   if (empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5) {$y[$x] = 1; continue; } 
394
+   $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p + 1)); 
395 395
   } 
396
-  if(isset($y[$x]['match']) && !hl_regex($y[$x]['match'])){unset($y[$x]['match']);} 
397
-  if(isset($y[$x]['nomatch']) && !hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} 
396
+  if (isset($y[$x]['match']) && !hl_regex($y[$x]['match'])) {unset($y[$x]['match']); } 
397
+  if (isset($y[$x]['nomatch']) && !hl_regex($y[$x]['nomatch'])) {unset($y[$x]['nomatch']); } 
398 398
  } 
399
- if(!count($y) && !count($n)){continue;} 
400
- foreach(explode(',', substr($w, 0, $e)) as $v){ 
401
-  if(!strlen(($v = strtolower($v)))){continue;} 
402
-  if(count($y)){$s[$v] = $y;} 
403
-  if(count($n)){$s[$v]['n'] = $n;} 
399
+ if (!count($y) && !count($n)) {continue; } 
400
+ foreach (explode(',', substr($w, 0, $e)) as $v) { 
401
+  if (!strlen(($v = strtolower($v)))) {continue; } 
402
+  if (count($y)) {$s[$v] = $y; } 
403
+  if (count($n)) {$s[$v]['n'] = $n; } 
404 404
  } 
405 405
 } 
406 406
 return $s; 
407 407
 // eof 
408 408
 } 
409 409
 
410
-function hl_tag($t){ 
410
+function hl_tag($t) { 
411 411
 // tag/attribute handler 
412 412
 global $C; 
413 413
 $t = $t[0]; 
414 414
 // invalid < > 
415
-if($t == '< '){return '&lt; ';} 
416
-if($t == '>'){return '&gt;';} 
417
-if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ 
415
+if ($t == '< ') {return '&lt; '; } 
416
+if ($t == '>') {return '&gt;'; } 
417
+if (!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)) { 
418 418
  return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t); 
419
-}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ 
419
+}elseif (!isset($C['elements'][($e = strtolower($m[2]))])) { 
420 420
  return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); 
421 421
 } 
422 422
 // attr string 
423 423
 $a = str_replace(array("\n", "\r", "\t"), ' ', trim($m[3])); 
424 424
 // tag transform 
425 425
 static $eD = array('applet'=>1, 'center'=>1, 'dir'=>1, 'embed'=>1, 'font'=>1, 'isindex'=>1, 'menu'=>1, 's'=>1, 'strike'=>1, 'u'=>1); // Deprecated
426
-if($C['make_tag_strict'] && isset($eD[$e])){ 
426
+if ($C['make_tag_strict'] && isset($eD[$e])) { 
427 427
  $trt = hl_tag2($e, $a, $C['make_tag_strict']); 
428
- if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '');} 
428
+ if (!$e) {return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); } 
429 429
 } 
430 430
 // close tag 
431 431
 static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1); // Empty ele 
432
-if(!empty($m[1])){ 
432
+if (!empty($m[1])) { 
433 433
  return (!isset($eE[$e]) ? (empty($C['hook_tag']) ? "</$e>" : $C['hook_tag']($e)) : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '')); 
434 434
 } 
435 435
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 static $aNP = array('action'=>1, 'cite'=>1, 'classid'=>1, 'codebase'=>1, 'data'=>1, 'href'=>1, 'longdesc'=>1, 'model'=>1, 'pluginspage'=>1, 'pluginurl'=>1, 'usemap'=>1); // Need scheme check; excludes style, on* & src 
440 440
 static $aNU = array('class'=>array('param'=>1, 'script'=>1), 'dir'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'id'=>array('script'=>1), 'lang'=>array('applet'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'xml:lang'=>array('applet'=>1, 'br'=>1, 'iframe'=>1, 'param'=>1, 'script'=>1), 'onclick'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'ondblclick'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeydown'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeypress'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onkeyup'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmousedown'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmousemove'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseout'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseover'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'onmouseup'=>array('applet'=>1, 'bdo'=>1, 'br'=>1, 'font'=>1, 'iframe'=>1, 'isindex'=>1, 'param'=>1, 'script'=>1), 'style'=>array('param'=>1, 'script'=>1), 'title'=>array('param'=>1, 'script'=>1)); // Univ & exceptions 
441 441
 
442
-if($C['lc_std_val']){ 
442
+if ($C['lc_std_val']) { 
443 443
  // predef attr vals for $eAL & $aNE ele 
444 444
  static $aNL = array('all'=>1, 'baseline'=>1, 'bottom'=>1, 'button'=>1, 'center'=>1, 'char'=>1, 'checkbox'=>1, 'circle'=>1, 'col'=>1, 'colgroup'=>1, 'cols'=>1, 'data'=>1, 'default'=>1, 'file'=>1, 'get'=>1, 'groups'=>1, 'hidden'=>1, 'image'=>1, 'justify'=>1, 'left'=>1, 'ltr'=>1, 'middle'=>1, 'none'=>1, 'object'=>1, 'password'=>1, 'poly'=>1, 'post'=>1, 'preserve'=>1, 'radio'=>1, 'rect'=>1, 'ref'=>1, 'reset'=>1, 'right'=>1, 'row'=>1, 'rowgroup'=>1, 'rows'=>1, 'rtl'=>1, 'submit'=>1, 'text'=>1, 'top'=>1); 
445 445
  static $eAL = array('a'=>1, 'area'=>1, 'bdo'=>1, 'button'=>1, 'col'=>1, 'form'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'xml:space'=>1); 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 } 
448 448
 
449 449
 $depTr = 0; 
450
-if($C['no_deprecated_attr']){ 
450
+if ($C['no_deprecated_attr']) { 
451 451
  // dep attr:applicable ele 
452 452
  static $aND = array('align'=>array('caption'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'object'=>1, 'p'=>1, 'table'=>1), 'bgcolor'=>array('table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1), 'border'=>array('img'=>1, 'object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'clear'=>array('br'=>1), 'compact'=>array('dl'=>1, 'ol'=>1, 'ul'=>1), 'height'=>array('td'=>1, 'th'=>1), 'hspace'=>array('img'=>1, 'object'=>1), 'language'=>array('script'=>1), 'name'=>array('a'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'map'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'size'=>array('hr'=>1), 'start'=>array('ol'=>1), 'type'=>array('li'=>1, 'ol'=>1, 'ul'=>1), 'value'=>array('li'=>1), 'vspace'=>array('img'=>1, 'object'=>1), 'width'=>array('hr'=>1, 'pre'=>1, 'td'=>1, 'th'=>1)); 
453 453
  static $eAD = array('a'=>1, 'br'=>1, 'caption'=>1, 'div'=>1, 'dl'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'object'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'script'=>1, 'table'=>1, 'td'=>1, 'th'=>1, 'tr'=>1, 'ul'=>1); 
@@ -455,197 +455,197 @@  discard block
 block discarded – undo
455 455
 } 
456 456
 
457 457
 // attr name-vals 
458
-if(strpos($a, "\x01") !== false){$a = preg_replace('`\x01[^\x01]*\x01`', '', $a);} // No comment/CDATA sec 
458
+if (strpos($a, "\x01") !== false) {$a = preg_replace('`\x01[^\x01]*\x01`', '', $a); } // No comment/CDATA sec 
459 459
 $mode = 0; $a = trim($a, ' /'); $aA = array(); 
460
-while(strlen($a)){ 
460
+while (strlen($a)) { 
461 461
  $w = 0; 
462
- switch($mode){ 
462
+ switch ($mode) { 
463 463
   case 0: // Name 
464
-   if(preg_match('`^[a-zA-Z][\-a-zA-Z:]+`', $a, $m)){ 
464
+   if (preg_match('`^[a-zA-Z][\-a-zA-Z:]+`', $a, $m)) { 
465 465
     $nm = strtolower($m[0]); 
466 466
     $w = $mode = 1; $a = ltrim(substr_replace($a, '', 0, strlen($m[0]))); 
467 467
    } 
468 468
   break; case 1: 
469
-   if($a[0] == '='){ // = 
469
+   if ($a[0] == '=') { // = 
470 470
     $w = 1; $mode = 2; $a = ltrim($a, '= '); 
471
-   }else{ // No val 
471
+   } else { // No val 
472 472
     $w = 1; $mode = 0; $a = ltrim($a); 
473 473
     $aA[$nm] = ''; 
474 474
    } 
475 475
   break; case 2: // Val 
476
-   if(preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)){ 
476
+   if (preg_match('`^((?:"[^"]*")|(?:\'[^\']*\')|(?:\s*[^\s"\']+))(.*)`', $a, $m)) { 
477 477
     $a = ltrim($m[2]); $m = $m[1]; $w = 1; $mode = 0; 
478 478
     $aA[$nm] = trim(str_replace('<', '&lt;', ($m[0] == '"' or $m[0] == '\'') ? substr($m, 1, -1) : $m)); 
479 479
    } 
480 480
   break; 
481 481
  } 
482
- if($w == 0){ // Parse errs, deal with space, " & ' 
482
+ if ($w == 0) { // Parse errs, deal with space, " & ' 
483 483
   $a = preg_replace('`^(?:"[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*`', '', $a); 
484 484
   $mode = 0; 
485 485
  } 
486 486
 } 
487
-if($mode == 1){$aA[$nm] = '';} 
487
+if ($mode == 1) {$aA[$nm] = ''; } 
488 488
 
489 489
 // clean attrs 
490 490
 global $S; 
491 491
 $rl = isset($S[$e]) ? $S[$e] : array(); 
492 492
 $a = array(); $nfr = 0; 
493
-foreach($aA as $k=>$v){ 
494
-  if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ 
495
-  if(isset($aNE[$k])){$v = $k;} 
496
-  elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues 
493
+foreach ($aA as $k=>$v) { 
494
+  if (((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])) { 
495
+  if (isset($aNE[$k])) {$v = $k; } 
496
+  elseif (!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')) { // Rather loose but ?not cause issues 
497 497
    $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; 
498 498
   } 
499
-  if($k == 'style' && !$C['style_pass']){ 
500
-   if(false !== strpos($v, '&#')){ 
499
+  if ($k == 'style' && !$C['style_pass']) { 
500
+   if (false !== strpos($v, '&#')) { 
501 501
     static $sC = array('&#x20;'=>' ', '&#32;'=>' ', '&#x45;'=>'e', '&#69;'=>'e', '&#x65;'=>'e', '&#101;'=>'e', '&#x58;'=>'x', '&#88;'=>'x', '&#x78;'=>'x', '&#120;'=>'x', '&#x50;'=>'p', '&#80;'=>'p', '&#x70;'=>'p', '&#112;'=>'p', '&#x53;'=>'s', '&#83;'=>'s', '&#x73;'=>'s', '&#115;'=>'s', '&#x49;'=>'i', '&#73;'=>'i', '&#x69;'=>'i', '&#105;'=>'i', '&#x4f;'=>'o', '&#79;'=>'o', '&#x6f;'=>'o', '&#111;'=>'o', '&#x4e;'=>'n', '&#78;'=>'n', '&#x6e;'=>'n', '&#110;'=>'n', '&#x55;'=>'u', '&#85;'=>'u', '&#x75;'=>'u', '&#117;'=>'u', '&#x52;'=>'r', '&#82;'=>'r', '&#x72;'=>'r', '&#114;'=>'r', '&#x4c;'=>'l', '&#76;'=>'l', '&#x6c;'=>'l', '&#108;'=>'l', '&#x28;'=>'(', '&#40;'=>'(', '&#x29;'=>')', '&#41;'=>')', '&#x20;'=>':', '&#32;'=>':', '&#x22;'=>'"', '&#34;'=>'"', '&#x27;'=>"'", '&#39;'=>"'", '&#x2f;'=>'/', '&#47;'=>'/', '&#x2a;'=>'*', '&#42;'=>'*', '&#x5c;'=>'\\', '&#92;'=>'\\'); 
502 502
     $v = strtr($v, $sC); 
503 503
    } 
504 504
    $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'hl_prot', $v); 
505 505
    $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; 
506
-  }elseif(isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o'){ 
506
+  }elseif (isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o') { 
507 507
    $v = str_replace("\xad", ' ', (strpos($v, '&') !== false ? str_replace(array('&#xad;', '&#173;', '&shy;'), ' ', $v) : $v)); 
508 508
    $v = hl_prot($v, $k); 
509
-   if($k == 'href'){ // X-spam 
510
-    if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ 
509
+   if ($k == 'href') { // X-spam 
510
+    if ($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0) { 
511 511
      $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); 
512
-    }elseif($C['anti_link_spam']){ 
512
+    }elseif ($C['anti_link_spam']) { 
513 513
      $r1 = $C['anti_link_spam'][1]; 
514
-     if(!empty($r1) && preg_match($r1, $v)){continue;} 
514
+     if (!empty($r1) && preg_match($r1, $v)) {continue; } 
515 515
      $r0 = $C['anti_link_spam'][0]; 
516
-     if(!empty($r0) && preg_match($r0, $v)){ 
517
-      if(isset($a['rel'])){ 
518
-       if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} 
519
-      }elseif(isset($aA['rel'])){ 
520
-       if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} 
521
-      }else{$a['rel'] = 'nofollow';} 
516
+     if (!empty($r0) && preg_match($r0, $v)) { 
517
+      if (isset($a['rel'])) { 
518
+       if (!preg_match('`\bnofollow\b`i', $a['rel'])) {$a['rel'] .= ' nofollow'; } 
519
+      }elseif (isset($aA['rel'])) { 
520
+       if (!preg_match('`\bnofollow\b`i', $aA['rel'])) {$nfr = 1; } 
521
+      } else {$a['rel'] = 'nofollow'; } 
522 522
      } 
523 523
     } 
524 524
    } 
525 525
   } 
526
-  if(isset($rl[$k]) && is_array($rl[$k]) && ($v = hl_attrval($v, $rl[$k])) === 0){continue;} 
526
+  if (isset($rl[$k]) && is_array($rl[$k]) && ($v = hl_attrval($v, $rl[$k])) === 0) {continue; } 
527 527
   $a[$k] = str_replace('"', '&quot;', $v); 
528 528
  } 
529 529
 } 
530
-if($nfr){$a['rel'] = isset($a['rel']) ? $a['rel']. ' nofollow' : 'nofollow';} 
530
+if ($nfr) {$a['rel'] = isset($a['rel']) ? $a['rel'].' nofollow' : 'nofollow'; } 
531 531
 
532 532
 // rqd attr 
533 533
 static $eAR = array('area'=>array('alt'=>'area'), 'bdo'=>array('dir'=>'ltr'), 'form'=>array('action'=>''), 'img'=>array('src'=>'', 'alt'=>'image'), 'map'=>array('name'=>''), 'optgroup'=>array('label'=>''), 'param'=>array('name'=>''), 'script'=>array('type'=>'text/javascript'), 'textarea'=>array('rows'=>'10', 'cols'=>'50')); 
534
-if(isset($eAR[$e])){ 
535
- foreach($eAR[$e] as $k=>$v){ 
536
-  if(!isset($a[$k])){$a[$k] = isset($v[0]) ? $v : $k;} 
534
+if (isset($eAR[$e])) { 
535
+ foreach ($eAR[$e] as $k=>$v) { 
536
+  if (!isset($a[$k])) {$a[$k] = isset($v[0]) ? $v : $k; } 
537 537
  } 
538 538
 } 
539 539
 
540 540
 // depr attrs 
541
-if($depTr){ 
541
+if ($depTr) { 
542 542
  $c = array(); 
543
- foreach($a as $k=>$v){ 
544
-  if($k == 'style' or !isset($aND[$k][$e])){continue;} 
545
-  if($k == 'align'){ 
543
+ foreach ($a as $k=>$v) { 
544
+  if ($k == 'style' or !isset($aND[$k][$e])) {continue; } 
545
+  if ($k == 'align') { 
546 546
    unset($a['align']); 
547
-   if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} 
548
-   elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} 
549
-   else{$c[] = 'text-align: '. $v;} 
550
-  }elseif($k == 'bgcolor'){ 
547
+   if ($e == 'img' && ($v == 'left' or $v == 'right')) {$c[] = 'float: '.$v; } 
548
+   elseif (($e == 'div' or $e == 'table') && $v == 'center') {$c[] = 'margin: auto'; } 
549
+   else {$c[] = 'text-align: '.$v; } 
550
+  }elseif ($k == 'bgcolor') { 
551 551
    unset($a['bgcolor']); 
552
-   $c[] = 'background-color: '. $v; 
553
-  }elseif($k == 'border'){ 
552
+   $c[] = 'background-color: '.$v; 
553
+  }elseif ($k == 'border') { 
554 554
    unset($a['border']); $c[] = "border: {$v}px"; 
555
-  }elseif($k == 'bordercolor'){ 
556
-   unset($a['bordercolor']); $c[] = 'border-color: '. $v; 
557
-  }elseif($k == 'clear'){ 
558
-   unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); 
559
-  }elseif($k == 'compact'){ 
555
+  }elseif ($k == 'bordercolor') { 
556
+   unset($a['bordercolor']); $c[] = 'border-color: '.$v; 
557
+  }elseif ($k == 'clear') { 
558
+   unset($a['clear']); $c[] = 'clear: '.($v != 'all' ? $v : 'both'); 
559
+  }elseif ($k == 'compact') { 
560 560
    unset($a['compact']); $c[] = 'font-size: 85%'; 
561
-  }elseif($k == 'height' or $k == 'width'){ 
562
-   unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); 
563
-  }elseif($k == 'hspace'){ 
561
+  }elseif ($k == 'height' or $k == 'width') { 
562
+   unset($a[$k]); $c[] = $k.': '.($v[0] != '*' ? $v.(ctype_digit($v) ? 'px' : '') : 'auto'); 
563
+  }elseif ($k == 'hspace') { 
564 564
    unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; 
565
-  }elseif($k == 'language' && !isset($a['type'])){ 
565
+  }elseif ($k == 'language' && !isset($a['type'])) { 
566 566
    unset($a['language']); 
567
-   $a['type'] = 'text/'. strtolower($v); 
568
-  }elseif($k == 'name'){ 
569
-   if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} 
570
-   if(!isset($a['id']) && preg_match('`[a-zA-Z][a-zA-Z\d.:_\-]*`', $v)){$a['id'] = $v;} 
571
-  }elseif($k == 'noshade'){ 
567
+   $a['type'] = 'text/'.strtolower($v); 
568
+  }elseif ($k == 'name') { 
569
+   if ($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')) {unset($a['name']); } 
570
+   if (!isset($a['id']) && preg_match('`[a-zA-Z][a-zA-Z\d.:_\-]*`', $v)) {$a['id'] = $v; } 
571
+  }elseif ($k == 'noshade') { 
572 572
    unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; 
573
-  }elseif($k == 'nowrap'){ 
573
+  }elseif ($k == 'nowrap') { 
574 574
    unset($a['nowrap']); $c[] = 'white-space: nowrap'; 
575
-  }elseif($k == 'size'){ 
576
-   unset($a['size']); $c[] = 'size: '. $v. 'px'; 
577
-  }elseif($k == 'start' or $k == 'value'){ 
575
+  }elseif ($k == 'size') { 
576
+   unset($a['size']); $c[] = 'size: '.$v.'px'; 
577
+  }elseif ($k == 'start' or $k == 'value') { 
578 578
    unset($a[$k]); 
579
-  }elseif($k == 'type'){ 
579
+  }elseif ($k == 'type') { 
580 580
    unset($a['type']); 
581 581
    static $ol_type = array('i'=>'lower-roman', 'I'=>'upper-roman', 'a'=>'lower-latin', 'A'=>'upper-latin', '1'=>'decimal'); 
582
-   $c[] = 'list-style-type: '. (isset($ol_type[$v]) ? $ol_type[$v] : 'decimal'); 
583
-  }elseif($k == 'vspace'){ 
582
+   $c[] = 'list-style-type: '.(isset($ol_type[$v]) ? $ol_type[$v] : 'decimal'); 
583
+  }elseif ($k == 'vspace') { 
584 584
    unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; 
585 585
   } 
586 586
  } 
587
- if(count($c)){ 
587
+ if (count($c)) { 
588 588
   $c = implode('; ', $c); 
589
-  $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $c. ';': $c. ';'; 
589
+  $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;').'; '.$c.';' : $c.';'; 
590 590
  } 
591 591
 } 
592 592
 // unique ID 
593
-if($C['unique_ids'] && isset($a['id'])){ 
594
- if(!preg_match('`^[A-Za-z][A-Za-z0-9_\-.:]*$`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); 
595
- }else{ 
596
-  while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} 
593
+if ($C['unique_ids'] && isset($a['id'])) { 
594
+ if (!preg_match('`^[A-Za-z][A-Za-z0-9_\-.:]*$`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)) {unset($a['id']); 
595
+ } else { 
596
+  while (isset($GLOBALS['hl_Ids'][$id])) {$id = $C['unique_ids'].$id; } 
597 597
   $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; 
598 598
  } 
599 599
 } 
600 600
 // xml:lang 
601
-if($C['xml:lang'] && isset($a['lang'])){ 
601
+if ($C['xml:lang'] && isset($a['lang'])) { 
602 602
  $a['xml:lang'] = isset($a['xml:lang']) ? $a['xml:lang'] : $a['lang']; 
603
- if($C['xml:lang'] == 2){unset($a['lang']);} 
603
+ if ($C['xml:lang'] == 2) {unset($a['lang']); } 
604 604
 } 
605 605
 // for transformed tag 
606
-if(!empty($trt)){ 
607
- $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;'). '; '. $trt : $trt; 
606
+if (!empty($trt)) { 
607
+ $a['style'] = isset($a['style']) ? rtrim($a['style'], ' ;').'; '.$trt : $trt; 
608 608
 } 
609 609
 // return with empty ele / 
610
-if(empty($C['hook_tag'])){ 
610
+if (empty($C['hook_tag'])) { 
611 611
  $aA = ''; 
612
- foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} 
613
- return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; 
612
+ foreach ($a as $k=>$v) {$aA .= " {$k}=\"{$v}\""; } 
613
+ return "<{$e}{$aA}".(isset($eE[$e]) ? ' /' : '').'>'; 
614 614
 } 
615
-else{return $C['hook_tag']($e, $a);} 
615
+else {return $C['hook_tag']($e, $a); } 
616 616
 // eof 
617 617
 } 
618 618
 
619
-function hl_tag2(&$e, &$a, $t=1){ 
619
+function hl_tag2(&$e, &$a, $t = 1) { 
620 620
 // transform tag 
621
-if($e == 'center'){$e = 'div'; return 'text-align: center;';} 
622
-if($e == 'dir' or $e == 'menu'){$e = 'ul'; return '';} 
623
-if($e == 's' or $e == 'strike'){$e = 'span'; return 'text-decoration: line-through;';} 
624
-if($e == 'u'){$e = 'span'; return 'text-decoration: underline;';} 
621
+if ($e == 'center') {$e = 'div'; return 'text-align: center;'; } 
622
+if ($e == 'dir' or $e == 'menu') {$e = 'ul'; return ''; } 
623
+if ($e == 's' or $e == 'strike') {$e = 'span'; return 'text-decoration: line-through;'; } 
624
+if ($e == 'u') {$e = 'span'; return 'text-decoration: underline;'; } 
625 625
 static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%'); 
626
-if($e == 'font'){ 
626
+if ($e == 'font') { 
627 627
  $a2 = ''; 
628
- if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)){ 
629
-  $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[2])). ';'; 
628
+ if (preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)) { 
629
+  $a2 .= ' font-family: '.str_replace('"', '\'', trim($m[2])).';'; 
630 630
  } 
631
- if(preg_match('`color\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m)){ 
632
-  $a2 .= ' color: '. trim($m[2]). ';'; 
631
+ if (preg_match('`color\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m)) { 
632
+  $a2 .= ' color: '.trim($m[2]).';'; 
633 633
  } 
634
- if(preg_match('`size\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m) && isset($fs[($m = trim($m[2]))])){ 
635
-  $a2 .= ' font-size: '. $fs[$m]. ';'; 
634
+ if (preg_match('`size\s*=\s*(\'|")?(.+?)(\\1|\s|$)`i', $a, $m) && isset($fs[($m = trim($m[2]))])) { 
635
+  $a2 .= ' font-size: '.$fs[$m].';'; 
636 636
  } 
637 637
  $e = 'span'; return ltrim($a2); 
638 638
 } 
639
-if($t == 2){$e = 0; return 0;} 
639
+if ($t == 2) {$e = 0; return 0; } 
640 640
 return ''; 
641 641
 // eof 
642 642
 } 
643 643
 
644
-function hl_tidy($t, $w, $p){ 
644
+function hl_tidy($t, $w, $p) { 
645 645
 // Tidy/compact HTM 
646
-if(strpos(' pre,script,textarea', "$p,")){return $t;} 
646
+if (strpos(' pre,script,textarea', "$p,")) {return $t; } 
647 647
 $t = preg_replace('`\s+`', ' ', preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)(</\2>)`sm'), create_function('$m', 'return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", " "), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4];'), $t)); 
648
-if(($w = strtolower($w)) == -1){ 
648
+if (($w = strtolower($w)) == -1) { 
649 649
  return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); 
650 650
 } 
651 651
 $s = strpos(" $w", 't') ? "\t" : ' '; 
@@ -657,66 +657,66 @@  discard block
 block discarded – undo
657 657
 $d = array('address'=>1, 'blockquote'=>1, 'center'=>1, 'colgroup'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'fieldset'=>1, 'form'=>1, 'hr'=>1, 'iframe'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'script'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1); 
658 658
 $T = explode('<', $t); 
659 659
 $X = 1; 
660
-while($X){ 
660
+while ($X) { 
661 661
  $n = $N; 
662 662
  $t = $T; 
663 663
  ob_start(); 
664
- if(isset($d[$p])){echo str_repeat($s, ++$n);} 
664
+ if (isset($d[$p])) {echo str_repeat($s, ++$n); } 
665 665
  echo ltrim(array_shift($t)); 
666
- for($i=-1, $j=count($t); ++$i<$j;){ 
666
+ for ($i = -1, $j = count($t); ++$i < $j;) { 
667 667
   $r = ''; list($e, $r) = explode('>', $t[$i]); 
668 668
   $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); 
669 669
   $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); 
670 670
   $e = "<$e>"; 
671
-  if(isset($d[$y])){ 
672
-   if(!$x){ 
673
-    if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} 
674
-    else{++$N; ob_end_clean(); continue 2;} 
671
+  if (isset($d[$y])) { 
672
+   if (!$x) { 
673
+    if ($n) {echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n); } 
674
+    else {++$N; ob_end_clean(); continue 2; } 
675 675
    } 
676
-   else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} 
676
+   else {echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n)); } 
677 677
    echo $r; continue; 
678 678
   } 
679
-  $f = "\n". str_repeat($s, $n); 
680
-  if(isset($c[$y])){ 
681
-   if(!$x){echo $e, $f, $r;} 
682
-   else{echo $f, $e, $r;} 
683
-  }elseif(isset($b[$y])){echo $f, $e, $r; 
684
-  }elseif(isset($a[$y])){echo $e, $f, $r; 
685
-  }elseif(!$y){echo $f, $e, $f, $r; 
686
-  }else{echo $e, $r;} 
679
+  $f = "\n".str_repeat($s, $n); 
680
+  if (isset($c[$y])) { 
681
+   if (!$x) {echo $e, $f, $r; } 
682
+   else {echo $f, $e, $r; } 
683
+  }elseif (isset($b[$y])) {echo $f, $e, $r; 
684
+  }elseif (isset($a[$y])) {echo $e, $f, $r; 
685
+  }elseif (!$y) {echo $f, $e, $f, $r; 
686
+  } else {echo $e, $r; } 
687 687
  } 
688 688
  $X = 0; 
689 689
 } 
690 690
 $t = str_replace(array("\n ", " \n"), "\n", preg_replace('`[\n]\s*?[\n]+`', "\n", ob_get_contents())); 
691 691
 ob_end_clean(); 
692
-if(($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)){ 
692
+if (($l = strpos(" $w", 'r') ? (strpos(" $w", 'n') ? "\r\n" : "\r") : 0)) { 
693 693
  $t = str_replace("\n", $l, $t); 
694 694
 } 
695 695
 return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); 
696 696
 // eof 
697 697
 } 
698 698
 
699
-function hl_version(){ 
699
+function hl_version() { 
700 700
 // rel 
701 701
 return '1.1.18'; 
702 702
 // eof 
703 703
 } 
704 704
 
705
-function kses($t, $h, $p=array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'mailto')){ 
705
+function kses($t, $h, $p = array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'mailto')) { 
706 706
 // kses compat 
707
-foreach($h as $k=>$v){ 
707
+foreach ($h as $k=>$v) { 
708 708
  $h[$k]['n']['*'] = 1; 
709 709
 } 
710 710
 $C['cdata'] = $C['comment'] = $C['make_tag_strict'] = $C['no_deprecated_attr'] = $C['unique_ids'] = 0; 
711 711
 $C['keep_bad'] = 1; 
712 712
 $C['elements'] = count($h) ? strtolower(implode(',', array_keys($h))) : '-*'; 
713 713
 $C['hook'] = 'kses_hook'; 
714
-$C['schemes'] = '*:'. implode(',', $p); 
714
+$C['schemes'] = '*:'.implode(',', $p); 
715 715
 return htmLawed($t, $C, $h); 
716 716
 // eof 
717 717
 } 
718 718
 
719
-function kses_hook($t, &$C, &$S){ 
719
+function kses_hook($t, &$C, &$S) { 
720 720
 // kses compat 
721 721
 return $t; 
722 722
 // eof 
Please login to merge, or discard this patch.
Braces   +49 added lines, -79 removed lines patch added patch discarded remove patch
@@ -22,9 +22,7 @@  discard block
 block discarded – undo
22 22
  unset($e['applet'], $e['embed'], $e['iframe'], $e['object'], $e['script']); 
23 23
 } 
24 24
 $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; 
25
-if($x == '-*'){$e = array();} 
26
-elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} 
27
-else{ 
25
+if($x == '-*'){$e = array();} elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} else{ 
28 26
  if(isset($x[1])){ 
29 27
   preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); 
30 28
   for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} 
@@ -166,10 +164,7 @@  discard block
 block discarded – undo
166 164
 if(isset($cE[$in])){ 
167 165
  return (!$do ? '' : str_replace(array('<', '>'), array('&lt;', '&gt;'), $t)); 
168 166
 } 
169
-if(isset($cS[$in])){$inOk = $cS[$in];} 
170
-elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
171
-elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} 
172
-elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} 
167
+if(isset($cS[$in])){$inOk = $cS[$in];} elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} 
173 168
 if(isset($cO[$in])){$inOk = $inOk + $cO[$in];} 
174 169
 if(isset($cN[$in])){$inOk = array_diff_assoc($inOk, $cN[$in]);} 
175 170
 
@@ -182,13 +177,10 @@  discard block
 block discarded – undo
182 177
  if($ql = count($q)){ 
183 178
   $p = array_pop($q); 
184 179
   $q[] = $p; 
185
-  if(isset($cS[$p])){$ok = $cS[$p];} 
186
-  elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
187
-  elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
188
-  elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
180
+  if(isset($cS[$p])){$ok = $cS[$p];} elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
189 181
   if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
190 182
   if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
191
- }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
183
+ } else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
192 184
  // bad tags, & ele content 
193 185
  if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
194 186
   echo '&lt;', $s, $e, $a, '&gt;'; 
@@ -196,13 +188,11 @@  discard block
 block discarded – undo
196 188
  if(isset($x[0])){ 
197 189
   if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
198 190
    echo '<div>', $x, '</div>'; 
199
-  } 
200
-  elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
201
-  elseif(strpos($x, "\x02\x04")){ 
191
+  } elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} elseif(strpos($x, "\x02\x04")){ 
202 192
    foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
203 193
     echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
204 194
    } 
205
-  }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
195
+  } elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
206 196
  } 
207 197
  // get markup 
208 198
  if(!preg_match('`^(/?)([a-z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} 
@@ -213,8 +203,7 @@  discard block
 block discarded – undo
213 203
   if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 
214 204
   $add = ''; // Nesting - close open tags that need to be 
215 205
   for($j=-1, $cj=count($q); ++$j<$cj;){   
216
-   if(($d = array_pop($q)) == $e){break;} 
217
-   else{$add .= "</{$d}>";} 
206
+   if(($d = array_pop($q)) == $e){break;} else{$add .= "</{$d}>";} 
218 207
   } 
219 208
   echo $add, '</', $e, '>'; unset($e); continue; 
220 209
  } 
@@ -256,8 +245,7 @@  discard block
 block discarded – undo
256 245
    $add = "</{$d}>"; 
257 246
    for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} 
258 247
    break; 
259
-  } 
260
-  else{$q2[] = $d;} 
248
+  } else{$q2[] = $d;} 
261 249
  } 
262 250
  $q = $q2; 
263 251
  if(!isset($cE[$e])){$q[] = $e;} 
@@ -268,26 +256,21 @@  discard block
 block discarded – undo
268 256
 if($ql = count($q)){ 
269 257
  $p = array_pop($q); 
270 258
  $q[] = $p; 
271
- if(isset($cS[$p])){$ok = $cS[$p];} 
272
- elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} 
273
- elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} 
274
- elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
259
+ if(isset($cS[$p])){$ok = $cS[$p];} elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} 
275 260
  if(isset($cO[$p])){$ok = $ok + $cO[$p];} 
276 261
  if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} 
277
-}else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
262
+} else{$ok = $inOk; unset($cI['del'], $cI['ins']);} 
278 263
 if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ 
279 264
  echo '&lt;', $s, $e, $a, '&gt;'; 
280 265
 } 
281 266
 if(isset($x[0])){ 
282 267
  if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ 
283 268
   echo '<div>', $x, '</div>'; 
284
- } 
285
- elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} 
286
- elseif(strpos($x, "\x02\x04")){ 
269
+ } elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} elseif(strpos($x, "\x02\x04")){ 
287 270
   foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ 
288 271
    echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); 
289 272
   } 
290
- }elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
273
+ } elseif($do > 4){echo preg_replace('`\S`', '', $x);} 
291 274
 } 
292 275
 while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} 
293 276
 $o = ob_get_contents(); 
@@ -304,8 +287,7 @@  discard block
 block discarded – undo
304 287
 if($v == 1){return '';} 
305 288
 if($n == 'comment'){ 
306 289
  if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} 
307
-} 
308
-else{$t = substr($t, 1, -1);} 
290
+} else{$t = substr($t, 1, -1);} 
309 291
 $t = $v == 2 ? str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $t) : $t; 
310 292
 return str_replace(array('&', '<', '>'), array("\x03", "\x04", "\x05"), ($n == 'comment' ? "\x01\x02\x04!--$t--\x05\x02\x01" : "\x01\x01\x04$t\x05\x01\x01")); 
311 293
 // eof 
@@ -342,11 +324,8 @@  discard block
 block discarded – undo
342 324
 if($C['abs_url']){ 
343 325
  if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel 
344 326
   $p = substr($p, strlen($C['base_url'])); 
345
- }elseif(empty($m[1])){ // Make URL abs 
346
-  if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} 
347
-  elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} 
348
-  elseif(strcspn($p, './')){$p = $C['base_url']. $p;} 
349
-  else{ 
327
+ } elseif(empty($m[1])){ // Make URL abs 
328
+  if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} elseif(strcspn($p, './')){$p = $C['base_url']. $p;} else{ 
350 329
    preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); 
351 330
    $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); 
352 331
    while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ 
@@ -363,15 +342,13 @@  discard block
 block discarded – undo
363 342
 function hl_regex($p){ 
364 343
 // ?regex 
365 344
 if(empty($p)){return 0;} 
366
-if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} 
367
-else{ini_set('track_errors', 1);} 
345
+if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} else{ini_set('track_errors', 1);} 
368 346
 unset($php_errormsg); 
369 347
 if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} 
370 348
 preg_match($p, ''); 
371 349
 if($d){ini_set('display_errors', 1);} 
372 350
 $r = isset($php_errormsg) ? 0 : 1; 
373
-if($t){$php_errormsg = isset($o) ? $o : null;} 
374
-else{ini_set('track_errors', 0);} 
351
+if($t){$php_errormsg = isset($o) ? $o : null;} else{ini_set('track_errors', 0);} 
375 352
 return $r; 
376 353
 // eof 
377 354
 } 
@@ -416,7 +393,7 @@  discard block
 block discarded – undo
416 393
 if($t == '>'){return '&gt;';} 
417 394
 if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ 
418 395
  return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t); 
419
-}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ 
396
+} elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ 
420 397
  return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); 
421 398
 } 
422 399
 // attr string 
@@ -468,7 +445,7 @@  discard block
 block discarded – undo
468 445
   break; case 1: 
469 446
    if($a[0] == '='){ // = 
470 447
     $w = 1; $mode = 2; $a = ltrim($a, '= '); 
471
-   }else{ // No val 
448
+   } else{ // No val 
472 449
     $w = 1; $mode = 0; $a = ltrim($a); 
473 450
     $aA[$nm] = ''; 
474 451
    } 
@@ -492,8 +469,7 @@  discard block
 block discarded – undo
492 469
 $a = array(); $nfr = 0; 
493 470
 foreach($aA as $k=>$v){ 
494 471
   if(((isset($C['deny_attribute']['*']) ? isset($C['deny_attribute'][$k]) : !isset($C['deny_attribute'][$k])) && (isset($aN[$k][$e]) or (isset($aNU[$k]) && !isset($aNU[$k][$e]))) && !isset($rl['n'][$k]) && !isset($rl['n']['*'])) or isset($rl[$k])){ 
495
-  if(isset($aNE[$k])){$v = $k;} 
496
-  elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues 
472
+  if(isset($aNE[$k])){$v = $k;} elseif(!empty($lcase) && (($e != 'button' or $e != 'input') or $k == 'type')){ // Rather loose but ?not cause issues 
497 473
    $v = (isset($aNL[($v2 = strtolower($v))])) ? $v2 : $v; 
498 474
   } 
499 475
   if($k == 'style' && !$C['style_pass']){ 
@@ -503,22 +479,22 @@  discard block
 block discarded – undo
503 479
    } 
504 480
    $v = preg_replace_callback('`(url(?:\()(?: )*(?:\'|"|&(?:quot|apos);)?)(.+?)((?:\'|"|&(?:quot|apos);)?(?: )*(?:\)))`iS', 'hl_prot', $v); 
505 481
    $v = !$C['css_expression'] ? preg_replace('`expression`i', ' ', preg_replace('`\\\\\S|(/|(%2f))(\*|(%2a))`i', ' ', $v)) : $v; 
506
-  }elseif(isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o'){ 
482
+  } elseif(isset($aNP[$k]) or strpos($k, 'src') !== false or $k[0] == 'o'){ 
507 483
    $v = str_replace("\xad", ' ', (strpos($v, '&') !== false ? str_replace(array('&#xad;', '&#173;', '&shy;'), ' ', $v) : $v)); 
508 484
    $v = hl_prot($v, $k); 
509 485
    if($k == 'href'){ // X-spam 
510 486
     if($C['anti_mail_spam'] && strpos($v, 'mailto:') === 0){ 
511 487
      $v = str_replace('@', htmlspecialchars($C['anti_mail_spam']), $v); 
512
-    }elseif($C['anti_link_spam']){ 
488
+    } elseif($C['anti_link_spam']){ 
513 489
      $r1 = $C['anti_link_spam'][1]; 
514 490
      if(!empty($r1) && preg_match($r1, $v)){continue;} 
515 491
      $r0 = $C['anti_link_spam'][0]; 
516 492
      if(!empty($r0) && preg_match($r0, $v)){ 
517 493
       if(isset($a['rel'])){ 
518 494
        if(!preg_match('`\bnofollow\b`i', $a['rel'])){$a['rel'] .= ' nofollow';} 
519
-      }elseif(isset($aA['rel'])){ 
495
+      } elseif(isset($aA['rel'])){ 
520 496
        if(!preg_match('`\bnofollow\b`i', $aA['rel'])){$nfr = 1;} 
521
-      }else{$a['rel'] = 'nofollow';} 
497
+      } else{$a['rel'] = 'nofollow';} 
522 498
      } 
523 499
     } 
524 500
    } 
@@ -544,43 +520,41 @@  discard block
 block discarded – undo
544 520
   if($k == 'style' or !isset($aND[$k][$e])){continue;} 
545 521
   if($k == 'align'){ 
546 522
    unset($a['align']); 
547
-   if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} 
548
-   elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} 
549
-   else{$c[] = 'text-align: '. $v;} 
550
-  }elseif($k == 'bgcolor'){ 
523
+   if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} elseif(($e == 'div' or $e == 'table') && $v == 'center'){$c[] = 'margin: auto';} else{$c[] = 'text-align: '. $v;} 
524
+  } elseif($k == 'bgcolor'){ 
551 525
    unset($a['bgcolor']); 
552 526
    $c[] = 'background-color: '. $v; 
553
-  }elseif($k == 'border'){ 
527
+  } elseif($k == 'border'){ 
554 528
    unset($a['border']); $c[] = "border: {$v}px"; 
555
-  }elseif($k == 'bordercolor'){ 
529
+  } elseif($k == 'bordercolor'){ 
556 530
    unset($a['bordercolor']); $c[] = 'border-color: '. $v; 
557
-  }elseif($k == 'clear'){ 
531
+  } elseif($k == 'clear'){ 
558 532
    unset($a['clear']); $c[] = 'clear: '. ($v != 'all' ? $v : 'both'); 
559
-  }elseif($k == 'compact'){ 
533
+  } elseif($k == 'compact'){ 
560 534
    unset($a['compact']); $c[] = 'font-size: 85%'; 
561
-  }elseif($k == 'height' or $k == 'width'){ 
535
+  } elseif($k == 'height' or $k == 'width'){ 
562 536
    unset($a[$k]); $c[] = $k. ': '. ($v[0] != '*' ? $v. (ctype_digit($v) ? 'px' : '') : 'auto'); 
563
-  }elseif($k == 'hspace'){ 
537
+  } elseif($k == 'hspace'){ 
564 538
    unset($a['hspace']); $c[] = "margin-left: {$v}px; margin-right: {$v}px"; 
565
-  }elseif($k == 'language' && !isset($a['type'])){ 
539
+  } elseif($k == 'language' && !isset($a['type'])){ 
566 540
    unset($a['language']); 
567 541
    $a['type'] = 'text/'. strtolower($v); 
568
-  }elseif($k == 'name'){ 
542
+  } elseif($k == 'name'){ 
569 543
    if($C['no_deprecated_attr'] == 2 or ($e != 'a' && $e != 'map')){unset($a['name']);} 
570 544
    if(!isset($a['id']) && preg_match('`[a-zA-Z][a-zA-Z\d.:_\-]*`', $v)){$a['id'] = $v;} 
571
-  }elseif($k == 'noshade'){ 
545
+  } elseif($k == 'noshade'){ 
572 546
    unset($a['noshade']); $c[] = 'border-style: none; border: 0; background-color: gray; color: gray'; 
573
-  }elseif($k == 'nowrap'){ 
547
+  } elseif($k == 'nowrap'){ 
574 548
    unset($a['nowrap']); $c[] = 'white-space: nowrap'; 
575
-  }elseif($k == 'size'){ 
549
+  } elseif($k == 'size'){ 
576 550
    unset($a['size']); $c[] = 'size: '. $v. 'px'; 
577
-  }elseif($k == 'start' or $k == 'value'){ 
551
+  } elseif($k == 'start' or $k == 'value'){ 
578 552
    unset($a[$k]); 
579
-  }elseif($k == 'type'){ 
553
+  } elseif($k == 'type'){ 
580 554
    unset($a['type']); 
581 555
    static $ol_type = array('i'=>'lower-roman', 'I'=>'upper-roman', 'a'=>'lower-latin', 'A'=>'upper-latin', '1'=>'decimal'); 
582 556
    $c[] = 'list-style-type: '. (isset($ol_type[$v]) ? $ol_type[$v] : 'decimal'); 
583
-  }elseif($k == 'vspace'){ 
557
+  } elseif($k == 'vspace'){ 
584 558
    unset($a['vspace']); $c[] = "margin-top: {$v}px; margin-bottom: {$v}px"; 
585 559
   } 
586 560
  } 
@@ -592,7 +566,7 @@  discard block
 block discarded – undo
592 566
 // unique ID 
593 567
 if($C['unique_ids'] && isset($a['id'])){ 
594 568
  if(!preg_match('`^[A-Za-z][A-Za-z0-9_\-.:]*$`', ($id = $a['id'])) or (isset($GLOBALS['hl_Ids'][$id]) && $C['unique_ids'] == 1)){unset($a['id']); 
595
- }else{ 
569
+ } else{ 
596 570
   while(isset($GLOBALS['hl_Ids'][$id])){$id = $C['unique_ids']. $id;} 
597 571
   $GLOBALS['hl_Ids'][($a['id'] = $id)] = 1; 
598 572
  } 
@@ -611,8 +585,7 @@  discard block
 block discarded – undo
611 585
  $aA = ''; 
612 586
  foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";} 
613 587
  return "<{$e}{$aA}". (isset($eE[$e]) ? ' /' : ''). '>'; 
614
-} 
615
-else{return $C['hook_tag']($e, $a);} 
588
+} else{return $C['hook_tag']($e, $a);} 
616 589
 // eof 
617 590
 } 
618 591
 
@@ -670,20 +643,17 @@  discard block
 block discarded – undo
670 643
   $e = "<$e>"; 
671 644
   if(isset($d[$y])){ 
672 645
    if(!$x){ 
673
-    if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} 
674
-    else{++$N; ob_end_clean(); continue 2;} 
675
-   } 
676
-   else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} 
646
+    if($n){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} else{++$N; ob_end_clean(); continue 2;} 
647
+   } else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} 
677 648
    echo $r; continue; 
678 649
   } 
679 650
   $f = "\n". str_repeat($s, $n); 
680 651
   if(isset($c[$y])){ 
681
-   if(!$x){echo $e, $f, $r;} 
682
-   else{echo $f, $e, $r;} 
683
-  }elseif(isset($b[$y])){echo $f, $e, $r; 
684
-  }elseif(isset($a[$y])){echo $e, $f, $r; 
685
-  }elseif(!$y){echo $f, $e, $f, $r; 
686
-  }else{echo $e, $r;} 
652
+   if(!$x){echo $e, $f, $r;} else{echo $f, $e, $r;} 
653
+  } elseif(isset($b[$y])){echo $f, $e, $r; 
654
+  } elseif(isset($a[$y])){echo $e, $f, $r; 
655
+  } elseif(!$y){echo $f, $e, $f, $r; 
656
+  } else{echo $e, $r;} 
687 657
  } 
688 658
  $X = 0; 
689 659
 } 
Please login to merge, or discard this patch.
html/inc/news.inc 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -65,6 +65,10 @@
 block discarded – undo
65 65
     return $forum->parent_type == 0 && ($forum->title === $forum_name);
66 66
 }
67 67
 
68
+/**
69
+ * @param integer $start
70
+ * @param integer $count
71
+ */
68 72
 function show_news($start, $count) {
69 73
     $forum = news_forum();
70 74
     if (!$forum) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,5 +118,5 @@
 block discarded – undo
118 118
     ";
119 119
 }
120 120
 
121
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
121
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
122 122
 ?>
Please login to merge, or discard this patch.
html/inc/pm.inc 3 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -27,6 +27,10 @@  discard block
 block discarded – undo
27 27
     echo "</div>\n";
28 28
 }
29 29
 
30
+/**
31
+ * @param null|integer $teamid
32
+ * @param string $error
33
+ */
30 34
 function pm_team_form($user, $teamid, $error=null) {
31 35
     global $bbcode_html, $bbcode_js;
32 36
     $team = BoincTeam::lookup_id($teamid);
@@ -78,6 +82,9 @@  discard block
 block discarded – undo
78 82
     page_tail();
79 83
 }
80 84
 
85
+/**
86
+ * @param string $error
87
+ */
81 88
 function pm_form($replyto, $userid, $error = null) {
82 89
     global $bbcode_html, $bbcode_js;
83 90
     global $g_logged_in_user;
@@ -196,6 +203,9 @@  discard block
 block discarded – undo
196 203
     return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
197 204
 }
198 205
 
206
+/**
207
+ * @param boolean $send_email
208
+ */
199 209
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
200 210
     $sql_subject = BoincDb::escape_string(sanitize_tags($subject));
201 211
     $sql_content = BoincDb::escape_string($content);
@@ -224,6 +234,9 @@  discard block
 block discarded – undo
224 234
     BoincNotify::insert("(userid, create_time, type, opaque) values ($to_user->id, ".time().", ".NOTIFY_PM.", $mid)");
225 235
 }
226 236
 
237
+/**
238
+ * @param integer $duration
239
+ */
227 240
 function pm_count($userid, $duration) {
228 241
     $time = time() - $duration;
229 242
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     echo "</div>\n";
28 28
 }
29 29
 
30
-function pm_team_form($user, $teamid, $error=null) {
30
+function pm_team_form($user, $teamid, $error = null) {
31 31
     global $bbcode_html, $bbcode_js;
32 32
     $team = BoincTeam::lookup_id($teamid);
33 33
     if (!$team) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         error_page("not admin");
38 38
     }
39 39
 
40
-    page_head(tra("Send message to team"),'','','', $bbcode_js);
40
+    page_head(tra("Send message to team"), '', '', '', $bbcode_js);
41 41
 
42 42
     $subject = post_str("subject", true);
43 43
     $content = post_str("content", true);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 function pm_form($replyto, $userid, $error = null) {
82 82
     global $bbcode_html, $bbcode_js;
83 83
     global $g_logged_in_user;
84
-    page_head(tra("Send private message"),'','','', $bbcode_js);
84
+    page_head(tra("Send private message"), '', '', '', $bbcode_js);
85 85
     
86 86
     if (post_str("preview", true) == tra("Preview")) {
87 87
         $content = post_str("content", true);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 function send_pm_notification_email(
164 164
     $logged_in_user, $to_user, $subject, $content
165 165
 ) {
166
-    $message  = "
166
+    $message = "
167 167
 You have received a new private message at ".PROJECT.".
168 168
 
169 169
 From: $logged_in_user->name (ID $logged_in_user->id)
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
194 194
     $from_user = BoincUser::lookup_id($pm->senderid);
195 195
     if (!$pm || !$from_user) return null;
196
-    return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
196
+    return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject";
197 197
 }
198 198
 
199 199
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 
258 258
 function pm_email_remind($user) {
259 259
     if (!$user->prefs->pm_notification) {
260
-        return "<br><small>" .
260
+        return "<br><small>".
261 261
             tra(
262 262
                 "For email notification, %1edit community prefs%2",
263 263
                 '<a href="edit_forum_preferences_form.php">', '</a>'
264
-            ) .
264
+            ).
265 265
             "</small>"
266 266
         ;
267 267
     }
@@ -287,5 +287,5 @@  discard block
 block discarded – undo
287 287
     }
288 288
 }
289 289
 
290
-$cvs_version_tracker[]="\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
290
+$cvs_version_tracker[] = "\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
291 291
 ?>
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -185,14 +185,18 @@
 block discarded – undo
185 185
 function pm_email_line($notify) {
186 186
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
187 187
     $from_user = BoincUser::lookup_id($pm->senderid);
188
-    if (!$pm || !$from_user) return null;
188
+    if (!$pm || !$from_user) {
189
+        return null;
190
+    }
189 191
     return "$from_user->name ".tra("sent you a private message; subject:")." '$pm->subject'";
190 192
 }
191 193
 
192 194
 function pm_web_line($notify) {
193 195
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
194 196
     $from_user = BoincUser::lookup_id($pm->senderid);
195
-    if (!$pm || !$from_user) return null;
197
+    if (!$pm || !$from_user) {
198
+        return null;
199
+    }
196 200
     return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
197 201
 }
198 202
 
Please login to merge, or discard this patch.
html/inc/prefs.inc 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -291,6 +291,9 @@  discard block
 block discarded – undo
291 291
     return $dp;
292 292
 }
293 293
 
294
+/**
295
+ * @param string $t
296
+ */
294 297
 function group_header($t) {
295 298
     echo "<tr><th class=\"bg-info\">$t</th><td class=\"bg-info\" colspan=4><br></td></tr>\n";
296 299
 }
@@ -413,6 +416,9 @@  discard block
 block discarded – undo
413 416
 
414 417
 // Display all venues as columns next to descriptions
415 418
 //
419
+/**
420
+ * @param stdClass $prefs
421
+ */
416 422
 function prefs_show_columns_global($prefs) {
417 423
     global $cpu_prefs;
418 424
     global $disk_prefs;
@@ -483,6 +489,11 @@  discard block
 block discarded – undo
483 489
     return PROJECT;
484 490
 }
485 491
 
492
+/**
493
+ * @param stdClass $prefs
494
+ * @param string $venue
495
+ * @param string $subset
496
+ */
486 497
 function prefs_display_venue($prefs, $venue, $subset) {
487 498
     global $g_logged_in_user;
488 499
     $tokens = url_tokens($g_logged_in_user->authenticator);
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
     $dp->disk_max_used_pct = parse_config($config, "<default_disk_max_used_pct>");
277 277
     $dp->disk_min_free_gb = parse_config($config, "<default_disk_min_free_gb>");
278 278
     // set some defaults if not found
279
-    if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0;  // no limit
279
+    if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0; // no limit
280 280
     if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 90; // 90 percent
281
-    if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1;   // 1 GB
281
+    if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1; // 1 GB
282 282
     // set mininimum free space scheduler allows 
283 283
     // - depends on which scheduler is running
284 284
     $dp->new_sched_flag = 1;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     global $text;
305 305
     global $venue_name;
306 306
 
307
-    switch($name) {
307
+    switch ($name) {
308 308
     case "venue":
309 309
         if (array_key_exists("name", $attrs)) {
310 310
             $venue_name = $attrs["name"];
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             return;
351 351
         }
352 352
     }
353
-    switch($name) {
353
+    switch ($name) {
354 354
     case "venue":
355 355
         $top_parse_result->$venue_name = $parse_result;
356 356
         $parse_result = $top_parse_result;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     }
510 510
 }
511 511
 
512
-function print_prefs_display_global($user, $columns=false) {
512
+function print_prefs_display_global($user, $columns = false) {
513 513
     $global_prefs = prefs_parse_global($user->global_prefs);
514 514
 
515 515
     echo tra("These settings apply to all computers using this account except")
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         .tra("Android devices")
520 520
         ."</ul>
521 521
     ";
522
-    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=". (int)!$columns .">".tra("(Switch view)")."</a></font>";
522
+    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=".(int)!$columns.">".tra("(Switch view)")."</a></font>";
523 523
     if ($columns) {
524 524
         echo "<h3>".tra("Combined preferences").$switch_link."</h3>";
525 525
         start_table();
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 // otherwise false
555 555
 //
556 556
 function print_prefs_form(
557
-    $action, $subset, $venue, $user, $prefs, $cols, $error=false,
558
-    $project_error=false
559
-){
557
+    $action, $subset, $venue, $user, $prefs, $cols, $error = false,
558
+    $project_error = false
559
+) {
560 560
     if ($action == "add") {
561 561
         $script = "add_venue.php";
562 562
         $submit_value = tra("Add preferences");
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 //
596 596
 // Functions to display preference subsets as forms
597 597
 //
598
-function prefs_form_global($user, $prefs, $error=false) {
598
+function prefs_form_global($user, $prefs, $error = false) {
599 599
     global $cpu_prefs;
600 600
     global $disk_prefs;
601 601
     global $mem_prefs;
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 //
636 636
 function prefs_form_radio_buttons($name, $yesno) {
637 637
     $rb = tra("yes")." <input type=radio name=$name value=yes "
638
-        .($yesno?"checked":"")
638
+        .($yesno ? "checked" : "")
639 639
         ."> ".tra("no")." <input type=radio name=$name value=no "
640
-        .($yesno?"":"checked")
640
+        .($yesno ? "" : "checked")
641 641
         .">\n";
642 642
     return $rb;
643 643
 }
@@ -656,12 +656,12 @@  discard block
 block discarded – undo
656 656
 }
657 657
 function venue_show($user) {
658 658
     $venue = $user->venue;
659
-    if ($venue =='') $venue = '---';
659
+    if ($venue == '') $venue = '---';
660 660
     tooltip_row2(VENUE_TOOLTIP, VENUE_DESC, $venue);
661 661
 }
662 662
 
663 663
 function venue_form($user) {
664
-    $n=$h=$w=$s=$m='';
664
+    $n = $h = $w = $s = $m = '';
665 665
     if ($user->venue == '') $n = 'selected';
666 666
     if ($user->venue == 'home') $h = 'selected';
667 667
     if ($user->venue == 'work') $w = 'selected';
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 //
718 718
 // convert prefs from structure to XML
719 719
 //
720
-function global_prefs_make_xml($prefs, $primary=true) {
720
+function global_prefs_make_xml($prefs, $primary = true) {
721 721
     global $cpu_prefs;
722 722
     global $disk_prefs;
723 723
     global $mem_prefs;
Please login to merge, or discard this patch.
Braces   +57 added lines, -18 removed lines patch added patch discarded remove patch
@@ -276,9 +276,18 @@  discard block
 block discarded – undo
276 276
     $dp->disk_max_used_pct = parse_config($config, "<default_disk_max_used_pct>");
277 277
     $dp->disk_min_free_gb = parse_config($config, "<default_disk_min_free_gb>");
278 278
     // set some defaults if not found
279
-    if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0;  // no limit
280
-    if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 90; // 90 percent
281
-    if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1;   // 1 GB
279
+    if (!$dp->disk_max_used_gb) {
280
+        $dp->disk_max_used_gb = 0;
281
+    }
282
+    // no limit
283
+    if (!$dp->disk_max_used_pct) {
284
+        $dp->disk_max_used_pct = 90;
285
+    }
286
+    // 90 percent
287
+    if (!$dp->disk_min_free_gb) {
288
+        $dp->disk_min_free_gb = 1;
289
+    }
290
+    // 1 GB
282 291
     // set mininimum free space scheduler allows 
283 292
     // - depends on which scheduler is running
284 293
     $dp->new_sched_flag = 1;
@@ -329,7 +338,9 @@  discard block
 block discarded – undo
329 338
     global $net_prefs;
330 339
 
331 340
     foreach ($cpu_prefs as $p) {
332
-        if (is_string($p)) continue;
341
+        if (is_string($p)) {
342
+            continue;
343
+        }
333 344
         if ($p->xml_parse($parse_result, $name, $text)) {
334 345
             return;
335 346
         }
@@ -345,7 +356,9 @@  discard block
 block discarded – undo
345 356
         }
346 357
     }
347 358
     foreach ($net_prefs as $p) {
348
-        if (is_string($p)) continue;
359
+        if (is_string($p)) {
360
+            continue;
361
+        }
349 362
         if ($p->xml_parse($parse_result, $name, $text)) {
350 363
             return;
351 364
         }
@@ -381,7 +394,9 @@  discard block
 block discarded – undo
381 394
 
382 395
     $p = new StdClass;
383 396
     foreach ($cpu_prefs as $pref) {
384
-        if (is_string($pref)) continue;
397
+        if (is_string($pref)) {
398
+            continue;
399
+        }
385 400
         $pref->set_default($p);
386 401
     }
387 402
     foreach ($disk_prefs as $pref) {
@@ -391,7 +406,9 @@  discard block
 block discarded – undo
391 406
         $pref->set_default($p);
392 407
     }
393 408
     foreach ($net_prefs as $pref) {
394
-        if (is_string($pref)) continue;
409
+        if (is_string($pref)) {
410
+            continue;
411
+        }
395 412
         $pref->set_default($p);
396 413
     }
397 414
     return $p;
@@ -479,7 +496,9 @@  discard block
 block discarded – undo
479 496
 }
480 497
 
481 498
 function subset_name($subset) {
482
-    if ($subset == "global") return tra("Computing");
499
+    if ($subset == "global") {
500
+        return tra("Computing");
501
+    }
483 502
     return PROJECT;
484 503
 }
485 504
 
@@ -487,7 +506,9 @@  discard block
 block discarded – undo
487 506
     global $g_logged_in_user;
488 507
     $tokens = url_tokens($g_logged_in_user->authenticator);
489 508
     $x = false;
490
-    if (isset($prefs->$venue)) $x = $prefs->$venue;
509
+    if (isset($prefs->$venue)) {
510
+        $x = $prefs->$venue;
511
+    }
491 512
 
492 513
     if ($x) {
493 514
         start_table();
@@ -656,16 +677,26 @@  discard block
 block discarded – undo
656 677
 }
657 678
 function venue_show($user) {
658 679
     $venue = $user->venue;
659
-    if ($venue =='') $venue = '---';
680
+    if ($venue =='') {
681
+        $venue = '---';
682
+    }
660 683
     tooltip_row2(VENUE_TOOLTIP, VENUE_DESC, $venue);
661 684
 }
662 685
 
663 686
 function venue_form($user) {
664 687
     $n=$h=$w=$s=$m='';
665
-    if ($user->venue == '') $n = 'selected';
666
-    if ($user->venue == 'home') $h = 'selected';
667
-    if ($user->venue == 'work') $w = 'selected';
668
-    if ($user->venue == 'school') $s = 'selected';
688
+    if ($user->venue == '') {
689
+        $n = 'selected';
690
+    }
691
+    if ($user->venue == 'home') {
692
+        $h = 'selected';
693
+    }
694
+    if ($user->venue == 'work') {
695
+        $w = 'selected';
696
+    }
697
+    if ($user->venue == 'school') {
698
+        $s = 'selected';
699
+    }
669 700
     tooltip_row2(
670 701
         VENUE_TOOLTIP,
671 702
         VENUE_DESC,
@@ -696,7 +727,9 @@  discard block
 block discarded – undo
696 727
 
697 728
     $error = false;
698 729
     foreach ($cpu_prefs as $p) {
699
-        if (is_string($p)) continue;
730
+        if (is_string($p)) {
731
+            continue;
732
+        }
700 733
         $p->parse_form($prefs, $error);
701 734
     }
702 735
     foreach ($disk_prefs as $p) {
@@ -706,7 +739,9 @@  discard block
 block discarded – undo
706 739
         $p->parse_form($prefs, $error);
707 740
     }
708 741
     foreach ($net_prefs as $p) {
709
-        if (is_string($p)) continue;
742
+        if (is_string($p)) {
743
+            continue;
744
+        }
710 745
         $p->parse_form($prefs, $error);
711 746
     }
712 747
     return $error;
@@ -731,7 +766,9 @@  discard block
 block discarded – undo
731 766
     }
732 767
 
733 768
     foreach ($cpu_prefs as $p) {
734
-        if (is_string($p)) continue;
769
+        if (is_string($p)) {
770
+            continue;
771
+        }
735 772
         $xml .= $p->xml_string($prefs);
736 773
     }
737 774
     foreach ($disk_prefs as $p) {
@@ -741,7 +778,9 @@  discard block
 block discarded – undo
741 778
         $xml .= $p->xml_string($prefs);
742 779
     }
743 780
     foreach ($net_prefs as $p) {
744
-        if (is_string($p)) continue;
781
+        if (is_string($p)) {
782
+            continue;
783
+        }
745 784
         $xml .= $p->xml_string($prefs);
746 785
     }
747 786
 
Please login to merge, or discard this patch.
html/inc/prefs_project.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -241,6 +241,9 @@
 block discarded – undo
241 241
     }
242 242
 }
243 243
 
244
+/**
245
+ * @param boolean $columns
246
+ */
244 247
 function prefs_show_privacy($user, $columns) {
245 248
     global $privacy_pref_descs;
246 249
     if ($columns) {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 }
69 69
 
70 70
 if ($app_types->cpu) {
71
-    $project_pref_descs[] = new PREF_BOOL (
71
+    $project_pref_descs[] = new PREF_BOOL(
72 72
         tra("Use CPU"),
73 73
         "Request CPU-only tasks from this project.",
74 74
         "no_cpu",
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     );
78 78
 }
79 79
 if ($app_types->ati) {
80
-    $project_pref_descs[] = new PREF_BOOL (
80
+    $project_pref_descs[] = new PREF_BOOL(
81 81
         tra("Use ATI GPU"),
82 82
         "Request ATI GPU tasks from this project.",
83 83
         "no_ati",
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     );
87 87
 }
88 88
 if ($app_types->cuda) {
89
-    $project_pref_descs[] = new PREF_BOOL (
89
+    $project_pref_descs[] = new PREF_BOOL(
90 90
         tra("Use NVIDIA GPU"),
91 91
         "Request NVIDIA GPU tasks from this project.",
92 92
         "no_cuda",
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     );
96 96
 }
97 97
 if ($app_types->intel_gpu) {
98
-    $project_pref_descs[] = new PREF_BOOL (
98
+    $project_pref_descs[] = new PREF_BOOL(
99 99
         tra("Use Intel GPU"),
100 100
         "Request Intel GPU tasks from this project.",
101 101
         "no_intel_gpu",
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     $x = "";
121 121
 }
122 122
 
123
-$privacy_pref_descs = array (
123
+$privacy_pref_descs = array(
124 124
     new PREF_BOOL(
125 125
         tra("Is it OK for %1 and your team (if any) to email you?", PROJECT).$x,
126 126
         "",
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     global $in_project_specific;
153 153
     global $venue_name;
154 154
 
155
-    switch($name) {
155
+    switch ($name) {
156 156
     case "venue":
157 157
         $venue_name = $attrs["name"];
158 158
         $top_parse_result = $parse_result;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         break;
165 165
     default:
166 166
         if ($in_project_specific) {
167
-            $text= $text."<$name>";
167
+            $text = $text."<$name>";
168 168
         } else {
169 169
             $text = "";
170 170
         }
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
     global $venue_name;
180 180
     global $project_pref_descs;
181 181
 
182
-    foreach($project_pref_descs as $p) {
182
+    foreach ($project_pref_descs as $p) {
183 183
         if ($p->xml_parse($parse_result, $name, $text)) {
184 184
             return;
185 185
         }
186 186
     }
187
-    switch($name) {
187
+    switch ($name) {
188 188
     case "venue":
189 189
         $top_parse_result->$venue_name = $parse_result;
190 190
         $parse_result = $top_parse_result;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     return $parse_result;
229 229
 }
230 230
 
231
-function prefs_show_project($prefs, $columns=false) {
231
+function prefs_show_project($prefs, $columns = false) {
232 232
     global $project_pref_descs;
233 233
     if ($columns) {
234 234
         foreach ($project_pref_descs as $p) {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     }
255 255
 }
256 256
 
257
-function prefs_show_project_specific($prefs, $columns=false) {
257
+function prefs_show_project_specific($prefs, $columns = false) {
258 258
     if ($columns) {
259 259
         $project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
260 260
         $project_specific_prefs->home = isset($prefs->home) ? project_specific_prefs_parse($prefs->home->project_specific) : "";
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     project_specific_prefs_show($project_specific_prefs, $columns);
267 267
 }
268 268
 
269
-function print_prefs_display_project($user, $columns=false) {
269
+function print_prefs_display_project($user, $columns = false) {
270 270
     $project_prefs = prefs_parse_project($user->project_prefs);
271 271
 
272
-    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=". (int)!$columns .">".tra("(Switch View)")."</a></font>";
272
+    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=".(int)!$columns.">".tra("(Switch View)")."</a></font>";
273 273
     if ($columns) {
274 274
         start_table();
275 275
         row_heading(tra("Combined preferences").$switch_link);
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
     }
312 312
 }
313 313
 
314
-function prefs_form_project($prefs, $error=false) {
314
+function prefs_form_project($prefs, $error = false) {
315 315
     global $project_pref_descs;
316 316
     foreach ($project_pref_descs as $p) {
317 317
         $p->show_form_row($prefs, $error);
318 318
     }
319 319
 }
320 320
 
321
-function prefs_form_project_specific($prefs_xml, $error=false) {
321
+function prefs_form_project_specific($prefs_xml, $error = false) {
322 322
     $prefs = project_specific_prefs_parse($prefs_xml);
323 323
     project_specific_prefs_edit($prefs, $error);
324 324
 }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
 // given a prefs structure, return the corresponding XML string
359 359
 //
360
-function project_prefs_make_xml($prefs, $primary=true) {
360
+function project_prefs_make_xml($prefs, $primary = true) {
361 361
     global $project_pref_descs;
362 362
     $xml = "";
363 363
     if ($primary) {
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 //
393 393
 function project_prefs_update(&$user, $prefs) {
394 394
     $prefs_xml = BoincDb::escape_string(project_prefs_make_xml($prefs));
395
-    $send_email = $user->send_email?1:0;
396
-    $show_hosts = $user->show_hosts?1:0;
395
+    $send_email = $user->send_email ? 1 : 0;
396
+    $show_hosts = $user->show_hosts ? 1 : 0;
397 397
     $retval = $user->update("project_prefs='$prefs_xml', send_email=$send_email, show_hosts=$show_hosts");
398 398
     if (!$retval) {
399 399
         return 1;
Please login to merge, or discard this patch.