aboutsummaryrefslogtreecommitdiffstats
path: root/php/node.php
diff options
context:
space:
mode:
authoradam <adam@>2021-02-13 22:12:39 +0200
committeradam <adam@>2021-02-13 22:12:39 +0200
commitfc779bb49a74da78689776391f5ea999c0a03f37 (patch)
tree18d12cf3286c4544acdcea4c8f2c31272e862f93 /php/node.php
parentdf1fcd07a15417173404b25b91cb8ac176e421c5 (diff)
downloadfileup-fc779bb49a74da78689776391f5ea999c0a03f37.tar.gz
share is share
Diffstat (limited to 'php/node.php')
-rw-r--r--php/node.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/php/node.php b/php/node.php
index 1336a5f..383cc97 100644
--- a/php/node.php
+++ b/php/node.php
@@ -2,7 +2,16 @@
require_once "database.php";
require_once "user.php";
+ class Node
+ {
+ public $node_id;
+ public $is_directory;
+ public $relative_path;
+ public $type;
+ public $code;
+ }
/*path is in terms of the simulated filesystem*/
+ /*returns NULL on error*/
function get_directory(string $abstract_path,User $user)
{
@@ -61,5 +70,39 @@ require_once "user.php";
$parent_dir_id=get_directory($abstract_path,$user);
$database->unlink_nodes($parent_dir_id,$filename);
}
+ function create_share_link(string $abstract_path,string $filename,string $password,User $user,bool $can_read,bool $can_write)
+ {
+ global $database;
+ global $domain_name;
+ global $use_https;
+
+ $dir_id=get_directory($abstract_path,$user);
+ if($dir_id==NULL)
+ {
+ return NULL;
+ }
+ $node_id=get_node_id($filename,$dir_id);
+ if($node_id==NULL)
+ {
+ return NULL;
+ }
+ if($database->create_shared_node($password,$node_id)==false)
+ {
+ return NULL;
+ }
+
+ $code=$database->get_code_of_node($node_id);
+ if($code==NULL)
+ {
+ return NULL;
+ }
+ if($use_https)
+ {
+ return "https://".$domain_name."/share?file=".$code;
+ }else
+ {
+ return "http://".$domain_name."/share?file=".$code;
+ }
+ }
?>