|
104 | 104 |
|
105 | 105 | if (isset($_POST['action'])) {
|
106 | 106 | if (!main::validCSRF()) {
|
107 |
| - header('Location: ' . main::getUrl() . "/tasks/".$task_name."?action&success=false&message=csrfFailed"); |
| 107 | + header('Location: ' . main::getUrl() . "/tasks/" . $task_name . "?action&success=false&message=csrfFailed"); |
108 | 108 | die();
|
109 | 109 | }
|
110 |
| - // FUNCTIONS |
111 | 110 |
|
112 |
| - if($_POST['action'] == "stopService" AND isset($_POST['service_id'])){ |
113 |
| - $response = $main::buildDefaultRequest("service/".$_POST['service_id'], "DELETE"); |
114 |
| - header('Location: ' . main::getUrl() . "/tasks/".$task_name."?action&success=true&message=stopService"); |
| 111 | + if ($_POST['action'] == "stopService" and isset($_POST['service_id'])) { |
| 112 | + $response = $main::buildDefaultRequest("service/" . $_POST['service_id'], "DELETE"); |
| 113 | + header('Location: ' . main::getUrl() . "/tasks/" . $task_name . "?action&success=true&message=stopService"); |
| 114 | + die(); |
115 | 115 | }
|
116 |
| - if($_POST['action'] == "startService" AND isset($_POST['count'])){ |
| 116 | + |
| 117 | + if ($_POST['action'] == "startService" and isset($_POST['count'])) { |
117 | 118 | $i = $_POST['count'];
|
118 | 119 | while ($i != 0) {
|
119 | 120 | $i -= 1;
|
120 | 121 | $response = $main::buildDefaultRequest("service/create", params: json_encode(array("start" => isset($_POST['start']), "serviceTaskName" => $task_name)));
|
121 | 122 | }
|
122 |
| - header('Location: ' . main::getUrl() . "/tasks/".$task_name."?action&success=true&message=startService"); |
| 123 | + |
| 124 | + header('Location: ' . main::getUrl() . "/tasks/" . $task_name . "?action&success=true&message=startService"); |
| 125 | + die(); |
123 | 126 | }
|
124 | 127 | }
|
125 | 128 |
|
|
135 | 138 | die();
|
136 | 139 | }
|
137 | 140 |
|
138 |
| - $ticket = main::buildDefaultRequest("wsTicket"); |
139 |
| - if (!$ticket['success']) { |
140 |
| - header('Location: ' . main::getUrl() . "/tasks/".$task_name."?action&success=false&message=notFound"); |
141 |
| - die(); |
142 |
| - } |
143 |
| - |
144 |
| - $ticket = $ticket['id']; |
| 141 | + $ticket = main::requestWsTicket("tasks/$task_name?action&success=false&message=notFound"); |
145 | 142 |
|
146 | 143 | include "../pages/header.php";
|
147 | 144 | include "../pages/webinterface/task/console.php";
|
|
165 | 162 | header('Location: ' . main::getUrl() . "/cluster?action&success=true&message=nodeStop");
|
166 | 163 | die();
|
167 | 164 | }
|
| 165 | + |
168 | 166 | if ($_POST['action'] == "deleteNode" and isset($_POST['node_id'])) {
|
169 | 167 | main::buildDefaultRequest("cluster/" . $_POST['node_id'], "DELETE", array(), array());
|
170 | 168 | header('Location: ' . main::getUrl() . "/cluster?action&success=true&message=nodeDelete");
|
171 | 169 | die();
|
172 | 170 | }
|
| 171 | + |
173 | 172 | if ($_POST['action'] == "createNode" and isset($_POST['name'])) {
|
174 | 173 | $action = main::buildDefaultRequest("cluster", "POST", array(), json_encode(array("properties" => array(), "uniqueId" => $_POST['name'], "listeners" => array((array("host" => $_POST['host'], "port" => $_POST['port']))))));
|
175 | 174 | header('Location: ' . main::getUrl() . "/cluster?action&success=true&message=nodeCreate");
|
|
182 | 181 | include "../pages/webinterface/cluster/index.php";
|
183 | 182 | include "../pages/footer.php";
|
184 | 183 | });
|
| 184 | + |
185 | 185 | $this->any('/?/console', function ($node_id) use ($main) {
|
186 | 186 | $cluster = main::buildDefaultRequest("node/" . $node_id, "GET");
|
187 | 187 | if (!$cluster['success']) {
|
188 | 188 | header('Location: ' . main::getUrl() . "/cluster?action&success=false&message=notFound");
|
189 | 189 | die();
|
190 | 190 | }
|
191 |
| - $ticket = main::buildDefaultRequest("wsTicket"); |
192 |
| - if (!$ticket['success']) { |
193 |
| - header('Location: ' . main::getUrl() . "/cluster?action&success=false&message=notFound"); |
194 |
| - die(); |
195 |
| - } |
196 | 191 |
|
197 |
| - $ticket = $ticket['id']; |
| 192 | + $ticket = main::requestWsTicket("cluster?action&success=false&message=notFound"); |
198 | 193 |
|
199 | 194 | include "../pages/header.php";
|
200 | 195 | include "../pages/webinterface/cluster/console.php";
|
|
0 commit comments