diff options
author | adam <adam@> | 2021-02-13 23:24:31 +0200 |
---|---|---|
committer | adam <adam@> | 2021-02-13 23:24:31 +0200 |
commit | c7a6eb6587b285f59a7c2c4bae9a7aa4ef8247e1 (patch) | |
tree | 970b84eb7103248e10d2a713850e0a314d921aa8 /php/database.php | |
parent | 3005c7774d4f32dc857a9b10c4e621f4df2019c4 (diff) | |
download | fileup-c7a6eb6587b285f59a7c2c4bae9a7aa4ef8247e1.tar.gz |
generates different code links
Diffstat (limited to 'php/database.php')
-rw-r--r-- | php/database.php | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/php/database.php b/php/database.php index 6762a5f..58ca251 100644 --- a/php/database.php +++ b/php/database.php @@ -458,19 +458,25 @@ require_once "node.php"; } } - function create_shared_node(string $password,int $node_id):bool + function create_shared_node(string $password,int $node_id) { - $prep=$this->pdo->prepare("insert into shared_nodes(node_id,passcode) - values (:id,:pass) + $code=$this->get_random_node_name(""); + $prep=$this->pdo->prepare("insert into shared_nodes(node_id,passcode,code) + values (:id,:pass,:code) "); $prep->bindParam(':id',$node_id); $prep->bindParam(':pass',$password); + $prep->bindParam(':code',$code); if($prep->execute()==false) { error_log("could not create shared node in create_shared_node"); - return false; + return NULL; } - return true; + $shared_node=new Shared_Node(); + $shared_node->code=$code; + $shared_node->node_id=$node_id; + $shared_node->password=$password; + return $shared_node; } function get_node(int $node_id) { @@ -588,6 +594,24 @@ require_once "node.php"; return false; } } + function get_shared_node(string $code) + { + $prepare=$this->pdo->prepare(" + select * from shared_nodes where code=:code + "); + $prepare->bindParam(':code',$code); + if($prepare->execute()==false) + { + error_log("sql statement at get_shared_node failed"); + return NULL; + } + $ret=$prepare->fetch(PDO::FETCH_ASSOC); + $nod=new Shared_Node(); + $nod->node_id=$ret["node_id"]; + $nod->password=$ret["passcode"]; + $nod->code=$ret["code"]; + return $nod; + } /*returns false if username is taken, email is not checked here*/ function register_user(string $user,string $password,string $email) : bool |