-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
375 lines (300 loc) · 13.1 KB
/
index.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?php
session_start();
$error = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
include 'db_config.php';
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
function test_input($data, $con)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
$data = mysqli_real_escape_string($con, $data);
return $data;
}
$id = test_input($_POST["id"], $con);
$password = test_input($_POST["password"], $con);
if(!empty($id) and !empty($password)) {
$sql = "SELECT * from staff WHERE staff_login_id = '$id' AND staff_password = '$password'";
$res = mysqli_query($con,$sql);
if (mysqli_num_rows($res) > 0) {
$row = mysqli_fetch_array($res);
//if (!isset($_SESSION['id'])) {
$_SESSION['name'] = $row["staff_name"];
$_SESSION['id'] = $row["staff_login_id"];
$_SESSION['priv'] = $row["privilege"];
if($row["privilege"] == "admin") {
header("Location: admin.php");
} else if($row["privilege"] == "staff") {
header("Location: staff.php");
}
die();
//}
} else {
$error = " [ <em><u>Invalid Id/Password</u></em> ]";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="An initiative by CWIT to let students have online access to study material and notes. Find notes by department, year and subject.">
<meta name="author" content="Aniket Bhadane">
<link rel="icon" href="favicon.ico">
<title>CWIT Learning Management System</title>
<!-- Bootstrap core CSS -->
<link href="docs/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="docs/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="docs/ext_css.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">CWIT LMS</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<input name="id" id="login_id" type="text" placeholder="Login Id" class="login_input form-control">
</div>
<div class="form-group">
<input name="password" id="login_password" type="password" placeholder="Password" class="login_input form-control">
</div>
<button id="btnSignin" type="submit" class="btn btn-success">Sign in</button>
</form>
<p class="navbar-text navbar-right" id="login_label">Staff / Admin Login<?php echo $error;?></p>
</div><!--/.navbar-collapse -->
</div>
</nav>
<!-- Main jumbotron for a primary message or call to action -->
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-3 col-md-offset-0 col-xs-8 col-xs-offset-2 vcenter">
<img src="college_logo.png" />
</div><!-- refer this as to why comments are added here: http://stackoverflow.com/a/20548578/5155835
--><div class="col-md-9 vcenter">
<h1>Cusrow Wadia Institute of Technology, Pune - 1</h1>
</div>
</div>
<h2>Learning Management System</h2>
<p>An initiative by CWIT to let students have online access to study material and notes. Find the notes by selecting appropriate department, year and subject.</p>
<!--p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p-->
<!--p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p-->
<div class="row">
<div class="form-group col-md-4">
<select id="dept_select" class="form-control">
<option selected disabled>Select Department</option>
<option value="comp">Computer</option>
<option value="electrical">Electrical</option>
<option value="mech">Mechanical</option>
<option value="civil">Civil</option>
<option value="electronics">Electronics</option>
</select>
</div>
<div class="form-group col-md-4">
<select id="year_select" class="form-control">
<option selected disabled>Select Year</option>
<option value="fy">FY</option>
<option value="sy">SY</option>
<option value="ty">TY</option>
</select>
</div>
<div class="form-group col-md-4">
<select id="subject_select" class="form-control">
<option selected disabled>Select Subject</option>
</select>
</div>
</div>
<div class="alert alert-danger hidden" id="missing_select" role="alert"></div>
<button id="btnSubmit" class="btn btn-primary">Submit</button>
</div>
</div>
<div class="container-fluid hidden" id="results_container">
<p id="results_desc"></p>
<div class="alert alert-info ch_results" role="alert">Chapter 1</div>
<div class="results" id="ch1"></div>
<div class="alert alert-info ch_results" role="alert">Chapter 2</div>
<div class="results" id="ch2"></div>
<div class="alert alert-info ch_results" role="alert">Chapter 3</div>
<div class="results" id="ch3"></div>
<div class="alert alert-info ch_results" role="alert">Chapter 4</div>
<div class="results" id="ch4"></div>
<div class="alert alert-info ch_results" role="alert">Chapter 5</div>
<div class="results" id="ch5"></div>
<div class="alert alert-info ch_results" role="alert">Chapter 6</div>
<div class="results" id="ch6"></div>
</div>
<footer class="footer">
<div class="container">
<p class="text-muted">Made by <a href="https://in.linkedin.com/in/aniketbhadane" target="_blank">Aniket Bhadane</a> for CWIT.</p>
</div>
</footer>
<!-- on admin page, admin can create and delete staff login, and add and delete subjects from dept dropdown ->year dropdown ->subjects listed
<!-- dropdowns: dept, year, subject : chapter wise notes will be displayed -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="docs/jquery.min.js"><\/script>')</script>
<script src="docs/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="docs/ie10-viewport-bug-workaround.js"></script>
<script>
$(function(){
$(".login_input").keyup(function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 13) {
$("#btnSignin").click();
}
});
/*$("#btnSignin").click(function(){
$.ajax({
url: "login.php",
type: "POST",
beforeSend: function() {
$("#btnSignin").prop('disabled', true);
},
data: {
id: $("#login_id").val(),
password: $("#login_password").val(),
}
}).done(function (data) {
if(data == "Success")
window.location = "http://localhost/cwit/staff.php";
else {
$("#login_label").html("Staff / Admin Login [ <em><u>Invalid Id/Password</u></em> ]");
$("#btnSignin").prop('disabled', false);
}
}).fail(function( jqXHR, textStatus, errorThrown ) {
alert( "Request failed: " + textStatus + " , " + errorThrown );
});
});*/
$("#dept_select").change(function () {
var dept = this.value;
var year = $('#year_select').val();
get_subjects_list(dept, year);
});
$("#year_select").change(function () {
var year = this.value;
var dept = $('#dept_select').val();
get_subjects_list(dept, year);
});
function get_subjects_list(dept, year) {
$.ajax({
url: "fetch_subjects.php",
type: "POST",
beforeSend: function() {
$("#subject_select").empty();
$('#subject_select').append("<option selected disabled>Please Wait</option>");
$("#subject_select").prop('disabled', true);
},
data: {
dept: dept,
year: year,
}
}).done(function (data) {
//alert(data);
var arr = JSON.parse(data);
$("#subject_select").empty();
$("#subject_select").prop('disabled', false);
$('#subject_select').append("<option selected disabled>Select Subject</option>");
$.each(arr, function(key, val) {
if(val!="")
$('#subject_select').append("<option value='" + val + "'>" + val + "</option>");
});
}).fail(function( jqXHR, textStatus, errorThrown ) {
alert( "Request failed: " + textStatus + " , " + errorThrown );
});
}
// $("#results").append("<button class='deleteNotes' value='" + arr[i] + "'>DELETE</button><br />");
$("#btnSubmit").click(function(){
var dept = $('#dept_select').val();
var year = $('#year_select').val();
var subj_code = $('#subject_select').val();
var missing = "Missing";
if(dept == null)
missing = missing + " Department,"
if(year == null)
missing = missing + " Year,"
if(subj_code == null)
missing = missing + " Subject,"
if(missing != "Missing") {
missing = missing.slice(0, -1);
$('#missing_select').empty();
$('#missing_select').removeClass('hidden').addClass('show');
$('#missing_select').append(missing);
return;
}
$.ajax({
url: "fetch_links.php",
type: "POST",
data: {
dept: dept,
year: year,
subj_code: subj_code,
}
}).done(function (data) {
// append(), after(), before()
//alert(data);
$("#results_desc").text("Showing results for " + dept + " " + year + " " + subj_code);
$(".results").empty();
$('#results_container').removeClass('hidden').addClass('show');
$('#missing_select').removeClass('show').addClass('hidden');
var arr = JSON.parse(data);
var i = 0;
while(arr[i].split("\\").slice(-2, -1)[0] == "ch1") {
$("#ch1").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
while(arr[i].split("\\").slice(-2, -1)[0] == "ch2") {
$("#ch2").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
while(arr[i].split("\\").slice(-2, -1)[0] == "ch3") {
$("#ch3").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
while(arr[i].split("\\").slice(-2, -1)[0] == "ch4") {
$("#ch4").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
while(arr[i].split("\\").slice(-2, -1)[0] == "ch5") {
$("#ch5").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
while(arr[i].split("\\").slice(-2, -1)[0] == "ch6") {
$("#ch6").append("<div class='row note'><div class='form-group col-md-offset-1 col-md-11'><a class='btn btn-default' role='button' href = '" + arr[i] + "' target='_blank'>" + arr[i].split("\\").pop() + "</a></div></div>");
i++;
}
/*for(var i = 0; i < arr.length; i++) {
$("#results").append("<a href = '" + arr[i] + "'>" + arr[i].split("\\").pop() + "</a><br />");
}*/
}).fail(function( jqXHR, textStatus, errorThrown ) {
alert( "Request failed: " + textStatus + " , " + errorThrown );
});
});
});
</script>
</body>
</html>