pull/1/head
韩天峰 3 years ago
parent 6cf8366b61
commit 42c0ae378d
  1. 3
      .gitignore
  2. 2
      conv.php
  3. 14
      web/public/convert.php

3
.gitignore vendored

@ -1 +1,2 @@
/.idea/
/.idea
/logs

@ -235,6 +235,8 @@ class Translator
return $this->parseCall($value);
case 'Constant':
return $this->parseConstant($value);
case 'Attribute':
return $this->parseAttribute($value);
case 'Name':
return $this->parseName($value);
case 'List':

@ -3,15 +3,21 @@ if (empty($_POST['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']);
$conv = dirname(__DIR__, 2) . '/conv.php';
$conv = ROOT_PATH . '/conv.php';
$cmd = 'php ' . $conv . ' ' . $file;
$out = shell_exec($cmd);
echo json_encode([
'data' => ['code' => $out, 'cmd' => $cmd]
'data' => ['code' => $out,]
]);
unlink($file);
file_put_contents($out_file, $out);

Loading…
Cancel
Save