File: /var/www/selfanalyse/counselor/index.php
<?php
include_once('../wp-config.php');
global $wpdb;
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 'ON');
$redirect_to=get_site_url().'/counselor/dashboard';
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
////9891531192 / 300a917c
unset($_SESSION["errMsg"]);
if(isset($_POST['submit']))
{
unset($_SESSION["errMsg"]);
$login=filter_var($_REQUEST['user_name'], FILTER_SANITIZE_STRING);
$password=$_REQUEST['password'];
$checkExist = $wpdb->get_row("select counselor_id, username, counselor_admin from $PSY_COUNSELORS where username='$login' and password='$password' limit 1");
if($login=='' || $password==''){
$_SESSION["errMsg"] = "Username/Password can not empty";
} else if($checkExist->username==''){
$_SESSION["errMsg"] = "Wrong username or password";
} else if($checkExist->counselor_admin!='1'){
$_SESSION["errMsg"] = "Your account is not active please contact Admin";
} else {
$_SESSION['COUN-ID'] = $checkExist->counselor_id;
$_SESSION['COUN-UNAME'] = $checkExist->username;
wp_redirect($redirect_to);
exit();
}
}
if(isset($_SESSION['COUN-ID'])){
$checkUser = $wpdb->get_var("select count(*) from $PSY_COUNSELORS where counselor_id='".$_SESSION['COUN-ID']."' and counselor_admin='1'");
if($checkUser!=''){
wp_redirect($redirect_to);
exit();
} else {
wp_redirect(get_site_url());
exit();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Title -->
<title>Selfanalyse Counselor | Admin Login</title>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta charset="UTF-8">
<meta name="description" content="Admin Dashboard Template" />
<meta name="keywords" content="admin,dashboard" />
<meta name="author" content="Steelcoders" />
<!-- Styles -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
<link href="assets/plugins/pace-master/themes/blue/pace-theme-flash.css" rel="stylesheet"/>
<link href="assets/plugins/uniform/css/uniform.default.min.css" rel="stylesheet"/>
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/fontawesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/line-icons/simple-line-icons.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/offcanvasmenueffects/css/menu_cornerbox.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/waves/waves.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/switchery/switchery.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/3d-bold-navigation/css/style.css" rel="stylesheet" type="text/css"/>
<!-- Theme Styles -->
<link href="assets/css/modern.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/themes/white.css" class="theme-color" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom.css" rel="stylesheet" type="text/css"/>
<script src="assets/plugins/3d-bold-navigation/js/modernizr.js"></script>
<script src="assets/plugins/offcanvasmenueffects/js/snap.svg-min.js"></script>
<script>
localStorage.removeItem("sa_liid");
</script>
</head>
<body class="page-login">
<main class="page-content">
<div class="page-inner">
<div id="main-wrapper">
<div class="row">
<div class="col-md-3 center">
<div class="login-box">
<a href="#" class="logo-name text-lg text-center">
<!--<img src="assets/images/college_nxt_now_logo.png" class="img-responsive" alt="" style="margin: 0 auto;">-->
Selfanalyse Counselor
</a>
<p class="text-center m-t-md"><?php if(isset($_SESSION["errMsg"])) echo $_SESSION["errMsg"]; ?></p>
<form class="m-t-md" method="post" action="">
<div class="form-group">
<input type="text" name="user_name" class="form-control" placeholder="Username" required>
</div>
<div class="form-group">
<input type="password" name="password" class="form-control" placeholder="Password" required>
</div>
<button type="submit" name="submit" class="btn btn-success btn-block">Login</button>
</form>
</div>
</div>
</div><!-- Row -->
</div><!-- Main Wrapper -->
</div><!-- Page Inner -->
</main><!-- Page Content -->
</body>
</html>