-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.php
116 lines (110 loc) · 5.98 KB
/
config.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
$strJSON = file_get_contents("config.json");
$configData = json_decode($strJSON, true);
$refresh = $configData["refresh"];
$workers = $configData["workers"];
$newWorkers = array();
$saveFile = false;
$htmlTop = "<!DOCTYPE html>";
$htmlTop .= "<html>";
$htmlTop .= "<head>";
$htmlTop .= "<title>Monero Lazy Monitor - Config</title>";
$htmlTop .= "<link rel='stylesheet' href='style.css' />";
$htmlTop .= "<meta name='viewport' content='width=device-width' />";
$htmlTop .= "</head>";
$htmlTop .= "<body>";
$htmlTop .= "<div class='mainwrapper'>";
$htmlBottom = "</div>";
$htmlBottom .= "</body>";
$htmlBottom .= "</html>";
if(isset($_GET['action']) && isset($_GET['oldid'])) {
$id = urldecode($_GET['oldid']);
foreach($workers as $worker) {
$newWorker=$worker;
if($worker["id"]==$id){
switch($_GET['action']){
case "NONE":
echo $htmlTop;
echo "<hr><h3 align='center'>-<( $id )>-</h3><hr>";
echo "<form action=" . $_SERVER['PHP_SELF'] . " method='get'>";
echo "<input type='hidden' name='oldid' value='" . $worker["id"] . "'>";
echo "<table>";
echo "<tr class='rowTitle'><td class='workerID' align='right'>ID: </td><td><input type='text' name='id' value='" . $worker["id"] . "'></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>IP: </td><td><input type='text' name='ip' value='" . $worker["ip"] . "'></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>Port: </td><td><input type='text' name='port' value='" . $worker["port"] . "'></td></tr>";
echo "<tr class='rowData'><td align='right'>Alert: </td><td colspan='2'><input type='text' name='alert' value='" . $worker["alert"] . "'></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>Soft: </td><td>";
echo "<select name='soft'>";
echo " <option " . ($worker["soft"]=="xmrig" ? "selected" : "") . " value='xmrig'>xmrig</option>";
echo " <option " . ($worker["soft"]=="stak" ? "selected" : "") . " value='stak'>stak</option>";
echo "</select></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>XMRig Access-token: </td><td><input type='text' name='xmrigtoken' value='" . $worker["xmrigtoken"] . "'></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>STAK User: </td><td><input type='text' name='stakuser' value='" . $worker["stakuser"] . "'></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>STAK Pass: </td><td><input type='text' name='stakpass' value='" . $worker["stakpass"] . "'></td></tr>";
echo "<tr class='rowTitle'><td> </td><td align='left'>";
echo "<input type='submit' name='action' value='EDIT'> ";
echo "<input type='submit' name='action' value='REMOVE'>";
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo $htmlBottom;
break;
case "EDIT":
$newWorker = array("id" => $_GET["id"], "ip" => $_GET["ip"], "port" => $_GET["port"], "soft" => $_GET["soft"], "alert" => (int) $_GET["alert"], "xmrigtoken"=> $_GET["xmrigtoken"], "stakuser" => $_GET["stakuser"], "stakpass" => $_GET["stakpass"]);
$saveFile = true;
array_push($newWorkers, $newWorker);
break;
case "REMOVE":
//echo "REMOVE";
//$newWorker = array("id" => $_GET["id"], "ip" => $_GET["ip"], "port" => $_GET["port"], "soft" => $_GET["soft"], "alert" => (int) $_GET["alert"]);
$saveFile = true;
break;
default:
break;
}
} else { array_push($newWorkers, $newWorker); }
}
if($_GET['action']=="ADD")
{
if($id!="")
{
$newWorker = array("id" => $id, "ip" => $_GET["ip"], "port" => $_GET["port"], "soft" => $_GET["soft"], "alert" => (int) $_GET["alert"], "xmrigtoken"=> $_GET["xmrigtoken"], "stakuser" => $_GET["stakuser"], "stakpass" => $_GET["stakpass"]);
array_push($newWorkers, $newWorker);
$saveFile = true;
} else {header('Location: index.php');}
}
if($saveFile)
{
$newConfigDataArr = array_merge(array('refresh'=>$refresh),array('workers'=>$newWorkers));
$newConfigDataJSON = json_encode($newConfigDataArr, JSON_PRETTY_PRINT);
//echo $newConfigDataJSON;
file_put_contents("config.json", $newConfigDataJSON);
header('Location: index.php');
}
} else {
echo $htmlTop;
echo "<hr><h3 align='center'>-<( ADD NEW )>-</h3><hr>";
echo "<form action=" . $_SERVER['PHP_SELF'] . " method='get'>";
//echo "<input type='hidden' name='oldid' value='" . $worker["id"] . "'>";
echo "<table>";
echo "<tr class='rowTitle'><td class='workerID' align='right'>ID: </td><td><input type='text' name='oldid' value=''></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>IP: </td><td><input type='text' name='ip' value=''></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>Port: </td><td><input type='text' name='port' value=''></td></tr>";
echo "<tr class='rowData'><td align='right'>Alert: </td><td colspan='2'><input type='text' name='alert' value=''></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>Soft: </td><td>";
echo "<select name='soft'>";
echo " <option value='xmrig'>xmrig</option>";
echo " <option value='stak'>stak</option>";
echo "</select></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>XMRig Access-token: </td><td><input type='text' name='xmrigtoken' value=''></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>STAK User: </td><td><input type='text' name='stakuser' value=''></td></tr>";
echo "<tr class='rowData'><td class='workerID' align='right'>STAK Pass: </td><td><input type='text' name='stakpass' value=''></td></tr>";
echo "<tr class='rowTitle'><td> </td><td align='left'>";
echo "<input type='submit' name='action' value='ADD'> ";
//echo "<input type='submit' name='action' value='REMOVE'>";
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo $htmlBottom;
}
?>