Exemplo n.º 1
0
 public static function archiver(array $path) : array
 {
     Site::requirePrivilege(Config::getCfg('permissions')['owner']);
     if (count($path) !== 5) {
         throw new Exception("Wrong number of parameters");
     }
     $board = Model::get()->getBoard(strtolower(alphanum($path[3])));
     switch (strtolower($path[4])) {
         case "start":
             self::ensurePOST();
             Archivers::run($board->getName());
             sleep(1);
             return ['result' => "Started"];
         case "stop":
             self::ensurePOST();
             Archivers::stop($board->getName());
             return ['result' => "Stopping"];
         case "output":
             self::ensureGET();
             return ['output' => Archivers::getOutput($board->getName())];
         case "error":
             self::ensureGET();
             return ['output' => Archivers::getError($board->getName())];
         case "clearerror":
             self::ensurePOST();
             Archivers::clearError($board->getName());
             return ['result' => 'success'];
         default:
             throw new Exception("Invalid command");
     }
 }