Completed
Push — ft/package ( 7b41d6...ceb161 )
by Philippe
13:50
created
resources/views/spirit/components/modal.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@
 block discarded – undo
38 38
     <p>You can trigger the modal by triggering the 'showModal' click event. This function is passed the id of the modal element. Put the trigger on a button like so:</p>
39 39
     <pre>
40 40
         <code class="html">
41
-<?= htmlentities('<button @click="showModal(\'exampleModal\')">Open modal</button>' ); ?>
41
+<?= htmlentities('<button @click="showModal(\'exampleModal\')">Open modal</button>'); ?>
42 42
         </code>
43 43
     </pre>
44 44
 
45 45
     <p>If you would like to activate the modal upon pageload and let it display immediately, you can add the <em>:active</em> attribute.</p>
46 46
     <pre>
47 47
         <code class="html">
48
-<?= htmlentities('<modal :active="true" id="exampleModal"> ... </modal>' ); ?>
48
+<?= htmlentities('<modal :active="true" id="exampleModal"> ... </modal>'); ?>
49 49
         </code>
50 50
     </pre>
51 51
 
Please login to merge, or discard this patch.
resources/views/spirit/components/multiselect.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                 <h3 id="setup">Setup</h3>
35 35
 
36 36
                 <p>The multiselect component is a vue component which provides you with a better selection experience. It allows for single and multiple selections, supports autocomplete, grouped options and object rendering. </p>
37
-                <p>The best thing is that as far as the form is concerned, it behaves exactly the same as a regular <?= htmlspecialchars( '<select>' ); ?> element</p>
37
+                <p>The best thing is that as far as the form is concerned, it behaves exactly the same as a regular <?= htmlspecialchars('<select>'); ?> element</p>
38 38
 
39 39
                 <h4 id="element">Element</h4>
40 40
                 <p>First, define the element on the location you wish to inject the select input.
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                 <p>If you want to accept multiple selections, do not add square brackets, e.g. tagid[], yourself. For multiple selections,
96 96
                     the name value will automatically be set as an array and the square brackets are added via the component.</p>
97 97
                 <p>
98
-                    Example: <code><?= htmlspecialchars( '<chief-multiselect name="tagid"></chief-multiselect>' ); ?></code>
98
+                    Example: <code><?= htmlspecialchars('<chief-multiselect name="tagid"></chief-multiselect>'); ?></code>
99 99
                 </p>
100 100
             </section>
101 101
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
                 <p>
105 105
                     Property that sets the available list of options. The options array can be either:
106 106
                 <ul>
107
-                    <li>a list of primitive values. e.g. <code><?= htmlspecialchars( '[\'first\',\'second\',\'third\']' ); ?></code></li>
108
-                    <li>a list of object values. e.g. <code><?= htmlspecialchars( '[{\'id\': 1, \'label\': \'first\'}, {id: 2, label: \'second\'}]' ); ?></code>. If you pass objects, you should also set the <code>valuekey</code> and <code>labelkey</code> properties.</li>
107
+                    <li>a list of primitive values. e.g. <code><?= htmlspecialchars('[\'first\',\'second\',\'third\']'); ?></code></li>
108
+                    <li>a list of object values. e.g. <code><?= htmlspecialchars('[{\'id\': 1, \'label\': \'first\'}, {id: 2, label: \'second\'}]'); ?></code>. If you pass objects, you should also set the <code>valuekey</code> and <code>labelkey</code> properties.</li>
109 109
                 </ul>
110 110
                 </p>
111 111
                 <p>
112
-                    Example: <code><?= htmlspecialchars( '<chief-multiselect :options="[\'first\',\'second\',\'third\']"></chief-multiselect>' ); ?></code>
112
+                    Example: <code><?= htmlspecialchars('<chief-multiselect :options="[\'first\',\'second\',\'third\']"></chief-multiselect>'); ?></code>
113 113
                 </p>
