vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Off-Topic Post Counter for Posts in Specified Forum(s) (https://vborg.vbsupport.ru/showthread.php?t=79131)

kall 04-01-2005 10:51 PM

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... :)

Carnage 04-03-2005 09:39 AM

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.

Snow 04-03-2005 10:10 AM

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')

Dan 04-06-2005 11:07 PM

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!

kall 04-07-2005 04:00 AM

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

Thanks. :)

Snow 04-07-2005 08:53 AM

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?

Dan 04-07-2005 10:27 AM

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. :(

Snow 04-07-2005 11:20 AM

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. :D

quachvu 06-19-2005 01:37 PM

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?


All times are GMT. The time now is 02:51 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01533 seconds
  • Memory Usage 1,760KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (11)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete