<?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']), "block_users.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,$visitorInfo,$userid,$userInfo;
	
	if (isUser($userid)) {
		echo "<div>"._HI_." <b>".$userInfo['user']."</b> <span>(";
		
		//Rank
		switch ($userInfo['rank']) {
			case 1 : echo _USER_; break;
			case 2 : echo _POWERUSER_; break;
			case 3 : echo _ADMIN_; break;
			case 4 : echo _SUPERADMIN_; break;
		}
		echo ")</span></div>\n";
		
		//IP
		echo "<div>"._IP_.": ".$visitorInfo['ip']."</div>\n";
		
		echo "<br>";
		//Avatar
		$avatar = ($userInfo['avatar']!="") ? $userInfo['avatar'] : "blank.png" ;
		echo "<div style='margin-bottom:4px;'><img src='images/avatar/$avatar' border='0' title='".$userInfo['user']."' alt='Avatar'></div>\n";
		
		//Private messages
		echo "<div><a href='index.php?page=pvtmsg&op=newMessage' title='"._SENDPM_."'>"._SENDPM_."</a></div>";
		
		if ($userInfo['newpm']>0) { echo "<div><a href='index.php?page=pvtmsg' title='"._NEWMESSAGES_."'><b>"._NEWMESSAGES_."</b></a>: ".$userInfo['newpm']."</div>"; }
		if ($userInfo['oldpm']>0) { echo "<div><a href='index.php?page=pvtmsg' title='"._OLDMESSAGES_."'>"._OLDMESSAGES_."</a>: ".$userInfo['oldpm']."</div>"; }
		
		echo "<br>";
		
		//Profile
		echo "<div><a href='index.php?page=users&op=editProfile' title='"._MODIFYPROFILE_."'>"._MODIFYPROFILE_."</a></div>\n";
		//Logout
		echo "<div><a href='index.php?page=users&logout=1' title='"._LOGOUT_."'>"._LOGOUT_."</a></div>\n";
	} else {
		echo "<div>"._HI_." <b>"._GUEST_."</b></div>";
		
		//IP
		echo "<div>"._IP_.": ".$visitorInfo['ip']."</div>\n";
		echo "<br>";
		//Login
		if ($dblink->get_num("SELECT ip FROM memht_login_flood WHERE ip='".$visitorInfo['ip']."' AND attempts>=5")==0) {
			echo "<form name='userlogin' method='post' action='index.php?page=users'>\n";
				echo "<div>"._USERNAME_."<br><input type='text' name='post_username' style='width:90%;' maxlength='255'></div>\n";
				echo "<div style='margin:4px 0;'>"._PASSWORD_."<br><input type='password' name='post_password' style='width:90%;' maxlength='255'></div>\n";
				echo "<div><input type='submit' name='Submit' value='"._LOGIN_."' class='std_button'></div>\n";
				echo "<div style='margin:4px 0;'><a href='index.php?page=users&op=lostPassword' title='"._LOSTPASS_."'>"._LOSTPASS_."</a></div>\n";
				echo "<div><a href='index.php?page=users&op=register' title='"._REGISTER_."'>"._REGISTER_."</a></div>\n";
			echo "<input type='hidden' name='login' value='true'>";
			echo "</form>\n";
		} else {
			echo "<div align='center'><b>"._YOUMUSTWAITTOLOGINAGAIN_."</b></div>\n";
		}
	}
	
?>