-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_progress.php
36 lines (22 loc) · 892 Bytes
/
push_progress.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
<?php
include 'modules/common/userlist_build.php';
include 'modules/common/check_login.php';
include 'modules/get_ids.php';
session_start();
if(valid_login()) {
$_SESSION['save_success'] = false;
$id_array = get_work_ids();
if ( isset($_POST['progress']) && empty(array_diff($_POST['progress'], $id_array)) ) { // checks if only valid work IDs are being saved
if ( isset($_POST['username']) && valid_user($_POST['username']) ) { // checks if user is valid
$progress = $_POST['progress'];
$user = $_POST['username'];
$handle = fopen("data/progress/$user", "w");
fwrite($handle, implode(',', $progress));
$_SESSION['save_success'] = true;
setcookie("user", $user); // always return to user that the work has been saved for to avoid confusion
}
}
}
header("Location: main.php");
exit();
?>