Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3d0074c
Paul
paulMolano Nov 2, 2021
0326be4
Skeleton and styles first stage
E-Hidalgo Nov 2, 2021
6cae5bf
Merge branch 'master' into Paul
paulMolano Nov 2, 2021
0bd43a8
Index.html deleted
paulMolano Nov 3, 2021
d9b1e19
form create
paulMolano Nov 3, 2021
8361d33
addfile
paulMolano Nov 3, 2021
0438a06
added git ignore
E-Hidalgo Nov 3, 2021
4d7a015
done
E-Hidalgo Nov 3, 2021
cc42ccd
si si si si
E-Hidalgo Nov 3, 2021
e5a1b23
connected with DB
E-Hidalgo Nov 4, 2021
d48008a
fixed bugs in mac OS
E-Hidalgo Nov 4, 2021
c68667e
db working
E-Hidalgo Nov 4, 2021
f7ac2d9
merge for joel
E-Hidalgo Nov 4, 2021
df8814b
delete functionality done
E-Hidalgo Nov 4, 2021
4dfbeba
for joel my bro
E-Hidalgo Nov 4, 2021
3e9247a
edit function 1.1 created
Joelmarfas Nov 4, 2021
3bfa904
edit 1.2 done
Joelmarfas Nov 4, 2021
48b7fbf
Changes for Paul
E-Hidalgo Nov 5, 2021
5468e57
Commit for merge
paulMolano Nov 5, 2021
479aecc
Editing ok
paulMolano Nov 5, 2021
6158122
icons added and folders created
YaiGenes Nov 5, 2021
c19a59c
folder tree
YaiGenes Nov 8, 2021
8f256e8
folder tree more
YaiGenes Nov 8, 2021
88cb0e6
root index pipe fixed
YaiGenes Nov 8, 2021
141b882
almost
YaiGenes Nov 8, 2021
c42f5d4
almost almost
YaiGenes Nov 8, 2021
aa787f5
pincha bien
YaiGenes Nov 8, 2021
465e590
it looks better
YaiGenes Nov 8, 2021
49ca0fd
almost killed
YaiGenes Nov 9, 2021
3d1554e
folder tree doone but submit button on lower kapput
YaiGenes Nov 9, 2021
832a37a
submit button done and tree dir running awesome
YaiGenes Nov 9, 2021
188710e
addFile and back
paulMolano Nov 9, 2021
56ab1d1
trying delete
paulMolano Nov 9, 2021
42d92e1
delete
paulMolano Nov 9, 2021
0b320e4
macpalpelo
E-Hidalgo Nov 9, 2021
71ed1a3
edit Ok
paulMolano Nov 9, 2021
88d7758
search
paulMolano Nov 9, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
root
.DS_Store
Empty file modified README.md
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions assets/icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions includes/addfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
require_once("./dbh.inc.php");


if (isset($_GET["directory"]) && $_GET["directory"] !== "" && $_GET["directory"] !== "root") {
$pathName = $_GET["directory"];
} else {
$pathName = "../root";
}
$fileName = $_FILES["addfile"]["name"];
$fileType = $_FILES["addfile"]["type"];
$fileTmp = $_FILES["addfile"]["tmp_name"];
$fileSize = $_FILES["addfile"]["size"];

if (!file_exists("../root")) {
echo "hola";
mkdir($pathName, 0777, true);
if (PHP_OS !== "WINNT") {
echo "otra cosa";
chmod("../root/", 0777);
}
}

if (file_exists("../root") && move_uploaded_file($fileTmp, $pathName . "/" . $fileName)) {
echo "Uploaded file";
} else {
echo "File upload failed";
}



$file = $_FILES["addfile"];
$name = $file["name"];
$extension = pathinfo($name, PATHINFO_EXTENSION);
$size = $file["size"];
$modified = date("Y-m-d", filemtime($pathName . $fileName));
$creation = date("Y-m-d", filectime($pathName . $fileName));

// prepare to upload to db

$uploadQuery = $db->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");
}
48 changes: 48 additions & 0 deletions includes/addfolder.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
session_start();
require_once('dbh.inc.php');

if (isset($_POST["addfolder"])) {
if (isset($_GET["directory"]) && $_GET["directory"] !== "" && $_GET["directory"] !== "root") {
$mkdirRoute = $_GET["directory"];
} else {
$mkdirRoute = "../root";
}
mkdir($mkdirRoute . "/" . $_POST["addfolder"], 0777, true);
if (PHP_OS !== "WINNT") {
chmod($mkdirRoute . "/" . $_POST["addfolder"], 0777);
}
}


