diff --git a/.gitignore b/.gitignore new file mode 100755 index 00000000..947f8dce --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +root +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/assets/icons/check.svg b/assets/icons/check.svg new file mode 100755 index 00000000..b1dbdd21 --- /dev/null +++ b/assets/icons/check.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/assets/icons/edit.svg b/assets/icons/edit.svg new file mode 100755 index 00000000..0a4f0aa8 --- /dev/null +++ b/assets/icons/edit.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/assets/icons/trash.svg b/assets/icons/trash.svg new file mode 100755 index 00000000..103f7660 --- /dev/null +++ b/assets/icons/trash.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/includes/addfile.php b/includes/addfile.php new file mode 100755 index 00000000..b7117a34 --- /dev/null +++ b/includes/addfile.php @@ -0,0 +1,64 @@ +prepare(" +INSERT INTO `files`(`name`, `size`, `modified`, `creation`, `extension`, `path`, `daddyPath`) +VALUES (:name, :size, :modified, :creation, :extension, :path, :daddyPath) +"); + + +//encrypt + +$uploadQuery->execute([ + "name" => $name, + "size" => $size, + "modified" => $modified, + "creation" => $creation, + "extension" => $extension, + "path" => $pathName . "/" . $fileName, + "daddyPath" => $pathName +]); + + +if ($_GET["directory"] == "root") { + header("location: ../index.php"); +} else { + header("location: ../lower.php?pathLower=$pathName"); +} diff --git a/includes/addfolder.inc.php b/includes/addfolder.inc.php new file mode 100755 index 00000000..15997192 --- /dev/null +++ b/includes/addfolder.inc.php @@ -0,0 +1,48 @@ +prepare(" +INSERT INTO `files`(`name`, `size`, `modified`, `creation`, `extension`, `path`, `daddyPath`) + VALUES (:name, :size, :modified, :creation, :extension, :path, :daddyPath); +"); + +//encryptfunction +$uploadQuery->execute([ + "name" => $_POST["addfolder"], + "size" => 0, + "modified" => $modified, + "creation" => $creation, + "extension" => "folder", + "path" => $mkdirRoute . "/" . $_POST["addfolder"], + "daddyPath" => $mkdirRoute +]); + +$_SESSION["directory"] = $mkdirRoute; + + +if ($_GET["directory"] == "root") { + header("location: ../index.php"); +} else { + header("location: ../lower.php?pathLower=$mkdirRoute"); +} diff --git a/includes/dbh.inc.php b/includes/dbh.inc.php new file mode 100755 index 00000000..ab362673 --- /dev/null +++ b/includes/dbh.inc.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/includes/delete.inc.php b/includes/delete.inc.php new file mode 100755 index 00000000..6074f3df --- /dev/null +++ b/includes/delete.inc.php @@ -0,0 +1,36 @@ +prepare(" +DELETE FROM `files` WHERE `id` = :id; +"); + +$deleteQuery->execute([ + "id" => $id +]); + + + +function rmDir_rf($path) +{ + foreach (glob($path . "/*") as $archivos_carpeta) { + if (is_dir($archivos_carpeta)) { + rmDir_rf($archivos_carpeta); + } else { + unlink($archivos_carpeta); + } + } + rmdir($path); +}; + +if (is_dir($path)) { + rmDir_rf($path); +} else { + unlink($path); +} + + +header("location: ../index.php"); diff --git a/includes/edit.inc.php b/includes/edit.inc.php new file mode 100755 index 00000000..ab6b7448 --- /dev/null +++ b/includes/edit.inc.php @@ -0,0 +1,20 @@ +prepare(" +UPDATE `files` SET `edit`= :edit WHERE `id`= :id +"); + +$editQuery->execute([ + "edit" => 1, + "id" => $id + +]); + + +$url = $_SERVER['HTTP_REFERER']; + +header("Location: $url"); diff --git a/includes/edittitle.inc.php b/includes/edittitle.inc.php new file mode 100755 index 00000000..4fcd6628 --- /dev/null +++ b/includes/edittitle.inc.php @@ -0,0 +1,24 @@ +prepare(" + UPDATE `files` SET `name`=:name,`path`=:path, `edit`=:edit WHERE `id`=:id + "); + +$edittitleQuery->execute([ + "name" => $newName, + "id" => $id, + "edit" => 0, + "path" => $newPath . "/" . $newName . "." . $extension +]); + +rename($oldPath, $newPath . "/" . $newName . "." . $extension); + +$url = $_SERVER['HTTP_REFERER']; +header("Location: $url"); diff --git a/includes/fetchFiles.inc.php b/includes/fetchFiles.inc.php new file mode 100755 index 00000000..d1e16456 --- /dev/null +++ b/includes/fetchFiles.inc.php @@ -0,0 +1,16 @@ + prepare(" +SELECT * FROM `files` WHERE daddyPath=:path +"); + +$fetchQuery -> execute([ + "path"=>"../root" +]); + +$fileFetched = $fetchQuery -> rowCount()? $fetchQuery : [] ; diff --git a/includes/fetchLower.inc.php b/includes/fetchLower.inc.php new file mode 100755 index 00000000..6e5a0844 --- /dev/null +++ b/includes/fetchLower.inc.php @@ -0,0 +1,18 @@ +prepare(" +SELECT * FROM `files` WHERE daddyPath=:path +"); + +$fetchQuery->execute([ + "path" => $pathLower +]); + +$fileFetched = $fetchQuery->rowCount() ? $fetchQuery : []; + +//header("Location: ../lower.php?directory=$pathLower"); diff --git a/includes/icons.inc.php b/includes/icons.inc.php new file mode 100755 index 00000000..31746234 --- /dev/null +++ b/includes/icons.inc.php @@ -0,0 +1,43 @@ +"; + break; + // case 'zip': + // case 'rar': + //ZipArchive::RDONLY ****PENDIENTE + // case '7z': + // gzread($path, filesize($path)); + // break; + case 'mp3': + echo ""; + break; + case 'mp4': + echo ""; + break; + case 'folder': + header("Location: ../lower.php?pathLower=$path"); + break; + default: + echo "File type not supported"; + break; +} diff --git a/includes/search.inc.php b/includes/search.inc.php new file mode 100644 index 00000000..0c2d8864 --- /dev/null +++ b/includes/search.inc.php @@ -0,0 +1,15 @@ +prepare(" +SELECT * FROM `files` WHERE name=:name +"); + +$fetchQuery->execute([ + "name" => $name +]); + +$fileFetched = $fetchQuery->rowCount() ? $fetchQuery : []; diff --git a/includes/utils.php b/includes/utils.php new file mode 100755 index 00000000..76220805 --- /dev/null +++ b/includes/utils.php @@ -0,0 +1,50 @@ + + + +', " ", $content); + $content = str_replace(' + ', "\r\n", $content); + $striped_content = strip_tags($content); + + echo $striped_content; + }; + + function read_txt($fileName){ + try { + if (!file_exists($fileName)) { + throw new Exception('File open failed'); + } + // The function returns a pointer to the file if it is successful or zero if it is not. Files are opened for read or write operations. + $file = fopen($fileName, "r"); + // Reads the file + $content = fread($file, filesize($fileName)); + echo $content; + // Close the file buffer + fclose($file); + } catch (Throwable $t) { + echo $t->getMessage(); + }; + }; \ No newline at end of file diff --git a/index.css b/index.css new file mode 100755 index 00000000..13d7623b --- /dev/null +++ b/index.css @@ -0,0 +1,24 @@ +/* Sticky Footer Classes */ +* { + box-sizing: border-box; + margin: 0; + padding: 0 +} + +html, +body { + height: 100vh; + min-height: 100vh; +} + +/* footer { + position: absolute; + bottom: 0; + width: 100%; +} */ + + + + + +/* Other Classes for Page Styling */ \ No newline at end of file diff --git a/index.php b/index.php new file mode 100755 index 00000000..8ebf8ddc --- /dev/null +++ b/index.php @@ -0,0 +1,138 @@ + + + + + + + + + + + + + File System Project + + + + +
+ +
../root/
+
+
+ +
+ + + + + + + + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSizeModifiedCreation ExtensionActions
+ +
&id=&name=&extension=" method="POST"> + > + +
+ + + &extension="> + +
+ + +
+
+ + + + + \ No newline at end of file diff --git a/lower.php b/lower.php new file mode 100755 index 00000000..ba6185c4 --- /dev/null +++ b/lower.php @@ -0,0 +1,138 @@ + + + + + + + + + + + + + File System Project + + + + +
+ +
" . $path . "" . "Back"; ?>
+ +
+
+ +
+ + + + + + + + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSizeModifiedCreation ExtensionActions
+ +
&id=&name=&extension=" method="POST"> + > + +
+ + + &extension=&daddyPath="> + +
+ + +
+
+ + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 00000000..290442e6 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,48 @@ +{ + "name": "filesystem-explorer", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "bootstrap": "^5.1.3" + } + }, + "node_modules/@popperjs/core": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.10.2.tgz", + "integrity": "sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ==", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/bootstrap": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz", + "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + }, + "peerDependencies": { + "@popperjs/core": "^2.10.2" + } + } + }, + "dependencies": { + "@popperjs/core": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.10.2.tgz", + "integrity": "sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ==", + "peer": true + }, + "bootstrap": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz", + "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==", + "requires": {} + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 00000000..7d1ac8d7 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "bootstrap": "^5.1.3" + } +} diff --git a/search.php b/search.php new file mode 100644 index 00000000..3b54a3ed --- /dev/null +++ b/search.php @@ -0,0 +1,140 @@ + + + + + + + + + + + + + File System Project + + + + +
+ +
" ?>
+ +
+
+ +
+ + + + + + + + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSizeModifiedCreation ExtensionActions
+ +
&id=&name=&extension=" method="POST"> + > + +
+ + + &extension="> + +
+ + +
+
+ + + + + \ No newline at end of file