|
Off-Topic Post Counter for Posts in Specified Forum(s)
This modification is in the archives.
PHP Code:
/*======================================================================*\
What does this hack do? Adds a new Post Counter, for off-topic posts. It enables you to define a Forum (or Forums) as 'Off-Topic Forums'. Any posts made by users in that Forum are not added to the Post count, they are added to the Off-Topic Post count instead. As a bonus, OT posting won't be rewarded with promotions or points or anything linked to $bbuserinfo[posts]. Queries to run: One Files to edit: One Templates to edit: One (postbit or postbit_legacy). ########################### SQL EDITS START ############################### Run this query: (change user to yourtableprefix_user if you use a table prefix). SQL Query: (how to run queries)
ALTER TABLE `user` ADD `otposts` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL; ############################ FILE EDITS START ############################## In includes/functions_newpost.php Find: PHP Code:
$doposts = 'posts = posts + 1,';
PHP Code:
if ($foruminfo['forumid'] == 'X')
############################ FILE EDITS DONE ############################### ############################ TEMPLATE EDITS START ########################## In postbit (or postbit_legacy) find: HTML Code:
$vbphrase[posts]: $post[posts]</div>
HTML Code:
<div class="smallfont" name="Off-Topic Posts">OT Posts: $post[otposts]</div> And you are done. Rejoice! Updates: 0850 1 April 2005 (GMT+12): Added name attribute to div tag for mouseover explanation. 1800 7 April 2005: Dan's AdminCP Update Offtopic Counter Addon: Spoiler (click to open)
Nevermind I figured it out xD
To Update Forum Posts Easily I created a easy modifcation! Find in /admincp/misc.php Code:
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_post_counts_successfully');
}
}
Code:
// ###################### Start update Off Topic Post Counts ################
if ($_REQUEST['do'] == 'updatespam')
{
if (empty($perpage))
{
$perpage = 1000;
}
echo '<p>' . $vbphrase['updating_post_counts'] . '</p>';
$forums = $DB_site->query("
SELECT forumid
FROM " . TABLE_PREFIX . "forum AS forum
WHERE !(forum.options & $_FORUMOPTIONS[countposts])
");
$gootforums = 'X';
while ($forum = $DB_site->fetch_array($forums))
{
$gootforums .= ',' . $forum['forumid'];
}
$users = $DB_site->query("SELECT userid FROM " . TABLE_PREFIX . "user WHERE userid >= $startat AND userid < $finishat ORDER BY userid DESC");
while ($user = $DB_site->fetch_array($users))
{
$totalposts = $DB_site->query_first("
SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post
INNER JOIN " . TABLE_PREFIX . "thread AS thread USING (threadid)
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog_t ON (deletionlog_t.primaryid = thread.threadid AND deletionlog_t.type = 'thread')
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog_p ON (deletionlog_p.primaryid = post.postid AND deletionlog_p.type = 'post')
WHERE post.userid = $user[userid] AND
thread.forumid IN (0$gootforums) AND
deletionlog_t.primaryid IS NULL AND
deletionlog_p.primaryid IS NULL
");
$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET otposts=$totalposts[posts] WHERE userid = $user[userid]");
echo construct_phrase($vbphrase['processing_x'], $user['userid']) . "<br />\n";
flush();
}
if ($checkmore = $DB_site->query_first("SELECT userid FROM " . TABLE_PREFIX . "user WHERE userid >= $finishat LIMIT 1"))
{
print_cp_redirect("misc.php?$session[sessionurl]do=updateposts&startat=$finishat&perpage=$perpage");
echo "<p><a href=\"misc.php?$session[sessionurl]do=updateposts&startat=$finishat&perpage=$perpage\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_post_counts_successfully');
}
}
Code:
$gootforums = 'X'; Now Find: Code:
print_submit_row($vbphrase['update_post_counts']); Code:
print_form_header('misc', 'updatespam');
print_table_header("Update Off Topic Posts", 2, 0);
print_description_row("This will update the Off Topic Post Count");
print_input_row($vbphrase['number_of_users_to_process_per_cycle'], 'perpage', 1000);
print_submit_row("Update Off Topic Posts");
Close
Download This modification is archived and cannot be downloaded. |
|||||||||