|
|
|
@ -3,15 +3,21 @@ if (empty($_POST['code'])) { |
|
|
|
die('require code'); |
|
|
|
die('require code'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$file = tempnam('/tmp', 'py2php'); |
|
|
|
define('ROOT_PATH', dirname(__DIR__, 2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$id = date('Ymd_H_') . uniqid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$file = ROOT_PATH . '/logs/' . $id . '.py'; |
|
|
|
|
|
|
|
$out_file = ROOT_PATH . '/logs/' . $id . '.php'; |
|
|
|
|
|
|
|
|
|
|
|
file_put_contents($file, $_POST['code']); |
|
|
|
file_put_contents($file, $_POST['code']); |
|
|
|
$conv = dirname(__DIR__, 2) . '/conv.php'; |
|
|
|
$conv = ROOT_PATH . '/conv.php'; |
|
|
|
|
|
|
|
|
|
|
|
$cmd = 'php ' . $conv . ' ' . $file; |
|
|
|
$cmd = 'php ' . $conv . ' ' . $file; |
|
|
|
$out = shell_exec($cmd); |
|
|
|
$out = shell_exec($cmd); |
|
|
|
|
|
|
|
|
|
|
|
echo json_encode([ |
|
|
|
echo json_encode([ |
|
|
|
'data' => ['code' => $out, 'cmd' => $cmd] |
|
|
|
'data' => ['code' => $out,] |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
unlink($file); |
|
|
|
file_put_contents($out_file, $out); |
|
|
|
|