Gazelle/sections/forums/ajax_get_edit.php

77 lines
1.8 KiB
PHP
Raw Permalink 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'];
$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("
2013-11-17 08:00:47 +00:00
SELECT EditUser, EditTime, Body
FROM comments_edits
2013-06-04 08:00:34 +00:00
WHERE Page = '$Type' AND PostID = $PostID
2013-11-17 08:00:47 +00:00
ORDER BY 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) {
2013-10-01 23:08:42 +00:00
case 'forums':
2011-03-28 14:21:28 +00:00
//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;
2013-10-01 23:08:42 +00:00
case 'collages':
case 'requests':
case 'artist':
case 'torrents':
2013-06-04 08:00:34 +00:00
$DB->query("
SELECT Body
2013-08-28 23:08:41 +00:00
FROM comments
WHERE Page = '$Type' AND ID = $PostID");
2011-10-06 08:00:12 +00:00
list($Body) = $DB->next_record();
2011-03-28 14:21:28 +00:00
break;
}
}
?>
2013-12-12 08:01:01 +00:00
<?=Text::full_format($Body)?>
2011-03-28 14:21:28 +00:00
<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>
<? } ?>