@@ -11,7 +11,7 @@ |
||
11 | 11 | array( |
12 | 12 | 'baseinstalldir' => '/', |
13 | 13 | 'packagefile' => 'package.xml', |
14 | - 'packagedirectory' => realpath(dirname(__FILE__) . '/library'), |
|
14 | + 'packagedirectory' => realpath(dirname(__FILE__).'/library'), |
|
15 | 15 | 'filelistgenerator' => 'file', |
16 | 16 | 'include' => array('*'), |
17 | 17 | 'dir_roles' => array('/' => 'php'), // hack to put *.ser files in the right place |
@@ -25,21 +25,21 @@ |
||
25 | 25 | |
26 | 26 | // ...in NEWS |
27 | 27 | if ($is_dev = (strpos($version, 'dev') === false)) { |
28 | - $date = date('Y-m-d'); |
|
29 | - $news_c = str_replace( |
|
30 | - $l = "$version, unknown release date", |
|
31 | - "$version, released $date", |
|
32 | - file_get_contents('NEWS'), |
|
33 | - $c |
|
34 | - ); |
|
35 | - if (!$c) { |
|
36 | - echo 'Could not update NEWS, missing ' . $l . PHP_EOL; |
|
37 | - exit; |
|
38 | - } elseif ($c > 1) { |
|
39 | - echo 'More than one release declaration in NEWS replaced' . PHP_EOL; |
|
40 | - exit; |
|
41 | - } |
|
42 | - file_put_contents('NEWS', $news_c); |
|
28 | + $date = date('Y-m-d'); |
|
29 | + $news_c = str_replace( |
|
30 | + $l = "$version, unknown release date", |
|
31 | + "$version, released $date", |
|
32 | + file_get_contents('NEWS'), |
|
33 | + $c |
|
34 | + ); |
|
35 | + if (!$c) { |
|
36 | + echo 'Could not update NEWS, missing ' . $l . PHP_EOL; |
|
37 | + exit; |
|
38 | + } elseif ($c > 1) { |
|
39 | + echo 'More than one release declaration in NEWS replaced' . PHP_EOL; |
|
40 | + exit; |
|
41 | + } |
|
42 | + file_put_contents('NEWS', $news_c); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // ...in Doxyfile |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
11 | -if (!isset($argv[1])) { |
|
11 | +if (!isset($argv[ 1 ])) { |
|
12 | 12 | echo |
13 | 13 | 'php release.php [version] |
14 | 14 | HTML Purifier release script |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -$version = trim($argv[1]); |
|
19 | +$version = trim($argv[ 1 ]); |
|
20 | 20 | |
21 | 21 | // Bump version numbers: |
22 | 22 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | $c |
34 | 34 | ); |
35 | 35 | if (!$c) { |
36 | - echo 'Could not update NEWS, missing ' . $l . PHP_EOL; |
|
36 | + echo 'Could not update NEWS, missing '.$l.PHP_EOL; |
|
37 | 37 | exit; |
38 | 38 | } elseif ($c > 1) { |
39 | - echo 'More than one release declaration in NEWS replaced' . PHP_EOL; |
|
39 | + echo 'More than one release declaration in NEWS replaced'.PHP_EOL; |
|
40 | 40 | exit; |
41 | 41 | } |
42 | 42 | file_put_contents('NEWS', $news_c); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 1, $c |
51 | 51 | ); |
52 | 52 | if (!$c) { |
53 | - echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL; |
|
53 | + echo 'Could not update Doxyfile, missing PROJECT_NUMBER.'.PHP_EOL; |
|
54 | 54 | exit; |
55 | 55 | } |
56 | 56 | file_put_contents('Doxyfile', $doxyfile_c); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 1, $c |
65 | 65 | ); |
66 | 66 | if (!$c) { |
67 | - echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL; |
|
67 | + echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.'.PHP_EOL; |
|
68 | 68 | exit; |
69 | 69 | } |
70 | 70 | $htmlpurifier_c = preg_replace( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 1, $c |
75 | 75 | ); |
76 | 76 | if (!$c) { |
77 | - echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL; |
|
77 | + echo 'Could not update HTMLPurifier.php, missing public $version.'.PHP_EOL; |
|
78 | 78 | exit; |
79 | 79 | } |
80 | 80 | $htmlpurifier_c = preg_replace( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 1, $c |
85 | 85 | ); |
86 | 86 | if (!$c) { |
87 | - echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL; |
|
87 | + echo 'Could not update HTMLPurifier.php, missing const $version.'.PHP_EOL; |
|
88 | 88 | exit; |
89 | 89 | } |
90 | 90 | file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c); |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | 1, $c |
98 | 98 | ); |
99 | 99 | if (!$c) { |
100 | - echo 'Could not update Config.php, missing public $version.' . PHP_EOL; |
|
100 | + echo 'Could not update Config.php, missing public $version.'.PHP_EOL; |
|
101 | 101 | exit; |
102 | 102 | } |
103 | 103 | file_put_contents('library/HTMLPurifier/Config.php', $config_c); |
104 | 104 | |
105 | 105 | passthru('php maintenance/flush.php'); |
106 | 106 | |
107 | -if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL; |
|
107 | +if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'".PHP_EOL; |
|
108 | 108 | else echo "Numbers updated to dev, no other modifications necessary!"; |
109 | 109 | |
110 | 110 | // vim: et sw=4 sts=4 |
@@ -104,7 +104,10 @@ |
||
104 | 104 | |
105 | 105 | passthru('php maintenance/flush.php'); |
106 | 106 | |
107 | -if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL; |
|
108 | -else echo "Numbers updated to dev, no other modifications necessary!"; |
|
107 | +if ($is_dev) { |
|
108 | + echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL; |
|
109 | +} else { |
|
110 | + echo "Numbers updated to dev, no other modifications necessary!"; |
|
111 | +} |
|
109 | 112 | |
110 | 113 | // vim: et sw=4 sts=4 |
@@ -15,9 +15,9 @@ |
||
15 | 15 | * explicitly says, "No, I do not need to migrate." |
16 | 16 | */ |
17 | 17 | |
18 | -if(!defined("PHORUM")) exit; |
|
18 | +if (!defined("PHORUM")) exit; |
|
19 | 19 | |
20 | -require_once(dirname(__FILE__) . "/../bbcode/bbcode.php"); |
|
20 | +require_once(dirname(__FILE__)."/../bbcode/bbcode.php"); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * 'format' hook style function that will be called to convert |
@@ -15,7 +15,9 @@ |
||
15 | 15 | * explicitly says, "No, I do not need to migrate." |
16 | 16 | */ |
17 | 17 | |
18 | -if(!defined("PHORUM")) exit; |
|
18 | +if(!defined("PHORUM")) { |
|
19 | + exit; |
|
20 | +} |
|
19 | 21 | |
20 | 22 | require_once(dirname(__FILE__) . "/../bbcode/bbcode.php"); |
21 | 23 |
@@ -9,22 +9,22 @@ |
||
9 | 9 | { |
10 | 10 | global $PHORUM; |
11 | 11 | $config_exists = phorum_htmlpurifier_config_file_exists(); |
12 | - if ($default || $config_exists || !isset($PHORUM['mod_htmlpurifier']['config'])) { |
|
12 | + if ($default || $config_exists || !isset($PHORUM[ 'mod_htmlpurifier' ][ 'config' ])) { |
|
13 | 13 | $config = HTMLPurifier_Config::createDefault(); |
14 | - include(dirname(__FILE__) . '/config.default.php'); |
|
14 | + include(dirname(__FILE__).'/config.default.php'); |
|
15 | 15 | if ($config_exists) { |
16 | - include(dirname(__FILE__) . '/config.php'); |
|
16 | + include(dirname(__FILE__).'/config.php'); |
|
17 | 17 | } |
18 | - unset($PHORUM['mod_htmlpurifier']['config']); // unnecessary |
|
18 | + unset($PHORUM[ 'mod_htmlpurifier' ][ 'config' ]); // unnecessary |
|
19 | 19 | } else { |
20 | - $config = HTMLPurifier_Config::create($PHORUM['mod_htmlpurifier']['config']); |
|
20 | + $config = HTMLPurifier_Config::create($PHORUM[ 'mod_htmlpurifier' ][ 'config' ]); |
|
21 | 21 | } |
22 | 22 | return $config; |
23 | 23 | } |
24 | 24 | |
25 | 25 | function phorum_htmlpurifier_config_file_exists() |
26 | 26 | { |
27 | - return file_exists(dirname(__FILE__) . '/config.php'); |
|
27 | + return file_exists(dirname(__FILE__).'/config.php'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // vim: et sw=4 sts=4 |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | $phorum_sig = ''; |
132 | 132 | if(isset($row["user"]["signature"]) |
133 | 133 | && isset($row['meta']['show_signature']) && $row['meta']['show_signature']==1){ |
134 | - $phorum_sig=trim($row["user"]["signature"]); |
|
135 | - if(!empty($phorum_sig)){ |
|
136 | - $phorum_sig="\n\n$phorum_sig"; |
|
137 | - } |
|
134 | + $phorum_sig=trim($row["user"]["signature"]); |
|
135 | + if(!empty($phorum_sig)){ |
|
136 | + $phorum_sig="\n\n$phorum_sig"; |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | return $phorum_sig; |
140 | 140 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg'])) { |
262 | 262 | $i = $GLOBALS['PHORUM']['DATA']['MODE']; |
263 | 263 | if ($i == 'quote' || $i == 'edit' || $i == 'moderation') { |
264 | - ?> |
|
264 | + ?> |
|
265 | 265 | <div> |
266 | 266 | <p> |
267 | 267 | <strong>Notice:</strong> HTML has been scrubbed for your safety. |
@@ -30,37 +30,37 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function phorum_htmlpurifier_format($data) |
32 | 32 | { |
33 | - $PHORUM = $GLOBALS["PHORUM"]; |
|
33 | + $PHORUM = $GLOBALS[ "PHORUM" ]; |
|
34 | 34 | |
35 | - $purifier =& HTMLPurifier::getInstance(); |
|
36 | - $cache_serial = $PHORUM['mod_htmlpurifier']['body_cache_serial']; |
|
35 | + $purifier = & HTMLPurifier::getInstance(); |
|
36 | + $cache_serial = $PHORUM[ 'mod_htmlpurifier' ][ 'body_cache_serial' ]; |
|
37 | 37 | |
38 | - foreach($data as $message_id => $message){ |
|
39 | - if(isset($message['body'])) { |
|
38 | + foreach ($data as $message_id => $message) { |
|
39 | + if (isset($message[ 'body' ])) { |
|
40 | 40 | |
41 | 41 | if ($message_id) { |
42 | 42 | // we're dealing with a real message, not a fake, so |
43 | 43 | // there a number of shortcuts that can be taken |
44 | 44 | |
45 | - if (isset($message['meta']['htmlpurifier_light'])) { |
|
45 | + if (isset($message[ 'meta' ][ 'htmlpurifier_light' ])) { |
|
46 | 46 | // format hook was called outside of Phorum's normal |
47 | 47 | // functions, do the abridged purification |
48 | - $data[$message_id]['body'] = $purifier->purify($message['body']); |
|
48 | + $data[ $message_id ][ 'body' ] = $purifier->purify($message[ 'body' ]); |
|
49 | 49 | continue; |
50 | 50 | } |
51 | 51 | |
52 | - if (!empty($PHORUM['args']['purge'])) { |
|
52 | + if (!empty($PHORUM[ 'args' ][ 'purge' ])) { |
|
53 | 53 | // purge the cache, must be below the following if |
54 | - unset($message['meta']['body_cache']); |
|
54 | + unset($message[ 'meta' ][ 'body_cache' ]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | if ( |
58 | - isset($message['meta']['body_cache']) && |
|
59 | - isset($message['meta']['body_cache_serial']) && |
|
60 | - $message['meta']['body_cache_serial'] == $cache_serial |
|
58 | + isset($message[ 'meta' ][ 'body_cache' ]) && |
|
59 | + isset($message[ 'meta' ][ 'body_cache_serial' ]) && |
|
60 | + $message[ 'meta' ][ 'body_cache_serial' ] == $cache_serial |
|
61 | 61 | ) { |
62 | 62 | // cached version is present, bail out early |
63 | - $data[$message_id]['body'] = base64_decode($message['meta']['body_cache']); |
|
63 | + $data[ $message_id ][ 'body' ] = base64_decode($message[ 'meta' ][ 'body_cache' ]); |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | } |
@@ -72,26 +72,26 @@ discard block |
||
72 | 72 | // create the $body variable |
73 | 73 | if ( |
74 | 74 | $message_id && // message must be real to migrate |
75 | - !isset($message['meta']['body_cache_serial']) |
|
75 | + !isset($message[ 'meta' ][ 'body_cache_serial' ]) |
|
76 | 76 | ) { |
77 | 77 | // perform migration |
78 | 78 | $fake_data = array(); |
79 | 79 | list($signature, $edit_message) = phorum_htmlpurifier_remove_sig_and_editmessage($message); |
80 | - $fake_data[$message_id] = $message; |
|
80 | + $fake_data[ $message_id ] = $message; |
|
81 | 81 | $fake_data = phorum_htmlpurifier_migrate($fake_data); |
82 | - $body = $fake_data[$message_id]['body']; |
|
82 | + $body = $fake_data[ $message_id ][ 'body' ]; |
|
83 | 83 | $body = str_replace("<phorum break>\n", "\n", $body); |
84 | - $updated_message['body'] = $body; // save it in |
|
85 | - $body .= $signature . $edit_message; // add it back in |
|
84 | + $updated_message[ 'body' ] = $body; // save it in |
|
85 | + $body .= $signature.$edit_message; // add it back in |
|
86 | 86 | } else { |
87 | 87 | // reverse Phorum's pre-processing |
88 | - $body = $message['body']; |
|
88 | + $body = $message[ 'body' ]; |
|
89 | 89 | // order is important |
90 | 90 | $body = str_replace("<phorum break>\n", "\n", $body); |
91 | - $body = str_replace(array('<','>','&', '"'), array('<','>','&','"'), $body); |
|
91 | + $body = str_replace(array('<', '>', '&', '"'), array('<', '>', '&', '"'), $body); |
|
92 | 92 | if (!$message_id && defined('PHORUM_CONTROL_CENTER')) { |
93 | 93 | // we're in control.php, so it was double-escaped |
94 | - $body = str_replace(array('<','>','&', '"'), array('<','>','&','"'), $body); |
|
94 | + $body = str_replace(array('<', '>', '&', '"'), array('<', '>', '&', '"'), $body); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | // a lot zippier. |
104 | 104 | |
105 | 105 | if ($message_id) { // make sure it's not a fake id |
106 | - $updated_message['meta'] = $message['meta']; |
|
107 | - $updated_message['meta']['body_cache'] = base64_encode($body); |
|
108 | - $updated_message['meta']['body_cache_serial'] = $cache_serial; |
|
106 | + $updated_message[ 'meta' ] = $message[ 'meta' ]; |
|
107 | + $updated_message[ 'meta' ][ 'body_cache' ] = base64_encode($body); |
|
108 | + $updated_message[ 'meta' ][ 'body_cache_serial' ] = $cache_serial; |
|
109 | 109 | phorum_db_update_message($message_id, $updated_message); |
110 | 110 | } |
111 | 111 | |
112 | 112 | // must not get overloaded until after we cache it, otherwise |
113 | 113 | // we'll inadvertently change the original text |
114 | - $data[$message_id]['body'] = $body; |
|
114 | + $data[ $message_id ][ 'body' ] = $body; |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | } |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | function phorum_htmlpurifier_generate_sig($row) |
130 | 130 | { |
131 | 131 | $phorum_sig = ''; |
132 | - if(isset($row["user"]["signature"]) |
|
133 | - && isset($row['meta']['show_signature']) && $row['meta']['show_signature']==1){ |
|
134 | - $phorum_sig=trim($row["user"]["signature"]); |
|
135 | - if(!empty($phorum_sig)){ |
|
136 | - $phorum_sig="\n\n$phorum_sig"; |
|
132 | + if (isset($row[ "user" ][ "signature" ]) |
|
133 | + && isset($row[ 'meta' ][ 'show_signature' ]) && $row[ 'meta' ][ 'show_signature' ] == 1) { |
|
134 | + $phorum_sig = trim($row[ "user" ][ "signature" ]); |
|
135 | + if (!empty($phorum_sig)) { |
|
136 | + $phorum_sig = "\n\n$phorum_sig"; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | return $phorum_sig; |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function phorum_htmlpurifier_generate_editmessage($row) |
146 | 146 | { |
147 | - $PHORUM = $GLOBALS['PHORUM']; |
|
147 | + $PHORUM = $GLOBALS[ 'PHORUM' ]; |
|
148 | 148 | $editmessage = ''; |
149 | - if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) { |
|
150 | - $editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]); |
|
151 | - $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date_time"],$row['meta']['edit_date']), $editmessage); |
|
152 | - $editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage); |
|
149 | + if (isset($row[ 'meta' ][ 'edit_count' ]) && $row[ 'meta' ][ 'edit_count' ] > 0) { |
|
150 | + $editmessage = str_replace("%count%", $row[ 'meta' ][ 'edit_count' ], $PHORUM[ "DATA" ][ "LANG" ][ "EditedMessage" ]); |
|
151 | + $editmessage = str_replace("%lastedit%", phorum_date($PHORUM[ "short_date_time" ], $row[ 'meta' ][ 'edit_date' ]), $editmessage); |
|
152 | + $editmessage = str_replace("%lastuser%", $row[ 'meta' ][ 'edit_username' ], $editmessage); |
|
153 | 153 | $editmessage = "\n\n\n\n$editmessage"; |
154 | 154 | } |
155 | 155 | return $editmessage; |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | $replacements = array(); |
170 | 170 | // we need to remove add <phorum break> as that is the form these |
171 | 171 | // extra bits are in. |
172 | - if ($signature) $replacements[str_replace("\n", "<phorum break>\n", $signature)] = ''; |
|
173 | - if ($editmessage) $replacements[str_replace("\n", "<phorum break>\n", $editmessage)] = ''; |
|
174 | - $row['body'] = strtr($row['body'], $replacements); |
|
172 | + if ($signature) $replacements[ str_replace("\n", "<phorum break>\n", $signature) ] = ''; |
|
173 | + if ($editmessage) $replacements[ str_replace("\n", "<phorum break>\n", $editmessage) ] = ''; |
|
174 | + $row[ 'body' ] = strtr($row[ 'body' ], $replacements); |
|
175 | 175 | return array($signature, $editmessage); |
176 | 176 | } |
177 | 177 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function phorum_htmlpurifier_posting($message) |
185 | 185 | { |
186 | - $PHORUM = $GLOBALS["PHORUM"]; |
|
187 | - unset($message['meta']['body_cache']); // invalidate the cache |
|
188 | - $message['meta']['body_cache_serial'] = $PHORUM['mod_htmlpurifier']['body_cache_serial']; |
|
186 | + $PHORUM = $GLOBALS[ "PHORUM" ]; |
|
187 | + unset($message[ 'meta' ][ 'body_cache' ]); // invalidate the cache |
|
188 | + $message[ 'meta' ][ 'body_cache_serial' ] = $PHORUM[ 'mod_htmlpurifier' ][ 'body_cache_serial' ]; |
|
189 | 189 | return $message; |
190 | 190 | } |
191 | 191 | |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function phorum_htmlpurifier_quote($array) |
196 | 196 | { |
197 | - $PHORUM = $GLOBALS["PHORUM"]; |
|
198 | - $purifier =& HTMLPurifier::getInstance(); |
|
199 | - $text = $purifier->purify($array[1]); |
|
200 | - $source = htmlspecialchars($array[0]); |
|
197 | + $PHORUM = $GLOBALS[ "PHORUM" ]; |
|
198 | + $purifier = & HTMLPurifier::getInstance(); |
|
199 | + $text = $purifier->purify($array[ 1 ]); |
|
200 | + $source = htmlspecialchars($array[ 0 ]); |
|
201 | 201 | return "<blockquote cite=\"$source\">\n$text\n</blockquote>"; |
202 | 202 | } |
203 | 203 | |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | HTMLPurifier::getInstance($config); |
215 | 215 | |
216 | 216 | // increment revision.txt if you want to invalidate the cache |
217 | - $GLOBALS['PHORUM']['mod_htmlpurifier']['body_cache_serial'] = $config->getSerial(); |
|
217 | + $GLOBALS[ 'PHORUM' ][ 'mod_htmlpurifier' ][ 'body_cache_serial' ] = $config->getSerial(); |
|
218 | 218 | |
219 | 219 | // load migration |
220 | - if (file_exists(dirname(__FILE__) . '/migrate.php')) { |
|
221 | - include(dirname(__FILE__) . '/migrate.php'); |
|
220 | + if (file_exists(dirname(__FILE__).'/migrate.php')) { |
|
221 | + include(dirname(__FILE__).'/migrate.php'); |
|
222 | 222 | } else { |
223 | 223 | echo '<strong>Error:</strong> No migration path specified for HTML Purifier, please check |
224 | 224 | <tt>modes/htmlpurifier/migrate.bbcode.php</tt> for instructions on |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | if (!function_exists('phorum_htmlpurifier_migrate')) { |
230 | 230 | // Dummy function |
231 | - function phorum_htmlpurifier_migrate($data) {return $data;} |
|
231 | + function phorum_htmlpurifier_migrate($data) {return $data; } |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | } |
@@ -239,16 +239,16 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function phorum_htmlpurifier_before_editor($message) |
241 | 241 | { |
242 | - if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg'])) { |
|
243 | - if (!empty($message['body'])) { |
|
244 | - $body = $message['body']; |
|
242 | + if (!empty($GLOBALS[ 'PHORUM' ][ 'mod_htmlpurifier' ][ 'wysiwyg' ])) { |
|
243 | + if (!empty($message[ 'body' ])) { |
|
244 | + $body = $message[ 'body' ]; |
|
245 | 245 | // de-entity-ize contents |
246 | - $body = str_replace(array('<','>','&'), array('<','>','&'), $body); |
|
247 | - $purifier =& HTMLPurifier::getInstance(); |
|
246 | + $body = str_replace(array('<', '>', '&'), array('<', '>', '&'), $body); |
|
247 | + $purifier = & HTMLPurifier::getInstance(); |
|
248 | 248 | $body = $purifier->purify($body); |
249 | 249 | // re-entity-ize contents |
250 | - $body = htmlspecialchars($body, ENT_QUOTES, $GLOBALS['PHORUM']['DATA']['CHARSET']); |
|
251 | - $message['body'] = $body; |
|
250 | + $body = htmlspecialchars($body, ENT_QUOTES, $GLOBALS[ 'PHORUM' ][ 'DATA' ][ 'CHARSET' ]); |
|
251 | + $message[ 'body' ] = $body; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | return $message; |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | { |
259 | 259 | // don't show this message if it's a WYSIWYG editor, since it will |
260 | 260 | // then be handled automatically |
261 | - if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg'])) { |
|
262 | - $i = $GLOBALS['PHORUM']['DATA']['MODE']; |
|
261 | + if (!empty($GLOBALS[ 'PHORUM' ][ 'mod_htmlpurifier' ][ 'wysiwyg' ])) { |
|
262 | + $i = $GLOBALS[ 'PHORUM' ][ 'DATA' ][ 'MODE' ]; |
|
263 | 263 | if ($i == 'quote' || $i == 'edit' || $i == 'moderation') { |
264 | 264 | ?> |
265 | 265 | <div> |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | } |
274 | 274 | return; |
275 | 275 | } |
276 | - if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message'])) return; |
|
276 | + if (!empty($GLOBALS[ 'PHORUM' ][ 'mod_htmlpurifier' ][ 'suppress_message' ])) return; |
|
277 | 277 | ?><div class="htmlpurifier-help"> |
278 | 278 | <p> |
279 | 279 | <strong>HTML input</strong> is enabled. Make sure you escape all HTML and |
280 | 280 | angled brackets with <code>&lt;</code> and <code>&gt;</code>. |
281 | 281 | </p><?php |
282 | - $purifier =& HTMLPurifier::getInstance(); |
|
282 | + $purifier = & HTMLPurifier::getInstance(); |
|
283 | 283 | $config = $purifier->config; |
284 | 284 | if ($config->get('AutoFormat.AutoParagraph')) { |
285 | 285 | ?><p> |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | $html_definition = $config->getDefinition('HTML'); |
292 | 292 | $allowed = array(); |
293 | - foreach ($html_definition->info as $name => $x) $allowed[] = "<code>$name</code>"; |
|
293 | + foreach ($html_definition->info as $name => $x) $allowed[ ] = "<code>$name</code>"; |
|
294 | 294 | sort($allowed); |
295 | 295 | $allowed_text = implode(', ', $allowed); |
296 | 296 | ?><p><strong>Allowed tags:</strong> <?php |
@@ -169,8 +169,12 @@ discard block |
||
169 | 169 | $replacements = array(); |
170 | 170 | // we need to remove add <phorum break> as that is the form these |
171 | 171 | // extra bits are in. |
172 | - if ($signature) $replacements[str_replace("\n", "<phorum break>\n", $signature)] = ''; |
|
173 | - if ($editmessage) $replacements[str_replace("\n", "<phorum break>\n", $editmessage)] = ''; |
|
172 | + if ($signature) { |
|
173 | + $replacements[str_replace("\n", "<phorum break>\n", $signature)] = ''; |
|
174 | + } |
|
175 | + if ($editmessage) { |
|
176 | + $replacements[str_replace("\n", "<phorum break>\n", $editmessage)] = ''; |
|
177 | + } |
|
174 | 178 | $row['body'] = strtr($row['body'], $replacements); |
175 | 179 | return array($signature, $editmessage); |
176 | 180 | } |
@@ -273,7 +277,9 @@ discard block |
||
273 | 277 | } |
274 | 278 | return; |
275 | 279 | } |
276 | - if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message'])) return; |
|
280 | + if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message'])) { |
|
281 | + return; |
|
282 | + } |
|
277 | 283 | ?><div class="htmlpurifier-help"> |
278 | 284 | <p> |
279 | 285 | <strong>HTML input</strong> is enabled. Make sure you escape all HTML and |
@@ -290,7 +296,9 @@ discard block |
||
290 | 296 | } |
291 | 297 | $html_definition = $config->getDefinition('HTML'); |
292 | 298 | $allowed = array(); |
293 | - foreach ($html_definition->info as $name => $x) $allowed[] = "<code>$name</code>"; |
|
299 | + foreach ($html_definition->info as $name => $x) { |
|
300 | + $allowed[] = "<code>$name</code>"; |
|
301 | + } |
|
294 | 302 | sort($allowed); |
295 | 303 | $allowed_text = implode(', ', $allowed); |
296 | 304 | ?><p><strong>Allowed tags:</strong> <?php |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | |
12 | 12 | $config = phorum_htmlpurifier_get_config(); |
13 | 13 | |
14 | - $frm = new PhorumInputForm ("", "post", "Save"); |
|
14 | + $frm = new PhorumInputForm("", "post", "Save"); |
|
15 | 15 | $frm->hidden("module", "modsettings"); |
16 | 16 | $frm->hidden("mod", "htmlpurifier"); // this is the directory name that the Settings file lives in |
17 | 17 | |
18 | - if (!empty($error)){ |
|
18 | + if (!empty($error)) { |
|
19 | 19 | echo "$error<br />"; |
20 | 20 | } |
21 | 21 | |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | When checked, contents sent for edit are now purified and the |
26 | 26 | informative message is disabled. If your WYSIWYG editor is disabled for |
27 | 27 | admin edits, you can safely keep this unchecked.</p>'); |
28 | - $frm->addRow('Use WYSIWYG?', $frm->checkbox('wysiwyg', '1', '', $PHORUM['mod_htmlpurifier']['wysiwyg'])); |
|
28 | + $frm->addRow('Use WYSIWYG?', $frm->checkbox('wysiwyg', '1', '', $PHORUM[ 'mod_htmlpurifier' ][ 'wysiwyg' ])); |
|
29 | 29 | |
30 | 30 | $frm->addMessage('<p>The box below sets <code>$PHORUM[\'mod_htmlpurifier\'][\'suppress_message\']</code>, |
31 | 31 | which removes the big how-to use |
32 | 32 | HTML Purifier message.</p>'); |
33 | - $frm->addRow('Suppress information?', $frm->checkbox('suppress_message', '1', '', $PHORUM['mod_htmlpurifier']['suppress_message'])); |
|
33 | + $frm->addRow('Suppress information?', $frm->checkbox('suppress_message', '1', '', $PHORUM[ 'mod_htmlpurifier' ][ 'suppress_message' ])); |
|
34 | 34 | |
35 | 35 | $frm->addMessage('<p>Click on directive links to read what each option does |
36 | 36 | (links do not open in new windows).</p> |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $htmlpurifier_form->setTextareaDimensions(23, 7); // widen a little, since we have space |
45 | 45 | |
46 | 46 | $frm->addMessage($htmlpurifier_form->render( |
47 | - $config, $PHORUM['mod_htmlpurifier']['directives'], false)); |
|
47 | + $config, $PHORUM[ 'mod_htmlpurifier' ][ 'directives' ], false)); |
|
48 | 48 | |
49 | 49 | $frm->addMessage("<strong>Warning: Changing HTML Purifier's configuration will invalidate |
50 | 50 | the cache. Expect to see a flurry of database activity after you change |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $frm->addrow('Reset to defaults:', $frm->checkbox("reset", "1", "", false)); |
54 | 54 | |
55 | 55 | // hack to include extra styling |
56 | - echo '<style type="text/css">' . $htmlpurifier_form->getCSS() . ' |
|
56 | + echo '<style type="text/css">'.$htmlpurifier_form->getCSS().' |
|
57 | 57 | .hp-config {margin-left:auto;margin-right:auto;} |
58 | 58 | </style>'; |
59 | 59 | $js = $htmlpurifier_form->getJavaScript(); |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | { |
5 | 5 | global $PHORUM; |
6 | 6 | $offset = 0; |
7 | - if (!empty($_POST['migrate-sigs'])) { |
|
8 | - if (!isset($_POST['confirmation']) || strtolower($_POST['confirmation']) !== 'yes') { |
|
7 | + if (!empty($_POST[ 'migrate-sigs' ])) { |
|
8 | + if (!isset($_POST[ 'confirmation' ]) || strtolower($_POST[ 'confirmation' ]) !== 'yes') { |
|
9 | 9 | echo 'Invalid confirmation code.'; |
10 | 10 | exit; |
11 | 11 | } |
12 | - $PHORUM['mod_htmlpurifier']['migrate-sigs'] = true; |
|
13 | - phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM["mod_htmlpurifier"])); |
|
12 | + $PHORUM[ 'mod_htmlpurifier' ][ 'migrate-sigs' ] = true; |
|
13 | + phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM[ "mod_htmlpurifier" ])); |
|
14 | 14 | $offset = 1; |
15 | - } elseif (!empty($_GET['migrate-sigs']) && $PHORUM['mod_htmlpurifier']['migrate-sigs']) { |
|
16 | - $offset = (int) $_GET['migrate-sigs']; |
|
15 | + } elseif (!empty($_GET[ 'migrate-sigs' ]) && $PHORUM[ 'mod_htmlpurifier' ][ 'migrate-sigs' ]) { |
|
16 | + $offset = (int) $_GET[ 'migrate-sigs' ]; |
|
17 | 17 | } |
18 | 18 | return $offset; |
19 | 19 | } |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $PHORUM; |
24 | 24 | |
25 | - if(!$offset) return; // bail out quick if $offset == 0 |
|
25 | + if (!$offset) return; // bail out quick if $offset == 0 |
|
26 | 26 | |
27 | 27 | // theoretically, we could get rid of this multi-request |
28 | 28 | // doo-hickery if safe mode is off |
29 | 29 | @set_time_limit(0); // attempt to let this run |
30 | - $increment = $PHORUM['mod_htmlpurifier']['migrate-sigs-increment']; |
|
30 | + $increment = $PHORUM[ 'mod_htmlpurifier' ][ 'migrate-sigs-increment' ]; |
|
31 | 31 | |
32 | - require_once(dirname(__FILE__) . '/../migrate.php'); |
|
32 | + require_once(dirname(__FILE__).'/../migrate.php'); |
|
33 | 33 | // migrate signatures |
34 | 34 | // do this in batches so we don't run out of time/space |
35 | 35 | $end = $offset + $increment; |
36 | 36 | $user_ids = array(); |
37 | 37 | for ($i = $offset; $i < $end; $i++) { |
38 | - $user_ids[] = $i; |
|
38 | + $user_ids[ ] = $i; |
|
39 | 39 | } |
40 | 40 | $userinfos = phorum_db_user_get_fields($user_ids, 'signature'); |
41 | 41 | foreach ($userinfos as $i => $user) { |
42 | - if (empty($user['signature'])) continue; |
|
43 | - $sig = $user['signature']; |
|
42 | + if (empty($user[ 'signature' ])) continue; |
|
43 | + $sig = $user[ 'signature' ]; |
|
44 | 44 | // perform standard Phorum processing on the sig |
45 | - $sig = str_replace(array("&","<",">"), array("&","<",">"), $sig); |
|
45 | + $sig = str_replace(array("&", "<", ">"), array("&", "<", ">"), $sig); |
|
46 | 46 | $sig = preg_replace("/<((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%]+?)>/i", "$1", $sig); |
47 | 47 | // prepare fake data to pass to migration function |
48 | 48 | $fake_data = array(array("author"=>"", "email"=>"", "subject"=>"", 'body' => $sig)); |
49 | 49 | list($fake_message) = phorum_htmlpurifier_migrate($fake_data); |
50 | - $user['signature'] = $fake_message['body']; |
|
50 | + $user[ 'signature' ] = $fake_message[ 'body' ]; |
|
51 | 51 | if (!phorum_api_user_save($user)) { |
52 | 52 | exit('Error while saving user data'); |
53 | 53 | } |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | unset($userinfos); // free up memory |
56 | 56 | |
57 | 57 | // query for highest ID in database |
58 | - $type = $PHORUM['DBCONFIG']['type']; |
|
59 | - $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; |
|
58 | + $type = $PHORUM[ 'DBCONFIG' ][ 'type' ]; |
|
59 | + $sql = "select MAX(user_id) from {$PHORUM[ 'user_table' ]}"; |
|
60 | 60 | $row = phorum_db_interact(DB_RETURN_ROW, $sql); |
61 | - $top_id = (int) $row[0]; |
|
61 | + $top_id = (int) $row[ 0 ]; |
|
62 | 62 | |
63 | 63 | $offset += $increment; |
64 | 64 | if ($offset > $top_id) { // test for end condition |
65 | 65 | echo 'Migration finished'; |
66 | - $PHORUM['mod_htmlpurifier']['migrate-sigs'] = false; |
|
66 | + $PHORUM[ 'mod_htmlpurifier' ][ 'migrate-sigs' ] = false; |
|
67 | 67 | phorum_htmlpurifier_commit_settings(); |
68 | 68 | return true; |
69 | 69 | } |
70 | - $host = $_SERVER['HTTP_HOST']; |
|
71 | - $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); |
|
72 | - $extra = 'admin.php?module=modsettings&mod=htmlpurifier&migrate-sigs=' . $offset; |
|
70 | + $host = $_SERVER[ 'HTTP_HOST' ]; |
|
71 | + $uri = rtrim(dirname($_SERVER[ 'PHP_SELF' ]), '/\\'); |
|
72 | + $extra = 'admin.php?module=modsettings&mod=htmlpurifier&migrate-sigs='.$offset; |
|
73 | 73 | // relies on output buffering to work |
74 | 74 | header("Location: http://$host$uri/$extra"); |
75 | 75 | exit; |
@@ -22,7 +22,10 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $PHORUM; |
24 | 24 | |
25 | - if(!$offset) return; // bail out quick if $offset == 0 |
|
25 | + if(!$offset) { |
|
26 | + return; |
|
27 | + } |
|
28 | + // bail out quick if $offset == 0 |
|
26 | 29 | |
27 | 30 | // theoretically, we could get rid of this multi-request |
28 | 31 | // doo-hickery if safe mode is off |
@@ -39,7 +42,9 @@ discard block |
||
39 | 42 | } |
40 | 43 | $userinfos = phorum_db_user_get_fields($user_ids, 'signature'); |
41 | 44 | foreach ($userinfos as $i => $user) { |
42 | - if (empty($user['signature'])) continue; |
|
45 | + if (empty($user['signature'])) { |
|
46 | + continue; |
|
47 | + } |
|
43 | 48 | $sig = $user['signature']; |
44 | 49 | // perform standard Phorum processing on the sig |
45 | 50 | $sig = str_replace(array("&","<",">"), array("&","<",">"), $sig); |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | settings, edit that file. To use the web form, delete that file.<br />"; |
9 | 9 | } else { |
10 | 10 | $config = phorum_htmlpurifier_get_config(true); |
11 | - if (!isset($_POST['reset'])) $config->mergeArrayFromForm($_POST, 'config', $PHORUM['mod_htmlpurifier']['directives']); |
|
12 | - $PHORUM['mod_htmlpurifier']['config'] = $config->getAll(); |
|
11 | + if (!isset($_POST[ 'reset' ])) $config->mergeArrayFromForm($_POST, 'config', $PHORUM[ 'mod_htmlpurifier' ][ 'directives' ]); |
|
12 | + $PHORUM[ 'mod_htmlpurifier' ][ 'config' ] = $config->getAll(); |
|
13 | 13 | } |
14 | - $PHORUM['mod_htmlpurifier']['wysiwyg'] = !empty($_POST['wysiwyg']); |
|
15 | - $PHORUM['mod_htmlpurifier']['suppress_message'] = !empty($_POST['suppress_message']); |
|
16 | - if(!phorum_htmlpurifier_commit_settings()){ |
|
17 | - $error="Database error while updating settings."; |
|
14 | + $PHORUM[ 'mod_htmlpurifier' ][ 'wysiwyg' ] = !empty($_POST[ 'wysiwyg' ]); |
|
15 | + $PHORUM[ 'mod_htmlpurifier' ][ 'suppress_message' ] = !empty($_POST[ 'suppress_message' ]); |
|
16 | + if (!phorum_htmlpurifier_commit_settings()) { |
|
17 | + $error = "Database error while updating settings."; |
|
18 | 18 | } else { |
19 | 19 | echo "Settings Updated<br />"; |
20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | function phorum_htmlpurifier_commit_settings() |
24 | 24 | { |
25 | 25 | global $PHORUM; |
26 | - return phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM["mod_htmlpurifier"])); |
|
26 | + return phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM[ "mod_htmlpurifier" ])); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // vim: et sw=4 sts=4 |
@@ -8,7 +8,9 @@ |
||
8 | 8 | settings, edit that file. To use the web form, delete that file.<br />"; |
9 | 9 | } else { |
10 | 10 | $config = phorum_htmlpurifier_get_config(true); |
11 | - if (!isset($_POST['reset'])) $config->mergeArrayFromForm($_POST, 'config', $PHORUM['mod_htmlpurifier']['directives']); |
|
11 | + if (!isset($_POST['reset'])) { |
|
12 | + $config->mergeArrayFromForm($_POST, 'config', $PHORUM['mod_htmlpurifier']['directives']); |
|
13 | + } |
|
12 | 14 | $PHORUM['mod_htmlpurifier']['config'] = $config->getAll(); |
13 | 15 | } |
14 | 16 | $PHORUM['mod_htmlpurifier']['wysiwyg'] = !empty($_POST['wysiwyg']); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | function phorum_htmlpurifier_show_migrate_sigs_form() |
4 | 4 | { |
5 | - $frm = new PhorumInputForm ('', "post", "Migrate"); |
|
5 | + $frm = new PhorumInputForm('', "post", "Migrate"); |
|
6 | 6 | $frm->hidden("module", "modsettings"); |
7 | 7 | $frm->hidden("mod", "htmlpurifier"); |
8 | 8 | $frm->hidden("migrate-sigs", "1"); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | $frm->addMessage('This operation will migrate your users signatures |
11 | 11 | to HTML. <strong>This process is irreversible and must only be performed once.</strong> |
12 | 12 | Type in yes in the confirmation field to migrate.'); |
13 | - if (!file_exists(dirname(__FILE__) . '/../migrate.php')) { |
|
13 | + if (!file_exists(dirname(__FILE__).'/../migrate.php')) { |
|
14 | 14 | $frm->addMessage('Migration file does not exist, cannot migrate signatures. |
15 | 15 | Please check <tt>migrate.bbcode.php</tt> on how to create an appropriate file.'); |
16 | 16 | } else { |