114 114
             </section>
115 115
             <section class="stack-l">
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                     If you pass object values as the available options set, you need to set the valuekey to identify which object value should be used as the option value.
119 119
                 <p>
120 120
                     Example:
121
-                <pre><code><?= htmlspecialchars( '<chief-multiselect
121
+                <pre><code><?= htmlspecialchars('<chief-multiselect
122 122
                         name="basicExample"
123 123
                         :options="[{\'id\': 1, \'label\': \'first\'}, {id: 2, label: \'second\'}, {id: 3, label: \'third\'}]"
124 124
                         :multiple="true"
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                     Mostly used together with the valuekey, if you pass object values as the available options set, the labelkey identifies which object value should be used as the displayed option label.
135 135
                 <p>
136 136
                     Example:
137
-                <pre><code><?= htmlspecialchars( '<chief-multiselect
137
+                <pre><code><?= htmlspecialchars('<chief-multiselect
138 138
                         name="basicExample"
139 139
                         :options="[{\'id\': 1, \'label\': \'first\'}, {id: 2, label: \'second\'}, {id: 3, label: \'third\'}]"
140 140
                         :multiple="true"
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                     For multiple selections, the selected options are presented as pills instead of plain text. Pills can be removed by either the backspace or by clicking the x on the right side of each pill.
152 152
                 </p>
153 153
                 <p>
154
-                    Example: <code><?= htmlspecialchars( ':multiple="true"' ); ?></code>
154
+                    Example: <code><?= htmlspecialchars(':multiple="true"'); ?></code>
155 155
                 </p>
156 156
             </section>
157 157
 
Please login to merge, or discard this patch.
resources/views/back/note/_form.blade.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     <div class="col-lg-6 pn {{ $errors->first('type') ? 'has-error' : null }}">
6 6
         <select name="type" id="edit-type" class="form-control">
7 7
             @foreach($note::$typeMapping as $key => $value)
8
-                <?php $selected = (old('type',$formValues->type()) == $key); ?>
8
+                <?php $selected = (old('type', $formValues->type()) == $key); ?>
9 9
                 <option {{ ($selected ? 'selected="true"' : null) }} value="{{ $key }}">{{ $value }}</option>
10 10
             @endforeach
11 11
         </select>
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
                 <?php
17 17
                     $bootstrapKey = $key;
18
-                    if($key == 'error') $bootstrapKey = 'danger';
18
+                    if ($key == 'error') $bootstrapKey = 'danger';
19 19
 
20
-                    $selected = (old('level',$formValues->level()) == $key);
20
+                    $selected = (old('level', $formValues->level()) == $key);
21 21
                 ?>
22 22
 
23 23
                 <input {{ ($selected ? 'checked="checked"' : null) }} type="radio" name="level" id="level-{{$key}}" value="{{ $key }}">
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@
 block discarded – undo
15 15
 
16 16
                 <?php
17 17
                     $bootstrapKey = $key;
18
-                    if($key == 'error') $bootstrapKey = 'danger';
18
+                    if($key == 'error') {
19
+                        $bootstrapKey = 'danger';
20
+                    }
19 21
 
20 22
                     $selected = (old('level',$formValues->level()) == $key);
21 23
                 ?>
Please login to merge, or discard this patch.
resources/views/back/_elements/formgroup.blade.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 
3 3
     // Normally field is a single string value representing the name of the input.
4 4
     // For multiple fields in the same formgroup we allow to add an array of fields as well.
5
-    $fields = (array) $field;
5
+    $fields = (array)$field;
6 6
 
7 7
     $hasErrors = false;
8
-    foreach($fields as $field){
9
-        if($errors->has($field)) $hasErrors = true;
8
+    foreach ($fields as $field) {
9
+        if ($errors->has($field)) $hasErrors = true;
10 10
     }
11 11
 
12 12
 ?>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@
 block discarded – undo
6 6
 
7 7
     $hasErrors = false;
8 8
     foreach($fields as $field){
9
-        if($errors->has($field)) $hasErrors = true;
9
+        if($errors->has($field)) {
10
+            $hasErrors = true;
11
+        }
10 12
     }
11 13
 
12 14
 ?>
Please login to merge, or discard this patch.
chief-core/utils/helpers.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * Helper: Teaser
6 6
  * --------------------------------------------------------------------------
7 7
  */
8
-if(!function_exists('teaser'))
8
+if (!function_exists('teaser'))
9 9
 {
10 10
     /**
11 11
      * @param $text
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
      */
17 17
     function teaser($text, $max = null, $ending = null, $clean = '')
18 18
     {
19
-        if(is_null($max) or is_string($max)) return $text;
20
-        if(!is_null($clean))
19
+        if (is_null($max) or is_string($max)) return $text;
20
+        if (!is_null($clean))
21 21
         {
22
-            $text = cleanupHTML($text,$clean);
22
+            $text = cleanupHTML($text, $clean);
23 23
         }
24
-        $teaser = substr($text,0,$max);
25
-        return strlen($text) <= $max ? $teaser : $teaser . $ending;
24
+        $teaser = substr($text, 0, $max);
25
+        return strlen($text) <= $max ? $teaser : $teaser.$ending;
26 26
     }
27 27
 }
28 28
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  * @param 	string 	$value
38 38
  * @return 	string
39 39
  */
40
-if(!function_exists('cleanupString'))
40
+if (!function_exists('cleanupString'))
41 41
 {
42
-    function cleanupString( $value )
42
+    function cleanupString($value)
43 43
     {
44 44
         $value = strip_tags($value);
45 45
 
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
  * @param 	string 	$whitelist - if false no tagstripping will occur - other than htmLawed
59 59
  * @return 	string
60 60
  */
61
-if(!function_exists('cleanupHTML'))
61
+if (!function_exists('cleanupHTML'))
62 62
 {
63
-    function cleanupHTML( $value, $whitelist = null )
63
+    function cleanupHTML($value, $whitelist = null)
64 64
     {
65
-        if(!function_exists('cleanupHTML')) {
66
-            require_once __DIR__ . '/vendors/htmlLawed.php';
65
+        if (!function_exists('cleanupHTML')) {
66
+            require_once __DIR__.'/vendors/htmlLawed.php';
67 67
         }
68
-        if(is_null($whitelist))
68
+        if (is_null($whitelist))
69 69
         {
70 70
             $whitelist = '<code><span><div><label><a><br><p><b><i><del><strike><u><img><video><audio><iframe><object><embed><param><blockquote><mark><cite><small><ul><ol><li><hr><dl><dt><dd><sup><sub><big><pre><code><figure><figcaption><strong><em><table><tr><td><th><tbody><thead><tfoot><h1><h2><h3><h4><h5><h6>';
71 71
         }
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
         $value = preg_replace(array(
74 74
             '@<script[^>]*?>.*?</script>@si',
75 75
             '@onclick=[^ ].*? @si'
76
-        ),'',$value);
76
+        ), '', $value);
77 77
         // strip unwanted tags via whitelist...
78
-        if(false !== $whitelist) $value = strip_tags($value, $whitelist);
78
+        if (false !== $whitelist) $value = strip_tags($value, $whitelist);
79 79
         // cleanup HTML and any unwanted attributes
80 80
         $value = htmLawed($value);
81 81
         return $value;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function isActiveUrl($name, $parameters = [])
93 93
 {
94
-    if(\Illuminate\Support\Facades\Route::currentRouteNamed($name))
94
+    if (\Illuminate\Support\Facades\Route::currentRouteNamed($name))
95 95
     {
96 96
         $flag = true;
97 97
         $current = \Illuminate\Support\Facades\Route::current();
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
          * If a single parameter is passed as string, we will convert this to
101 101
          * the proper array keyed by the first uri parameter
102 102
          */
103
-        if(!is_array($parameters))
103
+        if (!is_array($parameters))
104 104
         {
105 105
             $names = $current->parameterNames();
106 106
             $parameters = [reset($names) => $parameters];
107 107
         }
108 108
 
109
-        foreach($parameters as $key => $parameter)
109
+        foreach ($parameters as $key => $parameter)
110 110
         {
111
-            if($current->parameter($key,false) != $parameter)
111
+            if ($current->parameter($key, false) != $parameter)
112 112
             {
113 113
                 $flag = false;
114 114
             }
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
         return $flag;
118 118
     }
119 119
 
120
-    $name = ltrim($name,'/');
120
+    $name = ltrim($name, '/');
121 121
 
122
-    if(false !== strpos($name, '*'))
122
+    if (false !== strpos($name, '*'))
123 123
     {
124
-        $pattern = str_replace('\*','(.*)',preg_quote($name,'#'));
125
-        return !!preg_match("#$pattern#",request()->path());
124
+        $pattern = str_replace('\*', '(.*)', preg_quote($name, '#'));
125
+        return !!preg_match("#$pattern#", request()->path());
126 126
     }
127 127
 
128 128
     return ($name == request()->path());
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
  * @throws \InvalidArgumentException
139 139
  */
140 140
 
141
-if (! function_exists('revasset')) {
141
+if (!function_exists('revasset')) {
142 142
     function revasset($file)
143 143
     {
144 144
         static $manifest = null;
@@ -175,23 +175,23 @@  discard block
 block discarded – undo
175 175
             'scheme', 'host', 'port', 'path', 'query', 'fragment'
176 176
         ], null), $parsed_url, $overrides);
177 177
 
178
-        $scheme = $parsed_url['scheme'] ? $parsed_url['scheme'] . '://' : null;
179
-        $port = $parsed_url['port'] ? ':' . $parsed_url['port'] : null;
180
-        $fragment = $parsed_url['fragment'] ? '#' . $parsed_url['fragment'] : null;
178
+        $scheme = $parsed_url['scheme'] ? $parsed_url['scheme'].'://' : null;
179
+        $port = $parsed_url['port'] ? ':'.$parsed_url['port'] : null;
180
+        $fragment = $parsed_url['fragment'] ? '#'.$parsed_url['fragment'] : null;
181 181
 
182
-        $baseurl = $scheme . $parsed_url['host'] . $port . $parsed_url['path'];
182
+        $baseurl = $scheme.$parsed_url['host'].$port.$parsed_url['path'];
183 183
         $current_query = [];
184 184
 
185 185
         $_query = explode('&', $parsed_url['query']);
186 186
 
187
-        array_map(function ($v) use (&$current_query)
187
+        array_map(function($v) use (&$current_query)
188 188
         {
189 189
             if (!$v)
190 190
             {
191 191
                 return;
192 192
             }
193 193
             $split = explode('=', $v);
194
-            if(count($split) == 2) $current_query[$split[0]] = $split[1];
194
+            if (count($split) == 2) $current_query[$split[0]] = $split[1];
195 195
 
196 196
         }, $_query);
197 197
 
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 
206 206
         $query = urldecode(http_build_query(array_merge($current_query, $query_params)));
207 207
 
208
-        return $baseurl . '?' . $query . $fragment;
208
+        return $baseurl.'?'.$query.$fragment;
209 209
     }
210 210
 }
211 211
 
212 212
 /**
213 213
  * Form fields for honeypot protection on form submissions
214 214
  */
215
-if(!function_exists('honeypot_fields')){
216
-    function honeypot_fields(){
215
+if (!function_exists('honeypot_fields')) {
216
+    function honeypot_fields() {
217 217
         return '<div style="display:none;"><input type="text" name="your_name"/><input type="hidden" name="_timer" value="'.time().'" /></div>';
218 218
     }
219 219
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
      */
17 17
     function teaser($text, $max = null, $ending = null, $clean = '')
18 18
     {
19
-        if(is_null($max) or is_string($max)) return $text;
19
+        if(is_null($max) or is_string($max)) {
20
+            return $text;
21
+        }
20 22
         if(!is_null($clean))
21 23
         {
22 24
             $text = cleanupHTML($text,$clean);
@@ -75,7 +77,9 @@  discard block
 block discarded – undo
75 77
             '@onclick=[^ ].*? @si'
76 78
         ),'',$value);
77 79
         // strip unwanted tags via whitelist...
78
-        if(false !== $whitelist) $value = strip_tags($value, $whitelist);
80
+        if(false !== $whitelist) {
81
+            $value = strip_tags($value, $whitelist);
82
+        }
79 83
         // cleanup HTML and any unwanted attributes
80 84
         $value = htmLawed($value);
81 85
         return $value;
@@ -191,7 +195,9 @@  discard block
 block discarded – undo
191 195
                 return;
192 196
             }
193 197
             $split = explode('=', $v);
194
-            if(count($split) == 2) $current_query[$split[0]] = $split[1];
198
+            if(count($split) == 2) {
199
+                $current_query[$split[0]] = $split[1];
200
+            }
195 201
 
196 202
         }, $_query);
197 203
 
Please login to merge, or discard this patch.
chief-core/utils/vendors/htmlLawed.php 2 patches
Spacing   +288 added lines, -288 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
-        $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"=>'"'));
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
@@ -159,200 +159,200 @@  discard block
 block discarded – undo
159 159
     $eI = array('#pcdata'=>1, 'a'=>1, 'abbr'=>1, 'acronym'=>1, 'applet'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'br'=>1, 'button'=>1, 'cite'=>1, 'code'=>1, 'del'=>1, 'dfn'=>1, 'em'=>1, 'embed'=>1, 'font'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'kbd'=>1, 'label'=>1, 'map'=>1, 'object'=>1, 'q'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'select'=>1, 'script'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'textarea'=>1, 'tt'=>1, 'u'=>1, 'var'=>1);
160 160
     $eN = array('a'=>1, 'big'=>1, 'button'=>1, 'fieldset'=>1, 'font'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'label'=>1, 'object'=>1, 'ruby'=>1, 'script'=>1, 'select'=>1, 'small'=>1, 'sub'=>1, 'sup'=>1, 'textarea'=>1); // Exclude from specific ele; $cN values
161 161
     $eO = array('area'=>1, 'caption'=>1, 'col'=>1, 'colgroup'=>1, 'dd'=>1, 'dt'=>1, 'legend'=>1, 'li'=>1, 'optgroup'=>1, 'option'=>1, 'param'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'script'=>1, 'tbody'=>1, 'td'=>1, 'tfoot'=>1, 'thead'=>1, 'th'=>1, 'tr'=>1); // Missing in $eB & $eI
162
-    $eF = $eB + $eI;
162
+    $eF = $eB+$eI;
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,77 +360,77 @@  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;}
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 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]))])){
420
-        return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '');
419
+    }elseif (!isset($C['elements'][($e = strtolower($m[2]))])) {
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])){
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) : ''));
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) : ''));
434 434
     }
