User Management
+ + + + +Users List
+| Username | +Admin | +Default Path | +Delete Permission | +Download Permission | +Upload Permission | +Actions | +
|---|---|---|---|---|---|---|
| + | + | + | + | + | + | + + | +
diff --git a/Documentation/Img/RAID0_SpeedTest-New.png b/Documentation/Img/RAID0_SpeedTest-New.png new file mode 100644 index 0000000..5274a29 Binary files /dev/null and b/Documentation/Img/RAID0_SpeedTest-New.png differ diff --git a/Documentation/Img/RAID0_SpeedTest.png b/Documentation/Img/RAID0_SpeedTest.png new file mode 100644 index 0000000..f455a79 Binary files /dev/null and b/Documentation/Img/RAID0_SpeedTest.png differ diff --git a/Documentation/Img/RAID1_SpeedTest-New.png b/Documentation/Img/RAID1_SpeedTest-New.png new file mode 100644 index 0000000..75b43a8 Binary files /dev/null and b/Documentation/Img/RAID1_SpeedTest-New.png differ diff --git a/Documentation/Img/RAID1_SpeedTest.png b/Documentation/Img/RAID1_SpeedTest.png new file mode 100644 index 0000000..561a59f Binary files /dev/null and b/Documentation/Img/RAID1_SpeedTest.png differ diff --git a/Documentation/Img/RAID5_SpeedTest-New.png b/Documentation/Img/RAID5_SpeedTest-New.png new file mode 100644 index 0000000..df9a606 Binary files /dev/null and b/Documentation/Img/RAID5_SpeedTest-New.png differ diff --git a/Documentation/Img/RAID5_SpeedTest.png b/Documentation/Img/RAID5_SpeedTest.png new file mode 100644 index 0000000..0e8af74 Binary files /dev/null and b/Documentation/Img/RAID5_SpeedTest.png differ diff --git a/Documentation/Rocnikova prace Michal Sedlak.pdf b/Documentation/Rocnikova prace Michal Sedlak.pdf new file mode 100644 index 0000000..39d1ae1 Binary files /dev/null and b/Documentation/Rocnikova prace Michal Sedlak.pdf differ diff --git a/Documentation/Technická dokumentace - RAID Pole.docx b/Documentation/Technická dokumentace - RAID Pole.docx new file mode 100644 index 0000000..85ed579 Binary files /dev/null and b/Documentation/Technická dokumentace - RAID Pole.docx differ diff --git a/Documentation/Technická dokumentace - RAID Pole.pdf b/Documentation/Technická dokumentace - RAID Pole.pdf new file mode 100644 index 0000000..cdbaa09 Binary files /dev/null and b/Documentation/Technická dokumentace - RAID Pole.pdf differ diff --git a/Documentation/USB RAID pole.pptx b/Documentation/USB RAID pole.pptx new file mode 100644 index 0000000..293b204 Binary files /dev/null and b/Documentation/USB RAID pole.pptx differ diff --git a/Documentation/matice-rizik.pdf b/Documentation/matice-rizik.pdf new file mode 100644 index 0000000..ed29ad6 Binary files /dev/null and b/Documentation/matice-rizik.pdf differ diff --git a/Documentation/msedlak_itb4.pdf b/Documentation/msedlak_itb4.pdf new file mode 100644 index 0000000..3ffc770 Binary files /dev/null and b/Documentation/msedlak_itb4.pdf differ diff --git a/Documentation/usbraidlogin.sql b/Documentation/usbraidlogin.sql new file mode 100644 index 0000000..b261119 --- /dev/null +++ b/Documentation/usbraidlogin.sql @@ -0,0 +1,50 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.1deb5ubuntu1 +-- https://www.phpmyadmin.net/ +-- +-- Počítač: localhost:3306 +-- Vytvořeno: Čtv 20. bře 2025, 12:55 +-- Verze serveru: 8.0.41-0ubuntu0.22.04.1 +-- Verze PHP: 8.1.2-1ubuntu2.20 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Databáze: `usbraidlogin` +-- + +-- -------------------------------------------------------- + +-- +-- Struktura tabulky `users` +-- + +CREATE TABLE `users` ( + `uname` varchar(255) NOT NULL, + `pswd` varchar(60) NOT NULL, + `admin` tinyint(1) NOT NULL DEFAULT '0', + `defPath` varchar(255) NOT NULL DEFAULT '/', + `delPer` tinyint(1) NOT NULL DEFAULT '0', + `downPer` tinyint(1) NOT NULL DEFAULT '0', + `upPer` tinyint(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- +-- Vypisuji data pro tabulku `users` +-- + +INSERT INTO `users` (`uname`, `pswd`, `admin`, `defPath`, `delPer`, `downPer`, `upPer`) VALUES +('admin', '$2y$10$QZEnBMv01f92Ikrta3Qo4ewbmoozVuDT.uPhtztNT7bsIwDQ.Fy8e', 1, '/', 1, 1, 1); +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Documentation/Šablona MPO.docx b/Documentation/Šablona MPO.docx new file mode 100644 index 0000000..674f091 Binary files /dev/null and b/Documentation/Šablona MPO.docx differ diff --git a/LICENSE b/LICENSE index d74c5aa..a0de999 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Michal Sedlák +Copyright (c) 2024 Michal Sedlák Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5c3aaf5..37b6d05 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# USB-RAID-Array \ No newline at end of file +# USB-RAID-pole +Cílem práce je nalézt využití zastaralých paměťových médií jako například slabopaměťové USB flash disky s malou paměťovou kapacitou. Technologii RAID (NAS) pole v praxi implementujte na vícero RAID technologiích a vzájemně komparujte řešení. Komparujte chování navrženého systému minimálně na technologiích RAID 0, RAID 1 a RAID 5. Vytvořte vzdálené připojení na toto RAID pole s možností nahrání a stažení souborů po přihlášení uživatele (web login). K tomuto účelu vytvořte webovou aplikaci. Zabezpečte vzdálené připojení. Použité technologie: RAID, NAS, FTP, USB, Flash, HTML, PHP, MySQL. diff --git a/Web/betatest/composer.json b/Web/betatest/composer.json new file mode 100644 index 0000000..8f8e167 --- /dev/null +++ b/Web/betatest/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "phpseclib/phpseclib": "^3.0" + } +} diff --git a/Web/betatest/composer.lock b/Web/betatest/composer.lock new file mode 100644 index 0000000..8175aae --- /dev/null +++ b/Web/betatest/composer.lock @@ -0,0 +1,246 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6b7a718f1b7b53a21b92507cfa57827a", + "packages": [ + { + "name": "paragonie/constant_time_encoding", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "df1e7fde177501eee2037dd159cf04f5f301a512" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512", + "reference": "df1e7fde177501eee2037dd159cf04f5f301a512", + "shasum": "" + }, + "require": { + "php": "^8" + }, + "require-dev": { + "phpunit/phpunit": "^9", + "vimeo/psalm": "^4|^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2024-05-08T12:36:18+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "phpseclib/phpseclib", + "version": "3.0.43", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "709ec107af3cb2f385b9617be72af8cf62441d02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/709ec107af3cb2f385b9617be72af8cf62441d02", + "reference": "709ec107af3cb2f385b9617be72af8cf62441d02", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1|^2|^3", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": ">=5.6.1" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "suggest": { + "ext-dom": "Install the DOM extension to load XML formatted public keys.", + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib3\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "support": { + "issues": "https://github.com/phpseclib/phpseclib/issues", + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.43" + }, + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], + "time": "2024-12-14T21:12:59+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/Web/betatest/content/adminpanel.php b/Web/betatest/content/adminpanel.php new file mode 100644 index 0000000..838163a --- /dev/null +++ b/Web/betatest/content/adminpanel.php @@ -0,0 +1,248 @@ +set_charset("utf8"); + +if ($conn->connect_error) { + die("Database connection failed: " . $conn->connect_error); +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['uname']) && isset($_POST['pswd'])) { + $uname = trim($_POST['uname']); + $pswd = trim($_POST['pswd']); + $is_admin = isset($_POST['admin']) ? 1 : 0; + $defPath = isset($_POST['defPath']) ? trim($_POST['defPath']) : ''; + $delPer = isset($_POST['delPer']) ? (int)$_POST['delPer'] : 0; + $dowPer = isset($_POST['downPer']) ? (int)$_POST['downPer'] : 0; + $upPer = isset($_POST['upPer']) ? (int)$_POST['upPer'] : 0; + + if (empty($uname) || empty($pswd)) { + $_SESSION['message'] = 'Error: Username and password are required!'; + $_SESSION['message_type'] = 'error'; + } else { + $sql_check = "SELECT * FROM users WHERE uname = ?"; + $stmt_check = $conn->prepare($sql_check); + if (!$stmt_check) { + $_SESSION['message'] = 'Error: Database preparation failed.'; + $_SESSION['message_type'] = 'error'; + } else { + $stmt_check->bind_param("s", $uname); + $stmt_check->execute(); + $result_check = $stmt_check->get_result(); + + if ($result_check->num_rows > 0) { + $_SESSION['message'] = 'Error: Username already exists!'; + $_SESSION['message_type'] = 'error'; + } else { + $sql_insert = "INSERT INTO users (uname, pswd, admin, defPath, delPer, downPer, upPer) VALUES (?, ?, ?, ?, ?, ?, ?)"; + $stmt_insert = $conn->prepare($sql_insert); + if (!$stmt_insert) { + $_SESSION['message'] = 'Error: Database preparation failed.'; + $_SESSION['message_type'] = 'error'; + } else { + $hash = password_hash($pswd, PASSWORD_BCRYPT); + if (!$hash) { + $_SESSION['message'] = 'Error: Password hashing failed.'; + $_SESSION['message_type'] = 'error'; + } else { + $stmt_insert->bind_param("ssisiii", $uname, $hash, $is_admin, $defPath, $delPer, $dowPer, $upPer); + if ($stmt_insert->execute()) { + $_SESSION['message'] = 'User added successfully!'; + $_SESSION['message_type'] = 'success'; + } else { + $_SESSION['message'] = 'Error: Failed to add user. Please try again later.'; + $_SESSION['message_type'] = 'error'; + } + } + } + } + $stmt_check->close(); + if (isset($stmt_insert)) { + $stmt_insert->close(); + } + } + } + + header("Location: adminpanel.php"); + exit(); + } else { + $_SESSION['message'] = 'Error: Missing form data!'; + $_SESSION['message_type'] = 'error'; + header("Location: adminpanel.php"); + exit(); + } +} + +if (isset($_GET['delete'])) { + $delete_uname = htmlspecialchars($_GET['delete']); + $sql = "DELETE FROM users WHERE uname=?"; + $stmt = $conn->prepare($sql); + if ($stmt) { + $stmt->bind_param("s", $delete_uname); + if ($stmt->execute()) { + $_SESSION['message'] = 'User deleted successfully!'; + $_SESSION['message_type'] = 'success'; + } else { + $_SESSION['message'] = 'Error: Failed to delete user.'; + $_SESSION['message_type'] = 'error'; + } + $stmt->close(); + } else { + $_SESSION['message'] = 'Error: Database preparation failed.'; + $_SESSION['message_type'] = 'error'; + } + + header("Location: adminpanel.php"); + exit(); +} + +$result = $conn->query("SELECT uname, admin, defPath, delPer, downPer, upPer FROM users"); + +$message = $_SESSION['message'] ?? ''; +$message_type = $_SESSION['message_type'] ?? ''; +unset($_SESSION['message']); +unset($_SESSION['message_type']); +?> + + + +
+| Username | +Admin | +Default Path | +Delete Permission | +Download Permission | +Upload Permission | +Actions | +
|---|---|---|---|---|---|---|
| + | + | + | + | + | + | + + | +
| Name | +Size | +Actions | +
|---|---|---|
| .. (Go Back) | +||
| + = htmlspecialchars($directory) ?>/ + | ++ + + + + + + + + + + | +|
| + + + + = htmlspecialchars($file) ?> + + + Image + + Video + + Audio + + + + = htmlspecialchars($file) ?> + + = htmlspecialchars($fileExtension) ?> + + + = htmlspecialchars($file) ?> + + PDF + + = htmlspecialchars($file) ?> + = htmlspecialchars($fileExtension) ?> + + | ++ = formatBytes($sftp->stat($currentPath . '/' . $file)['size']) ?> + | ++ + + + + + + + + + + + + + | +
This link will expire on = date('F j, Y, g:i a', strtotime($share['expiration'])) ?>
+| File Name | += htmlspecialchars($fileName) ?> | +
|---|---|
| File Type | += htmlspecialchars(strtoupper($fileExtension)) ?> | +
| File Size | += formatBytes($fileSize) ?> | +
Share link created successfully!
+This link will expire on = date('F j, Y, g:i a', strtotime($shareExpiration)) ?>
+| File Name | += htmlspecialchars($fileName) ?> | +
|---|---|
| File Type | += htmlspecialchars(strtoupper($fileExtension)) ?> | +
| MIME Type | += htmlspecialchars($mimeType) ?> | +
| File Size | += formatBytes($fileSize) ?> | +