Просмотр исходного кода

iniziato comando create directory

cek 8 лет назад
Родитель
Сommit
a772c15a47

+ 4 - 1
arav_up_api/index.php

@@ -98,7 +98,10 @@ function parseRequest() {
             $requestHandler = new arkiwiRequestPostModifyMetadata($request);
             break;
 
-
+        case 'createdirectory':
+            require_once './requests/requestPostCreateDirectory.php';
+            $requestHandler = new arkiwiRequestPostCreateDirectory($request);
+            break;
 
 
 

+ 3 - 0
arav_up_api/requests/requestGetListMetadata.php

@@ -32,6 +32,9 @@ class arkiwiRequestGetListMetadata extends arkiwiRequest
             }
         }
 
+        if (empty($items))
+            $items = json_decode ("[]");
+
         json_encode($items);
         //FINE CAZZACCROCCHIO
 

+ 44 - 0
arav_up_api/requests/requestPostCreateDirectory.php

@@ -0,0 +1,44 @@
+<?php
+require_once('request.php');
+require_once('../arav_up_inclu/base64codec.php');
+require_once('../arav_up_inclu/utils.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 = "/".decoder($extra[0]);
+    }
+
+	public function run() {
+		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');
+
+        report(1, "AAAAA ".$input);
+
+
+		$this->setCode(201);
+		$this->setBodyJSON(true);
+	}
+
+	private function addKeyValue($k, $v) {
+		$this->metadata[$k] = $v;
+	}
+}

+ 68 - 0
arav_up_client/mkdir.php

@@ -0,0 +1,68 @@
+<?php
+    // includes
+    $includePath = array();
+    $includePath[] = '../arav_up_inclu';
+    $includePath[] = get_include_path();
+    $includePath = implode(PATH_SEPARATOR,$includePath);
+    set_include_path($includePath);
+
+    require '../arav_up_confs.php';
+    require_once('auth.php');
+    require_once('report.php');
+
+    // presenta auth
+    if (!isset($_SERVER['PHP_AUTH_USER'])) {
+         prompt_auth();
+    //     report(1,"PHP_AUTH_USER not set, exiting"); //Lo vogliamo davvero loggare?
+         exit;
+    }
+
+    $authstate = do_local_auth($_SERVER['PHP_AUTH_USER'], hash("sha256",$_SERVER['PHP_AUTH_PW']));
+    // report(1,"userid : ".$authstate["userid"]);
+    // report(1,"dir : ".$authstate["dir"]);
+    if ($authstate["esito"] != "AUTH_OK") {
+    //     // es: is_inside_dir($object, $authstate["dir"]);
+        prompt_auth();
+    //     report(1,"esito not AUTH_OK, exiting");
+        exit;
+    }
+
+    // -----------------
+
+    parse_str($_SERVER['QUERY_STRING'], $query);
+
+    // I am not afraid of errors:
+    error_reporting(E_ALL);
+?>
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <title>Arkiwi uploader</title>
+    <meta name="description" content="">
+
+    <script src="/arav_up_client/bower_components/jquery/dist/jquery.js"></script>
+    <script src="/arav_up_client/scripts/arkiwi.js"></script>
+    <script src="/arav_up_client/scripts/main.js"></script>
+
+</head>
+
+<body>
+
+    <form id="file-form" method="POST">
+        <p>Pippone con spiegone, si può anche mettere da un'altra parte, CRI vedi tu quando fai grafica</p>
+        <div id="metadata_container">
+        </div>
+        <div id="buttons_container">
+            <input type="text" placeholder="new directory name" id="mkdirInput"/>
+            <button type="submit" id="confirm-button" disabled>Ok</button>
+        </div>
+    </form>
+
+    <input type="hidden" id="document-type" value="<?php echo $query['type']; ?>"/>
+    <input type="hidden" id="document-value" value="<?php echo $query['value']; ?>"/>
+</body>
+
+</html>

+ 14 - 29
arav_up_client/scripts/arkiwi.js

