-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathindex.php
49 lines (45 loc) · 1.16 KB
/
index.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
<!DOCTYPE html>
<?php
require_once("../tsugi/config.php");
$code = $_POST['code'] ?? '';
$input = $_POST['input'] ?? '42';
$output = $_POST['output'] ?? '';
if ( strlen($code) > 100000 ) die ('Need less code');
if ( strlen($CFG->getExtension('emcc_secret', '')) < 1 ) die("EmScriptEn Compiles not available on this server");
if ( strlen($CFG->getExtension('emcc_path', '')) < 1 ) die("EmScriptEn Compiles not available on this server");
if ( strlen($code) < 1 ) {
$code = <<< EOF
#include <stdio.h>
main() { printf("hello world\\n"); }
EOF
;
}
?>
<html>
<head>
</head>
</body>
<h1>EmScriptEn Test Harness</h1>
<form method="post" action="execute.php" id="form">
Secret: <input type="password" name="secret"><br/>
<textarea name="code" style="width:95%;" rows="5">
<?= htmlentities($code); ?>
</textarea>
<br/>
<p>Input</p>
<textarea name="input" style="width:95%;" rows="5">
<?= htmlentities($input); ?>
</textarea>
<br/>
<input type="submit" value="Compile">
</form>
<?php
if ( strlen($output) > 0 ) {
echo("<p>Program Output</p>\n");
echo('<textarea name="code" style="width:95%;" rows="5">'."\n");
echo($output);
echo("\n</textarea>\n");
}
?>
</body>
</html>