Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
18c42b6
index
monica-reverte Jan 9, 2023
e359cea
basic index
monica-reverte Jan 9, 2023
968ab3d
archivos
monica-reverte Jan 9, 2023
1db85ca
conectando archivos
EdgarArcos Jan 9, 2023
6594bf8
index php
monica-reverte Jan 9, 2023
b29d7b6
plantilla
MarianRoibu Jan 10, 2023
09ed723
wireframe
monica-reverte Jan 10, 2023
b1850c1
small changes
MarianRoibu Jan 10, 2023
7da6a38
small changes
MarianRoibu Jan 10, 2023
d80ba5d
Merge branch 'dev' of https://github.com/monica-reverte/filesystem-ex…
MarianRoibu Jan 10, 2023
ed3397f
plantilla
MarianRoibu Jan 10, 2023
cb71f39
changes
MarianRoibu Jan 10, 2023
f9dd230
css changes
monica-reverte Jan 10, 2023
c2183a6
conflict
monica-reverte Jan 10, 2023
58d1dd1
new conflict
monica-reverte Jan 10, 2023
6008bdf
display files
MarianRoibu Jan 10, 2023
6e3d042
files are actually displaying
MarianRoibu Jan 10, 2023
295d643
no changes
monica-reverte Jan 10, 2023
6f05cc0
Merge branch 'files' of https://github.com/monica-reverte/filesystem-…
monica-reverte Jan 10, 2023
871883c
no conflicts
monica-reverte Jan 10, 2023
f0ee03c
new file alert js
monica-reverte Jan 10, 2023
fe9e512
Merge branch 'feature' into dev
monica-reverte Jan 10, 2023
85dbba8
side menu kind of works
MarianRoibu Jan 10, 2023
dfe8538
conflict
monica-reverte Jan 11, 2023
34df745
prueba
monica-reverte Jan 11, 2023
4480927
files
MarianRoibu Jan 11, 2023
d953e34
pruebas crear archivo
monica-reverte Jan 11, 2023
1a51edc
root
monica-reverte Jan 11, 2023
7d620ef
start create
monica-reverte Jan 11, 2023
4b6ec30
bootstrap
monica-reverte Jan 11, 2023
464f4bf
Merge branch 'dev' into feature
monica-reverte Jan 11, 2023
9570f93
create folder/file
monica-reverte Jan 11, 2023
a8cc758
create done
monica-reverte Jan 11, 2023
9a2c38f
files
MarianRoibu Jan 12, 2023
9ce3d8d
Merge branch 'dev' of https://github.com/monica-reverte/filesystem-ex…
MarianRoibu Jan 12, 2023
8968f45
merged
MarianRoibu Jan 12, 2023
a586bee
upload/root
monica-reverte Jan 12, 2023
ff294b7
probando openFolder
monica-reverte Jan 12, 2023
3247df2
probando eliminar
monica-reverte Jan 12, 2023
0eac02f
modales
monica-reverte Jan 13, 2023
f35c810
trying edit
monica-reverte Jan 16, 2023
4e6cac5
edit done
monica-reverte Jan 16, 2023
8d85e9b
cleaning code
monica-reverte Jan 17, 2023
cefb182
"trying"
monica-reverte Jan 18, 2023
e8da176
things
MarianRoibu Jan 18, 2023
0a3578a
estetica
monica-reverte Jan 19, 2023
439b41e
search, upload, delete
monica-reverte Jan 24, 2023
8d47326
Co-authored-by: Miquel Abella <MiquelAbella@users.noreply.github.com>
monica-reverte Jan 24, 2023
5a4c4a9
delete, search, upload
monica-reverte Jan 24, 2023
bd657e6
Cleaning
monica-reverte Jan 27, 2023
28e850e
cleaning finish
monica-reverte Jan 27, 2023
f4d0b39
Merge branch 'feature' into dev
monica-reverte Jan 27, 2023
83cac83
merge problems
monica-reverte Jan 27, 2023
bff6243
merge problems
monica-reverte Jan 27, 2023
42ed4a4
merge problems solutions
monica-reverte Jan 27, 2023
f60f6ca
finish
monica-reverte 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
1 change: 1 addition & 0 deletions Documents/Wireframe.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2023-01-09T15:08:13.651Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" etag="XovbN-9ulq9_esVGj_XZ" version="20.8.3" type="device"><diagram name="Page-1" id="03018318-947c-dd8e-b7a3-06fadd420f32">7Vtbd9o4EP41PIZjW77gxwVC+5Bue0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w+LZ0fMu3XEnEZUcXXE/JYQa4diruN2YTBwYchOyArfEmSed33IDHmK0deH4f13gNxiRVOGqzzbWNcobKKEsvgBb/hSLXchcPRYlvoJz+mTbI+rTy8C5+Wmgaxai7HqqcfMyUK2+VaCazdEX/C61vABL0S5Gs4Yni/opFif6pjifEazPheCp7rREeU3N7YzaN9pZElMyXjPmJ9CrUXPcB8bUYmaY9mHooj697DDifUjAUVK47gwwvpXLncn+a4BUCIuu09ZkSlOZEeSgRimLyEaWNKcZDTjDGTZ3pWLAGfOczHgmVw+poW+iCTMiijSbC0dTyo6t8GNXxgfZEy5CZ1IkKA1fsBdW/PD4Fg/+HFpflT3P65HEBikaIKgD4LcAEGCEwnit5YggBmC+5gKQI7dd0H7+fjhPNLFMwVqnovqW3WvB3C0y8iptlWHbeEIw7QhYUSQG0fS93snIGlgZGsxjwNjnlfByPrZAbnwfHphRsLY4HUwsplEdf1rMxJuoq8EyXrOxLXcayMJv/2+Ctv2T8DxkraNTshv1i9TnnoF83AY17iQub027Wz/qmEVOFZX3Zss7nW7xVw0J5HO0WQyPpNg9TMuokRP38IpHtmNXDRCQFnIwPnSX59fV5Dzn7/+NORv4GeA54bix7VoMqX6la82EithQyWGz2Km6ye/4YZkcXcZvqjb+48DdP8/</diagram></mxfile>
Binary file added Icons/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 Icons/doc.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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/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 Icons/zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@