435 435
 
436 436
 // open tag & attr
@@ -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(($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.17';
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.
chief-core/Models/Notes/NoteReminder.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $cookie = Cookie::get('optiphar-note');
21 21
 
22
-        if( ! isset($cookie[$note->id])) return false;
22
+        if (!isset($cookie[$note->id])) return false;
23 23
 
24
-        return ! self::shouldWatchAgain($note, $cookie[$note->id], $locale);
24
+        return !self::shouldWatchAgain($note, $cookie[$note->id], $locale);
25 25
     }
26 26
 
27 27
     /**
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
      */
39 39
     private static function shouldWatchAgain(Note $note, array $cookieData, $locale)
40 40
     {
41
-        if(!isset($cookieData['locale']) || !isset($cookieData['updated_at']))
41
+        if (!isset($cookieData['locale']) || !isset($cookieData['updated_at']))
42 42
         {
43 43
             throw new \LogicException('Cookie contains corrupted data. Locale or updated value missing for cookie ['.$note->id.'].');
44 44
         }
45 45
 
46
-        if($cookieData['locale'] != $locale) return true;
46
+        if ($cookieData['locale'] != $locale) return true;
47 47
 
48
-        if($cookieData['updated_at'] != $note->updated_at) return true;
48
+        if ($cookieData['updated_at'] != $note->updated_at) return true;
49 49
     }
50 50
 
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $cookie = Cookie::get('optiphar-note');
21 21
 
22
-        if( ! isset($cookie[$note->id])) return false;
22
+        if( ! isset($cookie[$note->id])) {
23
+            return false;
24
+        }
23 25
 
24 26
         return ! self::shouldWatchAgain($note, $cookie[$note->id], $locale);
25 27
     }
