<?php
/**
 * @package Flatnux_module_login
 * @author Alessandro Vernassa <speleoalex@gmail.com>
 * @copyright Copyright (c) 2011
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
 */
defined('_FNEXEC') or die('Restricted access');
require_once("modules/login/functions_login.php");
global $_FN;
$op=FN_GetParam("op",$_GET);
$username=FN_GetParam("user",$_GET);
if (!FN_IsAdmin())
	$username=$_FN['user'];
switch ($op)
{
	case "register":
	case "end_reg":
		if (!empty($_FN['enable_registration']))
		{
			FNREG_ManageRegister();
		}
		break;
	case "editreg":
		if (!empty($_FN['enable_registration']) || FN_IsAdmin())
		{
			FNREG_ManageEditRegister($username);
		}
		break;
	case "recovery":        
		FNREG_ManageRecovery();
		break;

	default:
		if (empty($op))
		{
			echo FN_HtmlContent("sections/{$_FN['mod']}");
		}
		if ($_FN['user'] == "")
		{
			FN_LoginForm();
			echo "<br /><a href=\"" . FN_RewriteLink("index.php?mod={$_FN['mod']}&amp;op=recovery") . "\">" . FN_Translate("password recovery") . "</a>";
			if (!empty($_FN['enable_registration']))
			{
				echo "<br /><a href=\"" . FN_RewriteLink("index.php?mod={$_FN['mod']}&amp;op=register") . "\">" . FN_Translate("register") . "</a>";
			}
		}
		else
		{
			$user=$_FN['user'];
			echo "<div  class=\"fnlogin\" style=\"text-align:center\">";
			echo "<a href=\"" . FN_RewriteLink("index.php?mod={$_FN['mod']}&amp;op=editreg") . "\">{$_FN['user']}</a><br />";
			echo FN_HtmlUserImage($user);
			echo "<br /><a href=\"" . FN_RewriteLink("index.php?mod={$_FN['mod']}&amp;op=editreg") . "\">" . FN_Translate("profile settings") . "</a><br /><br />";
			FN_LogoutForm();
			echo "</div>";
		}
		break;
}
?>