<?php 


ob_start(); session_start();$_SESSION['threeyears'] = null;$_SESSION['cannot'] = null;$_SESSION['tfbs'] = null; unset($_SESSION['tfbs']); ?>
<?php
function random_str($length,$keyspace){
    if ($length < 1) {
        throw new \RangeException("Length must be a positive integer");
    }
    $pieces = [];
    $max = mb_strlen($keyspace, '8bit') - 1;
    for ($i = 0; $i < $length; ++$i) {
        $pieces []= $keyspace[mt_rand(0, $max)];
    }
    return implode('', $pieces);
}

$_SESSION['tfbs'] = random_str(10,'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
//echo $_SESSION['tfbs'];
?>
<?php



$ssss="asdadasd";
 
if(isset($_POST["tfb"])){
          
	   if((!isset($_POST['us'])) || (!isset($_POST['ps']))){
        
         $_SESSION['tfbs'] = null;
        
    }else if(isset($_POST['us']) && isset($_POST['ps'])){
        

               $ssss="zzzz";
        
               $userflow = $_POST['us'];
               $userpassflow = $_POST['ps'];
        
               $data = array("qr"=>$userflow,"yu"=>$userpassflow);	
               $string  = http_build_query($data);
               $ch = curl_init("https://www.lajeh.ir/project/checktheval.php");	
               curl_setopt($ch, CURLOPT_POST,true);
               curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
               curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
               $return = curl_exec($ch);
               curl_close($ch);
 
               if($return !== "NONE"){
            
                   $_SESSION['threeyears'] = $userflow;
                   $_SESSION['cannot'] = $userpassflow;
                   $_SESSION['tfbs'] = $return;
                   header("Location: dashboard.php");


               }else{
				   header("Location: index.php");
			   } 
        

    }
    
}else{
 
    unset($_SESSION['tfbs']);
    
}




?>
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css">
    <title>ورود به سامانه صبا</title>
</head>

<body style="background-color:#2196f3;">
    <div class="wrapper fadeInDown">
        <div id="formContent">
            <!-- Tabs Titles -->

            <!-- Icon -->
            <div class="fadeIn first my-3 text-center">
                <img src="http://www.lajeh.ir/project/imgs/asdw_400_SABA_lajeh.jpg" id="icon" alt="User Icon" />
                
                <div class="h6 font-weight-bold my-2">داشبورد مدیریت لاژه</div>
                
            </div>
            <!-- Login Form -->
            <form action="index.php" method="post">
                <input type="text" id="login" class="fadeIn second" name="us" placeholder="نام کاربری">
                <input type="text" id="password" class="fadeIn third" name="ps" placeholder="رمز عبور">

                <input type="submit" class="my-2 fadeIn fourth" value="ورود به داشبورد" name="tfb">
            </form>

        </div>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>

</html>