コード例 #1
0
}
if (isset($_POST['operation'])) {
    // $fs /var/www/test/aqfaridi/
    $fs = new fs(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'users' . DIRECTORY_SEPARATOR . 'guest' . DIRECTORY_SEPARATOR);
    try {
        $rslt = null;
        switch ($_POST['operation']) {
            case 'code_run':
                $timelimit = $_POST['tl'];
                $lang = $_POST['lang'];
                $access = $_POST['access'];
                $input = $_POST['stdin'];
                $data = $_POST['sdata'];
                $fname = $_POST['fname'];
                $ext = $_POST['ext'];
                $rslt = $fs->save($data, $fname, $ext);
                $rslt = $fs->run($timelimit, $lang, $access, $input, $fname, $ext);
                break;
            default:
                throw new Exception('Unsupported operation: ' . $_GET['operation']);
                break;
        }
        header('Content-Type: application/json; charset=utf8');
        echo json_encode($rslt);
    } catch (Exception $e) {
        header($_SERVER["SERVER_PROTOCOL"] . ' 500 Server Error');
        header('Status:  500 Server Error');
        echo $e->getMessage();
    }
    die;
}
コード例 #2
0
 // $fs /var/www/test/aqfaridi/
 $fs = new fs(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'users' . DIRECTORY_SEPARATOR . $_SESSION['username'] . DIRECTORY_SEPARATOR);
 try {
     $rslt = null;
     switch ($_GET['operation']) {
         case 'get_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->lst($node, isset($_GET['id']) && $_GET['id'] === '#');
             break;
         case "get_content":
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->data($node);
             break;
         case 'save_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->save($node, isset($_GET['sdata']) ? $_GET['sdata'] : '');
             break;
         case 'temp_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->template($node);
             break;
         case 'create_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->create($node, isset($_GET['text']) ? $_GET['text'] : '', !isset($_GET['type']) || $_GET['type'] !== 'file');
             break;
         case 'rename_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
             $rslt = $fs->rename($node, isset($_GET['text']) ? $_GET['text'] : '');
             break;
         case 'delete_node':
             $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';