Exemple #1
0
 public function process()
 {
     switch ($this->request['command']) {
         case "ping":
             return "EasyInterface server is alive and kicking!";
             break;
         case "app_info":
             if (!array_key_exists('app_id', $this->request)) {
                 throw new Exception("Missing app_id");
             }
             return EIApps::get_app_info($this->request['app_id']);
         case "app_parameters":
             if (!array_key_exists('app_id', $this->request)) {
                 throw new Exception("Missing app_id");
             }
             return EIApps::get_app_parameters($this->request['app_id']);
         case "app_details":
             if (!array_key_exists('app_id', $this->request)) {
                 throw new Exception("Missing app_id");
             }
             return EIApps::get_app_details($this->request['app_id']);
         case "exset_details":
             if (!array_key_exists('exset_id', $this->request)) {
                 throw new Exception("Missing exset_id");
             }
             return EIExamples::get_exset_details($this->request['exset_id']);
         case "execute":
             if (!array_key_exists('app_id', $this->request)) {
                 throw new Exception("Missing app_id");
             }
             if (!array_key_exists('parameters', $this->request)) {
                 throw new Exception("Missing parameters");
             }
             return EIApps::execute($this->request['app_id'], $this->request['parameters']);
         case "get_stream":
             if (!array_key_exists('exec_id', $this->request)) {
                 throw new Exception("Missing exec_id");
             }
             return EIStream::get($this->request['exec_id']);
         case "kill_stream":
             if (!array_key_exists('exec_id', $this->request)) {
                 throw new Exception("Missing exec_id");
             }
             return EIStream::kill($this->request['exec_id']);
         default:
             throw new Exception("Invalid command in EI request");
     }
 }
Exemple #2
0
 private static function build_directories(&$files_str, $dir, $parameters)
 {
     foreach ($parameters['_ei_files'] as $file) {
         if (!EIApps::valid_file_name($file["name"])) {
             throw new Exception("Forbidden filename: " . $file["name"] . ". Filenames can only contain the " . "following characters: [a-z][A-Z][0-9][_][-][.][/]." . " Spaces and others characters are forbidden." . " It cannot contain .. as well");
         }
         // if it is a file, save it
         if (array_key_exists('type', $file) && strcmp($file['type'], 'text') == 0) {
             $filename = $dir . "/" . $file["name"];
             $dirname = dirname($filename);
             // create the directories of the leading path
             if (!file_exists($dirname)) {
                 mkdir($dirname, 0755, true);
             }
             file_put_contents($filename, $file["content"]);
             $files_str .= " " . $filename;
             // concatenate the filename to the list of filenames
         }
     }
 }