forked from ea1jay/tetrasvxdashboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
editdash.php
73 lines (65 loc) · 2.53 KB
/
editdash.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" lang="en">
<head>
<meta name="robots" content="index" />
<meta name="robots" content="follow" />
<meta name="language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Author" content="Iñigo Bastarrika (EA2CQ)" />
<meta name="Description" content="Tetra Dash Config Editor" />
<meta name="KeyWords" content="Tetra" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<meta http-equiv="Expires" content="0" />
<title>Tetra Dashboard Config Editor</title>
</head>
<body>
<div class="container">
<div class="contentwide">
<?php
include "config/config.php";
if(isset($_POST['data'])) {
// File Wrangling
exec('sudo cp ' . DASHCONFIG . ' /tmp/fmehg65694eh.tmp');
exec('sudo chown svxlink:svxlink /tmp/fmehg65694eh.tmp');
exec('sudo chmod 664 /tmp/fmehg65694eh.tmp');
// Open the file and write the data
$filepath = '/tmp/fmehg65694eh.tmp';
$fh = fopen($filepath, 'w');
fwrite($fh, $_POST['data']);
fclose($fh);
exec('sudo cp /tmp/fmehg65694eh.tmp ' . DASHCONFIG);
exec('sudo chmod 644 ' . DASHCONFIG);
exec('sudo chown root:root' . DASHCONFIG);
// Re-open the file and read it
$fh = fopen($filepath, 'r');
$theData = fread($fh, filesize($filepath));
echo '<p style="color: red; text-align: center">Dash Config file has been modified!</p>';
} else {
// File Wrangling
exec('sudo cp ' . DASHCONFIG . ' /tmp/fmehg65694eh.tmp');
exec('sudo chown svxlink:svxklink /tmp/fmehg65694eh.tmp');
exec('sudo chmod 664 /tmp/fmehg65694eh.tmp');
// Open the file and read it
$filepath = '/tmp/fmehg65694eh.tmp';
$fh = fopen($filepath, 'r');
$theData = fread($fh, filesize($filepath));
}
fclose($fh);
?>
<form name="test" method="post" action="">
<textarea name="data" cols="80" rows="45"><?php echo $theData; ?></textarea><br />
<br><br>
<input type="submit" name="submit" value="<?php echo "APPLY" ?>" />
</form>
<br>
<a href="index.php">
<button>BACK TO TETRA DASHBOARD</button>
</a>
</div>
</div>
</div>
</body>
</html>