$OldString) { $Key = $OldLine + $LineOffset; if ($Key < 0) { $Key = 0; } $Found = -1; while ($Key < count($LineArrayNew)) { if ($OldString != $LineArrayNew[$Key]) { $Key++; } elseif ($OldString == $LineArrayNew[$Key]) { $Found = $Key; break; } } if ($Found == '-1') { //we never found the old line in the new array $Result[] = '← '.$OldString.'
'; $LineOffset = $LineOffset - 1; } elseif ($Found == $OldLine + $LineOffset) { $Result[] = '↕ '.$OldString.'
'; } elseif ($Found != $OldLine + $LineOffset) { if ($Found < $OldLine + $LineOffset) { $Result[] = '⇤ '.$OldString.'
'; } else { $Result[] = '← '.$OldString.'
'; $Key = $OldLine + $LineOffset; while ($Key < $Found) { $Result[] = '→ '.$LineArrayNew[$Key].'
'; $Key++; } $Result[] = '→ '.$OldString.'
'; } $LineOffset = $Found - $OldLine; } } if (count($LineArrayNew) > count($LineArrayOld) + $LineOffset) { $Key = count($LineArrayOld) + $LineOffset; while ($Key < count($LineArrayNew)) { $Result[] = '→ '.$LineArrayNew[$Key].'
'; $Key++; } } return $Result; } function get_body($ID, $Rev) { global $DB, $Revision, $Body; if ($Rev == $Revision) { $Str = $Body; } else { $DB->query(" SELECT Body FROM wiki_revisions WHERE ID = '$ID' AND Revision = '$Rev'"); if (!$DB->has_results()) { error(404); } list($Str) = $DB->next_record(); } return $Str; } if (!isset($_GET['old']) || !isset($_GET['new']) || !isset($_GET['id']) || !is_number($_GET['old']) || !is_number($_GET['new']) || !is_number($_GET['id']) || $_GET['old'] > $_GET['new'] ) { error(0); } $ArticleID = $_GET['id']; $Article = $Alias->article($ArticleID); list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Article); if ($Read > $LoggedUser['EffectiveClass']) { error(404); } View::show_header('Compare Article Revisions'); $Diff2 = get_body($ArticleID, $_GET['new']); $Diff1 = get_body($ArticleID, $_GET['old']); ?>

Compare Revisions