<?php 
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# Display login screen
#
# !! be careful, this file must be saved under uft8 format, and display an e accentuated here : é
# ***************************************
$islogin=1;
$not_access=0;

require_once('includes_mobile.php');
require_once('../includes/template.inc.php');
require_once('../../../authentification.inc.php');
require_once('../../../../db_layer/'.__DBTYPE.'/portal.php');

if (!empty($_COOKIE["autoim"])) {
	$id = $_COOKIE["autoim"];
	$password = $_COOKIE["autopm"];
    $md5pass = md5($password);
	$md5 = true;
    $user = (object) null;
    $errormsg = "";
    if (user_login_cookie($id,$password,$user,$errormsg)){
        //user not avtivated in portaneo administration
        if (!user_control_mobile_access($user->id) || !user_control_webportal_opened($user->id)) {
            set_cookie('autoim','',time()-31536000);
            set_cookie('autopm','',time()-31536000);
        }
        else {
            init_session($user->id,$user->username,$user->type,$user->lang,$user->longname,$user->activity);
            header("location:index.php");
            exit();
        }
    }
    else {
        set_cookie('autoim','',time()-31536000);
        set_cookie('autopm','',time()-31536000);
    }
}
    
echo page_begining();
echo'<h1><img src="../images/lock.png" border="0" width="16" height="16">&nbsp;'.lg('login').'</h1>';

if (isset($_GET['error'])) {
    if ($_GET['error'] == "noPortalExisting")
        echo generate_warning('alert',''.lg($_GET['error'],__LOCALFOLDER).'','','');
    else
        echo generate_warning('alert',''.lg($_GET['error']).'','','');
}

echo'
    <div style="margin-left:5px;">
	<form method="post" action="scr_authentif.php">
	<p class="white"><strong>'.lg('email').'</strong><br /><input type="text" name="name" style="width: 180px" /></p><br />
	<p class="white"><strong>'.lg('password').'</strong><br /><input type="password" name="pass" style="width: 180px" /></p>
	<p><a href="../../../../portal/password_missing.php">'.lg("forgotenPassword").'</a></p><br />
	<p class="white"><input type="checkbox" name="autoim" value="autoim" checked=checked/> '.lg("rememberMe").'</p><br />
	<p><input type="submit" value="'.lg('login').'"/></p>
	</form>
    </div>';

echo generate_footer();
?>