diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..49e0fc6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules +/package-lock.json \ No newline at end of file diff --git a/README.md b/README.md index d12eebca..6c940208 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,19 @@ -`#html` `#css` `#js` `#php` `#master-in-software-engineering` +`#html` `#css` `#php` `#bootstrap` `#awesome-icons` -# PHP Local FileSystem explorer +# Install +Clone the repository. + ```http + git clone https://github.com/AntonioCopete/filesystem-explorer.git +``` +Install dependencies. + ```http + npm install +``` -

- Version -

+# Project goal +Build a File System Explorer using PHP and Apache as local server to +improve our knowledge dealing with files and folders in PHP. ->In this project you will have to create a system file explorer that allows the user to navigate, create directories and upload files in the same way as he would in his usual operating system. - ->The file explorer is a tool that allows you to directly view and manipulate the files and directories associated with a path, so you must take into account from which path the user starts and which path they can access. - - -## Index - -- [Requirements](#requirements) -- [Repository](#repository) -- [Technologies used](#technologies-used) -- [Project delivery](#project-delivery) -- [Resources](#resources) - -## Requirements - -- You cannot use file third-party libraries -- You will not be able to use global variables in PHP. -- You must use GIT -- You must use the PHP > v7 -- Create a clear and orderly directory structure -- Both the code and the comments must be written in English -- Use the camelCase code style to define variables and functions -- In the case of using HTML, never use inline styles -- In the case of using different programming languages ​​always define the implementation in separate terms -- Remember that it is important to divide the tasks into several sub-tasks so that in this way you can associate each particular step of the construction with a specific commit -- You should try as much as possible that the commits and the planned tasks are the same -Delete files that are not used or are not necessary to evaluate the project - -## Repository - -First of all you must fork this project into your GitHub account. - -To create a fork on GitHub is as easy as clicking the “fork” button on the repository page. - -Fork on GitHub ## Technologies used @@ -48,29 +21,16 @@ To create a fork on GitHub is as easy as clicking the “fork” button on the r \* CSS -\* JS - \* PHP -## Project delivery - -To deliver this project you must follow the steps indicated in the document: +\* Bootstrap -- [Submitting a solution](https://www.notion.so/Submitting-a-solution-524dab1a71dd4b96903f26385e24cdb6) +\* Awesome icons -- You must include the project documentation in PDF format. -- You must include a presentation in PDF format explaining: - - Comparison of the original design (Wireframe) with the final result of the project - - Comparison of the use case diagram with the actions that the user can finally perform - - Comparison of the original use case diagram with the final user actions - - What lessons you’ve learned during this project - - What problems have you encountered when developing this project? - - How you have organized and distributed the tasks -## Resources +## Authors -- [File system](https://es.wikipedia.org/wiki/Administrador_de_archivos) -- [PHP FileSystem W3C](https://www.w3schools.com/php/php_ref_filesystem.asp) -- [PHP FileSystem Oficial](https://www.php.net/manual/es/book.filesystem.php) -- [README Guidelines Example](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2) +- [@Antonio](https://github.com/AntonioCopete) +- [@Marc](https://github.com/CYBER-MARCUSSEN) +- [@Josep](https://github.com/JosepR3) diff --git a/assets/documentation/filesystem-explorer documentation.pdf b/assets/documentation/filesystem-explorer documentation.pdf new file mode 100644 index 00000000..b18b3a05 Binary files /dev/null and b/assets/documentation/filesystem-explorer documentation.pdf differ diff --git a/assets/icons/csv-icon.svg b/assets/icons/csv-icon.svg new file mode 100644 index 00000000..3cfb7582 --- /dev/null +++ b/assets/icons/csv-icon.svg @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/doc-icon.svg b/assets/icons/doc-icon.svg new file mode 100644 index 00000000..83589edd --- /dev/null +++ b/assets/icons/doc-icon.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/icons/exe-icon.svg b/assets/icons/exe-icon.svg new file mode 100644 index 00000000..8bd9164b --- /dev/null +++ b/assets/icons/exe-icon.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/folder.svg b/assets/icons/folder.svg new file mode 100644 index 00000000..5c8b693e --- /dev/null +++ b/assets/icons/folder.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/jpg-icon.svg b/assets/icons/jpg-icon.svg new file mode 100644 index 00000000..b0047d78 --- /dev/null +++ b/assets/icons/jpg-icon.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/mp3-icon.svg b/assets/icons/mp3-icon.svg new file mode 100644 index 00000000..32bc5e0e --- /dev/null +++ b/assets/icons/mp3-icon.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/mp4-icon.svg b/assets/icons/mp4-icon.svg new file mode 100644 index 00000000..50e7b1d1 --- /dev/null +++ b/assets/icons/mp4-icon.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/odt-icon.svg b/assets/icons/odt-icon.svg new file mode 100644 index 00000000..70f299b8 --- /dev/null +++ b/assets/icons/odt-icon.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/pdf-icon.svg b/assets/icons/pdf-icon.svg new file mode 100644 index 00000000..fad4374b --- /dev/null +++ b/assets/icons/pdf-icon.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/png-icon.svg b/assets/icons/png-icon.svg new file mode 100644 index 00000000..5bc975d1 --- /dev/null +++ b/assets/icons/png-icon.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/ppt-icon.svg b/assets/icons/ppt-icon.svg new file mode 100644 index 00000000..c53bfec0 --- /dev/null +++ b/assets/icons/ppt-icon.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/rar-icon.svg b/assets/icons/rar-icon.svg new file mode 100644 index 00000000..5aba9b12 --- /dev/null +++ b/assets/icons/rar-icon.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/svg-icon.svg b/assets/icons/svg-icon.svg new file mode 100644 index 00000000..a933d24c --- /dev/null +++ b/assets/icons/svg-icon.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/txt-icon.svg b/assets/icons/txt-icon.svg new file mode 100644 index 00000000..da1edf9b --- /dev/null +++ b/assets/icons/txt-icon.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/zip-icon.svg b/assets/icons/zip-icon.svg new file mode 100644 index 00000000..1d5f2704 --- /dev/null +++ b/assets/icons/zip-icon.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/styles.css b/assets/styles.css new file mode 100644 index 00000000..59c69ce4 --- /dev/null +++ b/assets/styles.css @@ -0,0 +1,59 @@ +h4 { + font-size: 1rem !important; +} + +p { + margin: 0 !important; + font-size: 0.8rem !important; +} + +a { + text-decoration: none !important; + color: black !important; +} + +img { + width: 5vh; + height: 5vh; + margin-right: 3vh; +} + +hr { + margin: 0 !important; +} +form { + padding: 0; +} +section:nth-child(1) { + padding: 0; + width: 30%; +} +section:nth-child(2) { + width: 70%; +} + +main { + margin-top: 5vh; + margin-bottom: 5vh; + min-height: 70vh; +} + +.hov:hover{ + background-color: rgba(0, 0, 0, 0.03); +} + +.search__form { + width: 40%; +} + +.btn-danger, +.btn-edit { + height: 6vh; + width: 6vh; + margin: 0.2rem 0 0.2rem 0; +} + +.web__icon { + width: 10vh; + height: 10vh; +} diff --git a/components/createFolderForm.php b/components/createFolderForm.php new file mode 100644 index 00000000..3d06acac --- /dev/null +++ b/components/createFolderForm.php @@ -0,0 +1,20 @@ + +
+ + +
+"; +} +?> + + diff --git a/components/directory.php b/components/directory.php new file mode 100644 index 00000000..62ba5c01 --- /dev/null +++ b/components/directory.php @@ -0,0 +1,18 @@ +
+ + " : "" ?> + +
+ +
+
\ No newline at end of file diff --git a/components/editFolderForm.php b/components/editFolderForm.php new file mode 100644 index 00000000..54fe58b9 --- /dev/null +++ b/components/editFolderForm.php @@ -0,0 +1,26 @@ + +
+ + +
+ + "; + + if (isset($_POST["edit-name"])) { + $directory = $_GET["directory"]; + + $editName = $_POST["edit-name"]; + $editPath = $_GET["edit"]; + + $editDirectory = explode("/", $editPath); + array_pop($editDirectory); + $editDirectory = implode("/", $editDirectory); + + rename($editPath, "$editDirectory/$editName"); + header("Location: index.php?directory=$directory"); + } +} diff --git a/components/erase.php b/components/erase.php new file mode 100644 index 00000000..73231da6 --- /dev/null +++ b/components/erase.php @@ -0,0 +1,27 @@ + +

