1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
|
if($action=="boardposts") {
$result=$db->query("SELECT boardid FROM bb".$n."_boards ORDER BY boardid ASC");
while($row=$db->fetch_array($result)) {
$postcount = $db->query_first("SELECT COUNT(*) AS countp FROM bb".$n."_posts p LEFT JOIN bb".$n."_threads t ON (p.threadid=t.threadid) WHERE t.boardid='$row[boardid]' AND p.visible=1");
$board = $db->query_first("SELECT childlist FROM bb".$n."_boards WHERE boardid='$row[boardid]'");
$count = $postcount[countp];
if($board[childlist] != "0") {
$childlist = explode(",", $board[childlist]);
for($i = 0; $i < count($childlist); $i++ ) {
if($childlist[$i] != "0") {
$postcount_childboard = $db->query_first("SELECT COUNT(*) AS countp FROM bb".$n."_posts p LEFT JOIN bb".$n."_threads t ON (p.threadid=t.threadid) WHERE t.boardid='$childlist[$i]' AND p.visible=1");
$count = $count + $postcount_childboard[countp];
}
}
}
$db->unbuffered_query("UPDATE bb".$n."_boards SET postcount='$count' WHERE boardid='$row[boardid]'",1);
}
eval("print(\"".gettemplate("working_done")."\");");
}
if($action=="boardthreads") {
$result=$db->query("SELECT boardid FROM bb".$n."_boards ORDER BY boardid ASC");
while($row=$db->fetch_array($result)) {
$threadcount=$db->query_first("SELECT COUNT(*) AS countthreads FROM bb".$n."_threads WHERE boardid='$row[boardid]' AND visible=1");
$board = $db->query_first("SELECT childlist FROM bb".$n."_boards WHERE boardid='$row[boardid]'");
$count = $threadcount[countthreads];
if($board[childlist] != "0") {
$childlist = explode(",", $board[childlist]);
for($i = 0; $i < count($childlist); $i++ ) {
if($childlist[$i] != "0") {
$threadcount_childboard = $db->query_first("SELECT COUNT(*) AS countthreads FROM bb".$n."_threads WHERE boardid='$childlist[$i]' AND visible=1");
$count = $count + $threadcount_childboard[countthreads];
}
}
}
$db->unbuffered_query("UPDATE bb".$n."_boards SET threadcount='$count' WHERE boardid='$row[boardid]'",1);
}
eval("print(\"".gettemplate("working_done")."\");");
}
if($action=="threadreplys") {
$result=$db->query("SELECT threadid FROM bb".$n."_threads ORDER BY threadid ASC");
while($row=$db->fetch_array($result)) {
$threadreply=$db->query_first("SELECT COUNT(postid) AS countreply FROM bb".$n."_posts p LEFT JOIN bb".$n."_threads t ON (p.threadid=t.threadid) WHERE t.threadid='$row[threadid]'");
$countreply=$threadreply[countreply]-1;
$db->unbuffered_query("UPDATE bb".$n."_threads SET replycount='$countreply' WHERE threadid='$row[threadid]'",1);
}
eval("print(\"".gettemplate("working_done")."\");");
} |