mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 04:01:35 +00:00
Empty commit
This commit is contained in:
parent
b43965b123
commit
39e692c98f
@ -1,77 +0,0 @@
|
||||
<?
|
||||
class ALIAS {
|
||||
function convert($str) {
|
||||
return trim(substr(preg_replace('/[^a-z0-9]/', '', strtolower(htmlentities($str))), 0, 50));
|
||||
}
|
||||
|
||||
//Alternative approach with potential.
|
||||
function flush() {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT Alias, ArticleID
|
||||
FROM wiki_aliases");
|
||||
$Aliases = G::$DB->to_array('Alias');
|
||||
G::$DB->set_query_id($QueryID);
|
||||
G::$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
||||
}
|
||||
|
||||
function to_id($Alias) {
|
||||
$Aliases = G::$Cache->get_value('wiki_aliases');
|
||||
if (!$Aliases) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT Alias, ArticleID
|
||||
FROM wiki_aliases");
|
||||
$Aliases = G::$DB->to_array('Alias');
|
||||
G::$DB->set_query_id($QueryID);
|
||||
G::$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
||||
}
|
||||
return $Aliases[$this->convert($Alias)]['ArticleID'];
|
||||
}
|
||||
/*
|
||||
function flush() {
|
||||
|
||||
}
|
||||
|
||||
function to_id($Alias) {
|
||||
$Alias = $this->convert($Alias);
|
||||
G::$DB->query("
|
||||
SELECT ArticleID
|
||||
FROM wiki_aliases
|
||||
WHERE Alias LIKE '$Alias'");
|
||||
list($ArticleID) = G::$DB->next_record();
|
||||
return $ArticleID;
|
||||
}
|
||||
*/
|
||||
function article($ArticleID, $Error = true) {
|
||||
$Contents = G::$Cache->get_value('wiki_article_'.$ArticleID);
|
||||
if (!$Contents) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
w.Revision,
|
||||
w.Title,
|
||||
w.Body,
|
||||
w.MinClassRead,
|
||||
w.MinClassEdit,
|
||||
w.Date,
|
||||
w.Author,
|
||||
u.Username,
|
||||
GROUP_CONCAT(a.Alias),
|
||||
GROUP_CONCAT(a.UserID)
|
||||
FROM wiki_articles AS w
|
||||
LEFT JOIN wiki_aliases AS a ON w.ID=a.ArticleID
|
||||
LEFT JOIN users_main AS u ON u.ID=w.Author
|
||||
WHERE w.ID='$ArticleID'
|
||||
GROUP BY w.ID");
|
||||
if (!G::$DB->has_results() && $Error) {
|
||||
error(404);
|
||||
}
|
||||
$Contents = G::$DB->to_array();
|
||||
G::$DB->set_query_id($QueryID);
|
||||
G::$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
|
||||
}
|
||||
return $Contents;
|
||||
}
|
||||
}
|
||||
?>
|
29
classes/revisionhistory.class.php
Normal file
29
classes/revisionhistory.class.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?
|
||||
class RevisionHistory {
|
||||
/**
|
||||
* Read the revision history of an artist or torrent page
|
||||
* @param string $Page artists or torrents
|
||||
* @param in $PageID
|
||||
* @return array
|
||||
*/
|
||||
public static function get_revision_history($Page, $PageID) {
|
||||
if ($Page == 'artists') {
|
||||
$Table = 'wiki_artists';
|
||||
} else {
|
||||
$Table = 'wiki_torrents';
|
||||
}
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
RevisionID,
|
||||
Summary,
|
||||
Time,
|
||||
UserID
|
||||
FROM $Table
|
||||
WHERE PageID = $PageID
|
||||
ORDER BY RevisionID DESC");
|
||||
$Ret = G::$DB->to_array();
|
||||
G::$DB->set_query_id($QueryID);
|
||||
return $Ret;
|
||||
}
|
||||
}
|
41
classes/revisionhistoryview.class.php
Normal file
41
classes/revisionhistoryview.class.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?
|
||||
class RevisionHistoryView {
|
||||
/**
|
||||
* Render the revision history
|
||||
* @param array $RevisionHistory see RevisionHistory::get_revision_history
|
||||
* @param string $BaseURL
|
||||
*/
|
||||
public static function render_revision_history($RevisionHistory, $BaseURL) {
|
||||
?>
|
||||
<table cellpadding="6" cellspacing="1" border="0" width="100%" class="border">
|
||||
<tr class="colhead">
|
||||
<td>Revision</td>
|
||||
<td>Date</td>
|
||||
<td>User</td>
|
||||
<td>Summary</td>
|
||||
</tr>
|
||||
<?
|
||||
$Row = 'a';
|
||||
foreach ($RevisionHistory as $Entry) {
|
||||
list($RevisionID, $Summary, $Time, $UserID) = $Entry;
|
||||
$Row = (($Row == 'a') ? 'b' : 'a');
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<td>
|
||||
<?= "<a href=\"$BaseURL&revisionid=$RevisionID\">#$RevisionID</a>" ?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$Time?>
|
||||
</td>
|
||||
<td>
|
||||
<?=Users::format_username($UserID, false, false, false)?>
|
||||
</td>
|
||||
<td>
|
||||
<?=($Summary ? $Summary : '(empty)')?>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
</table>
|
||||
<?
|
||||
}
|
||||
}
|
@ -1,80 +1,100 @@
|
||||
<?
|
||||
/*########################################################################
|
||||
## Wiki class ##
|
||||
##########################################################################
|
||||
|
||||
Seeing as each page has to manage its wiki separately (for performance
|
||||
reasons - JOINs instead of multiple queries), this class is rather bare.
|
||||
|
||||
The only useful function in here is revision_history(). It creates a
|
||||
table with the revision history for that particular wiki page.
|
||||
|
||||
|
||||
wiki.class depends on your wiki table being structured like this:
|
||||
|
||||
+------------+--------------+------+-----+----------------------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+--------------+------+-----+----------------------+-------+
|
||||
| RevisionID | int(12) | NO | PRI | 0 | |
|
||||
| PageID | int(10) | NO | MUL | 0 | |
|
||||
| Body | text | YES | | NULL | |
|
||||
| UserID | int(10) | NO | MUL | 0 | |
|
||||
| Summary | varchar(100) | YES | | NULL | |
|
||||
| Time | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
+------------+--------------+------+-----+----------------------+-------+
|
||||
|
||||
It is also recommended that you have a field in the main table for
|
||||
whatever the page is (e.g. details.php main table = torrents), so you can
|
||||
do a JOIN.
|
||||
|
||||
|
||||
########################################################################*/
|
||||
|
||||
class Wiki {
|
||||
/**
|
||||
* Normalize an alias
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public static function normalize_alias($str) {
|
||||
return trim(substr(preg_replace('/[^a-z0-9]/', '', strtolower(htmlentities($str))), 0, 50));
|
||||
}
|
||||
|
||||
public static function revision_history($Table = '', $PageID = 0, $BaseURL = '') {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
/**
|
||||
* Get all aliases in an associative array of Alias => ArticleID
|
||||
* @return array
|
||||
*/
|
||||
public static function get_aliases() {
|
||||
$Aliases = G::$Cache->get_value('wiki_aliases');
|
||||
if (!$Aliases) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT Alias, ArticleID
|
||||
FROM wiki_aliases");
|
||||
$Aliases = G::$DB->to_pair('Alias', 'ArticleID');
|
||||
G::$DB->set_query_id($QueryID);
|
||||
G::$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
||||
}
|
||||
return $Aliases;
|
||||
}
|
||||
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
RevisionID,
|
||||
Summary,
|
||||
Time,
|
||||
UserID
|
||||
FROM $Table
|
||||
WHERE PageID = $PageID
|
||||
ORDER BY RevisionID DESC");
|
||||
?>
|
||||
<table cellpadding="6" cellspacing="1" border="0" width="100%" class="border">
|
||||
<tr class="colhead">
|
||||
<td>Revision</td>
|
||||
<td>Date</td>
|
||||
<td>User</td>
|
||||
<td>Summary</td>
|
||||
</tr>
|
||||
<?
|
||||
$Row = 'a';
|
||||
while (list($RevisionID, $Summary, $Time, $UserID, $Username) = G::$DB->next_record()) {
|
||||
$Row = (($Row == 'a') ? 'b' : 'a');
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<td>
|
||||
<?= "<a href=\"$BaseURL&revisionid=$RevisionID\">#$RevisionID</a>" ?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$Time?>
|
||||
</td>
|
||||
<td>
|
||||
<?=Users::format_username($UserID, false, false, false)?>
|
||||
</td>
|
||||
<td>
|
||||
<?=($Summary ? $Summary : '(empty)')?>
|
||||
</td>
|
||||
</tr>
|
||||
<? } // while ?>
|
||||
</table>
|
||||
<?
|
||||
G::$DB->set_query_id($QueryID);
|
||||
} // function
|
||||
} // class
|
||||
?>
|
||||
/**
|
||||
* Flush the alias cache. Call this whenever you touch the wiki_aliases table.
|
||||
*/
|
||||
public static function flush_aliases() {
|
||||
G::$Cache->delete_value('wiki_aliases');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ArticleID corresponding to an alias
|
||||
* @param string $Alias
|
||||
* @return int
|
||||
*/
|
||||
public static function alias_to_id($Alias) {
|
||||
$Aliases = self::get_aliases();
|
||||
$Alias = self::normalize_alias($Alias);
|
||||
if (!isset($Aliases[$Alias])) {
|
||||
return false;
|
||||
} else {
|
||||
return (int)$Aliases[$Alias];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an article; returns false on error if $Error = false
|
||||
* @param int $ArticleID
|
||||
* @param bool $Error
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function get_article($ArticleID, $Error = true) {
|
||||
$Contents = G::$Cache->get_value('wiki_article_'.$ArticleID);
|
||||
if (!$Contents) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
w.Revision,
|
||||
w.Title,
|
||||
w.Body,
|
||||
w.MinClassRead,
|
||||
w.MinClassEdit,
|
||||
w.Date,
|
||||
w.Author,
|
||||
u.Username,
|
||||
GROUP_CONCAT(a.Alias),
|
||||
GROUP_CONCAT(a.UserID)
|
||||
FROM wiki_articles AS w
|
||||
LEFT JOIN wiki_aliases AS a ON w.ID=a.ArticleID
|
||||
LEFT JOIN users_main AS u ON u.ID=w.Author
|
||||
WHERE w.ID='$ArticleID'
|
||||
GROUP BY w.ID");
|
||||
if (!G::$DB->has_results()) {
|
||||
if ($Error) {
|
||||
error(404);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$Contents = G::$DB->to_array();
|
||||
G::$DB->set_query_id($QueryID);
|
||||
G::$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
|
||||
}
|
||||
return $Contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush an article's cache. Call this whenever you edited a wiki article or its aliases.
|
||||
* @param int $ArticleID
|
||||
*/
|
||||
public static function flush_article($ArticleID) {
|
||||
G::$Cache->delete_value('wiki_article_'.$ArticleID);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
<?
|
||||
include(SERVER_ROOT . '/classes/alias.class.php');
|
||||
$Alias = new ALIAS;
|
||||
|
||||
|
||||
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
|
||||
$ArticleID = $_GET['id'];
|
||||
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
|
||||
$ArticleID = $Alias->to_id($_GET['name']);
|
||||
$ArticleID = Wiki::alias_to_id($_GET['name']);
|
||||
} else {
|
||||
json_die("failure");
|
||||
}
|
||||
@ -14,7 +10,7 @@
|
||||
if (!$ArticleID) { //No article found
|
||||
json_die("failure", "article not found");
|
||||
}
|
||||
$Article = $Alias->article($ArticleID, false);
|
||||
$Article = Wiki::get_article($ArticleID, false);
|
||||
|
||||
if (!$Article) {
|
||||
json_die("failure", "article not found");
|
||||
|
@ -1,41 +1,27 @@
|
||||
<?
|
||||
/************************************************************************
|
||||
||------------|| Artist wiki history page ||---------------------------||
|
||||
|
||||
This page lists previous revisions of the artists page. It gets called
|
||||
if $_GET['action'] == 'history'.
|
||||
|
||||
It also requires $_GET['artistid'].
|
||||
|
||||
The wiki class is used here to generate the page history.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
$ArtistID = $_GET['artistid'];
|
||||
if (!is_number($ArtistID)) {
|
||||
if (!is_number($_GET['artistid'])) {
|
||||
error(0);
|
||||
}
|
||||
$ArtistID = (int)$_GET['artistid'];
|
||||
|
||||
// Get the artist name and the body of the last revision
|
||||
$DB->query("
|
||||
SELECT Name
|
||||
FROM artists_group
|
||||
WHERE ArtistID = '$ArtistID'");
|
||||
list($Name) = $DB->next_record(MYSQLI_NUM, true);
|
||||
WHERE ArtistID = $ArtistID");
|
||||
if (!$DB->has_results()) {
|
||||
error(404);
|
||||
}
|
||||
list($Name) = $DB->next_record();
|
||||
|
||||
View::show_header("Revision history for $Name"); // Set title
|
||||
|
||||
// Start printing form
|
||||
View::show_header("Revision history for $Name");
|
||||
?>
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
<h2>Revision history for <a href="artist.php?id=<?=$ArtistID?>"><?=$Name?></a></h2>
|
||||
</div>
|
||||
<?
|
||||
// the Wiki class takes over from here
|
||||
Wiki::revision_history('wiki_artists', $ArtistID, "artist.php?id=$ArtistID");
|
||||
RevisionHistoryView::render_revision_history(RevisionHistory::get_revision_history('artists', $ArtistID), "artist.php?id=$ArtistID");
|
||||
?>
|
||||
</div>
|
||||
<?
|
||||
View::show_footer();
|
||||
?>
|
||||
|
@ -1,45 +1,27 @@
|
||||
<?
|
||||
/************************************************************************
|
||||
||------------|| Torrent group wiki history page ||--------------------||
|
||||
|
||||
This page lists previous revisions of the torrent group page. It gets
|
||||
called if $_GET['action'] == 'history'.
|
||||
|
||||
It also requires $_GET['groupid'].
|
||||
|
||||
The Wiki class is used here to generate the page history.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
$GroupID = $_GET['groupid'];
|
||||
if (!is_number($GroupID) || !$GroupID) {
|
||||
if (!isset($_GET['groupid']) || !is_number($_GET['groupid'])) {
|
||||
error(0);
|
||||
}
|
||||
$GroupID = (int)$_GET['groupid'];
|
||||
|
||||
// Get the torrent group name and the body of the last revision
|
||||
$DB->query("
|
||||
SELECT Name
|
||||
FROM torrents_group
|
||||
WHERE ID = '$GroupID'");
|
||||
list($Name) = $DB->next_record();
|
||||
|
||||
if (!$Name) {
|
||||
WHERE ID = $GroupID");
|
||||
if (!$DB->has_results()) {
|
||||
error(404);
|
||||
}
|
||||
list($Name) = $DB->next_record();
|
||||
|
||||
View::show_header("Revision history for $Name"); // Set title
|
||||
|
||||
// Start printing form
|
||||
View::show_header("Revision history for $Name");
|
||||
?>
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
<h2>Revision history for <a href="torrents.php?id=<?=$GroupID?>"><?=$Name?></a></h2>
|
||||
</div>
|
||||
<?
|
||||
// the Wiki class takes over from here
|
||||
Wiki::revision_history('wiki_torrents', $GroupID, "/torrents.php?id=$GroupID");
|
||||
RevisionHistoryView::render_revision_history(RevisionHistory::get_revision_history('torrents', $GroupID), "torrents.php?id=$GroupID");
|
||||
?>
|
||||
</div>
|
||||
<?
|
||||
View::show_footer();
|
||||
?>
|
||||
|
@ -1,21 +1,27 @@
|
||||
<?
|
||||
authorize();
|
||||
|
||||
//TODO, check that loggeduser > edit
|
||||
if (!is_number($_POST['article']) || $_POST['article'] == '') {
|
||||
if (!isset($_POST['article']) || !is_number($_POST['article'])) {
|
||||
error(0);
|
||||
}
|
||||
|
||||
$ArticleID = $_POST['article'];
|
||||
$NewAlias = $Alias->convert($_POST['alias']);
|
||||
$Dupe = $Alias->to_id($_POST['alias']);
|
||||
$ArticleID = (int)$_POST['article'];
|
||||
|
||||
if ($NewAlias != '' && $NewAlias!='addalias' && !$Dupe) { //Not null, and not dupe
|
||||
$DB->query("SELECT MinClassEdit FROM wiki_articles WHERE ID = $ArticleID");
|
||||
list($MinClassEdit) = $DB->next_record();
|
||||
if ($MinClassEdit > $LoggedUser['EffectiveClass']) {
|
||||
error(403);
|
||||
}
|
||||
|
||||
$NewAlias = Wiki::normalize_alias($_POST['alias']);
|
||||
$Dupe = Wiki::alias_to_id($_POST['alias']);
|
||||
|
||||
if ($NewAlias != '' && $NewAlias!='addalias' && $Dupe === false) { //Not null, and not dupe
|
||||
$DB->query("INSERT INTO wiki_aliases (Alias, UserID, ArticleID) VALUES ('$NewAlias', '$LoggedUser[ID]', '$ArticleID')");
|
||||
$Alias->flush();
|
||||
} else {
|
||||
error('The alias you attempted to add was either null or already in the database.');
|
||||
}
|
||||
|
||||
$Cache->delete_value('wiki_article_'.$ArticleID);
|
||||
Wiki::flush_aliases();
|
||||
Wiki::flush_article($ArticleID);
|
||||
header('Location: wiki.php?action=article&id='.$ArticleID);
|
||||
|
@ -1,68 +0,0 @@
|
||||
<?
|
||||
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
|
||||
error(404);
|
||||
}
|
||||
$ArticleID = $_GET['id'];
|
||||
|
||||
$Latest = $Alias->article($ArticleID);
|
||||
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Latest);
|
||||
if ($Edit > $LoggedUser['EffectiveClass']) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
View::show_header($Title." Aliases");
|
||||
?>
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
<h2><a href="wiki.php?action=article&id=<?=$ArticleID?>"><?=$Title?></a> Aliases</h2>
|
||||
<p>
|
||||
Aliases are exact search strings or names that can be used to link to an article. [[Alias]]
|
||||
</p>
|
||||
</div>
|
||||
<form class="add_form" name="aliases" action="wiki.php" method="get">
|
||||
<input type="hidden" name="action" id="action" value="compare" />
|
||||
<input type="hidden" name="id" id="id" value="<?=$ArticleID?>" />
|
||||
<table class="layout">
|
||||
<tr class="colhead">
|
||||
<td>Add an alias to this article</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="action" value="link" />
|
||||
<input type="text" name="alias" size="20" />
|
||||
<input type="submit" value="Submit" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table>
|
||||
<tr class="colhead">
|
||||
<td>Alias</td>
|
||||
<td>Remove</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=$Revision?></td>
|
||||
<td><?=$Title?></td>
|
||||
|
||||
</tr>
|
||||
<?
|
||||
$DB->query("
|
||||
SELECT Alias
|
||||
FROM wiki_aliases
|
||||
WHERE ArticleID = '$ArticleID'");
|
||||
while (list($Revision, $Title, $AuthorID, $AuthorName, $Date) = $DB->next_record()) { ?>
|
||||
<tr>
|
||||
<td><?=$Revision?></td>
|
||||
<td><?=$Title?></td>
|
||||
</tr>
|
||||
<?
|
||||
} ?>
|
||||
<tr>
|
||||
<td class="center" colspan="6">
|
||||
<input type="submit" value="Compare" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<? View::show_footer(); ?>
|
@ -1,10 +1,11 @@
|
||||
<?
|
||||
Text::$TOC = true;
|
||||
|
||||
$ArticleID = false;
|
||||
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
|
||||
$ArticleID = $_GET['id'];
|
||||
$ArticleID = (int)$_GET['id'];
|
||||
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
|
||||
$ArticleID = $Alias->to_id($_GET['name']);
|
||||
$ArticleID = Wiki::alias_to_id($_GET['name']);
|
||||
} else { //No ID, No Name
|
||||
//error(404);
|
||||
error('Unknown article ['.display_str($_GET['id']).']');
|
||||
@ -21,8 +22,7 @@
|
||||
There is no article matching the name you requested.
|
||||
<ul>
|
||||
<li><a href="wiki.php?action=search&search=<?=display_str($_GET['name'])?>">Search</a> for an article similar to this.</li>
|
||||
<li><a href="wiki.php?action=link&alias=<?=display_str($Alias->convert($_GET['name']))?>">Link</a> this to an existing article.</li>
|
||||
<li><a href="wiki.php?action=create&alias=<?=display_str($Alias->convert($_GET['name']))?>">Create</a> an article in its place.</li>
|
||||
<li><a href="wiki.php?action=create&alias=<?=display_str(Wiki::normalize_alias($_GET['name']))?>">Create</a> an article in its place.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -30,7 +30,8 @@
|
||||
View::show_footer();
|
||||
die();
|
||||
}
|
||||
$Article = $Alias->article($ArticleID);
|
||||
|
||||
$Article = Wiki::get_article($ArticleID);
|
||||
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
|
||||
if ($Read > $LoggedUser['EffectiveClass']) {
|
||||
error('You must be a higher user class to view this wiki article');
|
||||
@ -46,9 +47,11 @@
|
||||
<h2><?=$Title?></h2>
|
||||
<div class="linkbox">
|
||||
<a href="wiki.php?action=create" class="brackets">Create</a>
|
||||
<? if ($Edit <= $LoggedUser['EffectiveClass']) { ?>
|
||||
<a href="wiki.php?action=edit&id=<?=$ArticleID?>" class="brackets">Contribute</a>
|
||||
<a href="wiki.php?action=revisions&id=<?=$ArticleID?>" class="brackets">History</a>
|
||||
<? if (check_perms('admin_manage_wiki') && $_GET['id'] != '136') { ?>
|
||||
<? } ?>
|
||||
<? if (check_perms('admin_manage_wiki') && $_GET['id'] != INDEX_ARTICLE) { ?>
|
||||
<a href="wiki.php?action=delete&id=<?=$ArticleID?>&authkey=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to delete?\nYes, DELETE, not as in \'Oh hey, if this is wrong we can get someone to magically undelete it for us later\' it will be GONE.\nGiven this new information, do you still want to DELETE this article and all its revisions and all its alias\' and act like it never existed?')">Delete</a>
|
||||
<? } ?>
|
||||
<!--<a href="reports.php?action=submit&type=wiki&article=<?=$ArticleID ?>" class="brackets">Report</a>-->
|
||||
@ -97,16 +100,17 @@
|
||||
<li>
|
||||
<strong>Aliases:</strong>
|
||||
<ul>
|
||||
<? if ($Aliases != $Title) {
|
||||
$AliasArray = explode(',', $Aliases);
|
||||
$UserArray = explode(',', $UserIDs);
|
||||
$i = 0;
|
||||
foreach ($AliasArray as $AliasItem) {
|
||||
<?
|
||||
if ($Aliases != $Title) {
|
||||
$AliasArray = explode(',', $Aliases);
|
||||
$UserArray = explode(',', $UserIDs);
|
||||
$i = 0;
|
||||
foreach ($AliasArray as $AliasItem) {
|
||||
?>
|
||||
<li id="alias_<?=$AliasItem?>"><a href="wiki.php?action=article&name=<?=$AliasItem?>"><?=Format::cut_string($AliasItem, 20, 1)?></a><? if (check_perms('admin_manage_wiki')) { ?> <a href="#" onclick="Remove_Alias('<?=$AliasItem?>'); return false;" class="brackets tooltip" title="Delete alias">X</a> <a href="user.php?id=<?=$UserArray[$i]?>" class="brackets tooltip" title="View user">U</a><? } ?></li>
|
||||
<? $i++;
|
||||
}
|
||||
<? $i++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -82,11 +82,11 @@ function get_body($ID, $Rev) {
|
||||
error(0);
|
||||
}
|
||||
|
||||
$ArticleID = $_GET['id'];
|
||||
$ArticleID = (int)$_GET['id'];
|
||||
|
||||
$Article = $Alias->article($ArticleID);
|
||||
$Article = Wiki::get_article($ArticleID);
|
||||
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Article);
|
||||
if ($Read > $LoggedUser['EffectiveClass']) {
|
||||
if ($Edit > $LoggedUser['EffectiveClass']) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,16 @@
|
||||
<?
|
||||
$ID = $_GET['id'];
|
||||
if (!check_perms('admin_manage_wiki') || !is_number($ID) || ($ID == '136')) {
|
||||
if (!check_perms('admin_manage_wiki')) {
|
||||
error(403);
|
||||
}
|
||||
|
||||
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
|
||||
error(404);
|
||||
}
|
||||
$ID = (int)$_GET['id'];
|
||||
|
||||
if ($ID == INDEX_ARTICLE) {
|
||||
error('You cannot delete the main wiki article.');
|
||||
}
|
||||
|
||||
$DB->query("
|
||||
SELECT Title
|
||||
@ -20,8 +28,7 @@
|
||||
$DB->query("DELETE FROM wiki_articles WHERE ID = $ID");
|
||||
$DB->query("DELETE FROM wiki_aliases WHERE ArticleID = $ID");
|
||||
$DB->query("DELETE FROM wiki_revisions WHERE ID = $ID");
|
||||
Wiki::flush_aliases();
|
||||
Wiki::flush_article($ID);
|
||||
|
||||
$Cache->delete_value('wiki_article_'.$ID);
|
||||
header("location: wiki.php");
|
||||
|
||||
?>
|
||||
|
@ -1,6 +1,14 @@
|
||||
<?
|
||||
authorize();
|
||||
$DB->query("DELETE FROM wiki_aliases WHERE Alias='".$Alias->convert($_GET['alias'])."'");
|
||||
$Cache->delete_value('wiki_article_'.$Alias->to_id($_GET['alias']));
|
||||
$Alias->flush();
|
||||
?>
|
||||
|
||||
$ArticleID = Wiki::alias_to_id($_GET['alias']);
|
||||
|
||||
$DB->query("SELECT MinClassEdit FROM wiki_articles WHERE ID = $ArticleID");
|
||||
list($MinClassEdit) = $DB->next_record();
|
||||
if ($MinClassEdit > $LoggedUser['EffectiveClass']) {
|
||||
error(403);
|
||||
}
|
||||
|
||||
$DB->query("DELETE FROM wiki_aliases WHERE Alias='".Wiki::normalize_alias($_GET['alias'])."'");
|
||||
Wiki::flush_article($ArticleID);
|
||||
Wiki::flush_aliases();
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?
|
||||
if (!is_number($_GET['id']) || $_GET['id'] === '') {
|
||||
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
|
||||
error(404);
|
||||
}
|
||||
$ArticleID = $_GET['id'];
|
||||
$ArticleID = (int)$_GET['id'];
|
||||
|
||||
$Article = $Alias->article($ArticleID);
|
||||
$Article = Wiki::get_article($ArticleID);
|
||||
list($Revision, $Title, $Body, $Read, $Edit, $Date, $Author) = array_shift($Article);
|
||||
if ($Edit > $LoggedUser['EffectiveClass']) {
|
||||
error('You do not have access to edit this article.');
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?
|
||||
enforce_login();
|
||||
|
||||
include(SERVER_ROOT.'/classes/alias.class.php');
|
||||
$Alias = new ALIAS;
|
||||
|
||||
|
||||
define('INDEX_ARTICLE', '1');
|
||||
|
||||
@ -40,13 +37,6 @@ function class_list($Selected = 0) {
|
||||
include('edit.php');
|
||||
}
|
||||
break;
|
||||
case 'link':
|
||||
if ($_POST['action']) {
|
||||
include('takelink.php');
|
||||
} else {
|
||||
include('link.php');
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if ($_POST['action']) {
|
||||
include('takedelete.php');
|
||||
@ -60,9 +50,6 @@ function class_list($Selected = 0) {
|
||||
case 'compare':
|
||||
include('compare.php');
|
||||
break;
|
||||
case 'revert':
|
||||
include('revert.php');
|
||||
break;
|
||||
case 'add_alias':
|
||||
include('add_alias.php');
|
||||
break;
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?
|
||||
View::show_header('Link an article');
|
||||
?>
|
||||
<div class="thin">
|
||||
<div class="box pad">
|
||||
<form class="add_form" name="aliases" action="wiki.php" method="post">
|
||||
<input type="hidden" name="action" value="link" />
|
||||
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
||||
<div>
|
||||
<p>Paste a wiki link into the box below to link this search string or article name to the appropriate article.</p>
|
||||
<strong>Link </strong> <input type="text" name="alias" size="20" value="<?=display_str($Alias->convert($_GET['alias']))?>" />
|
||||
to <strong>URL</strong> <input type="text" name="url" size="50" maxlength="150" />
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<? View::show_footer(); ?>
|
@ -2,9 +2,9 @@
|
||||
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
|
||||
error(404);
|
||||
}
|
||||
$ArticleID = $_GET['id'];
|
||||
$ArticleID = (int)$_GET['id'];
|
||||
|
||||
$Latest = $Alias->article($ArticleID);
|
||||
$Latest = Wiki::get_article($ArticleID);
|
||||
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Latest);
|
||||
if ($Read > $LoggedUser['EffectiveClass']) {
|
||||
error(404);
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
if (empty($_GET['nojump'])) {
|
||||
$ArticleID = $Alias->to_id($_GET['search']);
|
||||
if ($ArticleID) { //Found Article
|
||||
$ArticleID = Wiki::alias_to_id($_GET['search']);
|
||||
if ($ArticleID) {
|
||||
//Found the article!
|
||||
header('Location: wiki.php?action=article&id='.$ArticleID);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +72,7 @@
|
||||
<div class="header">
|
||||
<h2>Search articles</h2>
|
||||
<div class="linkbox">
|
||||
<a href="wiki.php?action=create&alias=<?=display_str($Alias->convert($_GET['search']))?>" class="brackets">Create an article</a> <a href="wiki.php?action=link&alias=<?=display_str($Alias->convert($_GET['search']))?>" class="brackets">Link this search</a>
|
||||
<a href="wiki.php?action=create&alias=<?=display_str(Wiki::normalize_alias($_GET['search']))?>" class="brackets">Create an article</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -54,25 +54,15 @@
|
||||
|
||||
$ArticleID = $DB->inserted_id();
|
||||
|
||||
/*
|
||||
$NewAlias = $Alias->convert($_POST['alias']);
|
||||
if ($NewAlias != '') {
|
||||
$DB->query("
|
||||
INSERT INTO wiki_aliases (Alias, ArticleID)
|
||||
VALUES ('$NewAlias', '$ArticleID')");
|
||||
}
|
||||
*/
|
||||
$TitleAlias = $Alias->convert($_POST['title']);
|
||||
if ($TitleAlias != $Alias) {
|
||||
$TitleAlias = Wiki::normalize_alias($_POST['title']);
|
||||
$Dupe = Wiki::alias_to_id($_POST['title']);
|
||||
if ($TitleAlias != '' && $Dupe === false) {
|
||||
$DB->query("
|
||||
INSERT INTO wiki_aliases (Alias, ArticleID)
|
||||
VALUES ('".db_string($TitleAlias)."', '$ArticleID')");
|
||||
Wiki::flush_aliases();
|
||||
}
|
||||
|
||||
$Alias->flush();
|
||||
|
||||
Misc::write_log("Wiki article $ArticleID (".$_POST['title'].") was created by ".$LoggedUser['Username']);
|
||||
|
||||
header("Location: wiki.php?action=article&id=$ArticleID");
|
||||
|
||||
?>
|
||||
|
@ -1,16 +1,15 @@
|
||||
<?
|
||||
authorize();
|
||||
|
||||
include(SERVER_ROOT.'/classes/validate.class.php');
|
||||
$Val = new VALIDATE;
|
||||
|
||||
if (!is_number($_POST['id']) || $_POST['id'] == '') {
|
||||
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);
|
||||
$ArticleID = $_POST['id'];
|
||||
|
||||
if ($Err) {
|
||||
error($Err);
|
||||
}
|
||||
@ -18,8 +17,8 @@
|
||||
$P = array();
|
||||
$P = db_array($_POST);
|
||||
|
||||
$Article = $Alias->article($ArticleID);
|
||||
list($Revision, $Title, $Body, $CurRead, $CurEdit, $Date, $Author) = array_shift($Article);
|
||||
$Article = Wiki::get_article($ArticleID);
|
||||
list($OldRevision, $OldTitle, $OldBody, $CurRead, $CurEdit, $OldDate, $OldAuthor) = array_shift($Article);
|
||||
if ($CurEdit > $LoggedUser['EffectiveClass']) {
|
||||
error(403);
|
||||
}
|
||||
@ -42,19 +41,22 @@
|
||||
}
|
||||
|
||||
$MyRevision = $_POST['revision'];
|
||||
if ($MyRevision != $Revision) {
|
||||
if ($MyRevision != $OldRevision) {
|
||||
error('This article has already been modified from its original version.');
|
||||
}
|
||||
|
||||
// Store previous revision
|
||||
$DB->query("
|
||||
INSERT INTO wiki_revisions
|
||||
(ID, Revision, Title, Body, Date, Author)
|
||||
VALUES
|
||||
('".db_string($ArticleID)."', '".db_string($Revision)."', '".db_string($Title)."', '".db_string($Body)."', '".db_string($Date)."', '".db_string($Author)."')");
|
||||
('".db_string($ArticleID)."', '".db_string($OldRevision)."', '".db_string($OldTitle)."', '".db_string($OldBody)."', '".db_string($OldDate)."', '".db_string($OldAuthor)."')");
|
||||
|
||||
// Update wiki entry
|
||||
$SQL = "
|
||||
UPDATE wiki_articles
|
||||
SET
|
||||
Revision = '".db_string($Revision + 1)."',
|
||||
Revision = '".db_string($OldRevision + 1)."',
|
||||
Title = '$P[title]',
|
||||
Body = '$P[body]',";
|
||||
if ($Read && $Edit) {
|
||||
@ -67,6 +69,6 @@
|
||||
Author = '$LoggedUser[ID]'
|
||||
WHERE ID = '$P[id]'";
|
||||
$DB->query($SQL);
|
||||
$Cache->delete_value("wiki_article_$ArticleID");
|
||||
Wiki::flush_article($ArticleID);
|
||||
|
||||
header("Location: wiki.php?action=article&id=$ArticleID");
|
||||
?>
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?
|
||||
authorize();
|
||||
|
||||
if (preg_match('/^'.SITELINK_REGEX.'\/wiki\.php\?action=article\&id=([0-9]+)/i',$_POST['url'],$Match)) {
|
||||
$ArticleID = $Match[2];
|
||||
}
|
||||
if (preg_match('/^'.SITELINK_REGEX.'\/wiki\.php\?action=article\&name=(.+)/i',$_POST['url'],$Match)) {
|
||||
$ArticleID = $Alias->to_id($Match[2]);
|
||||
}
|
||||
if (!$ArticleID) {
|
||||
error('Unable to link alias to an article.');
|
||||
}
|
||||
$NewAlias = $Alias->convert($_POST['alias']);
|
||||
if ($NewAlias != '') {
|
||||
$DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('$NewAlias', '$ArticleID')");
|
||||
$Alias->flush();
|
||||
}
|
||||
|
||||
header('Location: wiki.php?action=article&id='.$ArticleID);
|
||||
?>
|
Loading…
Reference in New Issue
Block a user