-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
144 lines (129 loc) · 6.95 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include('./class/Login.php');
$Error = '';
if (Login::isLoggedIn()){
header("location: ./User/vote.php");
} else if (LoginAdmin::isLoggedIn()){
header("location: ./Admin/index.php");
}
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (DB::query('SELECT username FROM datavoter WHERE username=:username', array(':username'=>$username))) {
if($password==DB::query('SELECT password FROM datavoter WHERE username=:username', array(':username'=>$username))[0]['password']) {
$cstrong = True;
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) ;
$userid = DB::query('SELECT userid FROM datavoter WHERE username=:username', array(':username'=>$username))[0]['userid'];
DB::query('DELETE FROM logintoken WHERE userid=:userid', array(':userid'=>$userid));
DB::query('INSERT INTO logintoken VALUES (\'\', :token, :userid)', array(':token'=>sha1($token), ':userid'=>$userid));
setcookie("SNID", $token, time() + 60 * 60 * 24 * 7, '/', NULL, NULL, TRUE);
setcookie("SNID_", '1', time() + 60 * 60 * 24 * 3, '/', NULL, NULL, TRUE);
header("location: ./User/changepass.php");
} else if(password_verify($password,DB::query('SELECT password FROM datavoter WHERE username=:username', array(':username'=>$username))[0]['password'])) {
$cstrong = True;
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) ;
$userid = DB::query('SELECT userid FROM datavoter WHERE username=:username', array(':username'=>$username))[0]['userid'];
DB::query('DELETE FROM logintoken WHERE userid=:userid', array(':userid'=>$userid));
DB::query('INSERT INTO logintoken VALUES (\'\', :token, :userid)', array(':token'=>sha1($token), ':userid'=>$userid));
setcookie("SNID", $token, time() + 60 * 60 * 24 * 7, '/', NULL, NULL, TRUE);
setcookie("SNID_", '1', time() + 60 * 60 * 24 * 3, '/', NULL, NULL, TRUE);
header("location: ./User/vote.php");
} else {
$Error = "Incorrect Password";
}
} else if (DB::query('SELECT username FROM admin WHERE username=:username', array(':username'=>$username))) {
if(password_verify($password,DB::query('SELECT password FROM admin WHERE username=:username', array(':username'=>$username))[0]['password'])) {
$cstrong = True;
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) ;
$id = DB::query('SELECT id FROM admin WHERE username=:username', array(':username'=>$username))[0]['id'];
DB::query('DELETE FROM logintokenadmin WHERE idadmin=:idadmin', array(':idadmin'=>$id));
DB::query('INSERT INTO logintokenadmin VALUES (\'\', :token, :id)', array(':token'=>sha1($token), ':id'=>$id));
setcookie("SNID", $token, time() + 60 * 60 * 24 * 7, '/', NULL, NULL, TRUE);
setcookie("SNID_", '1', time() + 60 * 60 * 24 * 3, '/', NULL, NULL, TRUE);
header("location: ./Admin/index.php");
} else {
$Error = "Incorrect Password";
}
} else {
$Error = "You're Not Registered";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pemira HIMATRO</title>
<link rel="stylesheet" href="./User/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./User/vendor/bootstrap/js/bootstrap.min.js">
<link rel="stylesheet" href="./User/style/stylesfix.css">
<link rel="icon" href="./User/assets/title.png" type="image/png">
<script src="https://kit.fontawesome.com/386e6055da.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="row">
<div class="col-12 col-xl-7 welcome-text">
<div class="text-1">Selamat Datang Di</div>
<div class="text-1">"PilihGeh"</div>
<div class="text-2">Choose the person you like to be the winner</div>
</div>
<div class="col-12 col-xl-5 right-content">
<div class="row">
<div class="col login">
<div class="row">
<div class="col login-logo text-center">
<img class="logo" src="./User/assets/Logo.png" alt="">
</div>
</div>
<div class="row">
<div class="col login-form">
<div style="font-size: 32px; font-weight: bold;">Log In.</div>
<div class="text-opacity info-login">Log in with username and password.</div>
<div class="form-login">
<form action="" method="post">
<label class="text-opacity" for="">Username</label><br>
<input class="form-box" type="text" name="username" placeholder="username"><br>
<label class="text-opacity" for="">Password</label><br>
<input class="form-box" type="password" name="password" placeholder="your password"><br>
<span class="error"><?php echo $Error;?></span><br>
<input class="submit-box" type="submit" name="login" value="Log in">
</form><br><br>
</div>
</div>
</div>
</div>
</div>
<div class="row footer-aje">
<div class="col login-footer">
<hr>
<span>2021 Copyright PilihGeh • All Rights reserved • Made in Lampung</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="scroll">
</div>
<script src="//code.jquery.com/jquery-3.1.0.js"></script>
<script>
function goTo(selector, timeout, cb) {
var $el = $(selector);
if (!$el[0]) return;
var $par = $el.parent();
if ($par.is("body")) $par = $("html, body");
setTimeout(() => {
$par.stop().animate({scrollTop: $el.offset().top}, 1000, cb && cb.call($el[0]));
}, timeout || 0);
}
goTo("#scroll", 3000, function(){
});
</script>
</body>
</html>