Merhaba, iyi akşamlar. Aşağıda ParseLogin.php mi paylaşıyorum. Ban sistemi yapmak istedim ama takıldım biraz.
users isimli tablomda
ban adında kolon bulunmaktadır. Ban 1 olursa kullanıcının sisteme giriş yapamamasını, yasaklandınız diye hata vermesini istiyorum. 0 Olursa ise işlem devam ederek giriş yapabilecek. Aşağıdaki kod üzerinden yardımcı olabilir misiniz? Teşekkürler
<?php
include_once'config/Database.php';
include_once'config/Utilities.php';
if(isset($_POST['loginBtn'])){
//initialise the array
if (isset($_POST['g-recaptcha-response'])) {
$captcha = $_POST['g-recaptcha-response'];
}
if (!$captcha) {
echo '<script> alert("Lütfen Robot Olmadığınızı Doğrulayın") </script> <meta http-equiv="refresh" content="1; URL=https://wonderpay.meetweb.me" />';
exit;
}
$kontrol = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRET KEY&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
if ($kontrol.success == false) {
echo '<script> alert("Olası Spam Tespit Edildi!")</script>';
} else {
echo '';
}
$form_errors = array();
//Validate the form
$required_fields = array('username', 'password');
$form_errors = array_merge($form_errors, check_empty_fields($required_fields));
if(empty($form_errors)){
//Collect the form data
$user = $_POST['username'];
$password = $_POST['password'];
isset($_POST['remember']) ? $remember = $_POST['remember'] : $remember = "";
//check if user exists in the db
$sqlQuery = "SELECT * FROM users WHERE username = :username";
$statement = $db->prepare($sqlQuery);
$statement->execute(array(':username' => $user));
//fetch data from DB & compare it with inputted data
while($row = $statement->fetch()){
$id = $row['id'];
$hashed_password = $row['password'];
$username = $row['username'];
//If pwd's match create the session
if(password_verify($password, $hashed_password)){
$_SESSION['id'] = $id;
$_SESSION['username'] = $username;
$fingerprint = md5($_SERVER['REMOTE_ADDR']. $_SERVER['HTTP_USER_AGENT']);
$_SESSION['last_active'] = time();
$_SESSION['fingerprint'] = $fingerprint;
if($remember == "yes") {
rememberMe($id);
}
//call sweetalert
echo $welcome = "
<script type=\"text/javascript\">
swal({
title: \"Hoşgeldin $username\",
text: \"Giriş yapılıyor\",
type: \"success\",
timer: 6000,
showConfirmButton: false});
setTimeout(function(){
window.location.href='./panel';
}, 3000);
</script>";
}
else{
$result = flashMessage("Hatalı kullanıcı adı yada şifre");
}
}
}
else {
if(count($form_errors) == 1) {
$result = flashMessage("Form 1 de Hata var<br>");
}
else {
$result = flashMessage('Toplam ' .count($form_errors). ' hata bulundu<br>');
}
}
}
function reCaptcha($recaptcha){
$secret = "6Lewj9wZAAAAAL2_hEPg6OL5wALHRI7Mcp7Q7zhm";
$ip = $_SERVER['REMOTE_ADDR'];
$postvars = array("secret"=>$secret, "response"=>$recaptcha, "remoteip"=>$ip);
$url = "https://www.google.com/recaptcha/api/siteverify";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
}
?>