<?php

include_once("../include/main.inc.php");

$title="Admin Login Panel";







if ($_REQUEST['action']=="remind_password") {

	$res=getResult("admin_details"," where 1");

	$To=$res[email]; 

	$from=SITE_EMAIL;

	$fromName=getAdminname();	

	$message='Dear '.$res[name].',<br/><br/>Your username is : '.$res[user_id].'<br/>Your password is : '.$res[pwd].'<br /><br />Regards<br /><br />'.WEBSITE_NAME.' Customer Support Team<br />'.SITE_EMAIL;	

	send_email($fromName,$from,$To,$subject,$message);

	$_SESSION['session_message']="An intimation mail has been sent to your email id about username and password.";

	//header("location:index.php");
	echo "<script>window.location.href='index.php';</script>";

	exit();

}



//admin_header();

if($id1=="Logout"){

	session_destroy();

	//header("Location:$PHP_SELF");
	echo "<script>window.location.href='$PHP_SELF';</script>";

}

if(isset($_SESSION['MyCpanel'])){

	//header("Location:welcome.php");
	echo "<script>window.location.href='welcome.php';</script>";

}

else{

	if($id1=="login"){

		$sql1="select slno, last_login, user_type, user_id, country from admin_details where user_id='".$login_id."' and pwd='".$password."'";

		$db=db_query($sql1);

		$num=NumRows($db);

		if($num > 0){

			$res=db_fetch_object($db);

			$_SESSION['MyCpanel']=$res->last_login;

			$_SESSION['MyAdminUserType']=$res->user_type;

			$_SESSION['MyAdminUserID']=$res->user_id;

			$_SESSION['MyAdminCountry']=$res->country;

			$_SESSION['MyAdminUserSLNO']=$res->slno;

			$db=db_query("update admin_details set last_login=now() where user_id='".$login_id."' and pwd='".$password."' and user_type='".$user_type."'");

			//header("location:welcome.php");
			echo "<script>window.location.href='welcome.php';</script>";
			

			exit;

		}

		else{

			$_SESSION['session_message']="Invalid Username/Password!! ";

			//header("Location:index.php");
			echo "<script>window.location.href='index.php';</script>";

			exit();

		}

	}	

	?>



<html>

    <head>

      <link rel="stylesheet" type="text/css" href="login-style.css">

        <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />	 

	 <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />	 

           </head>

<body>

        	<div class="limiter"  style="background-image: url('images/bg-01.jpg');">

		<div class="container-login100">

		<!-- 	<a href="https://www.webpulseindia.com/" target="_blank" class="logo-top"><img src="images/webpulse-logo.png"></a> -->

			<div class="wrap-login100 p-l-55 p-r-55 p-b-54 text-center">

         <div class="clogo">

            <img src="<?=SITE_URL_PATH;?>/cmadmin/images/webpulse-logo.png">

          </div>

                <?php 

    $admin=mysqli_query($GLOBALS['dbcon'],"select * from admin_details");

    $result_array=mysqli_fetch_array($admin);?>

				<form class="login100-form validate-form" method="POST" action=''>

					<!-- <span class="login100-form-title p-b-49">

					<?php echo $result_array['companyName'];?> Admin Panel

					</span> -->

          <span class="red">

            <?php if($_SESSION['session_message'] != ''){echo $_SESSION['session_message'];$_SESSION['session_message']='';}?>

          </span>



					<div class="wrap-input100 validate-input m-b-23" data-validate="Username is reauired">

						<!-- <span class="label-input100">Username</span> -->

						<input class="input100" type="text" name="login_id" placeholder="Type your username">

<i class="fa fa-user icon-fa"></i>

                    </div>



					<div class="wrap-input100 validate-input" data-validate="Password is required">

						<!-- <span class="label-input100">Password</span> -->

						<input class="input100" type="password" name="password" placeholder="Type your password">

            <input class="input100" type="hidden" name="user_type" value="admin">

<i class="fa fa-lock icon-fa"></i>

					</div>

					

					<div class="text-right p-t-8 p-b-31">

						

					</div>

					

					<div class="container-login100-form-btn">

						<div class="wrap-login100-form-btn">

							<div class="login100-form-bgbtn"></div>

							<button class="login100-form-btn" type="submit" name="id1" value="login">

								Login

							</button>

						</div>

					</div>



				

				



				



				

				</form>

			</div>

			<footer>

                    <div class="col-lg-12 col-md-12 text-center">Powered by Webpulse - <a href="https://www.webpulseindia.com/" target="_blank" title="Web Designing" style="display:inline">Web Designing</a>, <a href="https://www.webpulseindia.com/digital-marketing" target="_blank" title="Digital Marketing" style="display:inline">Digital Marketing</a> &amp; <a href="https://www.webpulseindia.com/branding" target="_blank" title="Branding Company" style="display:inline">Branding Company </a>

                    



                </div></footer>

		</div>

	

	</div>

	<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

	 <script type="text/javascript" src="js/bootstrap.min.js"></script>	

	 <script language="javascript" src="js/admin.js"></script>

	 

        </body>

 

</html>



<?php }?>



<!--358bf058488c752775a75de198a9fe0b-->