Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 12-05-2000 Last Update: Never Installs: 0
 
No support by the author.

Well, here's a little script I wrote to update the post count stored in the user table with the actual number of
posts that user has made. When would you want to run something like this? Well, normally you should
never have to, but in case your user's post counts become inaccurate, you can reset them with this.

The main reason I wrote this, however, was to update a user's post count excluding certain fourms, for
example if you have a testing forum and don't want those posts included in the user's total. If you would
like to do something like this, just look at the comments in the script and make the changes needed.

Just name upload this code to admin/usercounts.php

Enjoy!

Code:
<?php

if (function_exists("set_time_limit")==1 and get_cfg_var("safe_mode")==0) {
  set_time_limit(1200);
}

require ("global.php");

?>
<html>
<head>
<STYLE type=text/css>
BODY {
  font-family: arial;
  font-size: 10pt;
  font-variant: normal;
  font-style: normal;
}
P {
  font-family: arial;
  font-size: 10pt;
  font-variant: normal;
  font-style: normal;
}
</STYLE>
</head>
<body>

<?php
// ###################### Start user choices #######################
if (isset($action)==0 or $action=="") {

  echo "<p><b>Update User Counts</b> - updates user post counts, excluding certain forums<br>\n";

  echo doformheader("usercounts","updateuser");
  echo "<table border=0>";
  echo makeinputcode("Number of users to do per cycle","perpage","500");
  echo doformfooter();

}

// ###################### Start update user #######################
if ($action=="updateuser") {
  if (isset($perpage)==0 or $perpage=="") {
    $perpage=500;
  }
  if (isset($startat)==0 or $startat=="") {
    $startat=0;
  }
  $finishat=$startat+$perpage;

  echo "<p>User ids:</p>";

  $users=$DB_site->query("SELECT userid,username,posts FROM user WHERE userid>=$startat AND userid<$finishat ORDER BY userid DESC");
  while ($user=$DB_site->fetch_array($users)) {

    $userid=$user[userid];

    // update user stuff
    
    // If you want to exclude a certain forum, just add it to the query below
    // Ex.: AND thread.forumid<>1

    if ($posts=$DB_site->query_first("SELECT COUNT(post.postid) AS numberposts FROM post,thread WHERE thread.threadid=post.threadid  AND post.userid=$userid")) {
       $numposts=$posts[numberposts];
    } else {
      $numposts=0;
    }

    $DB_site->query("UPDATE user SET user.posts=$numposts WHERE userid=$user[userid]");

    echo "$user[userid] $user[username] $numposts <br>\n";
    flush();

  }
  if ($checkmore=$DB_site->query_first("SELECT userid FROM user WHERE userid>=$finishat")) {
    echo "<script language=\"javascript\">window.location=\"usercounts.php?action=updateuser&startat=$finishat&perpage=$perpage\";</script>";
    echo "<p><a href=\"usercounts.php?action=updateuser&startat=$finishat&perpage=$perpage\">Click here to continue updating users</a></p>";
  } else {
    echo "<p>All done!</p>";
  }

}


?>
</body>
</html>

Show Your Support

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

Comments
  #12  
Old 05-01-2001, 01:50 AM
bira's Avatar
bira bira is offline
 
Join Date: Nov 2001
Posts: 387
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Chris, question: since I used to prune threads/posts on UBB (up until I moved to vB a year ago), wouldn't the post count now REDUCE for the users, because it won't include the posts that are not in the database?
Reply With Quote
  #13  
Old 05-01-2001, 09:23 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works great, and ist just what i needed
Reply With Quote
  #14  
Old 07-13-2001, 04:31 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[B[Chris[/B]

I used your hack and it worked great.

I have one problem though. My total post count is lower than the sum of all member posts. Is there away I could add the difference to the total post sum?
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 10:12 PM.


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.04043 seconds
  • Memory Usage 2,228KB
  • Queries Executed 18 (?)
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
  • (1)bbcode_code
  • (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
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (4)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
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_imicons
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete