aboutsummaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authoradam <adam@>2021-02-13 18:39:26 +0200
committeradam <adam@>2021-02-13 18:39:26 +0200
commit32385bfd16fd588e13f5bdebae1c08fd729c5815 (patch)
tree359ddf50be0471339232be9455b72cccb74637f9 /php
parent3ed9e9c0350ecb299373b7e58139d142c72620b7 (diff)
downloadfileup-32385bfd16fd588e13f5bdebae1c08fd729c5815.tar.gz
unlink recurses
Diffstat (limited to 'php')
-rw-r--r--php/database.php31
-rw-r--r--php/delete.php15
-rw-r--r--php/node.php6
3 files changed, 39 insertions, 13 deletions
diff --git a/php/database.php b/php/database.php
index ba02fc7..4b701a2 100644
--- a/php/database.php
+++ b/php/database.php
@@ -378,6 +378,8 @@ require_once "node.php";
function unlink_nodes(int $dir_id, string $filename)
{
+ /*TODO delet this*/
+ error_log("in unlink nodes");
$prep=$this->pdo->prepare("delete from node_links
where directory_id=:dir_id and name=:name
");
@@ -388,21 +390,29 @@ require_once "node.php";
error_log("there was an error with the first statement in unlink_nodes");
return;
}
+ error_log("in pre stuff in unlink nodes");
+ $prep=$this->pdo->prepare("select count(1) as count from trash");
+ $prep->execute() or die(1);
do{
- $prep=$this->pdo->prepare("select count(1) as count from trash");
+
+
+ $prep=$this->pdo->prepare("select count(1) as count from super_trash");
$prep->execute() or die(1);
- $res=$prep->fetch(PDO::FETCH_ASSOC);
- $prep=$this->pdo->prepare("insert into super_trash select node_id from trash");
+ $super_trash_count=$prep->fetch(PDO::FETCH_ASSOC);
+ $prep=$this->pdo->prepare("delete from super_trash");
$prep->execute() or die(1);
- $prep=$this->pdo->prepare("delete from trash");
+
+
+
+ $prep=$this->pdo->prepare("select count(1) as count from trash");
$prep->execute() or die(1);
- $prep=$this->pdo->prepare("delete from links
- where directory_id in
- (select node_id from super_trash)
- ");
+ $trash_count=$prep->fetch(PDO::FETCH_ASSOC);
+ $prep=$this->pdo->prepare("delete from trash");
$prep->execute() or die(1);
- }while($res["count"]!=0);
+ error_log("asdf: ".$trash_count["count"]." ".$super_trash_count["count"]);
+ }while($trash_count["count"]!=$super_trash_count["count"]);
+
$prep=$this->pdo->prepare("select code from nodes where node_id in
(select node_id from super_trash)");
$prep->execute() or die(1);
@@ -412,9 +422,10 @@ require_once "node.php";
unlink($storage_root,"/".$node["code"]);
}
$prep=$this->pdo->prepare("delete from nodes where node_id in
- (select node_id from super_trash");
+ (select node_id from super_trash)");
$prep->execute() or die(1);
$prep=$this->pdo->prepare("delete from super_trash");
+ $prep->execute() or die(1);
}
diff --git a/php/delete.php b/php/delete.php
index b50dbad..af13a00 100644
--- a/php/delete.php
+++ b/php/delete.php
@@ -1,6 +1,15 @@
<?php
-
-
-
+require_once "database.php";
+require_once "user.php";
+require_once "node.php";
+
+session_start();
+$folder=$_POST["folder"];
+$filename=$_POST["filename"];
+$user=$_SESSION["user_object"];
+
+error_log("someone is trying to delete".$filename);
+unlink_from_folder($folder,$filename,$user);
+error_log("someone is trying to delete".$filename);
?>
diff --git a/php/node.php b/php/node.php
index 5074082..1336a5f 100644
--- a/php/node.php
+++ b/php/node.php
@@ -55,5 +55,11 @@ require_once "user.php";
return $dir_id;
}
}
+ function unlink_from_folder(string $abstract_path,string $filename,User $user)
+ {
+ global $database;
+ $parent_dir_id=get_directory($abstract_path,$user);
+ $database->unlink_nodes($parent_dir_id,$filename);
+ }
?>