-
Notifications
You must be signed in to change notification settings - Fork 1
/
adm.php
80 lines (68 loc) · 1.91 KB
/
adm.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
<?php
include_once("functions.php");
switch ($_REQUEST["do"]) {
case 'save':
# write to YAML file
if(saveConfig($_POST["config"])) {
$message = "Data has been saved: " . date("Ymd H:i:s");
$messageClass = "success";
}
else
{
$message = "Could not save the data. Check your config and file permissions.";
$messageClass = "error";
}
$formData = stripslashes($_POST["config"]);
break;
default:
$formData = loadConfig('config.yml');
break;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reload infoboard rotator ADMINISTRATION</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="http://reload.dk/favicon.ico">
<!-- Lets add some CodeMirror support -->
<script src="lib/codemirror-4.1/lib/codemirror.js"></script>
<link rel="stylesheet" href="lib/codemirror-4.1/lib/codemirror.css">
<link rel="stylesheet" href="lib/codemirror-4.1/theme/night.css">
<script src="lib/codemirror-4.1/mode/javascript/javascript.js"></script>
<style>
#editor {
width: 80%;
min-height: 600px;
border: 1px solid #333;
}
.error {
background-color: red;
}
.success {
background-color: green;
}
</style>
</head>
<body>
<h1>Infoboard Administration</h1>
<p>Only for YAML ninjas!</p>
<?php
if(isset($message) && isset($messageClass)) {
echo "<h2 class='".$messageClass."'>".$message."</h2>";
}
?>
<form action="?do=save" method="post">
<textarea id="editor" name="config"><?php echo $formData; ?></textarea>
<input type="submit" value="Gem - skriv til YAML fil" />
</form>
<script>
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
theme: "night"
});
</script>
</body>
</html>