<?php include 'inc_classes.php';?>
<?php require '../faculty_login/PHPMailer-5.2.14/class.phpmailer.php'; ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>ISAS | Log in</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/iCheck/square/blue.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<?php
if(isset($_POST['submit']))
{
	echo "<br/>".$email=$_POST['email'];
	$captch= $_POST['captcha'];
	if($email && $captch) //&& $captch 
	{
		if((trim(strtolower($_POST['captcha'])) == $_SESSION['captcha']))
		{
			echo "<br/>".$sql_user="select username,pass from site_setting where email='".$email."'";
			if(!mysql_num_rows($db->query($sql_user)))
			{
				?>
                <div class="callout callout-danger">
                <h4>Warning!</h4>
                <p>There is no user registered with this email address</p>
                </div>
                <?php
			}
			else
			{
				echo "<br/>".$sql_user= "SELECT username,pass FROM site_setting where email='".$email."'";
				$ptr_query=mysql_query($sql_user);
				$row_user=$mysql_fetch_array($ptr_query);
				
				$message ="
				<table width='100%' align='left' border='0' cellspadding='4'>
						<tr><td colspan='2' align='left'>You requested a password.</td></tr>
						<tr><td colspan='2' align='left'>Please use the following details to login</td></tr>
						<tr><td height='5'></td></tr>
						<tr><td width='15%' align='left'><b>Username</b></td>
							<td width='85%' align='left'>".$row_user['username']."<br></td>
						</tr>
						<tr><td align='left'><b>Password</b></td>
							<td align='left'><font color='#FF0000'>".$row_user['pass']."</font><br></td>
						</tr>
						<tr><td height='5'></td></tr>
						<tr><td colspan='2' align='left'>Thanks,<br>Support Team<br><strong> ISAS SYSTEMS</strong></td>
						</tr>
				</table>";
				
				echo "<br/>".$sendMessage =$message;
				echo "<input type='hidden' name='mail_content' id='mail_content' value='".addslashes($sendMessage)."'>";
				$mail = new PHPMailer(true);
				try {
						//$mail->IsSMTP();                                      // Set mailer to use SMTP
						$mail->SMTPDebug=1;   
						$mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
						$mail->SMTPAuth = true;                               // Enable SMTP authentication
						$mail->Username = 'erp.isas@gmail.com';                   // SMTP username
						$mail->Password = 'erp@frespa';                            // SMTP password
						$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
						$mail->Port = 465;
						$mail->setFrom('info@isasbeautyschool.com', 'ISAS');
						
						$emailss=$email;
						$mail->addAddress("$emailss"); 

						$mail->Subject = 'ISAS - Your Username & Password for ISAS Beauty School';
						
						$sendMessage=$GLOBALS['box_message_top'];
						$sendMessage.=$message;
						$sendMessage.=$GLOBALS['box_message_bottom'];
						
						$mail->WordWrap = 3000; 
						$mail->isHTML(true);                                  
						$mail->Body    = $sendMessage;
						 
						$mail->Send();
						echo "Email Sent Successfully.";
				} catch (phpmailerException $e) {
				  echo $e->errorMessage(); 
				} catch (Exception $e) {
				  echo $e->getMessage(); 
				}echo "<br/> Success";
					
				?>
				<div class="callout callout-success">
				<h4>Success!</h4>
				<p>Your username &  password have been sent to your email address<br>(If not received please check your spam folder) <br><br><button name="continue" onclick="window.location.href=\'login.php\'" class="btn btn-default">Continue to Login</button></center></p>
				</div>
				<?php
			}
		}
		else
		{
			//$msg="Please Enter Valid Security Code";
			?>
			<div class="callout callout-danger">
			<h4>Warning!</h4>
			<p>Please Enter Valid Security Code</p>
			</div>
			<?php
		}
	}
	 else 
	{
		?>
        <div class="callout callout-danger">
        <h4>Warning!</h4>
        <p>Please Enter correct Email Id</p>
        </div>
        <?php
		//$msg= "Please Enter Username Or Password Or Security Code";
	}
}
?>
<body class="hold-transition login-page" style="background-image:url(images/bg-1.jpg); background-repeat:no-repeat;background-size: auto;">
<div class="login-box" style=" margin-top:7%;">
  <div class="login-logo">
    <a href="index_home.php" style="color:#FFF"><b>ISAS Beauty School</b></a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body" style=" background-color:transparent;">
    <p class="login-box-msg" style="color:#FFF; font-size:20px !important">Forgot Password ?</p> 
	<p class="login-box-msg" style="color:#FFF">Please enter your registered Email id.</p>
    <form method="post" name="sign_in">
      <div class="form-group has-feedback">
        <input type="text" name="email" id="email" class="form-control" placeholder="Enter Registered Email">
        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
      </div>
      <div class="form-group">
          <div class="col-sm-12">
            <span class="text-form"><font color="#333333" size="2"> </font></span> 
            <label> <img  src="../faculty_login/captcha/captcha.php" id="captcha" height="52px"/><img src="../faculty_login/captcha/refresh.png" id="change-image" style="cursor: pointer; padding: 8px 6px;" onClick="document.getElementById('captcha').src='../faculty_login/captcha/captcha.php?'+Math.random();">
            </label>
          </div>
      </div>
      <div class="form-group has-feedback">
        <input type="password" name="captcha" id="captcha_form" class="form-control" placeholder="Security Code">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <div class="col-xs-12">
          <input type="submit" name="submit" id="submit" value="Submit" class="btn btn-primary btn-block btn-flat" >
        </div>
        <!-- /.col -->
      </div>
    </form>

    <!--<div class="social-auth-links text-center">
      <p>- OR -</p>
      <a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using
        Facebook</a>
      <a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign in using
        Google+</a>
    </div>-->
    <!-- /.social-auth-links -->

    <!--<a href="forgot_password.php" >I forgot my password</a><br>-->
    <!--<a href="register.html" class="text-center">Register a new membership</a>-->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="plugins/iCheck/icheck.min.js"></script>
<script>
  $(function () {
    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' /* optional */
    });
  });
</script>
</body>
</html>