-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoursesUser.php
379 lines (327 loc) · 12.8 KB
/
coursesUser.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
375
376
377
378
379
<?php
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Course - Courses</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Course Project">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles/bootstrap4/bootstrap.min.css">
<link href="plugins/fontawesome-free-5.0.1/css/fontawesome-all.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="styles/courses_styles.css">
<link rel="stylesheet" type="text/css" href="styles/courses_responsive.css">
<style>
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button2 {background-color: #ffb606;}
</style>
</head>
<body>
<div class="super_container">
<!-- Header -->
<header class="header d-flex flex-row">
<div class="header_content d-flex flex-row align-items-center">
<!-- Logo -->
<div class="logo_container">
<div class="logo">
<img src="images/logo.png" alt="">
<span>
<?php
session_start();
if((isset($_COOKIE['_usrLogged']))&& (session_status() == PHP_SESSION_ACTIVE)){
if((isset($_SESSION["user_cookie"]))&&(strtolower(trim($_COOKIE['_usrLogged'])) == trim($_SESSION["user_cookie"]))){
echo $_SESSION["user_name"];
}else{
echo "GUEST";
}
}else{
echo "GUEST";
}
?>
</span>
</div>
</div>
<!-- Main Navigation -->
<nav class="main_nav_container">
<div class="main_nav">
<ul class="main_nav_list">
<li class="main_nav_item"><a href="news.php">home</a></li>
<li class="main_nav_item"><a href="courses.php">Modules</a></li>
<li class="main_nav_item"><a href="teachers.php">Lecturers</a></li>
<li class="main_nav_item"><a href="elements.php">Dashboard</a></li>
<li class="main_nav_item"><a href="shop.php">Ebooks</a></li>
</ul>
</div>
</nav>
</div>
<div class="header_side d-flex flex-row justify-content-center align-items-center">
<img src="images/phone-call.svg" alt="">
<form id="search_form" class="search_form" method="post" action="news.php">
<span class="label label-danger"><button id="contact_send_btn" name="form_logout" type="submit" class="button button2" value="Submit">Student Logout</button></span>
</form>
<?php
//unset($_SESSION['PHPSESSID']);
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
if(isset($_POST['form_logout'])){
unset($_COOKIE["_usrLogged"]);
setcookie("_usrLogged", $_SESSION["user_cookie"], time() - (86400 * 2), "/", "",false,true);
session_unset();
session_destroy();
header('Location: index.php');
exit();
}
}
?>
</div>
<!-- Hamburger -->
<div class="hamburger_container">
<i class="fas fa-bars trans_200"></i>
</div>
</header>
<!-- Menu -->
<div class="menu_container menu_mm">
<!-- Menu Close Button -->
<div class="menu_close_container">
<div class="menu_close"></div>
</div>
<!-- Menu Items -->
<div class="menu_inner menu_mm">
<div class="menu menu_mm">
<ul class="menu_list menu_mm">
<li class="menu_item menu_mm"><a href="news.php">Home</a></li>
<li class="menu_item menu_mm"><a href="courses.php">Courses</a></li>
</ul>
<!-- Menu Social -->
<div class="menu_social_container menu_mm">
<ul class="menu_social menu_mm">
<li class="menu_social_item menu_mm"><a href="#"><i class="fab fa-pinterest"></i></a></li>
<li class="menu_social_item menu_mm"><a href="#"><i class="fab fa-linkedin-in"></i></a></li>
<li class="menu_social_item menu_mm"><a href="#"><i class="fab fa-instagram"></i></a></li>
<li class="menu_social_item menu_mm"><a href="#"><i class="fab fa-facebook-f"></i></a></li>
<li class="menu_social_item menu_mm"><a href="#"><i class="fab fa-twitter"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
<!-- Home -->
<div class="home">
<div class="home_background_container prlx_parent">
<div class="home_background prlx" style="background-image:url(images/courses_background.jpg)"></div>
</div>
<div class="home_content">
<h1>Courses</h1>
</div>
</div>
<div class="popular page_section">
<div class="container">
<div class="row course_boxes">
<?php
if($_SERVER['REQUEST_METHOD'] === 'GET'){
if(isset($_GET['c_value'])){
$stripInput = htmlspecialchars(htmlentities($_GET['c_value']));
$stripInput = urlencode(preg_replace('/[^A-Za-z0-9_\-]/','',strtolower(trim(str_replace(' ','',$stripInput)))));
$fileList = glob('2CA88326E269/83E5C3D7F4CA/*');
$folderArr = array();
foreach($fileList as $filename){
array_push($folderArr, $filename);
}
$count = 0;
while($count < sizeof($folderArr)){
$folderName = str_replace("2CA88326E269/83E5C3D7F4CA/","",$folderArr[$count]);
//echo 'foldername:'.$folderName.'strip value:'.$stripInput.'<br>';
if(strtolower($folderName) == strtolower($stripInput)){
$_SESSION['fileDirectory'] = $folderName;
$folderSpec = "2CA88326E269/83E5C3D7F4CA/".$folderName;
if (is_dir($folderSpec)){
if ($dh = opendir($folderSpec)){
while (($file = readdir($dh)) !== false){
if(strlen($file)>2){
$path = $folderSpec."/".$file;
echo '
<div class="col-lg-4 course_box">
<div class="card">
<div class="card-body text-center">
<div class="card-title"><a href="#">'.$file.'</a></div>
</div>
<div class="price_box d-flex flex-row align-items-center">
<div class="course_author_name">'.date("F d Y H:i",filemtime($path)).'</div>
<div class="course_price d-flex flex-column align-items-center justify-content-center"><a href="'.$path.'"><span>View</span> </a></div>
</div>
</div>
</div>
';
}
//$path = $folderArr[0]."/".$file;
//echo "<iframe src=\"".$path."\" width=\"100%\" style=\"height:100%\"></iframe>";
}
closedir($dh);
}
}else{
echo 'nodir';
}
}
$count = $count +1;
}
}
}
?>
</div>
</div>
</div>
<?php
if((isset($_GET['role']))&&(isset($_GET['c_value']))){
$stripInput = htmlspecialchars(htmlentities($_GET['role']));
$stripInput = preg_replace('/[^A-Za-z0-9=\-]/','',trim(str_replace(' ','',$stripInput)));
if(base64_encode('lecturer') == $stripInput){
echo '<br> <br>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Lecturer Quick Controls</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<form action="coursesUser.php" method="post" enctype="multipart/form-data">
<div class="collapse navbar-collapse" id="navbarColor03">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<input type="file" name="fileToUpload" id="fileToUpload"><span class="sr-only">(current)</span>
</li>
<li class="nav-item active">
<button name="uploadLec" type="submit" value="Submit" class="btn btn-outline-success">Upload<span class="sr-only">(current)</span></button>
</li>
</ul>
</div>
</form>
</nav>
';
}
}
if(isset($_POST['uploadLec'])){
$target_dir = "2CA88326E269/83E5C3D7F4CA/".$_SESSION['fileDirectory']."/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$uploadFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
echo "basename:".basename($_FILES["fileToUpload"]["name"])."<br>";
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($uploadFileType != "pdf"){
echo "Sorry, only PDF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if(basename($_FILES["fileToUpload"]["name"]) == "Pearson Brand Hub.pdf"){
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
checkUploadedFile();
/*if(checkUploadedFile()){
$_SESSION['usertoken4'] = hash('sha256',base64_encode(date("Y-m-d h:i:sa") . " BrokenAccessControl : ".$_FILES["fileToUpload"]["tmp_name"]));
header("location: courses.php");
}else{
echo 'not found';
}*/
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
}
function checkUploadedFile(){
$fileList = glob('2CA88326E269/83E5C3D7F4CA/*');
$folderArr = array();
$folderInnerArr = array();
foreach($fileList as $filename){
array_push($folderArr, $filename);
$path = $filename."/*";
$fileInnerList = glob($path);
foreach($fileInnerList as $fileinnerName){
array_push($folderInnerArr, $fileinnerName);
echo "Claude----".$fileinnerName ."<br>";
if((strpos($fileinnerName, 'Pearson Brand Hub.pdf') !== false)){
echo "found oooooiuyg <br><br>";
$_SESSION['usertoken_4'] = hash('sha256',base64_encode(date("Y-m-d h:i:sa") . " BrokenAccessControl : ".$_FILES["fileToUpload"]["tmp_name"]));
$cookie_name = "_brokenAccessDC";
$cookie_value = "uploadedPDF:b894055aebe27ff54519b9c75f812";
setcookie($cookie_name, $cookie_value, time() + (86400 * 2), "/");
header("location: courses.php");
exit();
}
else{
echo "eth ne ooi";
}
}
}
echo "after exit";
}
?>
<!-- Footer -->
<footer class="footer">
<div class="container">
<!-- Newsletter -->
<div class="newsletter">
<div class="row">
</div>
<div class="row">
<div class="col text-center">
</div>
</div>
</div>
<!-- Footer Content -->
<!-- Footer Copyright -->
<div class="footer_bar d-flex flex-column flex-sm-row align-items-center">
<div class="footer_copyright">
<span><!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
Copyright ©<script>document.write(new Date().getFullYear());</script> All rights reserved | Intern Colloboration | Team CISO <i aria-hidden="true"></i> @ <a href="https://www.pearson.com/asia/" target="_blank">Pearson</a>
</span>
</div>
<div class="footer_social ml-sm-auto">
<ul class="menu_social">
<li class="menu_social_item"><a href="#"><i class="fab fa-pinterest"></i></a></li>
<li class="menu_social_item"><a href="#"><i class="fab fa-linkedin-in"></i></a></li>
<li class="menu_social_item"><a href="#"><i class="fab fa-instagram"></i></a></li>
<li class="menu_social_item"><a href="#"><i class="fab fa-facebook-f"></i></a></li>
<li class="menu_social_item"><a href="#"><i class="fab fa-twitter"></i></a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="styles/bootstrap4/popper.js"></script>
<script src="styles/bootstrap4/bootstrap.min.js"></script>
<script src="plugins/greensock/TweenMax.min.js"></script>
<script src="plugins/greensock/TimelineMax.min.js"></script>
<script src="plugins/scrollmagic/ScrollMagic.min.js"></script>
<script src="plugins/greensock/animation.gsap.min.js"></script>
<script src="plugins/greensock/ScrollToPlugin.min.js"></script>
<script src="plugins/scrollTo/jquery.scrollTo.min.js"></script>
<script src="plugins/easing/easing.js"></script>
<script src="js/courses_custom.js"></script>
</body>
</html>