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