$modified = date("Y-m-d", filemtime($mkdirRoute . "/" . $_POST["addfolder"]));
$creation = date("Y-m-d", filectime($mkdirRoute . "/" . $_POST["addfolder"]));
$fileName = $_POST["addfolder"];


// prepare to upload to db

$uploadQuery = $db->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");
}
10 changes: 10 additions & 0 deletions includes/dbh.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// CONNECTION WITH DATA BASE

$dsn = "mysql:host=".$_SERVER["SERVER_NAME"].";dbname=files_system";
$dbusername ="root";
$dbpassword = "";

$db = new PDO($dsn, $dbusername, $dbpassword);
?>
36 changes: 36 additions & 0 deletions includes/delete.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
require_once("./dbh.inc.php");
$id = $_GET["id"];
$path = $_GET["path"];


$deleteQuery = $db->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");
20 changes: 20 additions & 0 deletions includes/edit.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require_once("./dbh.inc.php");
$id = $_GET["id"];


$editQuery = $db->prepare("
UPDATE `files` SET `edit`= :edit WHERE `id`= :id
");

$editQuery->execute([
"edit" => 1,
"id" => $id

]);


$url = $_SERVER['HTTP_REFERER'];

header("Location: $url");
24 changes: 24 additions & 0 deletions includes/edittitle.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

require_once("./dbh.inc.php");
$oldPath = $_GET["directory"];
$newPath = dirname($oldPath);
$newName = $_POST["title"];
$id = $_GET["id"];
$extension = $_GET["extension"];

$edittitleQuery = $db->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");
16 changes: 16 additions & 0 deletions includes/fetchFiles.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
session_start();
require_once("dbh.inc.php");




$fetchQuery = $db -> prepare("
SELECT * FROM `files` WHERE daddyPath=:path
");

$fetchQuery -> execute([
"path"=>"../root"
]);

$fileFetched = $fetchQuery -> rowCount()? $fetchQuery : [] ;
18 changes: 18 additions & 0 deletions includes/fetchLower.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
session_start();

require_once("dbh.inc.php");
$pathLower = $_GET["pathLower"];


$fetchQuery = $db->prepare("
SELECT * FROM `files` WHERE daddyPath=:path
");

$fetchQuery->execute([
"path" => $pathLower
]);

$fileFetched = $fetchQuery->rowCount() ? $fetchQuery : [];

//header("Location: ../lower.php?directory=$pathLower");
43 changes: 43 additions & 0 deletions includes/icons.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

function getFileType($extension){
switch($extension){
case 'pdf':
$type="fas fa-file-pdf";
break;
case 'folder':
$type="fas fa-folder";
break;
case 'docx':
case 'doc':
$type="fas fa-file-doc";
break;
case 'xls':
case 'xlsx':
$type='fas fa-file-word';
break;
case 'mp3':
case 'ogg':
case 'wav':
$type='fas fa-file-audio';
break;
case 'mp4':
case 'mov':
$type='fas fa-video';
break;
case 'zip':
case '7z':
case 'rar':
$type='fas fa-file-archive';
break;
case 'jpg':
case 'jpeg':
case 'png':
$type='fas fa-image';
break;
default:
$type='fas fa-file-alt';
}

return $type;
}
47 changes: 47 additions & 0 deletions includes/openfile.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
include_once "./utils.php";

$path = $_GET["path"];
$extension = $_GET["extension"];


switch ($extension) {
case 'txt':
case 'pdf':
read_txt($path);
break;
case 'docx':
case 'doc':
read_docx($path);
break;
case 'jpg':
case 'png':
case 'gif':
case 'jpeg':
case 'webp':
case 'svg':
echo "<img src='$path' alt='$path' />";
break;
// case 'zip':
// case 'rar':
//ZipArchive::RDONLY ****PENDIENTE
// case '7z':
// gzread($path, filesize($path));
// break;
case 'mp3':
echo "<audio controls>
<source src='$path' type='audio/mp3'>
</audio>";
break;
case 'mp4':
echo "<video controls>
<source src='$path' type='video/mp4'>
</video>";
break;
case 'folder':
header("Location: ../lower.php?pathLower=$path");
break;
default:
echo "File type not supported";
break;
}
15 changes: 15 additions & 0 deletions includes/search.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
session_start();
require_once("dbh.inc.php");
$name = $_GET["search"];


$fetchQuery = $db->prepare("
SELECT * FROM `files` WHERE name=:name
");

$fetchQuery->execute([
"name" => $name
]);

$fileFetched = $fetchQuery->rowCount() ? $fetchQuery : [];
Loading