123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- require_once('request.php');
- require_once('../arav_up_inclu/base64codec.php');
- require_once('../arav_up_inclu/utils.php');
- require_once('../arav_up_inclu/fileops.php');
- class arkiwiRequestPostCreateDirectory extends arkiwiRequest
- {
- private $item64 = null;
- private $metadata = Array();
- private $path = null;
- public function __construct($request) {
- parent::__construct($request);
- $extra = $this->getRequestExtra();
- $this->item64 = $extra[0];
- $this->path = DIRECTORY_SEPARATOR.decoder($extra[0]);
- }
- public function run() {
- $result = false;
- if($this->request['method'] != 'POST') {
- $this->setBodyError(500, "arkiwiRequestPostCreateDirectory: POST method required.");
- return;
- }
- if (!startsWith($this->path,$_SESSION['authstate']['dir'])) {
- report(REPPRIO::FATAL, "No permission to create a new directory inside ".$this->path);
- $this->setBodyError(401, "No permission to create a new directory inside ".$this->path);
- return;
- }
- $input = file_get_contents('php://input');
- $obj = json_decode($input);
- if (property_exists($obj, 'directory')) {
- $result = data_mkdir($this->path, $obj->directory);
- }
- else {
- report(REPPRIO::FATAL, "No new directory name found.");
- $this->setBodyError(401, "No new directory name found.");
- return;
- }
- if ($result) {
- $this->setCode(201);
- $this->setBodyJSON(true);
- }
- else {
- $this->setCode(201);
- $this->setBodyJSON(false);
- }
- }
- }
|