Made By Marc Parellada, Antonio Copete and Josep Romero Ros

+

© 2021

+ \ No newline at end of file diff --git a/components/header.php b/components/header.php new file mode 100644 index 00000000..ac42d3a6 --- /dev/null +++ b/components/header.php @@ -0,0 +1,6 @@ +
+
+ +

File System Explorer

+

+
\ No newline at end of file diff --git a/components/navBar.php b/components/navBar.php new file mode 100644 index 00000000..55cdc117 --- /dev/null +++ b/components/navBar.php @@ -0,0 +1,19 @@ +$arrDirectory[$i]"; + } else { + $value = $value . "/" . $arrDirectory[$i]; + echo "
$arrDirectory[$i]
"; + } + } else { + echo ""; + } + } +} diff --git a/components/renderFiles.php b/components/renderFiles.php new file mode 100644 index 00000000..cda18b78 --- /dev/null +++ b/components/renderFiles.php @@ -0,0 +1,127 @@ + + + +

$fileName

+
+

$creationDate

+

$modificationDate

+

Folder

+

+
+ + +
+ +
"; + } else { + echo " +
+ + +

$fileName

+
+

Unknown

+

$modificationDate

+

+
+ + +
+
+
"; + } + } else { + if (PHP_OS == "WINNT") { + echo " +
+

