Skip to content

Commit 8445941

Browse files
committed
Logincheck Update
1 parent 17e99e1 commit 8445941

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
2020
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
2121
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
22-
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
22+
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
2323
<link href="css/admin.css" type="text/css" rel="stylesheet" />
2424
</head>
2525
<body style="background:url('images/bgadmin.png');">

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
77
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
88
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
9-
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
9+
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
1010
<link rel="stylesheet" href="css/login.css" type="text/css"/>
1111
<link rel="stylesheet" href="css/index.css" type="text/css"/>
1212
<link rel="stylesheet" href="css/map.css" type="text/css"/>

main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
1414
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
1515
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
16-
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
16+
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
1717
<link href="css/secgen.css" rel="stylesheet" type="text/css">
1818
<link href="css/map.css" rel="stylesheet" type="text/css">
1919
<script>

template/logincheck.php

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,47 @@
55
$username = stripslashes(htmlspecialchars(htmlentities(trim(filter_var($_POST['uname']), FILTER_SANITIZE_STRING))));
66
$password = stripslashes(htmlspecialchars(htmlentities(trim(filter_var(($_POST['psw']), FILTER_SANITIZE_STRING)))));
77

8-
$hash = md5($password . "CTF");
9-
108
include 'connection.php';
11-
$result = mysqli_query($connection, "SELECT * FROM users WHERE USERNAME='$username' AND PASSWORD='$hash'");
12-
$num = mysqli_num_rows($result);
13-
$LoginCheck = mysqli_query($connection, "SELECT value FROM options WHERE name='LOGIN'");
14-
foreach (mysqli_fetch_assoc($LoginCheck) as $val) {
15-
$permission = $val;
16-
}
17-
if ($num === 1) {
18-
while ($row = mysqli_fetch_assoc($result)) {
19-
$user = $row['USERNAME'];
20-
$auth = $row['TEAM'];
21-
$level = $row['TYPE'];
22-
23-
if ($level == "A") {
24-
$_SESSION['USERNAME'] = $user;
25-
$_SESSION['TEAM'] = $auth;
26-
$_SESSION['TYPE'] = $level;
27-
echo "<h3 style='color:green;'>Admin Login</h3>";
28-
} else {
29-
if ($permission == "ALLOW") {
30-
$_SESSION['USERNAME'] = $user;
31-
$_SESSION['TEAM'] = $auth;
32-
$_SESSION['TYPE'] = $level;
33-
echo "<h3 style='color:green;'>Login Success</h3>";
34-
} else {
35-
echo "<h3 style='color:orange;'>Please wait for the game to start</h3>";
9+
if(strlen($username) >= 5 && strlen($username) <=10){
10+
if(strlen($password) >= 5 && strlen($password) <= 10){
11+
$hash = md5($password . "CTF");
12+
$result = mysqli_query($connection, "SELECT * FROM users WHERE USERNAME='$username' AND PASSWORD='$hash'");
13+
$num = mysqli_num_rows($result);
14+
$LoginCheck = mysqli_query($connection, "SELECT value FROM options WHERE name='LOGIN'");
15+
foreach (mysqli_fetch_assoc($LoginCheck) as $val) {
16+
$permission = $val;
17+
}
18+
if ($num === 1) {
19+
while ($row = mysqli_fetch_assoc($result)) {
20+
$user = $row['USERNAME'];
21+
$auth = $row['TEAM'];
22+
$level = $row['TYPE'];
23+
24+
if ($level == "A") {
25+
$_SESSION['USERNAME'] = $user;
26+
$_SESSION['TEAM'] = $auth;
27+
$_SESSION['TYPE'] = $level;
28+
echo "<h3 style='color:green;'>Admin Login</h3>";
29+
} else {
30+
if ($permission == "ALLOW") {
31+
$_SESSION['USERNAME'] = $user;
32+
$_SESSION['TEAM'] = $auth;
33+
$_SESSION['TYPE'] = $level;
34+
echo "<h3 style='color:green;'>Login Success</h3>";
35+
} else {
36+
echo "<h3 style='color:orange;'>Please wait for the game to start</h3>";
37+
}
38+
}
3639
}
40+
41+
} else {
42+
echo "<h3 style='color:orange;'>Login Fail</h3>";
3743
}
44+
}else{
45+
echo "<h3 style='color:orange;'>Login Fail</h3>";
3846
}
39-
40-
} else {
47+
}else{
4148
echo "<h3 style='color:orange;'>Login Fail</h3>";
4249
}
43-
4450
}
4551
?>

0 commit comments

Comments
 (0)