<?php

/**
 *
 * Api to login a member after connexion form
 * USE ONLY ON MOBILE
 *
 * @author flabadens
 * @version 1.0
 * @param login string
 * @param pwd string
 * @param sessid int session id
 * @uses with view : myAccount.view.php
 */

if ($versionmobile){
    include_once("../config.php3");
    $RACINE_DIR="../";
    $CORE = "";
}
else {
    include_once("config.php3");
    $RACINE_DIR="";
}

include_once($RACINE_DIR.$MOBILE_DIR."configMobile.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_db.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_generic.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_check_members.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."LOC_bib_check_members_vip.php3");

$sess = open_page($sessid);

$row = loginhashed($login, $pwd);

if ($row['Id'] == -1){
    echo "ErrorAuth";
    exit();

}
else {
        //Si le compte est comfirmé
        if( $row['Confirme'] != 0 )
        {
                $sess->memberid = $row['Id'];
                $sess->origine = $ORIGINE;
                $sess->save();

                # on récupère les params
		$member = getmember($sess->memberid);
		$player = getplayer($sess->memberid);

                // récupération des variables pour l'intégration à la vue
                //echo $login." ".$pwd." ".$member['Email'];
		$Email = $member['Email'];
		$Gender = $member['Gender'];
		$Name = $member['Name'];
		$FirstName = $member['FirstName'];
		$Zip = $member['Zip'];
		$Town = $member['Town'];
		$Country = $member['Country'];
		$Mobile = $member['Mobile'];
		$Ages = explode("-",$member['Birthdate']);
		$jj = $Ages[2];
		$mm = $Ages[1];
		$yyyy = $Ages[0];
		$Address = $member['Address'];
		$Telephone = $member['Telephone'];
		$InfoOpe = $member['InfoOpe'];
		$Password = $Password2 = $member['Password'];
		$NickName = $player['NickName'];
		$acceptNews = $member['acceptNews'];
		$acceptPartenaires = $member['acceptPartenaires'];

		$Password = "";
		$Password1 = "";
		$Password2 = "";

                include $VIEW_DIR.'MyAccount.view.php';
        }

}


?>
