Esempio n. 1
0
/**
* Undo patched changes to a string.
* $text: Final string
* $diff: Changes that were applied
* return: Unpatched string
*/
function phorum_unpatch($text, $diff)
{
    $text = str_replace(array("\r\n", "\r"), "\n", $text);
    if (!is_array($diff)) {
        $n = 0;
        for ($i = 0; $i < strlen($diff); $i++) {
            $c = substr($diff, $i, 1);
            if ($c == "-") {
                $n = substr($diff, 0, $i);
                $pre = substr($text, 0, $n);
                $post = substr($text, $n);
                return $pre . substr($diff, $i + 1) . $post;
            } elseif ($c == "+") {
                $n = substr($diff, 0, $i);
                $pre = substr($text, 0, $n);
                $post = substr($text, $n);
                return $pre . substr($post, strlen($diff) - $i - 1);
            }
        }
        return $text;
    }
    foreach (array_reverse($diff) as $d) {
        $text = phorum_unpatch($text, $d);
    }
    return $text;
}
Esempio n. 2
0
    
            $message_hist[count($message_hist)-1]["colored_subject"] = $colored_subject;
            $prev_subject = phorum_unpatch($prev_subject, $prev_diff_subject);
            $this_version["colored_subject"] = $prev_subject;
        } else {
            $prev_subject = $message["subject"];
            $this_version["colored_subject"] = $message["subject"];
        }*/
    // only happens in first loop
    if ($prev_subject == -1) {
        $prev_subject = $message["subject"];
    }
    // subject diffs
    if (isset($diff_info['diff_subject']) && !empty($diff_info['diff_subject'])) {
        $colored_subject = phorum_unpatch_color($prev_subject, $diff_info['diff_subject']);
        $prev_subject = phorum_unpatch($prev_subject, $diff_info['diff_subject']);
        $colored_subject = htmlspecialchars($colored_subject, ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
        $colored_subject = str_replace(array("[phorum addition]", "[phorum removal]", "[/phorum addition]", "[/phorum removal]"), array("<span class=\"addition\">", "<span class=\"removal\">", "</span>", "</span>"), $colored_subject);
        $colored_subject = nl2br($colored_subject);
        $this_version["colored_subject"] = $colored_subject;
    } elseif (!isset($diff_info['diff_subject'])) {
        $this_version['colored_subject'] = nl2br($prev_subject);
    } else {
        $this_version["colored_subject"] = nl2br($prev_subject);
    }
    // no nl2br for subject
    //$this_version["colored_subject"] = nl2br($this_version["colored_subject"]);
    $message_hist[] = $this_version;
}
$PHORUM["DATA"]["HEADING"] = $PHORUM["DATA"]["LANG"]["ChangeHistory"];
// unset default description