-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
executable file
·98 lines (75 loc) · 1.78 KB
/
main.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
92
93
94
95
96
97
98
<?
function do_ticker($id) {
include "frames.php";
}
function do_configure($id) {
include "configure.php";
}
function save_config($id) {
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (! isset($_POST['id'])) # no id - request again
include "request_id.php";
else {
$id = $_POST['id'];
$file = "/tmp/" . $id . ".cfg";
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "configure")
do_configure($id);
elseif ($action == "save") {
$num_pages = count($_POST['urls']);
if ($num_pages >= 2) {
$fd = fopen($file, "w");
$written = 0;
fwrite($fd, $_POST['autohide'] . "\n");
fwrite($fd, $_POST['linger'] . "\n");
for ($i = 0; $i < $num_pages; $i++) {
if($_POST['urls'][$i] != "") {
$delay = $_POST['delays'][$i];
$name = $_POST['names'][$i];
fwrite($fd, $_POST['urls'][$i]);
fwrite($fd, " ");
fwrite($fd, ($delay == "" || !is_numeric($delay)) ? "null" : $delay);
fwrite($fd, " ");
fwrite($fd, ($name == "") ? "null" : $name);
fwrite($fd, "\n");
$written++;
}
}
fclose($fd);
if($written < 2) {
unlink($file);
do_configure($id);
}
else
do_ticker($id);
}
else
do_configure($id);
}
}
else {
if (file_exists($file))
do_ticker($id);
else
do_configure($id);
}
}
}
elseif ($_SERVER['REQUEST_METHOD'] == "GET") {
if (! isset($_GET['id'])) { # ask them for an id
$first_time = True;
include "splash.php";
}
else {
$id = $_GET['id'];
if (isset($_GET['action'])) {
if ($_GET['action'] == "configure")
do_configure($id);
}
else
do_ticker($id);
}
}
?>