-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.php
51 lines (37 loc) · 1.08 KB
/
compiler.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
<?php
chdir(__DIR__);
/**
* Created by PhpStorm.
* User: alekseyyp
* Date: 24.07.15
* Time: 12:32
*/
if ( isset( $_POST['val'] ) ) {
class Variables {
public static $data;
}
register_shutdown_function(function(){
$response = [
'content' => ob_get_contents()
];
$variables = [];
foreach ( Variables::$data as $k=>$v ) {
if ( in_array($k, ['_SERVER', '_POST', '_FILES', '_ENV', '_GET', '_COOKIE', '_REQUEST']) === false ) {
ob_clean();
var_dump( $v );
$variables[] = "<b>" . $k . "</b>" . ob_get_contents();
}
}
ob_clean();
$response['variables'] = implode( "<br>", $variables );
echo json_encode( $response );
});
ob_start();
eval( $_POST['val'] );
Variables::$data = get_defined_vars();
$fr = fopen( getcwd() . '/code.log', 'a+');
fwrite($fr, date('Y-m-d H:i:s') . "\n" . $_POST['val'] . "\n ------------ \n");
fclose($fr);
} else {
throw new Exception('Welcome in WebAIS laboratory');
}