aboutsummaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/mkdir.php14
-rw-r--r--php/node.php25
-rw-r--r--php/readdir.php4
3 files changed, 38 insertions, 5 deletions
diff --git a/php/mkdir.php b/php/mkdir.php
new file mode 100644
index 0000000..cf5e8e4
--- /dev/null
+++ b/php/mkdir.php
@@ -0,0 +1,14 @@
+<?php
+require_once "database.php";
+require_once "user.php";
+require_once "node.php";
+
+session_start();
+$parent_directory=$_POST['parent_directory'];
+$dirname=$_POST['dirname'];
+$user=$_SESSION['user_object'];
+
+create_directory($parent_directory,$dirname,"",$user);
+
+
+?>
diff --git a/php/node.php b/php/node.php
index 3d56d99..b3b2c3f 100644
--- a/php/node.php
+++ b/php/node.php
@@ -3,7 +3,6 @@ require_once "database.php";
require_once "user.php";
- /*returns an assoc arrat of Node-s*/
/*path is in terms of the simulated filesystem*/
function get_directory(string $abstract_path,User $user)
{
@@ -14,7 +13,7 @@ require_once "user.php";
}
if($component=strtok($abstract_path,"/")==false)
{
- return $database->get_links_of($user->home_directory);
+ return $user->home_directory;
}
$current_dir=$database->get_node_id($component,$user->home_directory);
if($current_dir==NULL)
@@ -26,7 +25,27 @@ require_once "user.php";
if($current_dir==NULL)
return NULL;
}
- return $database->get_links_of($current_dir);
+ return $current_dir;
+ }
+
+ /*returns an assoc arrat of Node-s*/
+ /*path is in terms of the simulated filesystem*/
+ function get_directory_contents(string $abstract_path,User $user)
+ {
+ global $database;
+ $dir_id=get_directory($abstract_path,$user);
+ if($dir_id==NULL)
+ return NULL;
+ return $database->get_links_of($dir_id);
+ }
+
+ /*path is in terms of the simulated filesystem*/
+ function create_directory(string $abstract_path,string $directory_name,string $note,User $user)
+ {
+ global $database;
+ $dir_id=$database->create_dangling_directory();
+ $parent_dir_id=get_directory($abstract_path,$user);
+ $database->link_nodes($parent_dir_id,$dir_id,$directory_name,$note);
}
?>
diff --git a/php/readdir.php b/php/readdir.php
index e46d4ad..04587ee 100644
--- a/php/readdir.php
+++ b/php/readdir.php
@@ -1,10 +1,10 @@
<?php
require_once "node.php";
session_start();
- $user=$_SESSION["user_object"];
+ $user=$_SESSION['user_object'];
//echo '[ { "name": "file1.txt", "mimetype": "text/plain", "is_directory": false }, { "name": "file2.pdf", "mimetype": "application/pdf", "is_directory": false }, { "name": "dir", "mimetype": "", "is_directory": true } ] ';
- $ret=get_directory("/",$user);
+ $ret=get_directory_contents("/",$user);
$json=json_encode($ret);
echo $json;
?>