-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth1.php
executable file
·88 lines (48 loc) · 1.55 KB
/
auth1.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
<?php
include"master_inc.php";
include"settings.php";
$username_from_cookie = $_COOKIE[$cookiename]; //retrieve contents of cookie
if($permission_level==''){
$sql="SELECT * FROM users WHERE username='$username_from_cookie'";
}else{
$threshold = $permission_level-1;
$sql="SELECT * FROM users WHERE username='$username_from_cookie' AND permissions>'$threshold'";
}
$result=mysql_query($sql);
// Mysql_num_row is counting table rows
$count=mysql_num_rows($result);
// If result matches $myusername and $mypassword, table row must be 1 row
$username_from_cookie = $_COOKIE[$cookiename]; //retrieve contents of cookie
$con = mysql_connect("$host","$user","$pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$daba2", $con);
$result = mysql_query("SELECT * FROM users WHERE username='$username_from_cookie'");
while($row = mysql_fetch_array($result))
{
$pre = $row['permissions'];
}
if($pre !='5')
{
header("location:user.php");
}
if($count==0){
{
header("location:login.php");
}
}
$query = "SELECT * FROM users WHERE `username`='$username_from_cookie'";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// get results
$result = mysql_query($query) or die("Couldn't execute query");
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$permissions= $row["permissions"];
}
//end Chris Carr Auth Check Header
$username = $username_from_cookie;
mysql_close($con);
?>