-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroll.php
46 lines (46 loc) · 1.74 KB
/
roll.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
<!-- I have no idea how to write PHP, exposing this to the Internet WILL get you hacked. -->
<!DOCTYPE html>
<html>
<head>
<title>⚀ ⚁ ⚂ ⚃ ⚄ ⚅</title>
<link rel="icon" type="image/x-icon" href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAzMzMAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAgAgAgAgAiIiIiIiIiIAEBAQEBAQEAAAEBAQEBAAAAAQEBAQEAAAABAQEBAQAAAAABAQEAAAAAAAEBAQAAAAAAAQEBAAAAAAABAQEAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA//8AAP//AAC22wAAAAEAAKqrAADqrwAA6q8AAOqvAAD6vwAA+r8AAPq/AAD6vwAA/v8AAP//AAD//wAA">
</head>
<body>
<input name="d" id="d" type="text" required style="width: 50%" value="<?php echo $_GET['d'] ?>" />
<script>
const d = document.getElementById('d')
function submit(r) {
location.replace(`roll.php?${(r ? 'r&' : '')}d=${encodeURIComponent(d.value)}`)
}
d.onkeydown = function(ev) {
// 13 is enter
if(ev.keyCode == 13) {
submit(false)
return false
}
}
</script>
<br/>
<button onclick="submit(true)"> Roll </button>
<button onclick="submit(false)"> Histogram </button>
<br/>
<?php
if(!isset($_GET['d']) || $_GET['d'] === '') {
$command = "./roll -h";
} else {
$die = escapeshellarg($_GET['d']);
if(isset($_GET['r'])) {
$command = "./roll -v $die";
} else {
$command = "./roll -p $die";
}
}
echo "$command";
$output = shell_exec("$command 2>&1");
echo "<pre style=\"font-size: 120%;\">$output</pre>";
?>
<footer style="color: rgb(178, 172, 162); margin-top: 3em; font-size: 75%;">
roll is provided under the GPL-3.0 license without warranty. Source code is available <a href="https://github.com/loglob/roll">here</a>.
</footer>
</body>
</html>