Page 1 of 2

simple portal debug help.

Posted: 20 May 2010, 00:47
by neuropass
Hey guys
i added a piece of code in portal.php in order to get number of posts in the user menu block.
everything works fine but i get this error when i'm logged off.



Code: Select all

[phpBB Debug] PHP Notice: in file /portal.php on line 270: Undefined variable: new_posts_count
[phpBB Debug] PHP Notice: in file /portal.php on line 271: Undefined variable: you_posts_count
[phpBB Debug] PHP Notice: in file /portal.php on line 272: Undefined variable: unread_posts_count
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4349: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3497)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4351: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3497)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4352: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3497)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4353: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3497)

what should i do in order to fix it?

Re: simple portal debug help.

Posted: 20 May 2010, 02:09
by cisco007
wow, you really need to get rid of your portal with all those problems!
I don't know, but seems like you are missing some other code to get that working! are those variables added to the portal language file!? as for the other error i think the simple portal is already calling some code from functions.php, make sure what ever code you added isn't already being called in that file!

Re: simple portal debug help.

Posted: 20 May 2010, 17:48
by neuropass
Cisco this is the code that i'm using and it works perfectly when you are logged in.

this is the piece of code causing problems::

Code: Select all

	'L_NEW_POSTS'	    => $user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')',
	'L_SELF_POSTS'	    => $user->lang['SEARCH_SELF'] . ' (' . $you_posts_count . ')',
	'L_UNREAD_POSTS'    => $user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')',

where should i define them?

Re: simple portal debug help.

Posted: 20 May 2010, 18:55
by cisco007
i really don't know much about php coding, so i can't figure that out! sorry!

Re: simple portal debug help.

Posted: 20 May 2010, 18:59
by neuropass
cisco007 ยป 20 May 2010, 18:55 wrote:i really don't know much about php coding, so i can't figure that out! sorry!
ok thanks anyway cisco...
i hope Stoker can take a look at it.. :oops:

Re: simple portal debug help.

Posted: 21 May 2010, 17:44
by marc1706
It would be great if you could just post the content of your portal.php.

Without the code I would guess the answer to your question is 42.

Re: simple portal debug help.

Posted: 21 May 2010, 19:48
by neuropass
sorry i forgot about it. :D

Here it is, thanks a lot for your answer... I really appreciate it..


[spoiler2]

Code: Select all