$fileName

+

$creationDate

+

$modificationDate

+

$ext

+

$fileSize

+
+ +

+
+
+
"; + } else { + echo " +
+ $fileName +

Unknown

+

$modificationDate

+

$ext

+

$fileSize

+
+ +

+
+
+
"; + } + } +} + +if (!isset($_GET["search"])) { + if (isset($_GET["directory"]) && explode("/", $_GET["directory"])[0] == "root" && !str_contains($_GET["directory"], "..")) { + $directory = $_GET["directory"]; + } else { + $directory = 'root'; + } + scandir($directory, SCANDIR_SORT_ASCENDING); + if (is_dir($directory)) { + if ($dh = opendir($directory)) { + while (($file = readdir($dh)) !== false) { + if ($file === "." || $file === "..") { + } else { + $fullPath = "$directory/$file"; + printDirectory($fullPath); + } + } + closedir($dh); + } + } +} else { + $search = $_GET["search"]; + $folderPath = "root"; + readDirectory($search, $folderPath); +} diff --git a/components/search.php b/components/search.php new file mode 100644 index 00000000..e2fed5b2 --- /dev/null +++ b/components/search.php @@ -0,0 +1,8 @@ +
+
+ +
+ +
+
+
\ No newline at end of file diff --git a/components/sideBar.php b/components/sideBar.php new file mode 100644 index 00000000..98d3b7cb --- /dev/null +++ b/components/sideBar.php @@ -0,0 +1,20 @@ + + +
+ + +
method="post" enctype="multipart/form-data"> + + + +
+ + +
+ +
\ No newline at end of file diff --git a/components/titlesFiles.php b/components/titlesFiles.php new file mode 100644 index 00000000..456428cc --- /dev/null +++ b/components/titlesFiles.php @@ -0,0 +1,8 @@ +
+

Title

+

Create Date

+

Last Modified Date

+

Type

+

Size

+

+
\ No newline at end of file diff --git a/components/upload.php b/components/upload.php new file mode 100644 index 00000000..9e3ab8e5 --- /dev/null +++ b/components/upload.php @@ -0,0 +1,66 @@ + + 50000000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; +} + +// Allow certain file formats +if ( + $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "pdf" && $imageFileType != "txt" && $imageFileType != "mp4" && $imageFileType != "mp3" + && $imageFileType != "doc" && $imageFileType != "csv" && $imageFileType != "ppt" && $imageFileType != "odt" + && $imageFileType != "zip" && $imageFileType != "rar" && $imageFileType != "exe" && $imageFileType != "svg" +) { + echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; + $uploadOk = 0; +} + +// Check if $uploadOk is set to 0 by an error +if ($uploadOk == 0) { + echo "Sorry, your file was not uploaded."; + // if everything is ok, try to upload file +} else { + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_dir . "/" . $_FILES["fileToUpload"]["name"])) { + echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded."; + } else { + echo "Sorry, there was an error uploading your file."; + } +} + $path = explode("/", $directory); + + array_shift($path); + $path = implode("/", $path); + +header("Location: ../index.php?directory=$path"); diff --git a/index.php b/index.php new file mode 100644 index 00000000..3a581877 --- /dev/null +++ b/index.php @@ -0,0 +1,40 @@ + + + + + + + + + + FileSystem-Explorer + + + + + + + + +
+ + +
+
+
+ +
+
+ + +
+
+
+ + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..d8a1676c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,16 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "bootstrap": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz", + "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==" + }, + "font-awesome": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz", + "integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM=" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..613460f3 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "bootstrap": "^5.1.3", + "font-awesome": "^4.7.0" + } +} diff --git a/root/02Cara_de_cul.mp3 b/root/02Cara_de_cul.mp3 new file mode 100644 index 00000000..1471b920 Binary files /dev/null and b/root/02Cara_de_cul.mp3 differ diff --git a/root/Oques.zip b/root/Oques.zip new file mode 100644 index 00000000..b1a1ab04 Binary files /dev/null and b/root/Oques.zip differ diff --git a/root/carpeta1/carpeta2/IMG_2618.JPG b/root/carpeta1/carpeta2/IMG_2618.JPG new file mode 100644 index 00000000..d428a764 Binary files /dev/null and b/root/carpeta1/carpeta2/IMG_2618.JPG differ diff --git a/root/estreno.png b/root/estreno.png new file mode 100644 index 00000000..1b014cf7 Binary files /dev/null and b/root/estreno.png differ diff --git a/root/file_example_MP4_1920_18MG.mp4 b/root/file_example_MP4_1920_18MG.mp4 new file mode 100644 index 00000000..caa57b2b Binary files /dev/null and b/root/file_example_MP4_1920_18MG.mp4 differ