Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
Off-Topic Post Counter for Posts in Specified Forum(s) Details »»
Off-Topic Post Counter for Posts in Specified Forum(s)
Version: 1.00, by kall kall is offline
Developer Last Online: Aug 2021 Show Printable Version Email this Page

Version: 3.0.7 Rating:
Released: 03-30-2005 Last Update: Never Installs: 6
 
No support by the author.

PHP Code:
/*======================================================================*\
|| #################################################################### ||
|| # Off-Topic Post Count for Specified Forums                        # ||
|| # ---------------------------------------------------------------- # ||
|| # An NZBoards Production!                                          # ||
|| # Project Began: 0803 1 April 2005 (GMT)                           # ||
|| # Project Finished: 0818 1 April 2005   (GMT)                      # ||
|| # Version Released: 1.0                                            # ||
|| # Modification by: Kall                                            # ||
|| # This may not be redistributed without NZBoards Consent         # ||
|| # The above line applies to all you filthy pirates.                # ||
|| # Copyright 2005 [url]www.nzboards.com[/url]                                  # ||
|| #################################################################### ||
\*======================================================================*/ 
As requested by rex of www.cruiselineforums.com:

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]
ALTER TABLE `user` ADD `otposts` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL;
[/sql]
############################# SQL EDITS DONE ###############################



############################ FILE EDITS START ##############################

In includes/functions_newpost.php

Find:
PHP Code:
$doposts 'posts = posts + 1,'
Change to (make X equal to the forumid of your Off-topic forum):
PHP Code:
if ($foruminfo['forumid'] == 'X')
{
$doposts 'otposts = otposts + 1,';
}
else
{
$doposts 'posts = posts + 1,';

Save and upload.

############################ FILE EDITS DONE ###############################


############################ TEMPLATE EDITS START ##########################

In postbit (or postbit_legacy) find:
HTML Code:
$vbphrase[posts]: $post[posts]</div>
Under, add:
HTML Code:
<div class="smallfont" name="Off-Topic Posts">OT Posts: $post[otposts]</div>
############################ TEMPLATE EDITS DONE ###########################


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: https://vborg.vbsupport.ru/showpost....2&postcount=14

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 04-01-2005, 11:51 PM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Carnage-
mmm true...

i think it should be easy to do thou, just copy the update posts code and change this query:

PHP Code:
$forums $DB_site->query("
        SELECT forumid
        FROM " 
TABLE_PREFIX "forum AS forum
        WHERE (forum.options & 
$_FORUMOPTIONS[countposts])
    "
); 
i think the following should do it:

PHP Code:
$forums $DB_site->query("
        SELECT forumid
        FROM " 
TABLE_PREFIX "forum AS forum
        WHERE !(forum.options & 
$_FORUMOPTIONS[countposts])
    "
); 
alternativly you could try manually setting the folowing variable:

$gotforums = '';

to
$gotforums = '1,2,3';

where 1,2 and 3 are the forum ids of the forums you wish to count
Good stuff..thanks for that.

I don't really feel comfortable playing around with those things, but if anyone wnats to add this and see if it works for them...
Reply With Quote
  #13  
Old 04-03-2005, 10:39 AM
Carnage Carnage is offline
 
Join Date: Jan 2005
Location: uk
Posts: 760
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

when i've got more time, ie when i'm not about to go on holiday :P i'll have a play arround and get something fully working.
Reply With Quote
  #14  
Old 04-03-2005, 11:10 AM
Snow's Avatar
Snow Snow is offline
 
Join Date: Jul 2004
Posts: 134
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If we wanted to include a number of forums as off-topic forums, how would we do this? I've replaced x with the forumids which I want to count in the off-topic post count and seperated them with a comma but it doesn't seem to be working.
Code:
if ($foruminfo['forumid'] == '39,63,64,51')
Reply With Quote
  #15  
Old 04-07-2005, 12:07 AM
Dan's Avatar
Dan Dan is offline
 
Join Date: Dec 2002
Location: Titusville, Florida
Posts: 1,787
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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');
}
}
Add Below:

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&amp;startat=$finishat&amp;perpage=$perpage\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_post_counts_successfully');
}
}
Remember to change X in the above code
Code:
$gootforums = 'X';
To whatever your off topic forums are.


Now Find:

Code:
print_submit_row($vbphrase['update_post_counts']);
Add Below:

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");
And there you go! Now you can up date it easily!
Reply With Quote
  #16  
Old 04-07-2005, 05:00 AM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good stuff Dan, I'll reference it in the first post.

Thanks.
Reply With Quote
  #17  
Old 04-07-2005, 09:53 AM
Snow's Avatar
Snow Snow is offline
 
Join Date: Jul 2004
Posts: 134
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dan
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');
}
}
Add Below:

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&amp;startat=$finishat&amp;perpage=$perpage\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_post_counts_successfully');
}
}
Remember to change X in the above code
Code:
$gootforums = 'X';
To whatever your off topic forums are.


Now Find:

Code:
print_submit_row($vbphrase['update_post_counts']);
Add Below:

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");
And there you go! Now you can up date it easily!
Thank you works great at updating OT posts. Only one point, it doesn't seem to update the normal posts count though, that stays the same as before so if a member had a total of 50 posts, 25 of which are OT posts, before adding this hack and updating OT posts, they find themselves with posts 50 PLUS OT posts 25 giving a total of 75 posts. I've tried updating post counts but it doesn't work. Anyone know how to get round this problem?
Reply With Quote
  #18  
Old 04-07-2005, 11:27 AM
Dan's Avatar
Dan Dan is offline
 
Join Date: Dec 2002
Location: Titusville, Florida
Posts: 1,787
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Snow
Thank you works great at updating OT posts. Only one point, it doesn't seem to update the normal posts count though, that stays the same as before so if a member had a total of 50 posts, 25 of which are OT posts, before adding this hack and updating OT posts, they find themselves with posts 50 PLUS OT posts 25 giving a total of 75 posts. I've tried updating post counts but it doesn't work. Anyone know how to get round this problem?
We need the hack to include forums that don't have counting enabled which I can't figure out how to do.
Reply With Quote
  #19  
Old 04-07-2005, 12:20 PM
Snow's Avatar
Snow Snow is offline
 
Join Date: Jul 2004
Posts: 134
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dan
We need the hack to include forums that don't have counting enabled which I can't figure out how to do.
hmm, you just given me an idea..... far from ideal, but setting the OT forum in question to not count posts and then updating post counts brings the post count down, then resetting it to count posts and updating OT post counts seems to count all the OT posts..... it looks like it's worked.
Reply With Quote
  #20  
Old 06-19-2005, 02:37 PM
quachvu quachvu is offline
 
Join Date: Jun 2004
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how can man fix this script, so that it just count new threads in a forum for Off Topic, and dont count post reply of that thread?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13454 seconds
  • Memory Usage 2,325KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (11)bbcode_code
  • (2)bbcode_html
  • (5)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete