-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload2.php
53 lines (48 loc) · 1.75 KB
/
upload2.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
<?php
session_start();
if(!isset($_SESSION['username'])){header('Location: index.php');}
include("databaseconnection.php");
include("main_ics_processer.php");
function printEditingSchedule($array){
echo "<form action='showedited2.php' method='post' enctype='multipart/form-data'>";
echo "<table>";
echo "<tr>"; // start of headers
echo "<td class='header'></td>";
foreach($array["Monday"]as $subkey=>$subvalue){
echo "<td class='header'>".$subkey."</td>";
}
echo"</tr>";
foreach($array as $day=>$value){
//start of printing the values
echo "<tr>";
echo "<td class='day'>".$day."</td>"; // print day
foreach($value as $subkey=>$subvalue){
if($subvalue==0){
echo "<td class='free'><input type='checkbox' name='userinput[$day][$subkey]' value=1></td>";
} else {
echo "<td class='busy'>BUSY!</td>";
}
}
echo "</tr>";
}
echo "</table>";
echo "<input type='submit' value='Submit'>";
}
//print_r($_FILES['fileToUpload']);
$fileType = pathinfo($_FILES['fileToUpload']['name'],PATHINFO_EXTENSION);
if($fileType== 'ics'){
fillingArray($_FILES['fileToUpload']['tmp_name'],$userTimeslotArray);
$_SESSION['icsArray'] = $userTimeslotArray;
initialiseWeekArray($freeTimeArray);
comparison($userTimeslotArray, $freeTimeArray);
$usernameSession = $_SESSION['username'];
$serialisedArray=serialize($freeTimeArray);
$sql="UPDATE userid SET filename= '$serialisedArray' WHERE username='$usernameSession'";
$stmt = $database->prepare($sql);
$stmt->execute();
//printEditingSchedule($freeTimeArray);
header('Location: loginPage.php');
} else {
echo '<script>alert("Ops! That is not ics file!");window.location.href="dashboard.php"</script>';
}
?>