authorize(); if (!isset($_POST['id']) || !is_number($_POST['id'])) { error(0); } $ArticleID = (int) $_POST['id']; include SERVER_ROOT . '/classes/validate.class.php'; $Val = new VALIDATE(); $Val->SetFields('title', '1', 'string', 'The title must be between 3 and 100 characters', array('maxlength' => 100, 'minlength' => 3)); $Err = $Val->ValidateForm($_POST); if ($Err) { error($Err); } $P = array(); $P = db_array($_POST); $Article = Wiki::get_article($ArticleID); list($OldRevision, $OldTitle, $OldBody, $CurRead, $CurEdit, $OldDate, $OldAuthor) = array_shift($Article); if ($CurEdit > $LoggedUser['EffectiveClass']) { error(403); } if (check_perms('admin_manage_wiki')) { $Read = $_POST['minclassread']; $Edit = $_POST['minclassedit']; if (!is_number($Read)) { error(0); //int? } if (!is_number($Edit)) { error(0); } if ($Edit > $LoggedUser['EffectiveClass']) {
<?php if (!isset($_GET['id']) || !is_number($_GET['id'])) { error(404); } $ArticleID = (int) $_GET['id']; $Latest = Wiki::get_article($ArticleID); list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Latest); if ($Read > $LoggedUser['EffectiveClass']) { error(404); } if ($Edit > $LoggedUser['EffectiveClass']) { error(403); } View::show_header("Revisions of " . $Title); ?> <div class="thin"> <div class="header"> <h2>Revision history for <a href="wiki.php?action=article&id=<?php echo $ArticleID; ?> "><?php echo $Title; ?> </a></h2> </div> <form action="wiki.php" method="get"> <input type="hidden" name="action" id="action" value="compare" /> <input type="hidden" name="id" id="id" value="<?php echo $ArticleID; ?>
<?php if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID $ArticleID = $_GET['id']; } elseif ($_GET['name'] != '') { //Retrieve article ID via alias. $ArticleID = Wiki::alias_to_id($_GET['name']); } else { json_die("failure"); } if (!$ArticleID) { //No article found json_die("failure", "article not found"); } $Article = Wiki::get_article($ArticleID, false); if (!$Article) { json_die("failure", "article not found"); } list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article); if ($Read > $LoggedUser['EffectiveClass']) { json_die("failure", "higher user class required to view article"); } Text::$TOC = true; $TextBody = Text::full_format($Body, false); json_die("success", array('title' => $Title, 'bbBody' => $Body, 'body' => $TextBody, 'aliases' => $Aliases, 'authorID' => (int) $AuthorID, 'authorName' => $AuthorName, 'date' => $Date, 'revision' => (int) $Revision));