forked from phpython/phpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.exec.php
More file actions
44 lines (33 loc) · 793 Bytes
/
python.exec.php
File metadata and controls
44 lines (33 loc) · 793 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
37
38
39
40
41
42
43
44
<?php
##
require_once __DIR__.'/python.eval.php';
##
class lang_python_exec {
##
public static function __exec__($file,$endmarker=true) {
##
$code = file_get_contents($file);
##
$phpc = lang_python_eval::__eval__($code,$file,$endmarker);
##
echo '<xmp style="padding:5px;background:#f2f2f2;border:1px solid #ccc">';
echo $code;
echo '</xmp>';
##
echo '<xmp style="padding:5px;background:#f2f2f2;border:1px solid #ccc">';
echo $phpc;
echo '</xmp>';
##
$exec = __DIR__.'/'.md5($file).'.php';
##
file_put_contents($exec, "<?php\n".$phpc);
##
echo '<xmp style="padding:5px;border:1px solid #f2f2f2">';
try {
include($exec);
} catch (Exception $exception) {
echo $exception->getMessage();
}
echo '</xmp>';
}
}