diff --git a/classes/class_alias.php b/classes/class_alias.php index 093ccbe2..23b39ca4 100644 --- a/classes/class_alias.php +++ b/classes/class_alias.php @@ -35,7 +35,7 @@ function to_id($Alias) { return $ArticleID; } */ - function article($ArticleID) { + function article($ArticleID, $Error = true) { global $Cache, $DB; $Contents = $Cache->get_value('wiki_article_'.$ArticleID); if(!$Contents){ @@ -55,7 +55,7 @@ function article($ArticleID) { LEFT JOIN users_main AS u ON u.ID=w.Author WHERE w.ID='$ArticleID' GROUP BY w.ID"); - if(!$DB->record_count()) { error(404); } + if(!$DB->record_count() && $Error) { error(404); } $Contents = $DB->to_array(); $Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600*24*14); } diff --git a/sections/ajax/index.php b/sections/ajax/index.php index aa382968..b0999d00 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -12,11 +12,11 @@ header('Content-Type: application/json; charset=utf-8'); -switch ($_GET['action']){ +switch ($_GET['action']) { // things that (may be) used on the site case 'upload_section': // Gets one of the upload forms - require(SERVER_ROOT.'/sections/ajax/upload.php'); + require(SERVER_ROOT . '/sections/ajax/upload.php'); break; case 'preview': require('preview.php'); @@ -31,7 +31,7 @@ require('grab_report.php'); break; case 'stats': - require(SERVER_ROOT.'/sections/ajax/stats.php'); + require(SERVER_ROOT . '/sections/ajax/stats.php'); break; case 'checkprivate': @@ -42,78 +42,82 @@ require('torrentgroup.php'); break; case 'tcomments': - require(SERVER_ROOT.'/sections/ajax/tcomments.php'); + require(SERVER_ROOT . '/sections/ajax/tcomments.php'); break; case 'user': - require(SERVER_ROOT.'/sections/ajax/user.php'); + require(SERVER_ROOT . '/sections/ajax/user.php'); break; case 'forum': - require(SERVER_ROOT.'/sections/ajax/forum/index.php'); + require(SERVER_ROOT . '/sections/ajax/forum/index.php'); break; case 'top10': - require(SERVER_ROOT.'/sections/ajax/top10/index.php'); + require(SERVER_ROOT . '/sections/ajax/top10/index.php'); break; case 'browse': - require(SERVER_ROOT.'/sections/ajax/browse.php'); + require(SERVER_ROOT . '/sections/ajax/browse.php'); break; case 'usersearch': - require(SERVER_ROOT.'/sections/ajax/usersearch.php'); + require(SERVER_ROOT . '/sections/ajax/usersearch.php'); break; case 'requests': - require(SERVER_ROOT.'/sections/ajax/requests.php'); + require(SERVER_ROOT . '/sections/ajax/requests.php'); break; case 'artist': - require(SERVER_ROOT.'/sections/ajax/artist.php'); + require(SERVER_ROOT . '/sections/ajax/artist.php'); break; case 'inbox': - require(SERVER_ROOT.'/sections/ajax/inbox/index.php'); + require(SERVER_ROOT . '/sections/ajax/inbox/index.php'); break; case 'subscriptions': - require(SERVER_ROOT.'/sections/ajax/subscriptions.php'); + require(SERVER_ROOT . '/sections/ajax/subscriptions.php'); break; case 'index': - require(SERVER_ROOT.'/sections/ajax/info.php'); + require(SERVER_ROOT . '/sections/ajax/info.php'); break; case 'bookmarks': - require(SERVER_ROOT.'/sections/ajax/bookmarks/index.php'); + require(SERVER_ROOT . '/sections/ajax/bookmarks/index.php'); break; case 'announcements': - require(SERVER_ROOT.'/sections/ajax/announcements.php'); - break; + require(SERVER_ROOT . '/sections/ajax/announcements.php'); + break; case 'notifications': - require(SERVER_ROOT.'/sections/ajax/notifications.php'); + require(SERVER_ROOT . '/sections/ajax/notifications.php'); break; case 'request': - require(SERVER_ROOT.'/sections/ajax/request.php'); + require(SERVER_ROOT . '/sections/ajax/request.php'); break; case 'loadavg': - require(SERVER_ROOT.'/sections/ajax/loadavg.php'); + require(SERVER_ROOT . '/sections/ajax/loadavg.php'); break; case 'better': - require(SERVER_ROOT.'/sections/ajax/better/index.php'); + require(SERVER_ROOT . '/sections/ajax/better/index.php'); break; case 'password_validate': - require(SERVER_ROOT.'/sections/ajax/password_validate.php'); - break; + require(SERVER_ROOT . '/sections/ajax/password_validate.php'); + break; case 'similar_artists': - require(SERVER_ROOT.'/sections/ajax/similar_artists.php'); - break; + require(SERVER_ROOT . '/sections/ajax/similar_artists.php'); + break; case 'userhistory': - require(SERVER_ROOT.'/sections/ajax/userhistory/index.php'); - break; + require(SERVER_ROOT . '/sections/ajax/userhistory/index.php'); + break; case 'votefavorite': - require(SERVER_ROOT.'/sections/ajax/takevote.php'); - break; + require(SERVER_ROOT . '/sections/ajax/takevote.php'); + break; + case 'wiki': + require(SERVER_ROOT . '/sections/ajax/wiki.php'); + break; default: // If they're screwing around with the query string print json_encode(array('status' => 'failure')); } -function pullmediainfo($Array) { +function pullmediainfo($Array) +{ $NewArray = array(); foreach ($Array as $Item) { $NewArray[] = array( - 'id' => (int) $Item['id'], + 'id' => (int)$Item['id'], 'name' => $Item['name'] ); } diff --git a/sections/ajax/wiki.php b/sections/ajax/wiki.php new file mode 100644 index 00000000..b0910b37 --- /dev/null +++ b/sections/ajax/wiki.php @@ -0,0 +1,65 @@ + +include(SERVER_ROOT . '/classes/class_text.php'); +include(SERVER_ROOT . '/classes/class_alias.php'); +$Text = new TEXT(true); +$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']); +} else { + print json_encode( + array( + 'status' => 'error', + ) + ); + die(); +} + +if (!$ArticleID) { //No article found + print json_encode( + array( + 'status' => 'not found', + ) + ); + die(); +} +$Article = $Alias->article($ArticleID, false); + +if (!$Article) { + print json_encode( + array( + 'status' => 'not found', + ) + ); + die(); +} +list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article); +if ($Read > $LoggedUser['EffectiveClass']) { + print json_encode( + array( + 'status' => 'You must be a higher user class to view this wiki article', + ) + ); + die(); +} + +$TextBody = $Text->full_format($Body, false); + +print json_encode( + array( + 'status' => 'success', + 'response' => array( + 'title' => $Title, + 'bbBody' => $Body, + 'body' => $TextBody, + 'aliases' => $Aliases, + 'authorID' => (int)$AuthorID, + 'authorName' => $AuthorName, + 'date' => $Date, + 'revision' => (int)$Revision + ) + )); +?> \ No newline at end of file diff --git a/sections/reports/reports.php b/sections/reports/reports.php index 15d9f636..030e4b50 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -210,7 +210,7 @@