-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_check_header.php
executable file
·56 lines (30 loc) · 1.04 KB
/
auth_check_header.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
<?php
include"master_inc.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
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;
?>