@@ -43,9 +45,13 @@  discard block
 block discarded – undo
43 45
             throw new \LogicException('Cookie contains corrupted data. Locale or updated value missing for cookie ['.$note->id.'].');
44 46
         }
45 47
 
46
-        if($cookieData['locale'] != $locale) return true;
48
+        if($cookieData['locale'] != $locale) {
49
+            return true;
50
+        }
47 51
 
48
-        if($cookieData['updated_at'] != $note->updated_at) return true;
52
+        if($cookieData['updated_at'] != $note->updated_at) {
53
+            return true;
54
+        }
49 55
     }
50 56
 
51 57
 }
52 58
\ No newline at end of file
Please login to merge, or discard this patch.
chief-core/Models/Notes/FormValues.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function startAt()
31 31
     {
32
-        if($startAt = $this->model->start_at) return $startAt->format('Y-m-d');
32
+        if ($startAt = $this->model->start_at) return $startAt->format('Y-m-d');
33 33
 
34 34
         return null;
35 35
     }
36 36
 
37 37
     public function endAt()
38 38
     {
39
-        if($endAt = $this->model->end_at) return $endAt->format('Y-m-d');
39
+        if ($endAt = $this->model->end_at) return $endAt->format('Y-m-d');
40 40
 
41 41
         return null;
42 42
     }
