-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.php
More file actions
executable file
·36 lines (32 loc) · 1018 Bytes
/
Copy pathauth.php
File metadata and controls
executable file
·36 lines (32 loc) · 1018 Bytes
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
<?php
$resp = array(
'status' => 'fail',
'output' => 'Failed.'
);
if(!array_key_exists('passwd', $_POST)):
header('HTTP/1.1 400 Bad Request');
header('Content-Type: application/json');
echo json_encode($resp);
return false;
endif;
// password here
$passwd = md5('M8ke it s0!');
if (md5($_POST['passwd']) !== $passwd):
header('HTTP/1.1 200 OK');
header('Content-Type: application/json');
$resp['status'] = "not-authorized";
$resp['output'] = "You are not Authorized.<br>
<a href='javascript:location.reload()'>Try again</a>?";
echo json_encode($resp);
die();
endif;
// deploy!
header('HTTP/1.1 200 OK');
header('Content-Type: application/json');
// $output = shell_exec('rollout 2>&1');
// $output = "(no actual rollout command configured)";
$output = shell_exec('ls -l 2>&1');
$resp['status'] = 'success';
$resp['output'] = '<h1 style="color:rgba(30,255,30)">Deployed!</h1>';
$resp['output'] .= '<div class="console">'.sprintf("<pre>%s</pre>", $output)."</div>";
echo json_encode($resp);