<?php
/** 
*
* @package phpBB3
* @version $Id: portal.php,v 1.0 2009/07/04 15:49:44 stoker Exp $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/simple_portal');

// Lets build a page ...
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts	= $config['num_posts'];
$total_topics	= $config['num_topics'];
$total_files	= $config['num_files'];
$total_users	= $config['num_users'];
$start_date  	= date("d M Y, H:i:s", $config['board_startdate'] );
$boarddays = ceil((time() - $config['board_startdate']) / 86400);

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_file_s = ($total_files == 0) ? 'TOTAL_FILES_ZERO' : 'TOTAL_FILES_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

$posts_per_day = $total_posts / $boarddays;
$l_posts_per_day_s = ($posts_per_day == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
$posts_per_year = $posts_per_day * 365;
$l_posts_per_year_s = ($posts_per_year == 0) ? 'POSTS_PER_YEAR_ZERO' : 'POSTS_PER_YEAR_OTHER';
$posts_per_user = $total_posts / $total_users;
$l_posts_per_user_s = ($posts_per_user == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
$posts_per_topic = $total_posts / $total_topics;
$l_posts_per_topic_s = ($posts_per_topic == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
$topics_per_day = $total_topics / $boarddays;
$l_topics_per_day_s = ($topics_per_day == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
$topics_per_year = $topics_per_day * 365;
$l_topics_per_year_s = ($topics_per_year == 0) ? 'TOPICS_PER_YEAR_ZERO' : 'TOPICS_PER_YEAR_OTHER';
$topics_per_user = $total_topics / $total_users;
$l_topics_per_user_s = ($topics_per_user == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
$files_per_day = $total_files / $boarddays;
$l_files_per_day_s = ($files_per_day == 0) ? 'FILES_PER_DAY_ZERO' : 'FILES_PER_DAY_OTHER';
$files_per_year = $files_per_day * 365;
$l_files_per_year_s = ($files_per_year == 0) ? 'FILES_PER_YEAR_ZERO' : 'FILES_PER_YEAR_OTHER';
$files_per_user = $total_files / $total_users;
$l_files_per_user_s = ($files_per_day == 0) ? 'FILES_PER_USER_ZERO' : 'FILES_PER_USER_OTHER';
$users_per_day = $total_users / $boarddays;
$l_users_per_day_s = ($users_per_day == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
$users_per_year = $users_per_day * 365;
$l_users_per_year_s = ($users_per_year == 0) ? 'USERS_PER_YEAR_ZERO' : 'USERS_PER_YEAR_OTHER';

// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
	$sql = 'SELECT group_id, group_name, group_colour, group_type
		FROM ' . GROUPS_TABLE . '
		WHERE group_legend = 1
		ORDER BY group_name ASC';
}
else
{
	$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
		FROM ' . GROUPS_TABLE . ' g
		LEFT JOIN ' . USER_GROUP_TABLE . ' ug
			ON (
				g.group_id = ug.group_id
				AND ug.user_id = ' . $user->data['user_id'] . '
				AND ug.user_pending = 0
			)
		WHERE g.group_legend = 1
			AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
		ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
	$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
	$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

	if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
	{
		$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
	}
	else
	{
		$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
	}
}
$db->sql_freeresult($result);

$legend = implode('<br />', $legend);



// Get the avatar
if (!function_exists('get_user_avatar'))
    {    
        include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    }

//-- mod: top five ---------------------------------------------------------//
	include($phpbb_root_path . 'includes/top_five.' . $phpEx);
//-- end: top five ---------------------------------------------------------//

if ($config['rt_index'])
{
	if (!function_exists('display_recent_topics'))
	{
		include($phpbb_root_path . 'includes/functions_recenttopics.' . $phpEx);
	}
	display_recent_topics($config['rt_number'], $config['rt_page_number'], $config['rt_anti_topics'], 'recent_topics', request_var('f', 0), true);
}

// BEGIN mChat Mod
if(!defined('MCHAT_INCLUDE') && $config['mchat_on_index'] && $config['mchat_enable'] && $auth->acl_get('u_mchat_view'))
{
   define('MCHAT_INCLUDE', true);
   $mchat_include_index = true;
   include($phpbb_root_path.'mchat.'.$phpEx);
}
// END mChat Mod

// BEGIN Welcome Mod
$date = $user->format_date(time(), 'H');

if ($user->data['is_registered'])
{
    $u_user_name = get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']);
}
else
{
    $u_user_name = $user->lang['WELCOME_GUEST'];
}    

switch (true)
{
        case ($date < 4):
            // if the hour is 1-3 am 
            $s_welcome = sprintf($user->lang['UP_LATE'], $u_user_name);
        break;
        
        case ($date < 8):
            // if the hour is 4-7 am
            $s_welcome = sprintf($user->lang['UP_EARLY'], $u_user_name);
        break;
        
        case ($date < 12):
            // if the hour is 8-11 am
            $s_welcome = sprintf($user->lang['GOOD_MORNING'], $u_user_name);
        break;
        
        case ($date < 18):
            // if the hour is 12-5pm (12-17)
            $s_welcome = sprintf($user->lang['GOOD_AFTERNOON'], $u_user_name);
        break;
        
        case ($date < 24):
            // if the hour is 6pm-11pm (18-23_
            $s_welcome = sprintf($user->lang['GOOD_EVENING'], $u_user_name);;
        break;
}    
//END Welcome Mod



//
// + new posts since last visit & you post number 
//
if ($user->data['is_registered'])
{
	$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
	
	if ($auth->acl_get('m_approve'))
	{
		$m_approve_fid_ary = array(-1);
		$m_approve_fid_sql = '';
	}
	else if ($auth->acl_getf_global('m_approve'))
	{
		$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
		$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
	}
	else
	{
		$m_approve_fid_ary = array();
		$m_approve_fid_sql = ' AND p.post_approved = 1';
	}

	$sql = 'SELECT COUNT(distinct t.topic_id) as total
				FROM ' . TOPICS_TABLE . ' t
				WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
					AND t.topic_moved_id = 0
					' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
					' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
	$result = $db->sql_query($sql);
	$new_posts_count = (int) $db->sql_fetchfield('total');

	// your post number
	$sql = "SELECT user_posts
		FROM " . USERS_TABLE . "
		WHERE user_id = " . $user->data['user_id'];
	$result = $db->sql_query($sql);
	$you_posts_count = (int) $db->sql_fetchfield('user_posts');
	
	// unread posts
	$sql_where = 'AND t.topic_moved_id = 0
					' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
					' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
	$unread_list = array();
	$unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
	
	if (!empty($unread_list))
	{
		$sql = 'SELECT COUNT(distinct t.topic_id) as total
			FROM ' . TOPICS_TABLE . ' t
			WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list));
		$result = $db->sql_query($sql);
		$unread_posts_count = (int) $db->sql_fetchfield('total');
	}
	else
	{
		$unread_posts_count = 0;
	}
}
//
// - new posts since last visit & you post number
//



// Assign index specific vars
$template->assign_vars(array(
    'TOTAL_POSTS'		=> sprintf($user->lang[$l_total_post_s], number_format($total_posts, 0, ',', '.')),
	'POSTS_PER_DAY'		=> str_replace('.', ',', sprintf($user->lang[$l_posts_per_day_s], $posts_per_day)),
	'POSTS_PER_YEAR'	=> sprintf($user->lang[$l_posts_per_year_s], number_format($posts_per_year, 0, ',', '.')),
	'POSTS_PER_TOPIC'	=> str_replace('.', ',', sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic)),
	'POSTS_PER_USER'	=> str_replace('.', ',', sprintf($user->lang[$l_posts_per_user_s], $posts_per_user)),
	'TOTAL_TOPICS'		=> sprintf($user->lang[$l_total_topic_s], number_format($total_topics, 0, ',', '.')),
	'TOPICS_PER_DAY'	=> str_replace('.', ',', sprintf($user->lang[$l_topics_per_day_s], $topics_per_day)),
	'TOPICS_PER_YEAR'	=> sprintf($user->lang[$l_topics_per_year_s], number_format($topics_per_year, 0, ',', '.')),
	'TOPICS_PER_USER'	=> str_replace('.', ',', sprintf($user->lang[$l_topics_per_user_s], $topics_per_user)),
	'TOTAL_FILES'		=> sprintf($user->lang[$l_total_file_s], number_format($total_files, 0, ',', '.')),
	'FILES_PER_DAY'		=> str_replace('.', ',', sprintf($user->lang[$l_files_per_day_s], $files_per_day)),
	'FILES_PER_YEAR'	=> sprintf($user->lang[$l_files_per_year_s], number_format($files_per_year, 0, ',', '.')),
	'FILES_PER_USER'	=> str_replace('.', ',', sprintf($user->lang[$l_files_per_user_s], $files_per_user)),
	'TOTAL_USERS'		=> sprintf($user->lang[$l_total_user_s], number_format($total_users, 0, ',', '.')),
	'USERS_PER_DAY'		=> str_replace('.', ',', sprintf($user->lang[$l_users_per_day_s], $users_per_day)),
	'USERS_PER_YEAR'	=> sprintf($user->lang[$l_users_per_year_s], number_format($users_per_year, 0, ',', '.')),
	'NEWEST_USER'		=> sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
	'S_LOGIN_ACTION'	=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'USER_AVATAR'		=> get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
	'USERNAME'			=> get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
	'LEGEND'		    => $legend,
	'START_DATE'		=> $start_date,
	'S_WELCOME'         => $s_welcome,
	'U_MARK_FORUMS'     => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
	'L_NEW_POSTS'	    => $user->lang['SEARCH_NEW'] . '&nbsp;(' . $new_posts_count . ')',
	'L_SELF_POSTS'	    => $user->lang['SEARCH_SELF'] . '&nbsp;(' . $you_posts_count . ')',
	'L_UNREAD_POSTS'    => $user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')',

	'U_NEW_POSTS'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
	'U_SELF_POSTS'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
	'U_UNREAD_POSTS'		=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),

));




page_header($user->lang['PORTAL_HEADLINE']);

$template->set_filenames(array(
	'body' => 'simpleportal_body.html'
));

page_footer();

?>
[/spoiler2]

Re: simple portal debug help.

Posted: 24 May 2010, 16:50
by marc1706
Ok, let's try this.
Replace the content of your portal.php with this:

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: portal.php,v 1.0 2009/07/04 15:49:44 stoker Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/simple_portal');

// Lets build a page ...
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts   = $config['num_posts'];
$total_topics   = $config['num_topics'];
$total_files   = $config['num_files'];
$total_users   = $config['num_users'];
$start_date     = date("d M Y, H:i:s", $config['board_startdate'] );
$boarddays = ceil((time() - $config['board_startdate']) / 86400);

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_file_s = ($total_files == 0) ? 'TOTAL_FILES_ZERO' : 'TOTAL_FILES_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

$posts_per_day = $total_posts / $boarddays;
$l_posts_per_day_s = ($posts_per_day == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
$posts_per_year = $posts_per_day * 365;
$l_posts_per_year_s = ($posts_per_year == 0) ? 'POSTS_PER_YEAR_ZERO' : 'POSTS_PER_YEAR_OTHER';
$posts_per_user = $total_posts / $total_users;
$l_posts_per_user_s = ($posts_per_user == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
$posts_per_topic = $total_posts / $total_topics;
$l_posts_per_topic_s = ($posts_per_topic == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
$topics_per_day = $total_topics / $boarddays;
$l_topics_per_day_s = ($topics_per_day == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
$topics_per_year = $topics_per_day * 365;
$l_topics_per_year_s = ($topics_per_year == 0) ? 'TOPICS_PER_YEAR_ZERO' : 'TOPICS_PER_YEAR_OTHER';
$topics_per_user = $total_topics / $total_users;
$l_topics_per_user_s = ($topics_per_user == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
$files_per_day = $total_files / $boarddays;
$l_files_per_day_s = ($files_per_day == 0) ? 'FILES_PER_DAY_ZERO' : 'FILES_PER_DAY_OTHER';
$files_per_year = $files_per_day * 365;
$l_files_per_year_s = ($files_per_year == 0) ? 'FILES_PER_YEAR_ZERO' : 'FILES_PER_YEAR_OTHER';
$files_per_user = $total_files / $total_users;
$l_files_per_user_s = ($files_per_day == 0) ? 'FILES_PER_USER_ZERO' : 'FILES_PER_USER_OTHER';
$users_per_day = $total_users / $boarddays;
$l_users_per_day_s = ($users_per_day == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
$users_per_year = $users_per_day * 365;
$l_users_per_year_s = ($users_per_year == 0) ? 'USERS_PER_YEAR_ZERO' : 'USERS_PER_YEAR_OTHER';

// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
   $sql = 'SELECT group_id, group_name, group_colour, group_type
      FROM ' . GROUPS_TABLE . '
      WHERE group_legend = 1
      ORDER BY group_name ASC';
}
else
{
   $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
      FROM ' . GROUPS_TABLE . ' g
      LEFT JOIN ' . USER_GROUP_TABLE . ' ug
         ON (
            g.group_id = ug.group_id
            AND ug.user_id = ' . $user->data['user_id'] . '
            AND ug.user_pending = 0
         )
      WHERE g.group_legend = 1
         AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
      ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
   $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
   $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

   if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
   {
      $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
   }
   else
   {
      $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
   }
}
$db->sql_freeresult($result);

$legend = implode('<br />', $legend);



// Get the avatar
if (!function_exists('get_user_avatar'))
    {   
        include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    }

//-- mod: top five ---------------------------------------------------------//
   include($phpbb_root_path . 'includes/top_five.' . $phpEx);
//-- end: top five ---------------------------------------------------------//

if ($config['rt_index'])
{
   if (!function_exists('display_recent_topics'))
   {
      include($phpbb_root_path . 'includes/functions_recenttopics.' . $phpEx);
   }
   display_recent_topics($config['rt_number'], $config['rt_page_number'], $config['rt_anti_topics'], 'recent_topics', request_var('f', 0), true);
}

// BEGIN mChat Mod
if(!defined('MCHAT_INCLUDE') && $config['mchat_on_index'] && $config['mchat_enable'] && $auth->acl_get('u_mchat_view'))
{
   define('MCHAT_INCLUDE', true);
   $mchat_include_index = true;
   include($phpbb_root_path.'mchat.'.$phpEx);
}
// END mChat Mod

// BEGIN Welcome Mod
$date = $user->format_date(time(), 'H');

if ($user->data['is_registered'])
{
    $u_user_name = get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']);
}
else
{
    $u_user_name = $user->lang['WELCOME_GUEST'];
}   

switch (true)
{
        case ($date < 4):
            // if the hour is 1-3 am
            $s_welcome = sprintf($user->lang['UP_LATE'], $u_user_name);
        break;
       
        case ($date < 8):
            // if the hour is 4-7 am
            $s_welcome = sprintf($user->lang['UP_EARLY'], $u_user_name);
        break;
       
        case ($date < 12):
            // if the hour is 8-11 am
            $s_welcome = sprintf($user->lang['GOOD_MORNING'], $u_user_name);
        break;
       
        case ($date < 18):
            // if the hour is 12-5pm (12-17)
            $s_welcome = sprintf($user->lang['GOOD_AFTERNOON'], $u_user_name);
        break;
       
        case ($date < 24):
            // if the hour is 6pm-11pm (18-23_
            $s_welcome = sprintf($user->lang['GOOD_EVENING'], $u_user_name);;
        break;
}   
//END Welcome Mod



//
// + new posts since last visit & you post number
//
if ($user->data['is_registered'])
{
   $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
   
   if ($auth->acl_get('m_approve'))
   {
      $m_approve_fid_ary = array(-1);
      $m_approve_fid_sql = '';
   }
   else if ($auth->acl_getf_global('m_approve'))
   {
      $m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
      $m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
   }
   else
   {
      $m_approve_fid_ary = array();
      $m_approve_fid_sql = ' AND p.post_approved = 1';
   }

   $sql = 'SELECT COUNT(distinct t.topic_id) as total
            FROM ' . TOPICS_TABLE . ' t
            WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
               AND t.topic_moved_id = 0
               ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
               ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
   $result = $db->sql_query($sql);
   $new_posts_count = (int) $db->sql_fetchfield('total');

   // your post number
   $sql = "SELECT user_posts
      FROM " . USERS_TABLE . "
      WHERE user_id = " . $user->data['user_id'];
   $result = $db->sql_query($sql);
   $you_posts_count = (int) $db->sql_fetchfield('user_posts');
   
   // unread posts
   $sql_where = 'AND t.topic_moved_id = 0
               ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
               ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
   $unread_list = array();
   $unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
   
   if (!empty($unread_list))
   {
      $sql = 'SELECT COUNT(distinct t.topic_id) as total
         FROM ' . TOPICS_TABLE . ' t
         WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list));
      $result = $db->sql_query($sql);
      $unread_posts_count = (int) $db->sql_fetchfield('total');
   }
   else
   {
      $unread_posts_count = 0;
   }
}
//
// - new posts since last visit & you post number
//



// Assign index specific vars
$template->assign_vars(array(
    'TOTAL_POSTS'      => sprintf($user->lang[$l_total_post_s], number_format($total_posts, 0, ',', '.')),
   'POSTS_PER_DAY'      => str_replace('.', ',', sprintf($user->lang[$l_posts_per_day_s], $posts_per_day)),
   'POSTS_PER_YEAR'   => sprintf($user->lang[$l_posts_per_year_s], number_format($posts_per_year, 0, ',', '.')),
   'POSTS_PER_TOPIC'   => str_replace('.', ',', sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic)),
   'POSTS_PER_USER'   => str_replace('.', ',', sprintf($user->lang[$l_posts_per_user_s], $posts_per_user)),
   'TOTAL_TOPICS'      => sprintf($user->lang[$l_total_topic_s], number_format($total_topics, 0, ',', '.')),
   'TOPICS_PER_DAY'   => str_replace('.', ',', sprintf($user->lang[$l_topics_per_day_s], $topics_per_day)),
   'TOPICS_PER_YEAR'   => sprintf($user->lang[$l_topics_per_year_s], number_format($topics_per_year, 0, ',', '.')),
   'TOPICS_PER_USER'   => str_replace('.', ',', sprintf($user->lang[$l_topics_per_user_s], $topics_per_user)),
   'TOTAL_FILES'      => sprintf($user->lang[$l_total_file_s], number_format($total_files, 0, ',', '.')),
   'FILES_PER_DAY'      => str_replace('.', ',', sprintf($user->lang[$l_files_per_day_s], $files_per_day)),
   'FILES_PER_YEAR'   => sprintf($user->lang[$l_files_per_year_s], number_format($files_per_year, 0, ',', '.')),
   'FILES_PER_USER'   => str_replace('.', ',', sprintf($user->lang[$l_files_per_user_s], $files_per_user)),
   'TOTAL_USERS'      => sprintf($user->lang[$l_total_user_s], number_format($total_users, 0, ',', '.')),
   'USERS_PER_DAY'      => str_replace('.', ',', sprintf($user->lang[$l_users_per_day_s], $users_per_day)),
   'USERS_PER_YEAR'   => sprintf($user->lang[$l_users_per_year_s], number_format($users_per_year, 0, ',', '.')),
   'NEWEST_USER'      => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
   'S_LOGIN_ACTION'   => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
   'USER_AVATAR'      => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
   'USERNAME'         => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
   'LEGEND'          => $legend,
   'START_DATE'      => $start_date,
   'S_WELCOME'         => $s_welcome,
   'U_MARK_FORUMS'     => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
   'L_NEW_POSTS'       => (isset($new_posts_count)) ? $user->lang['SEARCH_NEW'] . '&nbsp;(' . $new_posts_count . ')' : $user->lang['SEARCH_NEW'],
   'L_SELF_POSTS'       => (isset($you_posts_count)) ? $user->lang['SEARCH_SELF'] . '&nbsp;(' . $you_posts_count . ')' : $user->lang['SEARCH_SELF'],
   'L_UNREAD_POSTS'    => (isset($unread_posts_count)) ? $user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')' : $user->lang['SEARCH_UNREAD'],

   'U_NEW_POSTS'         => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
   'U_SELF_POSTS'         => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
   'U_UNREAD_POSTS'      => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),

));




page_header($user->lang['PORTAL_HEADLINE']);

$template->set_filenames(array(
   'body' => 'simpleportal_body.html'
));

page_footer();

?>

Re: simple portal debug help.

Posted: 24 May 2010, 16:53
by cisco007
nice replacement code there marc!

Re: simple portal debug help.

Posted: 24 May 2010, 16:57
by marc1706
You mean the empty codebox? Yeah, stupid php parsing. Everytime you have more than about 200 lines of code, you'll just get an empty box. :D