Journal Home Official Blog

3/4/2012 - How to moderate thousands of posts in vBulletin 3.x without timeout

Posted in PHP Code

I manage an old vBulletin (3.6.9) board and from time to time I need to moderate some posts/threads. One of the problems I have is, as the the only moderator, I sometime have 5000 or more posts/threads to moderate.

By default, vBulletin tries to display/moderate all the threads at once, this is ridiculous, even if your server can handle +5000 queries in one script your browser certainly cannot handle it, (you would need a truck load of memory to handle it).

So the best way is to edit the vBulletin code and limit the size of the posts been returned, that way you can moderate ~500 posts/threads at a time.

Look for the file called "moderate.php", it is found in the modcp folder.

Look for the code

  1. ...
  2. $moderated = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "moderation");
  3. ...

And add/replace the following limit checks to make sure it does not get out of hand.

  1. ...
  2. $moderated = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "moderation");
  3. while($moderate = $db->fetch_array($moderated))
  4. {
  5.  if($moderate['type'] == 'thread')
  6.  {
  7.   if(count($threadids) < 250)
  8.   {
  9.    $threadids[] = $moderate['threadid'];
  10.   }
  11.  }
  12.  else
  13.  {
  14.    if(count($threadids) < 500)
  15.    {
  16.      $postids[] = $moderate['postid'];
  17.    }
  18.   }
  19.   if(count($threadids) >= 500 && count($threadids) >= 250)
  20.   {
  21.     break;
  22.   }
  23. }
  24. ...

I know it would have been better to change the queries, (have 2 queries with type='thread' and limit of 250), but doing it this way makes it a little easier to explain.
Once you understand what is going on maybe you can change the code yourself to use more efficient queries.

The reason why I chose 250 threads and 500 posts? because, on my server, this seemed to be the safest way to prevent timeouts.

If you have version 4.x of vBulletin, I would be quite curious to hear how it works for you. I don't have that code, so I cannot say for sure if the same issue happens, (but I would hope that they fixed it).

Share |
6 CommentsPermanent Link
Share and enjoy
  • Digg
  • DZone
  • Netvouz
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

5/31/2011 - Restore MySQL database from sql dump file?

Posted in PHP Code

This is more of a personal note for myself because I keep forgetting the syntax :p.

When developing web applications I often, 'mess around' with the database and I then need to restore it to make sure everything is running ok, (or simply to run some kind of test again and again).
MySQL, (my current development database here), allows me to reload the db from the command line. And the command is...

z:\mysql.exe - u USERNAME -p DATABASE < dump.sql
Enter password: ********

Replace USERNAME with your database username, DATABASE with your database name and of course the 'dumpo.sql' with the name of your sql dump file.

You will then be asked to enter your password and the update should happen with not too much problems.

if you get an error message like "'mysql.exe' is not recignized as ab internal or external command, ...." this is because mysql is not in your &#xpa;th%, so you will need to run the command above with the full path where mysql.exe is located, (normally in your program files directory).

Share |
Technorati Tags: , , , ,
Filed under: , , , ,
2 CommentsPermanent Link
Share and enjoy
  • Digg
  • DZone
  • Netvouz
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb
<<Last Page • Next Page>>

About Me has created this blog for the purpose of keeping members and visitors up to date with site information.
The easiest way to stay up to date is by using the RSS/XML feed.
Place this URL within your rss aggregator and it will automatically update itself whenever a new journal entry is published.

«  March 2017  »


View my profile
Email Me
My Wall
Webmaster Forum
Free Blog
Follow JournalHome on Twitter


Ant Onaf
Silver Wind