-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
91 lines (76 loc) · 2.21 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
<?php
/*
* @project phpParticleDashboard
* @file index.php
* @authors Harrison Jones ([email protected])
* @date March 13, 2015
* @brief A dashboard example using the phpParticle class
*/
/* For Debugging, Comment this in
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
*/
session_start();
// checks the post and gets for p otherwise sets it to index
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : 'index';
$renderedPage = "login";
switch ($page) {
case 'login':
if($_POST['inputAccessToken'] != "DS")
{
$_SESSION['accessToken'] = $_POST['inputAccessToken'];
$renderedPage = "index";
}
else
{
$loginError = "Bad/missing username";
// unset($_SESSION['accessToken']);
// setcookie('accessToken', '', time() - 3600); // empty value and old timestamp
$renderedPage = "login";
}
break;
case 'logout':
unset($_SESSION['accessToken']);
$renderedPage = "login";
$loginError = "You have been logged out!";
session_destroy();
break;
case 'devices':
$renderedPage = "index";
break;
case 'device':
$renderedPage = "device";
break;
case 'firmwareUpload':
$renderedPage = "firmwareUpload";
break;
case 'signal_on':
$action = 'signal_on';
$renderedPage = 'deviceSignal';
break;
case 'signal_off':
$action = 'signal_off';
$renderedPage = 'deviceSignal';
break;
case 'tokens':
$renderedPage = 'tokens';
break;
case 'newDevice':
$renderedPage = 'claimDevice';
break;
case 'removeDevice':
$renderedPage = 'removeDevice';
break;
default:
// Don't do anything
if($_SESSION['accessToken'])
$renderedPage = "index";
else
$renderedPage = "login";
break;
}
// Load the page header
if((@include 'pages/header.php') === false) die("Unable to load page header");
if((@include 'pages/' . $renderedPage . '.php') === false) die("Unable to load desired page");
if((@include 'pages/footer.php') === false) die("Unable to load page footer");