Gazelle/sections/forums/ajax_get_edit.php

80 lines
1.9 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-05-01 08:00:16 +00:00
if (!check_perms('site_admin_forums')) {
2011-03-28 14:21:28 +00:00
error(403);
}
2013-05-01 08:00:16 +00:00
if (empty($_GET['postid']) || !is_number($_GET['postid'])) {
2011-03-28 14:21:28 +00:00
die();
}
$PostID = $_GET['postid'];
2013-05-01 08:00:16 +00:00
if (!isset($_GET['depth']) || !is_number($_GET['depth'])) {
2011-03-28 14:21:28 +00:00
die();
}
$Depth = $_GET['depth'];
2013-05-01 08:00:16 +00:00
if (empty($_GET['type']) || !in_array($_GET['type'], array('forums', 'collages', 'requests', 'torrents', 'artist'))) {
2011-03-28 14:21:28 +00:00
die();
}
$Type = $_GET['type'];
2013-05-27 08:00:58 +00:00
include(SERVER_ROOT.'/classes/text.class.php');
2011-03-28 14:21:28 +00:00
$Text = new TEXT;
$Edits = $Cache->get_value($Type.'_edits_'.$PostID);
2013-05-01 08:00:16 +00:00
if (!is_array($Edits)) {
2013-06-04 08:00:34 +00:00
$DB->query("
SELECT ce.EditUser, ce.EditTime, ce.Body
FROM comments_edits AS ce
WHERE Page = '$Type' AND PostID = $PostID
ORDER BY ce.EditTime DESC");
2011-03-28 14:21:28 +00:00
$Edits = $DB->to_array();
$Cache->cache_value($Type.'_edits_'.$PostID, $Edits, 0);
}
2013-02-22 08:00:24 +00:00
2012-03-28 08:00:20 +00:00
list($UserID, $Time) = $Edits[$Depth];
2013-05-01 08:00:16 +00:00
if ($Depth != 0) {
2012-03-28 08:00:20 +00:00
list(,,$Body) = $Edits[$Depth - 1];
2011-03-28 14:21:28 +00:00
} else {
//Not an edit, have to get from the original
2013-05-01 08:00:16 +00:00
switch ($Type) {
2011-03-28 14:21:28 +00:00
case 'forums' :
//Get from normal forum stuffs
2013-06-04 08:00:34 +00:00
$DB->query("
SELECT Body
FROM forums_posts
WHERE ID = $PostID");
2011-10-06 08:00:12 +00:00
list($Body) = $DB->next_record();
2011-03-28 14:21:28 +00:00
break;
case 'collages' :
case 'requests' :
2012-10-27 08:00:09 +00:00
case 'artist' :
2011-03-28 14:21:28 +00:00
case 'torrents' :
2013-06-04 08:00:34 +00:00
$DB->query("
SELECT Body
FROM {$Type}_comments
WHERE ID = $PostID");
2011-10-06 08:00:12 +00:00
list($Body) = $DB->next_record();
2011-03-28 14:21:28 +00:00
break;
}
}
?>
<?=$Text->full_format($Body)?>
<br />
<br />
2013-05-01 08:00:16 +00:00
<? if ($Depth < count($Edits)) { ?>
2011-03-28 14:21:28 +00:00
<a href="#edit_info_<?=$PostID?>" onclick="LoadEdit('<?=$Type?>', <?=$PostID?>, <?=($Depth + 1)?>); return false;">&laquo;</a>
<?=(($Depth == 0) ? 'Last edited by' : 'Edited by')?>
2013-06-04 08:00:34 +00:00
<?=Users::format_username($UserID, false, false, false) ?> <?=time_diff($Time, 2, true, true)?>
2011-03-28 14:21:28 +00:00
<? } else { ?>
<em>Original Post</em>
<? }
2013-05-01 08:00:16 +00:00
if ($Depth > 0) { ?>
2011-03-28 14:21:28 +00:00
<a href="#edit_info_<?=$PostID?>" onclick="LoadEdit('<?=$Type?>', <?=$PostID?>, <?=($Depth - 1)?>); return false;">&raquo;</a>
<? } ?>