@@ -66,7 +66,12 @@ ARKIWI.Uploader.prototype.listMetadata = function (item64, callback) {
         data: '',
         dataType: 'json',
         error: function (xhr, status, error) {
-            throw 'Arkiwi.listMetadata(): status ' + status + ' error ' + error;
+            if (status != 'parsererror')
+                throw 'Arkiwi.listMetadata(): status ' + status + ' error ' + error;
+            else {
+                if (callback != undefined)
+                    callback(JSON.parse("[]"));
+            }
         },
         success: function (result, status, xhr) {
             if (callback != undefined)
@@ -88,7 +93,7 @@ ARKIWI.Uploader.prototype.modifyMetadata = function (item64, jsonKVString, callb
         dataType: 'json',
         contentType: "application/json",
         error: function (xhr, status, error) {
-            throw 'Arkiwi.metadata(): status ' + status + ' error ' + error;
+            throw 'Arkiwi.modifyMetadata(): status ' + status + ' error ' + error;
         },
         success: function (result, status, xhr) {
             if (callback != undefined)
@@ -98,39 +103,19 @@ ARKIWI.Uploader.prototype.modifyMetadata = function (item64, jsonKVString, callb
     });
 };
 
-/* Cancella un metadato da un file */
-ARKIWI.Uploader.prototype.removeMetadata = function (jsonKVString, callback) {
+/* Aggiunge o sovrascrive i metadati di un file. */
+ARKIWI.Uploader.prototype.createDirectory = function (item64, newDirectory, callback) {
     $.ajax({
-        url: this.uploaderUrl + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
+        url: this.uploaderUrl + '/createdirectory/' + item64 + '/?' + this.defaultParameters,
         type: 'POST',
         async: true,
         cache: false,
         context: this,
-        data: jsonKVString,
-        dataType: 'json',
-        error: function (xhr, status, error) {
-            throw 'Arkiwi.removeMetadata(): status ' + status + ' error ' + error;
-        },
-        success: function (result, status, xhr) {
-            if (callback != undefined)
-                callback(result);
-        },
-        complete: function (xhr, status) {}
-    });
-};
-
-/* Chiude la sessione con l'asset store */
-ARKIWI.Uploader.prototype.close = function (callback) {
-    $.ajax({
-        url: this.uploaderUrl + '/close/' + this.sessionId + '/?' + this.defaultParameters,
-        type: 'GET',
-        async: true,
-        cache: false,
-        context: this,
-        data: '',
-        dataType: 'json',
+        data: newDirectory,
+        dataType: 'text',
+        contentType: "text/plain ",
         error: function (xhr, status, error) {
-            throw 'Arkiwi.close(): status ' + status + ' error ' + error;
+            throw 'Arkiwi.createDirectory(): status ' + status + ' error ' + error;
         },
         success: function (result, status, xhr) {
             if (callback != undefined)

+ 13 - 1
arav_up_client/scripts/main.js

@@ -76,7 +76,18 @@ function initializeEdit(endpoint) {
             e.preventDefault();
         });
     })
-}
+};
+
+function createDirectory(endpoint) {
+    arkiwi = new ARKIWI.Uploader(endpoint);
+    documentType = $('#document-type').val();
+    documentValue = $('#document-value').val();
+    newDirectory = $('#mkdirInput').val();
+
+    arkiwi.createDirectory(documentValue, newDirectory, function (result) {
+
+    });
+};
 
 function uploadMetadata() {
     var metadataArray = Array();
@@ -159,3 +170,4 @@ function fileInputUpdate(files) {
         e.preventDefault();
     });
 };
+

+ 62 - 0
arav_up_users/arav_up_confs.php

@@ -0,0 +1,62 @@
+<?php
+
+$GLOBALS["conf"]["executables"] = array("ogginfo" => "/usr/bin/ogginfo",
+                    "mkvinfo" => "/usr/bin/mkvinfo",
+                    "ffmpegthumbnailer" => "/usr/local/bin/ffmpegthumbnailer",
+                    "oggthumb" => "/usr/local/bin/oggThumb",
+                    "mktorrent" => "/usr/bin/mktorrent",
+                    "qrencode" => "/usr/bin/qrencode",
+                    "vorbiscomment" => "/usr/bin/vorbiscomment"
+                    );
+
+
+// http://www.w3.org/1999/02/22-rdf-syntax-ns# o http://www.w3.org/2000/xmlns/
+$GLOBALS["conf"]["namespaces"] = array("rdf" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                              "qualifiedName" => "xmlns:rdf",
+                              "value" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
+                       "arav" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                               "qualifiedName" => "xmlns:arav",
+                               "value" => "http://wiki.indivia.net/wikka.php?wakka=ArAv"),
+                       "uimd" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                               "qualifiedName" => "xmlns:uimd",
+                               "value" => "http://wiki.indivia.net/wikka.php?wakka=UiMd"),
+                       "dc" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                             "qualifiedName" => "xmlns:dc",
+                             "value" => "http://purl.org/dc/elements/1.1/"),
+                       "rss" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                              "qualifiedName" => "xmlns:rss",
+                              "value" => "http://purl.org/rss/1.0/"),
+                       "ctag" => array("namespaceURI" => "http://www.w3.org/2000/xmlns/",
+                               "qualifiedName" => "xmlns:ctag",
+                               "value" => "http://commontag.org/ns#")
+                       );
+
+
+$GLOBALS["conf"]["supportedexetensions"] = array("ogg","oga","ogv","ogm","webm");
+$GLOBALS["conf"]["DirsNotRegex"] =  "/^arav_|^oembed|^ft_plugins|^tmp$|^\.$/i";
+$GLOBALS["conf"]["FilesRegex"] = "/\.oga$|\.ogv$|\.ogg$|\.webm$|\.mkv$/i";
+
+// campi stabili durante la sessione
+$GLOBALS["conf"]["stablestoredfields"] = array("REMOTE_ADDR", "HTTP_USER_AGENT", "HTTP_HOST");
+// campi che cambiano durante la sessione
+$GLOBALS["conf"]["volatilestoredfields"] = array("REQUEST_TIME");
+
+$GLOBALS["conf"]["xml_version"] = "1.0";
+$GLOBALS["conf"]["xml_encoding"] = "UTF-8";
+
+$GLOBALS["conf"]["report_threshold"] = 0;
+
+$GLOBALS["conf"]["dirmetadatafile"] = "dir.data";
+
+$GLOBALS["conf"]["user_db"] = "./arav_up_users/arav_users.sqlite3";
+
+$GLOBALS["conf"]["data_basedir"] = "/tmp"; // dove stanno i doc fisici
+$GLOBALS["conf"]["metadata_basedir"] = "/tmp"; // dove stanno i metadati derivati
+
+//campi di configurazione per il client html
+$GLOBALS["conf"]["api_endpoint"] = "http://upload.arkiwi.org/arav_up_api";
+
+//campi di configurazione per la parte "CAZZACCROCCHIO"
+$GLOBALS["conf"]["assetstore_endpoint"] = "http://assetstore.arkiwi.org";
+
+?>