mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-25 22:43:47 +01:00
First commit. Check if all is uploaded well.
This commit is contained in:
36
login.php
Executable file
36
login.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require "functions.php";
|
||||
|
||||
if (isset($_GET['do'])){
|
||||
if ($_GET['do'] == 'logout'){
|
||||
require_once "connect.php";
|
||||
dbw_query($db_conn, "UPDATE USERS SET SessionID = NULL WHERE SessionID='$_COOKIE[SessionID]'");
|
||||
setcookie("SessionID", "", time()-3600,"/");
|
||||
header('Location: index.php');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['SessionID'])){ //Ya está logueado
|
||||
header('Location: panel.php');
|
||||
}
|
||||
|
||||
if (!isset($_POST['nick'])){
|
||||
echo $twig->render('login.twig');
|
||||
}
|
||||
if (isset($_POST['nick'])){
|
||||
$nick=$_POST['nick'];
|
||||
$pass= hash("sha256",$_POST['pass']);
|
||||
$finalpass = dbw_query_fetch_array($db_conn,"SELECT `Passw` FROM `USERS` WHERE nick ='$nick'");
|
||||
$passcomprobar = $finalpass[0];
|
||||
if ($pass == $passcomprobar)
|
||||
{
|
||||
$sesid = RandomString(12);
|
||||
dbw_query($db_conn, "UPDATE USERS SET SessionID = '$sesid' WHERE nick = '$nick'");
|
||||
setcookie("SessionID",$sesid,"0","/");
|
||||
header('Location: panel.php');
|
||||
}else{
|
||||
echo $twig->render('login.twig', array('status' => 'error'));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user