<?php
/* **
 * @application PhpMyShopping
 * @part        Admin boutique
 * @file        verif_login.php
 * @path        ./admin/
 * @author      Stephane DINE <stephane@phpmyshopping.org>
 * @site        http://www.phpmyshopping.org
 * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
 *
 * PHP version 5
 */

session_start();

include('../ident.php');
include('./include/class.admin.php');
$admin = new admin();
$result = $admin->adminShopIdent($_POST['Username'], $_POST['Password']);

/**
 * User present dans la table User
 */
if ($result != false) {
	if ($result['Status'] == 'A') {
		/**
		 * Autorisation de se logguer
		 */
		$_SESSION['LoginOk']       = 'IdentOk';
		$_SESSION['Level']         = $result['Status'];
		$_SESSION['Username']      = $_POST['Username'];
		$_SESSION['ID_ShopAdmin']  = $result['ID_ShopAdmin'];
		$_SESSION['msgErrorLogin'] = '';
		$file = 'index.php';
	} elseif ($result['Status'] == 'L') {
		/**
		 * Compte desactive
		 */
		$_SESSION['msgErrorLogin'] = 'Votre compte &agrave; &eacute;t&eacute; bloqu&eacute;.<br />Pour plus d\'infos, veuillez contacter l\'administrateur de votre boutique.';
		$file = 'login.php';
	} elseif ($result['Status'] == 'D') {
		/**
		 * Compte efface
		 */
	   $_SESSION['msgErrorLogin'] = 'Votre compte &agrave; &eacute;t&eacute; effac&eacute;.<br />Pour plus d\'infos, veuillez contacter l\'administrateur de votre boutique.';
		$file = 'login.php';
	}
} else {
	$_SESSION['msgErrorLogin'] = 'Identification incorrecte';
	$file = 'login.php';
}

header('Location: ./'.$file);
?>
