This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/main/forums/library/reply.inc

34 lines
1,000 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class main_forums_reply {
function main_forums_reply($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($a, $post, $sub, $txt, $ec, $es) {
$tm = time();
$fid = $post['fid']; $tid = $post['tid']; $pid = $post['id'];
$qs = "INSERT INTO f_post(forum,topic,reply_to,author,moment,title,contents,enable_code,enable_smileys) VALUES ("
. "$fid,$tid,$pid,$a,$tm,'".addslashes($sub)."','".addslashes($txt)."',"
. dbBool($ec) . "," . dbBool($es) . ")";
if (!$this->db->query($qs)) {
return false;
}
$q = $this->db->query("SELECT id FROM f_post WHERE topic=$tid AND reply_to=$pid AND author=$a AND moment=$tm ORDER BY id DESC LIMIT 1");
if (!$q || dbCount($q) != 1) {
return false;
}
list($pid) = dbFetchArray($q);
$this->db->query("UPDATE f_topic SET last_post=$pid WHERE id=$tid");
$this->db->query("UPDATE f_forum SET posts=posts+1,last_post=$pid WHERE id=$fid");
$this->lib->call('markUnread', $tid,$a);
return $pid;
}
}
?>