<?php

/********************************************************************************
	- MemHT Portal -
	
	Copyright (C) 2007-2008 by Miltenovik Manojlo
	http://www.memht.com
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your opinion) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License along
	with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
	or write to the Free Software Foundation, Inc., 51 Franklin Street,
	Fifth Floor, Boston, MA02110-1301, USA.
		
********************************************************************************/

if (stristr(htmlentities($_SERVER['PHP_SELF']), "inc_readConfig.php")) {
	die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}

global $dblink,$userid,$userInfo;

//==================================
// Site configuration
//==================================
$row_conf = $dblink->get_row("SELECT * FROM memht_config");
$siteConfig['site_name'] = outCode($row_conf['nome']);
$siteConfig['site_url'] = outCode($row_conf['site_url']);
$siteConfig['site_description'] = outCode($row_conf['descrizione']);
$siteConfig['metatags'] = outCode($row_conf['metatags']);
$siteConfig['footmsg'] = outCode($row_conf['footmsg']);
$siteConfig['copyright'] = outCode($row_conf['copyright']);
$siteConfig['site_open'] = intval($row_conf['site_open']);
$siteConfig['offlinemsg'] = outCode($row_conf['offlinemsg']);
if (isset($_COOKIE['template'])) { $siteConfig['template'] = inCode($_COOKIE['template']); } else { $siteConfig['template'] = outCode($row_conf['template']); }
if (!file_exists("templates/".$siteConfig['template']."/home.html") AND file_exists("templates/memht/home.html")) { $siteConfig['template'] = "memht"; }
if (isset($_COOKIE['language'])) { $siteConfig['language'] = inCode($_COOKIE['language']); } else { $siteConfig['language'] = outCode($row_conf['lingua']); }
$siteConfig['num_news_home'] = intval($row_conf['num_news_home']);
$siteConfig['num_news_page'] = intval($row_conf['num_news_page']);
$siteConfig['webmaster_mail'] = outCode($row_conf['email']);
$siteConfig['guest_comment'] = intval($row_conf['guest_com']);
$siteConfig['guest_msgbox'] = intval($row_conf['guest_msgbox']);
$siteConfig['guest_download'] = intval($row_conf['guest_download']);
$siteConfig['admin_ghosts'] = intval($row_conf['admin_ghosts']);
$siteConfig['user_max_lunghezza'] = intval($row_conf['user_max_lunghezza']);
$siteConfig['pass_max_lunghezza'] = intval($row_conf['pass_max_lunghezza']);
$siteConfig['defpage'] = outCode($row_conf['defpage']);
$siteConfig['timestamp'] = outCode($row_conf['timestamp']); //%d/%m/%Y %H:%i
$siteConfig['forumattachment'] = intval($row_conf['forumattachment']);
$siteConfig['forumattachmentfolder'] = outCode($row_conf['forumattachmentfolder']);
$siteConfig['avatar_max_w'] = intval($row_conf['avatar_max_w']);
$siteConfig['avatar_max_h'] = intval($row_conf['avatar_max_h']);
$siteConfig['informationbar'] = intval($row_conf['informationbar']);
$siteConfig['graphic_check'] = intval($row_conf['graphic_check']);
$siteConfig['textarea_editor'] = intval($row_conf['textarea_editor']);
$siteConfig['modrewrite'] = intval($row_conf['modrewrite']);
$siteConfig['searchengineinstat'] = intval($row_conf['searchengineinstat']);
$siteConfig['approve_users'] = intval($row_conf['approve_users']);
$siteConfig['user_confirm_email'] = intval($row_conf['user_confirm_email']);
$siteConfig['ftp_server'] = outCode($row_conf['ftp_server']);
$siteConfig['ftp_user'] = outCode($row_conf['ftp_user']);
$siteConfig['ftp_pass'] = outCode($row_conf['ftp_pass']);
$siteConfig['ftp_base'] = outCode($row_conf['ftp_base']);
$siteConfig['usecomments'] = intval($row_conf['usecomments']);
$siteConfig['moderate_comments'] = intval($row_conf['moderate_comments']);
$siteConfig['moderate_comments_onspam'] = intval($row_conf['moderate_comments_onspam']);
$siteConfig['comments_spam_words'] = outCode($row_conf['comments_spam_words']);
$siteConfig['usecronjobs'] = intval($row_conf['usecronjobs']);
$siteConfig['virtualpages'] = intval($row_conf['virtualpages']);
$siteConfig['welcome_pm'] = outCode($row_conf['welcome_pm']);
$siteConfig['welcome_pm_title'] = outCode($row_conf['welcome_pm_title']);
$siteConfig['welcome_pm_author'] = outCode($row_conf['welcome_pm_author']);
$siteConfig['mail_usesmtp'] = intval($row_conf['mail_usesmtp']);
$siteConfig['mail_smtp'] = outCode($row_conf['mail_smtp']);
$siteConfig['mail_smtpauth'] = intval($row_conf['mail_smtpauth']);
$siteConfig['mail_smtpuser'] = outCode($row_conf['mail_smtpuser']);
$siteConfig['mail_smtppass'] = outCode($row_conf['mail_smtppass']);

