Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d019667
add main HTML and load basic files
devs-toni Jan 9, 2023
2eeaccc
add files
Alvaro-S89 Jan 10, 2023
7f4db1d
add open file options
devs-toni Jan 11, 2023
b940cee
assets
Alvaro-S89 Jan 11, 2023
9361883
refactorize code
devs-toni Jan 11, 2023
3f0590e
add delete All with FETCH
devs-toni Jan 11, 2023
6f648ed
add new proof files
devs-toni Jan 12, 2023
8f59207
reestructure project
devs-toni Jan 12, 2023
9694eee
add delete function
devs-toni Jan 12, 2023
b561493
add breadcrumb logic
devs-toni Jan 12, 2023
8c74bed
Co-authored-by: Antonio Rufino Casasus <devs.toni@gmail.com>
Alvaro-S89 Jan 12, 2023
f1b3449
add script.js to delete files
devs-toni Jan 12, 2023
974e489
little refactorizes
Alvaro-S89 Jan 12, 2023
3707cb0
delete breadcrump form
Alvaro-S89 Jan 12, 2023
815b783
init search function
Alvaro-S89 Jan 12, 2023
1803b29
add rename form and js script, add some styles
devs-toni Jan 12, 2023
e654889
add modal and alerts, deleteAll finished
devs-toni Jan 12, 2023
3078b9e
single delete finished
devs-toni Jan 12, 2023
7d8aa46
solve bug spaces in href, alert when extract
devs-toni Jan 12, 2023
d2f5b4a
improve alerts when extract rar and zip
devs-toni Jan 13, 2023
7adfcef
change search method
devs-toni Jan 13, 2023
b1e8b55
finish local search
devs-toni Jan 13, 2023
885481c
implement trash logic
devs-toni Jan 13, 2023
b8ff112
add rename and gitignore
Alvaro-S89 Jan 13, 2023
40b6289
ignore root folder
Alvaro-S89 Jan 13, 2023
d24500a
solve rename spaces bug
devs-toni Jan 13, 2023
118cf4e
add advanced search and trash
devs-toni Jan 14, 2023
8e7c985
add copy and move
devs-toni Jan 16, 2023
db79d2b
delete no_copy script
devs-toni Jan 16, 2023
75ce3a4
add rename doubled function
devs-toni Jan 16, 2023
e44d9b5
add create function
devs-toni Jan 16, 2023
d159a0b
resolve delete file bug
devs-toni Jan 16, 2023
7d573b4
disable inputs when move function
devs-toni Jan 16, 2023
c03f85a
solve create bug
devs-toni Jan 16, 2023
c388083
solve rename bugs with permisions
devs-toni Jan 17, 2023
c110630
implement drag and drop
devs-toni Jan 17, 2023
d3f883e
solve name front when rename
devs-toni Jan 17, 2023
af4216b
implement recover function
devs-toni Jan 17, 2023
0d6525f
solve copy and cut bug in session
devs-toni Jan 17, 2023
52e526d
solve recursive unknown function
devs-toni Jan 17, 2023
e2c3ca6
change alerts
devs-toni Jan 17, 2023
dfd2115
add create alert and txt open fixed
Alvaro-S89 Jan 17, 2023
c4751f1
add alert to exit
Alvaro-S89 Jan 17, 2023
3d2c4bd
copy and cut fixed
Alvaro-S89 Jan 17, 2023
4d512e6
add advanced search
devs-toni Jan 17, 2023
1441b15
add assets and review
Alvaro-S89 Jan 18, 2023
ffbe021
reestructure project
devs-toni Jan 18, 2023
81d6315
Merge branch 'dev'
devs-toni Jan 18, 2023
ab2f9d5
open pdf
devs-toni Jan 18, 2023
be9c799
first readme commit
devs-toni Jan 18, 2023
1d02b62
Update README.md
devs-toni Jan 18, 2023
dc19614
update Readme
devs-toni Jan 18, 2023
984b978
update readme
devs-toni Jan 18, 2023
8832138
Update README.md
devs-toni Jan 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitignore
Empty file.
51 changes: 12 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
`#html` `#css` `#js` `#php` `#master-in-software-development`

# PHP Local FileSystem explorer <!-- omit in toc -->
# PHP Local FileSystem

<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000" />
</p>

>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.
![app](assets/readme/app.png)

>In this project we 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 <!-- omit in toc -->