## Requirements

- You cannot use file third-party libraries
- You will not be able to use global variables in PHP.
- You will not be able to use the $GLOBALS variable.
- You must use GIT
- You must use the PHP > v8
- Create a clear and orderly directory structure
- Create a clear and ordered 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
- When using HTML, never use inline styles
- Remember that it is important to divide the tasks into several sub-tasks so that 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
- Delete files and comments that are not used or are not necessary


## Repository

Expand Down
16 changes: 16 additions & 0 deletions back.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

if (isset($_FILES['file'])) {
$currentPath = $_POST['currentFolder'];

$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$newFileName = $_FILES['file']['name'];

move_uploaded_file($_FILES['file']['tmp_name'], $currentPath . '/' . $newFileName);

echo json_encode([
"extension" => $extension,
"fileName" => $_FILES['file']['name'],
]);
}

42 changes: 42 additions & 0 deletions create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php


$fileName = $_POST['file-name'];
$path = "root/";
$dir = $path . '/' . $fileName;

if(file_exists($dir)) {
if(!is_dir($dir)){
echo'<script type="text/javascript"> alert("Failed to create file"); window.location.href="index.php";</script>';
header('Location: index.php');
}else {
echo'<script type="text/javascript"> alert("Failed to create folder"); window.location.href="index.php";</script>';
header('Location: index.php');
}

}
else{
//Check if it should be a folder or file
if(strpos($fileName, '.') > 1) {
if(touch($dir)) {
echo "<li><a href='root/" . $file . "'>" . $fileName . "</a><button actualPath='$folder/$file' class='editBtn'>Edit</button>button deletePath='$folder/$file'class='delete-button'>Delete</button></li>";
header('Location: index.php');

}
}
else {
if(mkdir($dir)) {
echo "<li class='folder'>" . $fileName;
header('Location: index.php');

}

}
}

fopen($dir, 'r');



?>

9 changes: 9 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$deleteFile = $_GET["file"];

unlink($deleteFile);
echo json_encode(["file" => $deleteFile]);


?>
7 changes: 7 additions & 0 deletions download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// $target_dir = "uploads/";
// $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
// move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);

?>
17 changes: 17 additions & 0 deletions edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$newName = $_GET['newName'];
$actualPath = $_GET['actualPathFile'];
$indexSlashPath = strrpos($actualPath, "/");
$actualFolder = substr($actualPath, 0, $indexSlashPath + 1);

$indexExtensionPath = strrpos($actualPath, ".");
$extensionFile = substr($actualPath,$indexExtensionPath);

echo "$extensionFile";

rename($actualPath, $actualFolder . $newName . $extensionFile);
header("Location: index.php");


?>
217 changes: 217 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://bootswatch.com/5/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="logic.js?v=<?php echo time() ?>" defer></script>
<title>Document</title>

</head>

<body>

<header class="header">

<nav class="navbar navbar-expand-lg navbar-dark bg-primary">

<div class="container-fluid justify-content-start">

<input type="file" class="btn m-3 btn-secondary" name="fileToUpload" id="fileToUpload">
<input type="button" id="submitUploadBtn" class="btn m-3 btn-secondary" value="Upload File" name="submit">
<button type="button" class="btn m-3 btn-secondary" id="newBtn">New</button>
</div>
<div class="d-flex m-4 search-bar">
<input class="form-control me-sm-2" type="search" placeholder="Search" id="search-input" name="search_term">
<button id="searchBtn" class="btn btn-secondary my-2 my-sm-0" type="submit" class="search-button">Search</button>
<div id="search-result" class="searchResult main-header-link"></div>
</div>

