예제 #1
0
     case 'copy_node':
         $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
         $parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
         $rslt = $fs->copy($node, $parn);
         break;
     case 'code_run':
         $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
         $timelimit = $_GET['tl'];
         $lang = $_GET['lang'];
         $access = $_GET['access'];
         $input = $_GET['stdin'];
         $rslt = $fs->run($node, $timelimit, $lang, $access, $input);
         break;
     case 'download_node':
         $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
         $rslt = $fs->download($node);
         break;
     case 'down_node':
         $fname = $_GET['fname'];
         $ext = $_GET['ext'];
         $rslt = $fs->down($fname, $ext);
         break;
     default:
         throw new Exception('Unsupported operation: ' . $_GET['operation']);
         break;
 }
 header('Content-Type: application/json; charset=utf8');
 //json_encode — Returns the JSON representation of a value
 //$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5)
 //echo json_encode($arr);
 //{"a":1,"b":2,"c":3,"d":4,"e":5}