<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2006, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sourceforge.net>
	*	@link		http://www.gekkoware.org
	*/

	if (!defined("IN-BLOCK")) die();

	/*
	<%%>
	<?xml version="1.0" encoding="UTF-8"?>
	<blockscript>
		<info lang="en">
			<title>Who am I?</title>
			<description>Shows an identification if user is already logged in or a login form otherwise.</description>
			<author><![CDATA[xiam &lt;<a href="mailto:xiam@users.sourceforge.net">xiam@users.sourceforge.net</a>&gt;]]></author>
			<homepage><![CDATA[<a href="http://www.gekkoware.org">http://www.gekkoware.org</a>]]></homepage>
		</info>
	</blockscript>
	<%%>
	*/

	LoadLib("users");

	if (is_user()) {

		$avatar = cacheFunc("users::mkAvatar", $GLOBALS["USER"]["id"]);

		$return = "<div style=\"height: 80px;\"><div class=\"avatar\" style=\"float: left; margin: 4px;\">{$avatar}</div><b style=\"font-size: large;\">".cacheFunc("users::mkUserLink", $GLOBALS["USER"]["id"])."</b><br /><small>{$GLOBALS["USER"]["realname"]}</small></div>";

	} else {

		$safe_mode = isset($_SERVER["HTTPS"]) ?  _l("L_SAFE") : '<a href="https://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"].'">'._l("L_SAFE").'</a>';
		$normal_mode = isset($_SERVER["HTTPS"]) ? '<a href="http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"].'">'._l("L_NORMAL").'</a>' : _l("L_NORMAL");

		$return = '
		<form action="'._l("C_SITE.REL_URL").'modules/users/main.act.php" method="post">
		<input type="hidden" name="action" value="login" />
		<input type="hidden" name="block_flag" value="1" />
		<input type="hidden" name="return" value="" />
		'._l("L_USERNAME").':<br />
		<input class="text" type="text" name="username" value="" /><br />
		'._l("L_PASSWORD").':<br />
		<input class="text" type="password" name="password" /><br />
		<button type="submit">'.mkicon("login.png", 16).' '._l("L_LOGIN").'</button>
		<div class="buttons">
			'.mkicon("lock.png", 16).' [ '.$normal_mode.' | '.$safe_mode.' ]<br />
			'.(conf::getKey("users", "account.enable_self_registration") ? mklink('index.php/module=users/action=register', _l("L_REGISTER"), "users.png") : '').'
		</div>
		</form>';
	}
?>