<?php
// +-------------------------------------------------------------------------+
// | Mobile Melody Plug-in for PHP Melody ( www.phpsugar.com )
// +-------------------------------------------------------------------------+
// | MOBILE MELODY IS NOT FREE SOFTWARE
// | If you have downloaded this software from a website other
// | than www.phpsugar.com or if you have received
// | this software from someone who is not a representative of
// | phpSugar, you are involved in an illegal activity.
// | ---
// | In such case, please contact: support@phpsugar.com.
// +-------------------------------------------------------------------------+
// | Developed by: phpSugar (www.phpsugar.com) / support@phpsugar.com
// | Copyright: (c) 2004-2012 PhpSugar.com. All rights reserved.
// +-------------------------------------------------------------------------+
session_start();
$page_type = 'video';
include('settings.php');

if ($_GET['do'] == 'activate')
{
	header("Location: ". _URL_MOBI ."/signin.php?do=activate&u=". $_GET['u'] ."&key=". $_GET['key']);
	exit();
}

$meta_title = $lang['login']." - "._SITENAME;
include('header.php');

$ref = mobi_get_last_referer();
$info_msg = '';

if ($_GET['reason'] != '')
{
	switch ($_GET['reason'])
	{
		case '1': $info_msg = $lang['login_msg1']; break;
		case '2': $info_msg = $lang['login_msg3']; break;
		case '3': $info_msg = $lang['login_msg2']; break;
		case '4': $info_msg = $lang['login_msg3']; break;
		case '5': $info_msg = sprintf($lang['login_msg16'], ''); break;
		case '6': $info_msg = $lang['login_msg4']; break;
		case '100': $info_msg = $lang['login_msg12']; break;
		case '101': $info_msg = $lang['login_msg13']; break;
		case '102': $info_msg = $lang['login_msg14']; break;
	}
	$info_msg = '<ul class="reg_warning"><li>'. $info_msg .'</li></ul>';
}

if ($_GET['msg'] == 'activated')
{
	$info_msg = $lang['activate_account_msg1'];
}

if ($logged_in == 1)
{
	$info_msg .= $lang['loggedin'];
}
?>
<div id="welcome">
<strong><?php echo $lang['login']; ?></strong>
<?php echo $info_msg; ?>
</div>
<div id="content">

<?php
if($logged_in != 1) {
?> 
	<form action="signin.php" method="post" name="login_form" class="login" autocomplete="off">
	<input name="username" type="email" size="15" class="inputtext" placeholder="<?php echo $lang['your_username_or_email'];?>" autofocus="autofocus" />
	<input name="pass" type="password" size="15" class="inputtext" placeholder="<?php echo $lang['password'];?>" />
	<input type="hidden" name="ref" value="<?php echo $ref; ?>" />
	<button class="submit border2" name="Login"><?php echo $lang['login']; ?></button>
	</form>
<?php
} elseif($logged_in == 1) {
?>
<div id="logged_redirect" class="border4">
	<img src="<?php echo getavatar($userdata['user_id'], $userdata['username']); ?>" border="0" class="comm_avatar border4" />
	<div align="center"><?php echo str_replace("%s", "index.php", $lang['login_msg15']); ?></div>
	</div>
<meta http-equiv="refresh" content="3;URL=index.php?login=1" />
<?php
}
?>
</div>
<?php
include('footer.php');
?>