1
|
<html>
|
2
|
<head>
|
3
|
<title>FabLab Radio</title>
|
4
|
<style>
|
5
|
.generale {
|
6
|
font-family: Tahoma, Geneva, sans-serif;
|
7
|
font-size: 14px;
|
8
|
}
|
9
|
</style>
|
10
|
</head>
|
11
|
<body class="generale">
|
12
|
|
13
|
<?php
|
14
|
$num_sta = 16;
|
15
|
$name_arr = array();
|
16
|
$url_arr = array();
|
17
|
|
18
|
$file = "stations.json";
|
19
|
$json_arr = array();
|
20
|
|
21
|
if (isset($_POST['submit'])) {
|
22
|
for ($i = 0; $i < 16; $i++) {
|
23
|
$url = sprintf("url%02d", $i + 1);
|
24
|
$name = sprintf("name%02d", $i + 1);
|
25
|
$json_arr[$i] = array("name" => $_POST[$name], "url" => $_POST[$url]);
|
26
|
|
27
|
//$line = $url . " = " . $_POST[$url] . " | " . $name . " = " . $_POST[$name] . "<br>\n";
|
28
|
//print($line);
|
29
|
}
|
30
|
file_put_contents($file, json_encode($json_arr, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
31
|
}
|
32
|
|
33
|
$json = json_decode(file_get_contents($file), true);
|
34
|
//print("<br>\n");
|
35
|
//print_r($json);
|
36
|
//print("<br>\n");
|
37
|
|
38
|
foreach ($json as $i => $value) {
|
39
|
$name = $value['name'];
|
40
|
$url = $value['url'];
|
41
|
$name_arr[$i] = $name;
|
42
|
$url_arr[$i] = $url;
|
43
|
//print($i . " - " . $name . " - " . $url);
|
44
|
//print("<br>\n");
|
45
|
}
|
46
|
|
47
|
$num_js = $i + 1;
|
48
|
?>
|
49
|
|
50
|
<h2 align="center">FabLab Radio - Channel Selection</h2>
|
51
|
<form action="radio.php" method="post">
|
52
|
|
53
|
<?php
|
54
|
for ($i = 0; $i < $num_sta; $i++) {
|
55
|
$ind = sprintf("%02d", $i + 1);
|
56
|
$u = sprintf("url%02d", $i + 1);
|
57
|
$n = sprintf("name%02d", $i + 1);
|
58
|
$url = $url_arr[$i];
|
59
|
$name = $name_arr[$i];
|
60
|
echo "Name $ind: <input type='text' name='$n' size='30' value='$name'>\n";
|
61
|
echo "Channel $ind: <input type='text' name='$u' size='60' value='$url'><br>\n";
|
62
|
}
|
63
|
?>
|
64
|
|
65
|
<br><input type='submit' name='submit' value='Submit'>
|
66
|
</form>
|
67
|
</body>
|
68
|
</html>
|
69
|
|