</nav>

</header>

<main class="main">

<!-- Modal Create -->
<div id="newModal" class="modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New</h5>
</div>
<div class="modal-body">
<form action="create.php" method="POST" id="createItems" enctype="multipart/form-data">
<label for="formGroupExampleInput" class="form-label">Enter folder/file name</label>
<input type="text" class="form-control" id="formGroupExampleInput" name="file-name">
<button class="btn mt-1 btn-secondary" type="cancel">Cancel</button>
<button class="btn mt-1 btn-primary" type="submit">Accept</button>
</form>
</div>
</div>
</div>
</div>


<!-- <div class="container-fluid aside"> -->
<div id="mainFolder" class="container-fluid aside">
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
<button type="button" class="btn btn-primary">Open Menu</button>
<div class="btn-group" role="group">
<button id="menu-button" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
<?php generateMenu("root"); ?>
</div>
</div>

<!-- Modal Edit -->

<div class="editModal modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit</h5>
</div>
<div class="modal-body">
<form action="edit.php" method="GET" id="editItems" enctype="multipart/form-data">
<label for="newName" >New name</label>
<input type="text" id="fileName" name="newName">
<input type="hidden" name="actualPathFile" id="actualPathFile">
<button class="btn btn-secondary cancel" type="button">Cancel</button>
<button class="btn mt-1 btn-primary" type="submit">Accept</button>
</form>
</div>
</div>
</div>
</div>

<!-- Modal Delete -->

<div class="deleteModal modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete</h5>
</div>
<div class="modal-body">
<label for="deleteName" >Do you want to delete?</label>
<input type="hidden" name="deletePathFile" id="deletePathFile">
<button class="btn btn-secondary cancel" type="button">Cancel</button>
<button id ="submitDelete" class="btn mt-1 btn-primary" type="submit">Accept</button>
</div>
</div>
</div>
</div>
</main>
</body>

</html>

<?php

$extensionIcon = "";
$dir = "root";
$dirEx = explode(".", $dir);

$extension = end($dirEx);


function generateMenu($folder) {
// Use scandir to get the files and folders inside the folder
$files = array_diff(scandir($folder), array('.','..'));

// Create a list element
echo "<ul id='menu' class='list-group'>";

// Loop through the files and folders
foreach ($files as $file) {
// Check if the file is a folder
if (is_dir("$folder/$file")) {
// If it is a folder, create a list item with the folder name
echo "<li path='$folder/$file' class='list-group-item folder'>" . $file;
// Call the function recursively to generate the submenu for the folder
generateMenu("$folder/$file");

echo "</li>";
} else {

$extensionIcon = "";

$dirEx = explode(".", $file);

$extension = end($dirEx);

switch($extension){

case "csv":
$extensionIcon = "icons/csv.png";
break;
case "doc":
$extensionIcon = "icons/doc.png";
break;
case "exe":
$extensionIcon = "icons/exe.png";
break;
case "jpg":
$extensionIcon = "icons/jpg.png";
break;
case "jpeg":
$extensionIcon = "icons/jpg.png";
break;
case "mp3":
$extensionIcon = "icons/mp3.png";
break;
case "mp4":
$extensionIcon = "icons/mp4.png";
break;
case "odt":
$extensionIcon = "icons/odt.png";
break;
case "pdf":
$extensionIcon = "icons/pdf.png";
break;
case "png":
$extensionIcon = "icons/png.png";
break;
case "rar":
$extensionIcon = "icons/rar.png";
break;
case "txt":
$extensionIcon = "icons/txt.png";
break;
case "zip":
$extensionIcon = "icons/zip.png";
break;
case "mov":
$extensionIcon = "icons/mp4.png";
break;
}

// If it is a file, create a list item with a link to the file
echo "<li id='$folder/$file' class='list-group-item file' name = 'file-name'>
<a class='dropdown-item input-name' href='$folder/$file'> <img src='$extensionIcon' width='30px'> $file </a>
<button actualPath='$folder/$file' class='btn m-1 btn-dark editBtn'>Edit</button>
<button deletePath='$folder/$file'class='btn btn-dark delete-button'>Delete</button>
</li>";
$file_path = "$folder/$file";
// Get the file size in MB
$file_size = filesize($file_path);
$file_size_mb = round($file_size / 1024 / 1024, 2);

// Get the last modified time of the file
$file_last_modified = filemtime($file_path);
$file_last_modified_formatted = date('Y-m-d H:i:s', $file_last_modified);

// Print the file size and last modified time
echo "<br>File size: " . $file_size_mb . " MB";
echo "<br>Modificated: " . $file_last_modified_formatted;
}
}
echo "</ul>";
}

?>
Loading