-
Notifications
You must be signed in to change notification settings - Fork 0
/
required.php
88 lines (59 loc) · 2.49 KB
/
required.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
/*this file contains bootstrap header files and includes connect_db.php and core.inc.php' and also stores the
variable $l_id which contains the L_id of the user*/
require 'connect_db.php';
require 'core.inc.php';
$path = '/mcqs/';
$allowed = false;
$log = array('signup.php','signup(form).php','signup_specific.php');
$l_id = logged_in();
if($l_id || ($current_file == $path.'abc.php'))
$allowed = true;
else {
$handle = fopen("allowed.txt","r");
if($handle) {
while(($line = fgets($handle)) != false) {
$line = substr($line, 0, strlen($line)-1); //removing the next_line character from end of $line
$string = $path.$line;
//echo $line.' '.strlen($line).' '.$current_file.' '.strcmp($current_file, $string).'<br>';
if(strcmp($current_file, $string) == 0) {
$allowed = true;
break;
}
}
fclose($handle);
} else echo 'error opening file';
}
if(isset($_SESSION['user_id'])){
foreach($log as $l) {
if($path.$l == $current_file) {
echo '<script> window.location.href="home.php" </script>';
break;
}
}
}
if(!$allowed)
echo '<script> window.location.href="abc.php" </script>';
//echo $allowed;
$image_folder = 'profile photos/';
$universitypapers = 'university papers/';
$logo = 'images and logos/';
//displaying all the files in allowed.txt
?>
<!DOCTYPE html>
<!--Before Login-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<!--for offline css-->
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>