diff options
author | adam <adam@> | 2021-02-14 11:58:35 +0200 |
---|---|---|
committer | adam <adam@> | 2021-02-14 11:58:35 +0200 |
commit | 66040941492d590fd7a93d6c85f5f095335355e8 (patch) | |
tree | a06b764d773092926c1231ad07ae271bc5d937f9 /php/database.php | |
parent | 47a01771243568017a5aedfb948a7fb2bf9543f8 (diff) | |
download | fileup-66040941492d590fd7a93d6c85f5f095335355e8.tar.gz |
trash
Diffstat (limited to 'php/database.php')
-rw-r--r-- | php/database.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/php/database.php b/php/database.php index 61ff344..57aac3d 100644 --- a/php/database.php +++ b/php/database.php @@ -21,7 +21,7 @@ require_once "node.php"; $this->pdo=new PDO("mysql:dbname={$database_name};host={$database_location}",$database_username,$database_password); } - /*returns NULL if this isn't a user, otherwise returns the user*/ + /*returns NULL if this isn't a user, otherwise returns the user in the form of the User class*/ function get_user(string $user) { $ret=new User; @@ -75,7 +75,7 @@ require_once "node.php"; } } - /*returns assoc array*/ + /*returns assoc array , or NULL on error*/ function get_nodes_with_name($name) { $statement=$this->pdo->prepare( @@ -92,7 +92,7 @@ require_once "node.php"; return $statement->fetchAll(PDO::FETCH_ASSOC); } - /*returns id*/ + /*returns id or NULL on error*/ function get_node_with_code($code) { $statement=$this->pdo->prepare( @@ -461,15 +461,22 @@ require_once "node.php"; } } - function create_shared_node(string $password,int $node_id) + function create_shared_node(string $password,int $node_id,string $users) { $code=$this->get_random_node_name(""); - $prep=$this->pdo->prepare("insert into shared_nodes(node_id,passcode,code) - values (:id,:pass,:code) + $prep=$this->pdo->prepare("insert into shared_nodes(node_id,passcode,code,is_public) + values (:id,:pass,:code,:is_public) "); $prep->bindParam(':id',$node_id); $prep->bindParam(':pass',$password); $prep->bindParam(':code',$code); + if($users=="") + { + $prep->bindParam(':is_public',true); + }else + { + $prep->bindParam(':is_public',false); + } if($prep->execute()==false) { error_log("could not create shared node in create_shared_node"); |