View file index.php

File size: 7.3Kb
<?php

/*************************************************
 *    apwa.ru       index.php
 *                 -------------
 * [email protected] 2009 Модуль портала для phpbb 2.0.23
 ************************************************/
$sape_block = true;

define('IN_PHPBB', true);

$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/weblogs_common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_weblog.'.$phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);

$userdata = session_pagestart($user_ip, PAGE_PORTAL);
init_userprefs($userdata);
   
$module = ( isset($HTTP_GET_VARS['module']) ) ? htmlspecialchars($HTTP_GET_VARS['module']) : '';
   
//---------------Настройки портала-----------------------------
$sql = "SELECT * FROM " . $table_prefix . "portal_config";
if( !($result = $db->sql_query($sql)) )
{
	message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
	$CFG[$row['config_name']] = $row['config_value'];
}
//---------------Настроили-------------------------------------
	
//----------------STATISTICA-----------------------------------		    
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$total_topics = get_db_stat('topiccount');
$total_attach = get_db_stat('attachcount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];
//-----------gbook----------------------
$result = mysql_query("SELECT count(*) AS total FROM " . $table_prefix . guestbook); 
$total_gb = mysql_fetch_array($result); 
$total_gb = $total_gb['total'];
//-----------viktorina----------------------
$result = mysql_query("SELECT count(*) AS total FROM " . $table_prefix . question); 
$total_vika = mysql_fetch_array($result); 
$total_vika = $total_vika['total'];
//-----------album---------------------------
$result = mysql_query("SELECT count(*) AS total FROM " . $table_prefix . album); 
$total_album = mysql_fetch_array($result); 
$total_album = $total_album['total'];
//-----------blogs---------------------------
$result = mysql_query("SELECT count(*) AS total FROM " . $table_prefix . blog_replies); 
$total_blog = mysql_fetch_array($result); 
$total_blog = $total_blog['total'];
//------------END-----------------------------------------------

$admin_link = ( $userdata['user_level'] == ADMIN ) ? '<a href="admin/index.' . $phpEx . '?sid=' . $userdata['session_id'] . '">' . $lang['Admin_panel'] . '</a><br/>' : '';

//------------ПЕРЕКЛЮЧАТЕЛЬ СТИЛЕЙ------------------------------
if ( $userdata['session_logged_in'] && !empty($HTTP_POST_VARS['submit']) && !empty($HTTP_POST_VARS['style_id']) )
{
        $style_id = intval($HTTP_POST_VARS['style_id']);
        
        $sql = "SELECT style_text  
		FROM " . STYLES_CSS . " 
		WHERE style_id = $style_id";
	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, "Could not get data from styles table", "", __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$style_text = $row['style_text'];
	
	$sql = "UPDATE " . USERS_TABLE . "
		SET style_text = '" . str_replace("\'", "''", $style_text) . "'
		WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
	}
} 
else if (!empty($HTTP_POST_VARS['submit']) && !empty($HTTP_POST_VARS['style_id']) )
{
	$style_id = intval($HTTP_POST_VARS['style_id']);  
}	

$style_select = style_select($board_config['default_style'], 'style_id');
//------------ПЕРЕКЛЮЧАТЕЛЬ СТИЛЕЙ------------------------------
//------------ПЕРЕКЛЮЧАТЕЛЬ ВЕРСИИ------------------------------
if (($HTTP_GET_VARS['ver'] == 'wap' || $HTTP_GET_VARS['ver'] == 'web') && $userdata['session_logged_in'])
{
        $ver = ( !empty($HTTP_GET_VARS['ver']) ) ? trim(htmlspecialchars($HTTP_GET_VARS['ver'])) : '';
        
        $sql = "UPDATE " . USERS_TABLE . "
		SET theme = '" . str_replace("\'", "''", $ver) . "'
		WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
	}     
        $template->assign_vars(array(
			'META' => '<meta http-equiv="refresh" content="2;url=' . append_sid("index.$phpEx") . '">')
	);
        $message = 'Версия ' . $ver . ' включена<br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
        message_die(GENERAL_MESSAGE, $message);
} 
//------------ПЕРЕКЛЮЧАТЕЛЬ ВЕРСИИ------------------------------
	
define('SHOW_ONLINE', true);

$page_title = $board_config['sitename'] . ' :: ' . (($userdata['session_logged_in']) ? $userdata['username'] : $board_config['site_desc']);	
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
        'body' => ($module == 'news' || $module == 'birthday' || $module == 'lenta') ? 'module/module_body.tpl' : 'portal_body.tpl')
);
                    
$template->assign_vars(array( 
	'STYLE_SELECT' => $style_select,		
	'TOTAL_POSTS' => sprintf($total_posts),	
	'TOTAL_USERS' => sprintf($total_users),
	'TOTAL_TOPICS' => sprintf($total_topics),
	'TOTAL_GB' => sprintf($total_gb),
	'TOTAL_VIKA' => sprintf($total_vika),
	'TOTAL_ALBUM' => sprintf($total_album),
	'TOTAL_BLOG' => sprintf($total_blog),
	'ATTACH_TOTAL' => sprintf($total_attach),	
	'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),	
	'L_FORUM' => $lang['Forum'],
	'L_STATISTICS' => $lang['Statistics'],		
	'L_POSTED' => $lang['Posted'],
	'L_COMMENTS' => $lang['Comments'],	
	'L_ANNOUNCEMENT' => $lang['Post_Announcement'],	
	'L_POST_COMMENT' => $lang['Post_your_comment'],	
	'L_REMEMBER_ME' => $lang['Remember_me'],
	'L_VIEW_COMPLETE_LIST' => $lang['View_complete_list'],
	'L_VOTE_BUTTON' => $lang['Vote'],
	'U_NAME_LINK' => $name_link,   
	'ADMIN_LINK' => $admin_link)	
);

if (!$module && $CFG['recent'] ) // Активные темы форума
{
	include($phpbb_root_path . 'module/recent.'.$phpEx);	
}

if (!$module && $CFG['gallery'] ) // Последние, случайные фото
{
        include($phpbb_root_path . 'module/gallery.'.$phpEx);
}
if (!$module && $CFG['last'] ) // Последние посетители
{
        include($phpbb_root_path . 'module/visit.'.$phpEx);
}
if ( !$module)
{
        include($phpbb_root_path . 'module/entryes.'.$phpEx); // Последние записи в дневниках
}
if ((!$module || $module == 'news') && $CFG['news'] ) // Новости, объявления
{
        include($phpbb_root_path . 'module/news.'.$phpEx);
}
if ((!$module || $module == 'birthday') && $CFG['birthday']) // Дни рождения
{  
        include($phpbb_root_path . 'module/birthday.'.$phpEx);
}	
if ( !$module || $module == 'lenta' )
{
        include($phpbb_root_path . 'module/lenta.'.$phpEx); // Лента событий
}
	
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>