Saturnidae
Bugs!! :3
Akanjão .
<?php
define("IN_FORUM", 1);
require_once "../global.php";
$action = $bb->input['action'];
$tid = intval($bb->input['tid']);
switch($action)
{
case "lockthread":
$query = "SET locked=1";
$logtext = "Locked Thread";
break;
case "unlockthread":
$query = "SET locked=0";
$logtext = "Unlocked Thread";
break;
case "approvethread":
$query = "SET approved=1";
$logtext = "Approved Thread";
break;
case "unapprovethread":
$query = "SET approved=0";
$logtext = "Unapproved Thread";
break;
case "stickthread":
$query = "SET sticky=1";
$logtext = "Stuck Thread";
break;
case "unstickthread":
$query = "SET sticky=0";
$logtext = "Unstuck Thread";
break;
case "edittitle":
$query = "SET title='" . $db->escape($bb->input['title']) . "'";
$logtext = "Changed Thread Title";
break;
}
$db->query("UPDATE threads " . $query . " WHERE tid=" . $tid);
if($action=="edittitle")
{
//First update the subject of the first post
$query = $db->query("SELECT p.pid, p.tid, t.fid FROM posts p LEFT JOIN threads t ON (p.tid=t.tid) WHERE p.tid=$tid ORDER BY p.time ASC LIMIT 1");
$firstpost = $db->fetch_row($query);
$fid = $firstpost['fid'];
$query = $db->query("UPDATE posts SET `subject`='" . $db->escape($bb->input['title']) . "' WHERE pid=" . $firstpost['pid']);
// Now fetch the lastest thread info to make sure the forum is up to date with the name
$query = $db->query("SELECT t.*, u.username FROM threads t LEFT JOIN users u ON (t.lastposteruid=u.uid) WHERE t.fid=$fid ORDER BY t.lastposttime DESC LIMIT 1");
$lastthread = $db->fetch_row($query);
$forumupdate = array(
"lastposter" => $lastthread['username'],
"lastposteruid" => $lastthread['lastposteruid'],
"lastposttime" => $lastthread['lastposttime'],
"lastpostpid" => $lastthread['lastpostpid'],
"lastposttid" => $lastthread['tid'],
"lastposttopic" => $lastthread['title']
);
$db->update("forums", $forumupdate, "fid=" . $lastthread['fid']);
}
$moddata = array(
"tid" => $tid,
"action" => $logtext,
"type" => "thread",
"gid" => 0
);
log_mod_action($moddata);
echo $logtext;
?>