aboutsummaryrefslogtreecommitdiffstats
path: root/php/node.php
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 14:10:46 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 14:10:46 +0200
commit820a552e7d69cdee9c040a4b683014f13b7ed6b2 (patch)
treef6c18c65b2cd5a5558f9309a40b8f420085a8f7b /php/node.php
parent0d02fe02d61bfc4db1418c9bfad2206bbfc2f3c5 (diff)
parent8b1393b3f06fdd86abc3dca396670965c42ba8c2 (diff)
downloadfileup-820a552e7d69cdee9c040a4b683014f13b7ed6b2.tar.gz
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'php/node.php')
-rw-r--r--php/node.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/php/node.php b/php/node.php
index d7c2a6c..5074082 100644
--- a/php/node.php
+++ b/php/node.php
@@ -1,25 +1,27 @@
<?php
require_once "database.php";
require_once "user.php";
-
/*path is in terms of the simulated filesystem*/
function get_directory(string $abstract_path,User $user)
{
+
global $database;
- if($abstract_path[0] != "/") {
+ if($abstract_path[0] != "/")
+ {
return NULL;
}
- $component = strtok($abstract_path,"/");
- $current_dir = $user->home_directory;
+ $component = strtok($abstract_path,"/");
+ $current_dir = $user->home_directory;
- while ($component) {
+ while($component)
+ {
$current_dir = $database->get_node_id($component, $current_dir);
- $component = strtok("/");
- };
+ $component = strtok("/");
+ }
- return $current_dir;
+ return $current_dir;
}
/*returns an assoc arrat of Node-s*/
@@ -39,6 +41,7 @@ require_once "user.php";
global $database;
$parent_dir_id=get_directory($abstract_path,$user);
+
if($database->check_if_name_is_taken($directory_name,$parent_dir_id))
{
return NULL;