Exemplo n.º 1
0
    public function verif_post_connect()
    {
        if (!isset($_POST['action']) || $_POST['action'] != 'connection') {
            return;
        }
        if ($_POST['action'] == 'connection') {
            $login = strip_tags($_POST['login']);
            $mdp = strip_tags($_POST['password']);
            unset($_POST);
            $message = '';
            $login = strtolower($login);
            $mdp = strtolower($mdp);
            if (isset($login) && $login != '' && (isset($mdp) && $mdp != '')) {
                $res_fx_login = parent::select_simple($var = 'id, login', $from = 'login', $where = '', $order = '', $type_return = 'object');
                foreach ($res_fx_login as $login_fx) {
                    if ($login == $login_fx->login) {
                        //ici ok
                        $res_fx_mdp = parent::select_simple($var = 'id, mdp', $from = 'login', $where = '', $order = '', $type_return = 'object');
                        foreach ($res_fx_mdp as $mdp_fx) {
                            //ici ok
                            if ($mdp == $mdp_fx->mdp) {
                                $id = $mdp_fx->id;
                                $where = 'id = ' . $id;
                                $level_user = parent::select_simple($var = 'auth', $from = 'login', $where, $order = '', $type_return = 'object');
                                if (isset($_SESSION['login'])) {
                                    session_unset();
                                } else {
                                    $_SESSION['login'] = $login;
                                    $_SESSION['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
                                    $_SESSION['SERVER_ADDR'] = $_SERVER['SERVER_ADDR'];
                                    $security = new security();
                                    $ban_ip = true;
                                    if ($ban_ip == 'true') {
                                        $_SESSION['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
                                        if ($level_user[0]->auth == self::LEVEL_MODO) {
                                            $_SESSION['level_user'] = self::LEVEL_MODO;
                                            $security->set_user_lvl(self::LEVEL_MODO);
                                        } else {
                                            if ($level_user[0]->auth == self::LEVEL_ADMIN) {
                                                $_SESSION['level_user'] = self::LEVEL_ADMIN;
                                                $security->set_user_lvl(self::LEVEL_ADMIN);
                                            } else {
                                                if ($level_user[0]->auth == self::LEVEL_SUPER_ADMIN) {
                                                    $_SESSION['level_user'] = self::LEVEL_SUPER_ADMIN;
                                                    $security->set_user_lvl(self::LEVEL_SUPER_ADMIN);
                                                } else {
                                                    $_SESSION['level_user'] = self::LEVEL_USER;
                                                    $security->set_user_lvl(0);
                                                }
                                            }
                                        }
                                    }
                                }
                                ?>
									<p style="font-size:17px; padding:10px; margin-top:15px; text-align:center;" class="bg-warning">Vous êtes bien connecté !</p>
									<p style="font-size:17px; padding:10px; text-align:center;" class="bg-warning">Bienvenue <?php 
                                echo $login;
                                ?>
</p>
									
									<script>
					     				
					    				function return_after(){
					    					document.location.href="../../";
					    				}	
					    				setTimeout(return_after,1000);				     				
					     				
									</script>
									<?php 
                                break;
                            }
                        }
                    }
                }
            } else {
                $message = 'Erreur de connection , vérifiez vos données !';
                echo '<div class="alert alert-danger" role="alert">' . $message . '</div>';
            }
        }
    }