<?php ob_start(); ?>
<!DOCTYPE html>
<html>
<?php include "layouts/db_connect.php"; ?>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>INFOSSEL DAILY WEEKLY COLLECTION SOFTWARE | DAILY COLLECTION SOFTWARE | WEEKLY COLLECTION SOFTWARE</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
    integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf"
    crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="./style.css">

</head>
<body>
    
    <section class="container-fluid" style="height: 100vh;">
        
       <div class="row row-cols-1 row-cols-lg-6 g-2 g-lg-3">
        <div class="col-lg-8" >
            <div id="carouselExampleFade" class="carousel slide carousel-fade" data-bs-ride="carousel">
                <div class="carousel-inner">
                  <div class="carousel-item active">
                   <center> <img src="daily (2).gif" class="img-fluid W-75 h-75" alt="..."></center>
                  </div>
                </div>
                <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="prev">
                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  <span class="visually-hidden">Previous</span>
                </button>
                <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="next">
                  <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  <span class="visually-hidden">Next</span>
                </button>
              </div>
        </div>
        <div class="col-lg-4 bg-light">
            <div class="form-container ">
				  <?php $sql3=mysqli_query($conn, "select * from mfin");
	  $row3 = mysqli_fetch_array($sql3);
	  $mmfin = $row3['name']; ?>
<form class="form-horizontal" method="post" action="" enctype="multipart/form-data" role="form">
                    <center><img class="img-fluid w-75 h-75" style="margin-top: 70px;" src="DAILY WEEKLY SOFTWARE.jpg" alt=""></center>
                     
                     <h2><center>INFOSSEL DAILY FINANCE</center></h2>
                  
                    <center><input type="username" name="uname" placeholder="Username" required style="width: 70%;height: 40px;border: none;background-color: #eee;color: #222;border-radius:20px;text-align: center;" /></center> 
                   <center><input type="password" name="pwd" placeholder="Password" required style="width: 70%;height: 40px;border: none;background-color: #eee;color: #222;border-radius:20px;text-align: center;margin-top: 20px;"/></center> 
                   <center>
				   <select  name="mfin" style="text-align: center;width:70%;height: 40px;border: none;background-color: #eee;color: #222;margin-top: 30px;border-radius: 20px;">
                       	<?php $sql2 = mysqli_query($conn, "select * from mfin");  while($row2 = mysqli_fetch_array($sql2)) { ?>
				<option><?php echo $row2['name']; ?></option> <?php } ?>
				</select>
                        
                      </select></center>
                 <center>  <button class="bg-danger"  name="s2"style="border-radius: 20px;margin-top: 20px;width: 70%;height: 40px;">log In</button></center> 
    <div>
	  <?php
								if(isset($_POST['s2']))
								{
									extract($_POST);
									
							 $uname = str_replace(' ', '-', $uname); 

  $uname = preg_replace('/@![^A-Za-z0-9\-]/', '', $uname);
     $pwd = str_replace(' ', '-', $pwd); 

  $pwd = preg_replace('/@![^A-Za-z0-9\-]/', '', $pwd);
									$qry=mysqli_query($conn, "select * from customer where mail='$uname' && pwd='$pwd'");
																
                						
										
									$n=mysqli_num_rows($qry);
									
									if($n==0)
									{
									echo '<script language="javascript">';
echo 'alert("Invalid username or password")';
echo '</script>';	
									}
									else
									{
										$row=mysqli_fetch_array($qry);
										$dis = $row['desig'];
										$pno = $row['mno'];
										$name = $row['name']; $mfin222 = $row['inter']; $ff = NULL;
									if(($mfin222 == 'All Company') || ($mfin222 == NULL)) {  }
									else { $mfin = $mfin222; }
										if($dis=='MDD') { 
$alpha = "1234567890";
$alpha_upper = "1234567890";
$numeric = "0123456789";
$special = "1234567890";
$chars = "";
 
if (isset($_POST['length'])){
    // if you want a form like above
    if (isset($_POST['alpha']) && $_POST['alpha'] == 'on')
        $chars .= $alpha;
     
    if (isset($_POST['alpha_upper']) && $_POST['alpha_upper'] == 'on')
        $chars .= $alpha_upper;
     
    if (isset($_POST['numeric']) && $_POST['numeric'] == 'on')
        $chars .= $numeric;
     
    if (isset($_POST['special']) && $_POST['special'] == 'on')
        $chars .= $special;
     
    $length = $_POST['length'];
} 
else {
    // default [a-zA-Z0-9]{9}
    $chars = $alpha . $alpha_upper . $numeric;
    $length = 3;
}
$len = strlen($chars);
$pw = '';
 
for ($i=0;$i<$length;$i++)
        $pw .= substr($chars, rand(0, $len-1), 1);
 
// the finished password
$pw = str_shuffle($pw);

$username="senthoor"; 
$password="Somu1712.";
$message="Hello ".$name." , ".$pw." is the OTP for senthoormotorfinance.in . INFOSSEL SOFT SOLUTIONS.";
$sender="SENTOR"; //ex:INVITE
$mobile_number=$pno;

$url="http://osm.bulksms5.com/sendmessage.php?user=".urlencode($username)."&password=".urlencode($password)."&mobile=".urlencode($mobile_number)."&message=".urlencode($message)."&sender=".urlencode($sender)."&type=".urlencode('3');

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo $curl_scraped_page = curl_exec($ch);

curl_close($ch);

$_SESSION['uname']=$uname;
$_SESSION['pwd']=$pwd;
$_SESSION['code']=$row['code'];
	$_SESSION['mfin']=$mfin;
		$_SESSION['mfin222']=$mfin222;
$_SESSION['name']=$row['name'];
$_SESSION['postt']=$row['desig'];
$_SESSION['otp']=$pw;
$_SESSION['id']=11;
$_SESSION['username']="admin";
$_SESSION['usertype']="adminn";	
header("location:indexotp.php");

										}
										
										
										
										
										
										
										
										
										else {
										$timef = strtotime($row['timef']);
										$timet = strtotime($row['timet']);
										$timec2 =  date('H:i:s');
										$timec = strtotime($timec2);
									
										if(($timef<=$timec) && ($timet>=$timec)) {
										    	session_start();
										$_SESSION['uname']=$uname;
					                                        $_SESSION['pwd']=$pwd;						
										$code = $row['code'];
										$_SESSION['code']=$row['code'];
										$_SESSION['mfin']=$mfin;
										$_SESSION['mfin222']=$mfin222;
										$_SESSION['name']=$row['name'];
										$_SESSION['postt']=$row['desig'];
																		$_SESSION['id']=11;
$_SESSION['username']="admin";
$_SESSION['usertype']="adminn";
date_default_timezone_set("Asia/Kolkata");
$ipp = $_SERVER['REMOTE_ADDR'];
$date =  date("Y-m-d"); 
$dtime =  date("d-m-Y h:i:sa"); 
	$insert=mysqli_query($conn, "insert into loginlog(code,uname,date,dtime,ipp,mfin)
	values('$code','$uname','$date','$dtime','$ipp','$mfin')");
	if($insert) {
	header("location:index3.php"); }
										
										} 
										
										else {
echo '<script language="javascript">';
echo 'alert("Un Official Login Time . Contact Admin.")';
echo '</script>';										
										}
										
										}
								
										}
								}
							?>
	 </div> </form>
            </div>
        </div>
       </div>


      </section>

  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
    <script src="./script.js"></script>
</body>
</html>