Skip to content

Instantly share code, notes, and snippets.

Created October 24, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2cfd878f3ee5d70b3e40affbc1d4bf3f to your computer and use it in GitHub Desktop.
Save anonymous/2cfd878f3ee5d70b3e40affbc1d4bf3f to your computer and use it in GitHub Desktop.
$days = db_select("SELECT * FROM mybb_stats ORDER BY dateline");
$posts = db_column("SELECT dateline FROM mybb_posts ORDER BY dateline");
$threads = db_column("SELECT dateline FROM mybb_threads ORDER BY dateline");
$users = db_column("SELECT regdate FROM mybb_users ORDER BY regdate");
$posts_i = 0;
$threads_i = 0;
$users_i = 0;
$posts_total = 0;
$threads_total = 0;
$users_total = 0;
foreach ( $days as $day )
{
for ( ; isset($posts[$posts_i]) && $posts[$posts_i] < $day['dateline']; $posts_i++ )
$posts_total ++;
for ( ; isset($threads[$threads_i]) && $threads[$threads_i] < $day['dateline']; $threads_i++ )
$threads_total ++;
for ( ; isset($users[$users_i]) && $users[$users_i] < $day['dateline']; $users_i++ )
$users_total ++;
if ( $day['numposts'] != $posts_total || $day['numthreads'] != $threads_total || $day['numusers'] != $users_total )
db_execute("UPDATE mybb_stats SET numposts = '".$posts_total."', numthreads = '".$threads_total."', numusers = '".$users_total."' WHERE dateline = '".$day['dateline']."' ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment