fetchq("SELECT forum,closed,title,icon,replies,lastpostdate,lastposter,sticky FROM threads WHERE id=$id");
$forumid = $thread['forum'];
$posticons = file('posticons.dat');
if (@mysql_num_rows($sql->query("SELECT user FROM forummods WHERE forum={$forumid} and user={$loguserid}")))
$ismod = 1;
if (!$forumid)
$ismod = 0;
elseif ($sql->resultq("SELECT minpower FROM forums WHERE id={$forumid}") > $loguser['powerlevel'])
$ismod = 0;
if (!$ismod)
errorpage("You aren't allowed to edit this thread.",'the thread',"thread.php?id={$id}");
// Quickmod
if (substr($_GET['action'], 0, 1) == 'q') {
switch ($_GET['action']) {
case 'qstick': $update = 'sticky=1'; break;
case 'qunstick': $update = 'sticky=0'; break;
case 'qclose': $update = 'closed=1'; break;
case 'qunclose': $update = 'closed=0'; break;
default: return header("Location: thread.php?id={$id}");
}
$sql->query("UPDATE threads SET {$update} WHERE id={$id}");
return header("Location: thread.php?id={$id}");
}
elseif ($_POST['action'] == "trashthread") {
$sql->query("UPDATE threads SET sticky=0, closed=1, forum=$trashid WHERE id='$id'");
$numposts = $thread['replies'] + 1;
$t1 = $sql->fetchq("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forumid ORDER BY lastpostdate DESC LIMIT 1");
$t2 = $sql->fetchq("SELECT lastpostdate,lastposter FROM threads WHERE forum=$trashid ORDER BY lastpostdate DESC LIMIT 1");
$sql->query("UPDATE forums SET numposts=numposts-$numposts,numthreads=numthreads-1,lastpostdate=$t1[lastpostdate],lastpostuser=$t1[lastposter] WHERE id=$forumid");
$sql->query("UPDATE forums SET numposts=numposts+$numposts,numthreads=numthreads+1,lastpostdate=$t2[lastpostdate],lastpostuser=$t2[lastposter] WHERE id=$trashid");
// Yeah whatever
errorpage("Thread successfully trashed.",'return to the thread',"thread.php?id=$id");
}
elseif ($_POST['action'] == 'editthread') {
$posticons[$iconid]=str_replace("\n",'',$posticons[$iconid]);
$icon=$posticons[$iconid];
if($custposticon) $icon=$custposticon;
$sql->query("UPDATE `threads` SET `forum` = '$forummove', `closed` = '$closed', `title` = '$subject', `icon` = '$icon', `sticky` = '$sticky' WHERE `id` = '$id'");
if($forummove!=$forumid) {
$numposts=$thread['replies']+1;
$t1 = $sql->fetchq("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forumid ORDER BY lastpostdate DESC LIMIT 1");
$t2 = $sql->fetchq("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forummove ORDER BY lastpostdate DESC LIMIT 1");
$sql->query("UPDATE forums SET numposts=numposts-$numposts,numthreads=numthreads-1,lastpostdate=$t1[lastpostdate],lastpostuser=$t1[lastposter] WHERE id=$forumid");
$sql->query("UPDATE forums SET numposts=numposts+$numposts,numthreads=numthreads+1,lastpostdate=$t2[lastpostdate],lastpostuser=$t2[lastposter] WHERE id=$forummove");
}
errorpage("Thank you, $loguser[name], for editing the thread.",'return to the thread',"thread.php?id=$id");
}
// Deletion disallowed for now
/* elseif ($_POST['action'] == 'deletethread') {
$sql->query("DELETE FROM threads WHERE id=$id");
$sql->query("DELETE FROM posts WHERE thread=$id");
$numdeletedposts=$thread[replies]+1;
$t1 = $sql->fetchq("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forumid ORDER BY lastpostdate DESC LIMIT 1");
$sql->query("UPDATE forums SET numposts=numposts-$numdeletedposts,numthreads=numthreads-1,lastpostdate=$t1[lastpostdate],lastpostuser=$t1[lastposter] WHERE id=$forumid");
errorpage("Thank you, $loguser[name], for deleting the thread.",'return to the thread',"thread.php?id=$id");
} */
elseif ($_GET['action'] == 'trashthread') {
print "$header
$tblstart