View file module/entryes.php

File size: 3.32Kb
<?php
if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}

if ( $weblog_config['show_latest_entries'] ) // Последние записи в дневниках
{
        $sql = "SELECT * FROM " . WEBLOG_CONTRIBUTORS_TABLE . " 
                WHERE user_id = " . $userdata['user_id'];
        if ( !($result = $db->sql_query($sql)) )
        {
	        message_die(GENERAL_ERROR, 'Error querying to find user weblog information', '', __LINE__, __FILE__, $sql);
        }

        $contributor = FALSE;
        if ( $row = $db->sql_fetchrow($result) || $userdata['user_level'] == ADMIN )
        {
	        $contributor = TRUE;
        }
	
	$auth_level = get_auth_level($weblog_data, $friends_data, $blocked_data, $weblog_data['user_id'], $contributor);
	
	$limit = ($template_name == 'web') ? $weblog_config['latest_entry_max']+$weblog_config['latest_entry_max'] : $weblog_config['latest_entry_max'];
	
	$sql = "SELECT e.entry_id, e.entry_subject, e.entry_time, e.entry_replies, u.user_id, u.username
		FROM " . WEBLOG_ENTRIES_TABLE . " e, " . USERS_TABLE . " u
		WHERE e.entry_access <= $auth_level		
		AND e.entry_poster_id = u.user_id
		ORDER BY e.entry_time DESC LIMIT " . $limit;
	if (!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, 'Could not query blog information', '', __LINE__, __FILE__, $sql);
	}

	$blog_row = array();
	while ($row = $db->sql_fetchrow($result))
	{
		$blog_row[] = $row;
	}
	$db->sql_freeresult($result);
	
        $template->set_filenames(array(
	        'entryes' => 'module/entryes_body.tpl')
        );
	
	$template->assign_block_vars('switch_show', array(
		'L_AUTHOR' => $lang['Author'],
	        'L_REPLIES' => $lang['Replies'],
	        'L_LAST_ENTRY' => $lang['Last_entry'])
	);	
	for ($i = 0; $i < count($recentrow); $i += 2)      
        {
                $template->assign_block_vars('switch_show.entry', array());
		
		for ($j = $i; $j < ($i + 2); $j++)
		{ 
			if( $j >= count($recentrow) )
			{
				break;
			}		
		        $entry_id = $blog_row[$j]['entry_id'];
		        $entry_subject = strip_tags(htmlspecialchars($blog_row[$j]['entry_subject']));
		        $entry_subject = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $entry_subject);
	                $entry_subject = ( strlen($entry_subject) > $CFG['topic_length']) ? substr($entry_subject, 0, $CFG['topic_length']-strlen(strrchr(substr($entry_subject, 0, $CFG['topic_length']), ' '))) . '&hellip;' : $entry_subject;
	        
		        $entry_poster = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . "u" . "=" . $blog_row[$j]['user_id']) . '">' . $blog_row[$j]['username'] . '</a>';		        
		        $row_class = ( !($j % 2) ) ? 'row_easy' : 'row_hard';		
		        $template->assign_block_vars('switch_show.entry.row', array(		
			       'ROW_CLASS' => $row_class,			
			       'U_LATEST_ENTRY' => append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $blog_row[$j]['entry_id']),
			       'L_LATEST_ENTRIES' => $entry_subject,
			       'L_ENTRY_REPLIES' => $blog_row[$j]['entry_replies'],
			       'S_POSTER' => $entry_poster,
			       'S_POSTTIME' => create_date($board_config['default_dateformat'], $blog_row[$j]['entry_time'], $board_config['board_timezone']))
		        );
		}        
	}
        $template->assign_var_from_handle('MODULE_ENTRYES', 'entryes');			
}
?>