Page 2 of 2

Re: Posts this month (Viewprofile)

Posted: Sun Jul 20, 2008 2:22 pm
by quahappy
quahappy wrote:I really appreciate that most are busy with phpBB3 but I would be grateful if anyone knows how I could display the "posts this month" in a column either the memberlist or, preferably, list of members in a User Group.

Many thanks!
I'm currently looking at the Statistics MOD which I believe will show me the top X monthly posters AND the actual number of posts done for the month...
wittykitty wrote:]Hi, I've run this, says it went through fine, but when I click on "profile" at the bottom of a topic, I get an error!

Fatal error: Call to undefined function display_online_offline() in /home/fordesco/public_html/phpBB2T/includes/usercp_viewprofile.php on line 184
Have you double-checked all your edits and additional code required by the MOD? Is the BEFORE, ADD code section below in the right place? It's common (done it myself!) to AFTER, ADD instead as so many MOD's use this frequently.

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php

#
#-----[ FIND ]------------------------------------------
#
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);

#
#-----[ BEFORE, ADD ]------------------------------------------
#
$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);
Hope that helps.

Re: Posts this month (Viewprofile)

Posted: Sun Jul 20, 2008 2:35 pm
by wittykitty
Hi, not sure which file this script is in. I am very basic on amending script, but if I know exactly where to go and what to do I should be fine!

Thanks again,

Re: Posts this month (Viewprofile)

Posted: Sun Jul 20, 2008 3:11 pm
by quahappy
wittykitty wrote:Hi, not sure which file this script is in. I am very basic on amending script, but if I know exactly where to go and what to do I should be fine!

Thanks again,
Any problems, PM me. :D

Re: Posts this month (Viewprofile)

Posted: Sat Jan 03, 2009 4:49 pm
by quahappy
I've hit a problem. I inserted some code for this MOD so it shows the present months post count and an extra field that shows LAST months post count. Now it's January - a new year, Last Months post count is showing the total number of posts for 2008 instead of just December 2008!!

Would be grateful if someone could enlighten me as to what I need to tweak:

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);
As you can see above, I've had to temporarily "disable" Last Months post count field and make it show "Temporarily unavailable" to users.

Look forward to any help and thanks in advance. :D

Re: Posts this month (Viewprofile)

Posted: Sun Jan 04, 2009 4:05 pm
by quahappy
My problem has been resolved. Big thanks to battye at CMX forum! Solution to correctly display a members previous months post count in view profile here: http://forums.cricketmx.com/viewtopic.php?f=43&t=4546