diff options
author | adam <adam@> | 2021-02-12 12:14:00 +0200 |
---|---|---|
committer | adam <adam@> | 2021-02-12 12:14:00 +0200 |
commit | 9102b9017d978be8c119a3ac8e79c661f2dad6b1 (patch) | |
tree | 0c822b20ac56ad5ac4b5eccf294f874fe6b91bf8 /php | |
parent | f2bf4d23d5be9b4d24a830ddaecabe2e87a0e93c (diff) | |
download | fileup-9102b9017d978be8c119a3ac8e79c661f2dad6b1.tar.gz |
galin
Diffstat (limited to 'php')
-rw-r--r-- | php/.database.php.swp | bin | 0 -> 16384 bytes | |||
-rw-r--r-- | php/.node.php.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | php/database.php | 37 | ||||
-rw-r--r-- | php/node.php | 26 |
4 files changed, 62 insertions, 1 deletions
diff --git a/php/.database.php.swp b/php/.database.php.swp Binary files differnew file mode 100644 index 0000000..5193729 --- /dev/null +++ b/php/.database.php.swp diff --git a/php/.node.php.swp b/php/.node.php.swp Binary files differnew file mode 100644 index 0000000..2046c2b --- /dev/null +++ b/php/.node.php.swp diff --git a/php/database.php b/php/database.php index a5a8c20..a46bdd2 100644 --- a/php/database.php +++ b/php/database.php @@ -2,6 +2,7 @@ require_once "configuration.php"; require_once "user.php"; require_once "misc.php"; +require_once "node.php"; /*handles database stuff*/ class Database @@ -72,6 +73,17 @@ require_once "misc.php"; return false; } } + function get_home_id($user_id) + { + $statement=$this->pdo->prepare("select home_directory + from users + where user_id=:id + "); + $statement->bindParam(':id',$user_id); + + $ret=$statement->execute(PDO::FETCH_ASSOC); + return $ret["home_directory"]; + } function get_node_id($name,$directory_id) { $hold=NULL; @@ -152,6 +164,29 @@ require_once "misc.php"; //print count($id); return $id[0]; } + function are_linked(int $directory_id,int $node_id): bool + { + $prepare=$this->pdo->prepare("select node_id + from node_links + where node_id=:node_id and directory_id=:dir_id + "); + $prepare->bindParam(':node_id',$node_id); + $prepare->bindParam(':dir_id',$directory_id); + if($prepare->execute()==false) + { + error_log("there is an sql error in are_linked"); + /*quiet error*/ + return false; + } + if(count($prepare->fetch(PDO::FETCH_ASSOC))==1) + { + return true; + }else + { + return false; + } + } + /*returns false if username is taken, email is not checked here*/ function register_user(string $user,string $password,string $email) : bool { @@ -190,5 +225,5 @@ require_once "misc.php"; } } - +$database=new Database(); ?> diff --git a/php/node.php b/php/node.php new file mode 100644 index 0000000..b6c3428 --- /dev/null +++ b/php/node.php @@ -0,0 +1,26 @@ +<?php +require_once "database.php"; + + class Current_Directory + { + public $node_id; + /*an array of the dir_ids taken to reach here*/ + public $path; + + function __construct($user_id) + { + $this->dir_id=get_home_id($user_id); + $this->path=[$dir_id]; + } + function change_directory($directory_id):bool + { + global $database; + if(!$database->is_directory($directory_id)) + { + return false; + } + + } + } + +?> |