-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_app.php
69 lines (58 loc) · 1.76 KB
/
setup_app.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
<?php
require_once('config.php');
require_once('lib/misc.php');
if(!logged_in()) {
require_once('index.php');
exit();
}
require_once('lib/db.php');
require_once('lib/rabbit.php');
$rabbit = find_rabbit($db, $_REQUEST['rabbit']);
$app = app_for_rabbit($db, $rabbit, $_REQUEST['app']);
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// we need to save the data!
$app_data = array();
foreach($_POST as $key => $value) {
if($key == 'submit') {
// do nothing
} else if($key == 'next_update') {
$app['next_update'] = strtotime($value);
} else if($key == 'interval') {
$app['reschedule_interval'] = $value;
} else if($key == 'on_days') {
$app['on_days'] = $value;
} else {
$app_data[$key] = $value;
}
}
$app['data'] = serialize($app_data);
save_rabbit_app($db, $rabbit, $app);
header("Location: apps.php?rabbit=".$rabbit['mac_id']);
exit();
} else {
if($app['data']) {
$app_data = unserialize($app['data']);
} else {
$app_data = array();
}
}
require('header.php');
$app_name = $app['application'];
?>
<header class="jumbotron masthead">
<div class="inner">
<h1>Nabaztag Server</h1>
<p><?php echo rabbit_name($rabbit); ?></p>
</div>
</header>
<hr class="soften">
<div class="marketing">
<h1>Configure <?php echo $app_name; ?></h1>
<form method="post" action="setup_app.php?rabbit=<?php echo $_REQUEST['rabbit']; ?>&app=<?php echo $_REQUEST['app']; ?>" id="app-setup-form" data-ajax="false" class="ui-body ui-body-b ui-corner-all">
<?php require('apps/'.$app_name.'_config.php'); ?>
<fieldset data-role="controlgroup">
<input type="submit" name="submit" value="Save" id="submit" data-role="none" class="btn button"/>
</fieldset>
</form>
</div>
<?php require('footer.php'); ?>