-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateState.php
62 lines (47 loc) · 1.44 KB
/
updateState.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
<?php
// start unique session array
if (!isset($_SESSION)) {
session_start();
}
// turn on debugging mode
error_reporting(E_ALL);
ini_set('display_errors', True);
//print_r($_POST);
// store post variables in session
if (!empty($_POST['category'])) {
$_SESSION['category'] = $_POST['category'];
}
if (isset($_POST['sortBy'])) {
$_SESSION['sortBy'] = $_POST['sortBy'];
}
if (isset($_POST['sortDir'])) {
$_SESSION['sortDir'] = $_POST['sortDir'];
}
if (isset($_POST['view'])) {
$_SESSION['view'] = $_POST['view'];
}
if (isset($_POST['docID'])) {
$_SESSION['docID'] = $_POST['docID'];
}
//// DEFAULTS /////
// array of sorting types with label on left and DB table column name on right
$sortArr = array(
'By title' => 'title',
'By release year' => 'year',
'By running time' => 'totalMins',
'By date added' => 'createdOn',
'By free' => 'isFree'
);
// default sorting value
if(!isset($_SESSION['sortBy'])){
$sortKeys = array_values($sortArr);
$_SESSION['sortBy'] = $sortKeys[0];
}
// default sorting direction (null = ascending)
if(!isset($_SESSION['sortDir'])) $_SESSION['sortDir'] = "ASC";
// default category
if(!isset($_SESSION['category'])) $_SESSION['category'] = "all";
// default view (null = list/detailed view)
if(!isset($_SESSION['view'])) $_SESSION['view'] = 0;
//header("Location: index.php");
?>