if ($userdata['user_id'] != ANONYMOUS )
{
$poster_id = $userdata['user_id'];
$sql = "SELECT post_id, poster_id, post_time, MAX(post_time) FROM " . BB_POSTS . " WHERE topic_id = $topic_id GROUP BY post_time ORDER BY post_time DESC LIMIT 1";
if ( !($result = DB()->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
$post_id_last_row = DB()->sql_fetchrow($result);
$post_data['poster_post'] = ($post_id_last_row['poster_id'] == $userdata['user_id']);
$post_id = $post_id_last_row['post_id'];
$current_time = time();
$difference_time = $current_time - $post_id_last_row['post_time'];
$hours = floor($difference_time/60/60);
$minutes = floor($difference_time/60%60);
$seconds = $difference_time%60;
$separator = '[br][size=9][color=#999999]' . $lang['ADDED_LATER'] . delta_time($post_id_last_row['post_time'], TIMENOW, 'seconds'). ':[/color][/size][br]';
if ($post_id_last_row['poster_id'] == $poster_id && $post_data['poster_post'] && $t_data['topic_replies'] >= 1 && ( $difference_time < ( $bb_cfg['join_interval'] * 3600 ) ) )
{
$sql = "SELECT post_text FROM " . BB_POSTS_TEXT . " WHERE post_id = $post_id";
if ( !($result = DB()->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
$last_message_row = DB()->sql_fetchrow($result);
// i don't know much about parsing the message, so it may well be that, there are some wrongs, anyway all seems to work fine
$last_message = str_replace(':', '', $last_message_row['post_text']);
$last_message = preg_replace('/:[0-9a-z:]+]/si', ']', $last_message);
$last_message = addslashes($last_message);
}
}