@@ -48,6 +48,6 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function __get($key)
50 50
     {
51
-        if(method_exists($this, $key)) return $this->{$key}();
51
+        if (method_exists($this, $key)) return $this->{$key}();
52 52
     }
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,14 +29,18 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function startAt()
31 31
     {
32
-        if($startAt = $this->model->start_at) return $startAt->format('Y-m-d');
32
+        if($startAt = $this->model->start_at) {
33
+            return $startAt->format('Y-m-d');
34
+        }
33 35
 
34 36
         return null;
35 37
     }
36 38
 
37 39
     public function endAt()
38 40
     {
39
-        if($endAt = $this->model->end_at) return $endAt->format('Y-m-d');
41
+        if($endAt = $this->model->end_at) {
42
+            return $endAt->format('Y-m-d');
43
+        }
40 44
 
41 45
         return null;
42 46
     }
@@ -48,6 +52,8 @@  discard block
 block discarded – undo
48 52
 
49 53
     public function __get($key)
50 54
     {
51
-        if(method_exists($this, $key)) return $this->{$key}();
55
+        if(method_exists($this, $key)) {
56
+            return $this->{$key}();
57
+        }
52 58
     }
53 59
 }
54 60
\ No newline at end of file
Please login to merge, or discard this patch.
chief-core/Models/Notes/Note.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public $table = 'notes';
18 18
     public $translatedAttributes = ['content'];
