As a temporarily measure, I've inserted a quick month check so it displays to members in the Last Month posts field: Temporarily unavailable.
Anyhow, here's the code:
File: ncludes/usercp_viewprofile.php
Code: Select all
// First, work how many posts they've made this month
$current_time = time();
$this_months_posts = 0;
$year = date('Y', $current_time);
$month [0] = mktime (0,0,0,1,1, $year);
$month [1] = $month [0] + 2678400;
$month [2] = mktime (0,0,0,3,1, $year);
$month [3] = $month [2] + 2678400;
$month [4] = $month [3] + 2592000;
$month [5] = $month [4] + 2678400;
$month [6] = $month [5] + 2592000;
$month [7] = $month [6] + 2678400;
$month [8] = $month [7] + 2678400;
$month [9] = $month [8] + 2592000;
$month [10] = $month [9] + 2678400;
$month [11] = $month [10] + 2592000;
$month [12] = $month [11] + 2592000;
$arr_num = ( date('n')-1);
$time_thismonth = $month[$arr_num];
$sql = "SELECT count(post_id) as monthly_posts
FROM " . POSTS_TABLE . "
WHERE poster_id = {$profiledata['user_id']}
AND post_time > '" . intval($time_thismonth) . "'";
if(! $result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain last months postcount.', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$this_months_posts = $row['monthly_posts'];
$db->sql_freeresult($result);
// Now then, how many did they make last month?
$current_time = time();
$last_months_posts = 0;
$year = date('Y', $current_time);
$month [0] = mktime (0,0,0,1,1, $year);
$month [1] = $month [0] + 2678400;
$month [2] = mktime (0,0,0,3,1, $year);
$month [3] = $month [2] + 2678400;
$month [4] = $month [3] + 2592000;
$month [5] = $month [4] + 2678400;
$month [6] = $month [5] + 2592000;
$month [7] = $month [6] + 2678400;
$month [8] = $month [7] + 2678400;
$month [9] = $month [8] + 2592000;
$month [10] = $month [9] + 2678400;
$month [11] = $month [10] + 2592000;
$month [12] = $month [11] + 2592000;
$arr_num = ( date('n')-2);
$time_lastmonth = $month[$arr_num];
$sql = "SELECT count(post_id) as lastmonthly_posts
FROM " . POSTS_TABLE . "
WHERE poster_id = {$profiledata['user_id']}
AND post_time > '" . intval($time_lastmonth) . "'";
if(! $result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain last months postcount.', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$last_months_posts = $row['lastmonthly_posts'] - $this_months_posts ;
if ( $time_lastmonth = 12 )
{
$last_months_posts = 'Temporarily unavailable';
}
if ( $last_months_posts <0 )
{
$last_months_posts = 0 ;
}
$db->sql_freeresult($result);
$last_months_posts = $row['lastmonthly_posts'] - $this_months_posts ; to obtain the previous months post count.
Any help greatly appreciated!
![Very Happy :D](./images/smilies/icon_biggrin.gif)