-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·70 lines (59 loc) · 2.02 KB
/
login.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
<?php
/**
* PC Audit
* (C) Gregory Oakley-Stevenson
* @package pcaudit
*/
require_once('config.php');
include('getfloorrooms.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
//CHECK USER CREDS
$username=$_POST['username'];
$password=$_POST['password'];
$sql = "SELECT * FROM users WHERE user_name='$username' LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
// print_r($row);
// echo "<p>";
// echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";
//echo "<p>";
$hash=$row['user_password'];
$userid=$row['userid'];
$first_name=$row['first_name'];
$last_name=$row['last_name'];
if (password_verify($password, $hash)) {
//echo 'Password is valid!';
$keystring="$key-$userid";
$authkey=hash('sha256', $keystring);
echo "Keystring is:$keystring authkey is:$authkey";
print_r($pubnub->grant(true, true, "device_add", $authkey, 0));
print_r($pubnub->grant(true, true, "device_delete", $authkey, 0));
print_r($pubnub->grant(true, true, "broadcastmessage", $authkey, 0));
print_r($pubnub->grant(true, true, "broadcastmessage_ack", $authkey, 0));
$_SESSION['authkey']=$authkey;
$_SESSION['loggedin']="1";
$_SESSION['userid']=$userid;
$_SESSION['username']=$username;
$_SESSION['first_name']=$first_name;
$_SESSION['last_name']=$last_name;
$url="index.php";
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
die();
} else {
$url="login.php?incorrect=incorrect";
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
die();
}
}
} else {
$url="login.php?incorrect=incorrectc";
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
die();
}
} else {
$smarty->display('login.tpl');
}