19 19
     public $translationForeignKey = 'note_id';
20
-    protected $dates = [ 'start_at', 'end_at' ];
20
+    protected $dates = ['start_at', 'end_at'];
21 21
 
22 22
     public static $types = ['general', 'payment', 'delivery'];
23 23
     public static $levels = ['info', 'warning', 'error'];
@@ -36,23 +36,23 @@  discard block
 block discarded – undo
36 36
 
37 37
     public static function render($type)
38 38
     {
39
-        if($type != 'general')
39
+        if ($type != 'general')
40 40
         {
41
-            if($note = self::getActiveNote($type))
41
+            if ($note = self::getActiveNote($type))
42 42
             {
43
-                return '<div class="note note-' . $note->level . '"><span><i class="fa fa-fw fa-' . $note->level . '"></i>'.
43
+                return '<div class="note note-'.$note->level.'"><span><i class="fa fa-fw fa-'.$note->level.'"></i>'.
44 44
                     $note->content
45 45
                     .'</span></div>';
46 46
             }
47
-        }else{
48
-            if($note = self::getActiveNote($type)) {
49
-                if(NoteReminder::hasWatched($note, app()->getLocale()))
47
+        }else {
48
+            if ($note = self::getActiveNote($type)) {
49
+                if (NoteReminder::hasWatched($note, app()->getLocale()))
50 50
                 {
51 51
                     return null;
52
-                }else{
52
+                }else {
53 53
                     NoteReminder::watch($note->id, $note->updated_at, app()->getLocale());
54 54
 
55
-                    return '<div id="note" class="note-' . $note->level . '">' . $note->content . '<a class="close-note" aria-label="Close"><i class="fa fa-inverse fa-times-circle"></i></a></div>';
55
+                    return '<div id="note" class="note-'.$note->level.'">'.$note->content.'<a class="close-note" aria-label="Close"><i class="fa fa-inverse fa-times-circle"></i></a></div>';
56 56
                 }
57 57
             }
58 58
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $note->cookies  = $cookies;
87 87
         $note->save();
88 88
 
89
-        $note->saveTranslation('nl','content',  $content);
89
+        $note->saveTranslation('nl', 'content', $content);
90 90
         return $note;
91 91
     }
92 92
 
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
     {
102 102
         $notes = self::findByType($type);
103 103
 
104
-        $notes = $notes->reject(function ($note){
104
+        $notes = $notes->reject(function($note) {
105 105
             return !Carbon::now()->between($note->start_at, $note->end_at);
106 106
         });
107 107
 
108
-        if($notes->count() > 1)
108
+        if ($notes->count() > 1)
109 109
         {
110
-            $note = $notes->sortBy(function($note){
110
+            $note = $notes->sortBy(function($note) {
111 111
                 return implode(' ', [$note->start_at, $note->created_at]);
112 112
             })->last();
113
-        }else{
113
+        }else {
114 114
             $note = $notes->first();
115 115
         }
116 116
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
                     $note->content
45 45
                     .'</span></div>';
46 46
             }
47
-        }else{
47
+        } else{
48 48
             if($note = self::getActiveNote($type)) {
49 49
                 if(NoteReminder::hasWatched($note, app()->getLocale()))
50 50
                 {
51 51
                     return null;
52
-                }else{
52
+                } else{
53 53
                     NoteReminder::watch($note->id, $note->updated_at, app()->getLocale());
54 54
 
55 55
                     return '<div id="note" class="note-' . $note->level . '">' . $note->content . '<a class="close-note" aria-label="Close"><i class="fa fa-inverse fa-times-circle"></i></a></div>';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             $note = $notes->sortBy(function($note){
111 111
                 return implode(' ', [$note->start_at, $note->created_at]);
112 112
             })->last();
113
-        }else{
113
+        } else{
114 114
             $note = $notes->first();
115 115
         }
116 116
 
Please login to merge, or discard this patch.