- [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 > v8
- 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
- [PHP Local FileSystem](#php-local-filesystem)
- [Wireframe](#wireframe)
- [ShowCase Diagram](#showcase-diagram)
- [Repository](#repository)

## Wireframe

![app](assets/readme/wireframe.png)

## Repository

Expand All @@ -41,20 +31,3 @@ 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.

<img src="https://docs.github.com/assets/cb-23088/images/help/repository/fork_button.png" alt="Fork on GitHub" width='450'>

## Technologies used

\* HTML

\* CSS

\* JS

\* PHP

## Resources

- [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)
17 changes: 17 additions & 0 deletions advancedSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once('utils/utils.php');
$search = $_POST['search'];
$root = './root';

$matches = [];
$allFiles = Utils::getDirContents('./root');

foreach ($allFiles as $file) {
$array = explode('\\', $file);
$strCompare = $array[count($array) - 1];
if (strstr(strtolower($strCompare), strtolower($search))) {
array_push($matches, $file);
}
}

echo json_encode($matches);
Binary file added assets/csv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/docx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/exe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/jpg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mp3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mp4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/odt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/other.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ppt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/case.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/txt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions copy_path.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
require_once('utils/utils.php');
session_start();
$action = $_POST['action'];

$root = $_SESSION['absolutePath'];
$name = $_REQUEST['name'];
$path = $root . '/' . $name;

if ($action == 'copy') {
if (!isset($_SESSION['copies'][$name]))
$_SESSION['copies'][$name] = $path;
$size = count($_SESSION['copies']);
} else {
if (!isset($_SESSION['moves'][$name]))
$_SESSION['moves'][$name] = $path;
$size = count($_SESSION['moves']);
}

Utils::saveSession(SESSION);

echo json_encode($size);
28 changes: 28 additions & 0 deletions create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
require_once('utils/utils.php');
session_start();

$absolutePath = $_SESSION['absolutePath'];
$fileName = $_POST['nameCreated'];
$path = $absolutePath . "/" . $fileName;
$type = $_POST['select'];

if ($type == ".txt") {
$finalName = Utils::chooseName($path . $type, $fileName . $type);
$finalPath = $absolutePath . '/' . $finalName;
echo $finalPath;
file_put_contents(rtrim($finalPath, '.'), "Documento de texto");

} else {
$finalName = Utils::chooseName($path, $fileName);
$finalPath = $absolutePath . '/' . $finalName;
echo $finalPath;
mkdir(rtrim($finalPath, '.'));
}

if (isset($_SESSION['relativePath']))
$returnPath = $_SESSION['relativePath'];


header("Location: index.php?p=$returnPath&create");
?>
61 changes: 61 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
body {
background-color: #f7f7f7;
}

.folder-btn {
background-color: transparent;
border: none;
padding: 0;
}

.home-btn {
color: white;
}

.icon {
max-width: 22px;
max-height: 22px;
}

.link {
text-decoration: none;
color: black;
}

.pre {
background-color: white;
padding: 10px 30px;
overflow: scroll;
}

.p {
margin-left: 30px;
}


input[type="file"] {
display: none;
}
.custom-file-upload {
display: inline-block;
padding: 6px 12px;
cursor: pointer;
color: white;
}

.custom-file-create {
display: inline-block;
padding: 6px 12px;
cursor: pointer;
color: white;
}
i {
font-size: 1.3em;
}
label {
font-size: 1.3em;
}

form {
display: inline-block;
}
15 changes: 15 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

session_start();
require_once('utils/utils.php');
$absolutePath = $_SESSION['absolutePath'];
$fileName = $_POST['fileName'];
$oldPath = $absolutePath . '/' . $fileName;
$newPath = './trash/' . $fileName;
$finalName = Utils::chooseName($newPath, $fileName);
Utils::moveFiles($oldPath, './trash/' . $finalName);

$_SESSION['recovers'][$fileName] = $oldPath;
Utils::saveSession(SESSION);
echo json_encode('ok');
?>
44 changes: 44 additions & 0 deletions deleteAll.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
session_start();
require_once 'utils/utils.php';
$type = $_GET['el'];

if ($type === 'folder') {
$path = $_SESSION['absolutePath'];
} else {
$path = './trash';
}

$files = glob($path . '/*');
$msg = [];

if ($type === 'folder') { // FOLDER
if (count($files) > 0) {
foreach ($files as $oldPath) {
$newPath = Utils::changeFileRoute('./trash/', $oldPath);
$name = Utils::getNameFile($oldPath);
$finalName = Utils::chooseName($newPath, $name);
Utils::moveFiles($oldPath, './trash/' . $finalName);
$_SESSION['recovers'][$name] = $oldPath;
}
$msg['folder'] = 'ok';
} else {
$msg['folder'] = 'is-empty';
}
} else { // TRASH
if (count($files) > 0) {
foreach ($files as $file) {
if (is_dir($file))
Utils::deleteAll($file);
else
unlink($file);

unset($_SESSION['recovers'][Utils::getNameFile($file)]);
}
$msg['trash'] = 'ok';
} else {
$msg['trash'] = 'is-empty';
}
}
Utils::saveSession(SESSION);
echo json_encode($msg);
7 changes: 7 additions & 0 deletions destroySession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require_once('utils/utils.php');

session_start();
$_SESSION['recovers'] = [];
Utils::saveSession(SESSION);
echo json_encode('ok');
17 changes: 17 additions & 0 deletions drop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once('utils/utils.php');
session_start();
$currentPath = $_SESSION['absolutePath'];

$oldFile = $_REQUEST['old'];
$newFolder = $_REQUEST['new'];


$oldPath = $currentPath . '/' . $oldFile;
$newPath = $currentPath . '/' . $newFolder . '/' . $oldFile;

$finalName = Utils::chooseName($newPath, $oldFile);
$finalPath = $currentPath . '/' . $newFolder . '/' . $finalName;
Utils::moveFiles($oldPath, rtrim($finalPath, '.'));

echo json_encode('ok');
17 changes: 17 additions & 0 deletions getSearchFiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once('utils/utils.php');
$name = $_POST['name'];
$path = $_POST['path'];

$array = explode('\\root\\', $path);
$path = './root' . '/' . $array[1];
$path = str_replace('\\', '/', $path);
$size = Utils::formatSize(filesize($path));
$type = filetype($path);
$time = filemtime($path);
$relativePath = str_replace('./root/', '', $path);

date_default_timezone_set('Europe/Madrid');
$formattedTime = date("D d M Y", $time);

echo json_encode(["path" => $path, "size" => $size, "type" => $type, "time" => $formattedTime, "relative" => $relativePath]);
Loading