//==================================
// Site maintenance
//==================================
$row_maint = $dblink->get_row("SELECT * FROM memht_maintenance");
$siteConfig['maintenance'] = intval($row_maint['maintenance']);
$siteConfig['maintenance_mesboxflood'] = intval($row_maint['maintenance_mesboxflood']);
$siteConfig['maintenance_waitusers'] = intval($row_maint['maintenance_waitusers']);
$siteConfig['maintenance_oldpm'] = intval($row_maint['maintenance_oldpm']);
$siteConfig['maintenance_failedlogin'] = intval($row_maint['maintenance_failedlogin']);
$siteConfig['maintenance_standbygroup'] = intval($row_maint['maintenance_standbygroup']);
$siteConfig['maintenance_loadtime'] = intval($row_maint['maintenance_loadtime']);

//==================================
// User informations
//==================================
if (isUser($userid)) {
	$row = $dblink->get_row("SELECT u.user,u.email,u.avatar,u.rank,SUM(p.new) AS newpm,COUNT(p.id) AS totpm FROM memht_utenti AS u LEFT JOIN memht_pvtmsg AS p ON u.user=p.recipient WHERE u.id=$userid GROUP BY p.recipient");
	$userInfo['user'] = outCode($row['user']);
	$userInfo['email'] = outCode($row['email']);
	$userInfo['avatar'] = outCode($row['avatar']);
	$userInfo['rank'] = intval($row['rank']);
	$userInfo['newpm'] = intval($row['newpm']);
	$userInfo['oldpm'] = intval($row['totpm'])-intval($row['newpm']);
} else {
	$userInfo['user'] = "";
	$userInfo['email'] = "";
	$userInfo['avatar'] = "";
	$userInfo['rank'] = 0;
	$userInfo['newpm'] = 0;
	$userInfo['oldpm'] = 0;
}

//==================================
// Update data
//==================================
$siteConfig['versionremotefile'] = "http://www.memht.com/update/lastrelease.txt";
$row_info = $dblink->get_row("SELECT version FROM memht_info");
$siteInfo['version'] = intval($row_info['version']);

//=====================================================================
// MemHT Portal is free, released under a very permissive license as
// GNU/GPL: you can use, modify and distribute it. I'm only asking to
// leave the following copyright piece of code intact according to the
// license policy. Thanks
//=====================================================================
$copytext = "<a href='http://www.memht.com' title='MemHT.com' target='_blank'><b>MemHT Portal</b></a> is a free software released under the GNU/GPL License by <a href='http://www.memht.com' title='MemHT.com' target='_blank'><b>Miltenovik Manojlo</b></a>";

?>