mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
Make module compatible with Phorum 5.2.6. Changes:
- Modify signature/edit message handling to account for <phorum break> - Update line numbers - Update edit message fragile code - Prevent message blanking when signature or edit message is empty - Armor source for quote - Update bbcode function call - Use phorum_db_interact for our custom call git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1499 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
57f897661e
commit
8a17b1fbc3
@ -81,7 +81,7 @@ function phorum_htmlpurifier_format($data)
|
||||
$fake_data[$message_id] = $message;
|
||||
$fake_data = phorum_htmlpurifier_migrate($fake_data);
|
||||
$body = $fake_data[$message_id]['body'];
|
||||
$body = str_replace("<phorum break>", '', $body);
|
||||
$body = str_replace("<phorum break>\n", "\n", $body);
|
||||
$updated_message['body'] = $body; // save it in
|
||||
$body .= $signature . $edit_message; // add it back in
|
||||
} else {
|
||||
@ -121,7 +121,7 @@ function phorum_htmlpurifier_format($data)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// This is fragile code, copied from read.php:359. It will break if
|
||||
// This is fragile code, copied from read.php:596 (Phorum 5.2.6). It will break if
|
||||
// that is changed
|
||||
|
||||
/**
|
||||
@ -147,9 +147,9 @@ function phorum_htmlpurifier_generate_editmessage($row) {
|
||||
$editmessage = '';
|
||||
if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) {
|
||||
$editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]);
|
||||
$editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date"],$row['meta']['edit_date']), $editmessage);
|
||||
$editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date_time"],$row['meta']['edit_date']), $editmessage);
|
||||
$editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage);
|
||||
$editmessage="\n\n\n\n$editmessage";
|
||||
$editmessage = "\n\n\n\n$editmessage";
|
||||
}
|
||||
return $editmessage;
|
||||
}
|
||||
@ -166,7 +166,10 @@ function phorum_htmlpurifier_remove_sig_and_editmessage(&$row) {
|
||||
// we must not process the signature or editmessage
|
||||
$signature = phorum_htmlpurifier_generate_sig($row);
|
||||
$editmessage = phorum_htmlpurifier_generate_editmessage($row);
|
||||
$row['body'] = strtr($row['body'], array($signature => '', $editmessage => ''));
|
||||
$replacements = array();
|
||||
if ($signature) $replacements[str_replace("\n", "<phorum break>\n", $signature)] = '';
|
||||
if ($editmessage) $replacements[str_replace("\n", "<phorum break>\n", $editmessage)] = '';
|
||||
$row['body'] = strtr($row['body'], $replacements);
|
||||
return array($signature, $editmessage);
|
||||
}
|
||||
|
||||
@ -174,7 +177,7 @@ function phorum_htmlpurifier_remove_sig_and_editmessage(&$row) {
|
||||
* Indicate that data is fully HTML and not from migration, invalidate
|
||||
* previous caches
|
||||
* @note This function used to generate the actual cache entries, but
|
||||
* since there's data missing that must be deferred to the first read
|
||||
* since there's data missing that must be deferred to the first read
|
||||
*/
|
||||
function phorum_htmlpurifier_posting($message) {
|
||||
$PHORUM = $GLOBALS["PHORUM"];
|
||||
@ -190,7 +193,8 @@ function phorum_htmlpurifier_quote($array) {
|
||||
$PHORUM = $GLOBALS["PHORUM"];
|
||||
$purifier =& HTMLPurifier::getInstance();
|
||||
$text = $purifier->purify($array[1]);
|
||||
return "<blockquote cite=\"$array[0]\">\n$text\n</blockquote>";
|
||||
$source = htmlspecialchars($array[0]);
|
||||
return "<blockquote cite=\"$source\">\n$text\n</blockquote>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,11 +23,5 @@ process may take a long time. After installing the HTML Purifier module and
|
||||
then configuring 'migrate.php', navigate to Settings and click 'Migrate
|
||||
Signatures' to migrate all user signatures.
|
||||
|
||||
The version of HTML Purifier bundled with is a custom modified 2.0.1.
|
||||
Do not attempt to replace it with a version equal to or less than
|
||||
downloaded from the HTML Purifier website: the module will combust
|
||||
spectacularly. (Greater versions, however, are okay, because the changes
|
||||
made to accomodate this module have been committed to the trunk).
|
||||
|
||||
Visit HTML Purifier at <http://htmlpurifier.org/>. May the force
|
||||
be with you.
|
||||
|
@ -23,6 +23,6 @@ require_once(dirname(__FILE__) . "/../bbcode/bbcode.php");
|
||||
* legacy markup into HTML.
|
||||
*/
|
||||
function phorum_htmlpurifier_migrate($data) {
|
||||
return phorum_bb_code($data); // bbcode's 'format' hook
|
||||
return phorum_mod_bbcode_format($data); // bbcode's 'format' hook
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ function phorum_htmlpurifier_migrate_sigs($offset) {
|
||||
$fake_data = array(array("author"=>"", "email"=>"", "subject"=>"", 'body' => $sig));
|
||||
list($fake_message) = phorum_htmlpurifier_migrate($fake_data);
|
||||
$user['signature'] = $fake_message['body'];
|
||||
if (!phorum_user_save($user)) {
|
||||
if (!phorum_api_user_save($user)) {
|
||||
exit('Error while saving user data');
|
||||
}
|
||||
}
|
||||
@ -55,17 +55,7 @@ function phorum_htmlpurifier_migrate_sigs($offset) {
|
||||
// query for highest ID in database
|
||||
$type = $PHORUM['DBCONFIG']['type'];
|
||||
$sql = "select MAX(user_id) from {$PHORUM['user_table']}";
|
||||
if ($type == 'mysql') {
|
||||
$conn = phorum_db_mysql_connect();
|
||||
$res = mysql_query($sql, $conn);
|
||||
$row = mysql_fetch_row($res);
|
||||
} elseif ($type == 'mysqli') {
|
||||
$conn = phorum_db_mysqli_connect();
|
||||
$res = mysqli_query($conn, $sql);
|
||||
$row = mysqli_fetch_row($res);
|
||||
} else {
|
||||
exit('Unrecognized database!');
|
||||
}
|
||||
$row = phorum_db_interact(DB_RETURN_ROW, $sql);
|
||||
$top_id = (int) $row[0];
|
||||
|
||||
$offset += $increment;
|
||||
|
Loading…
Reference in New Issue
Block a user