mirror of
https://github.com/michalcz10/USB-RAID-Array.git
synced 2026-11-11 16:09:03 +00:00
Modernize FTP UI: use modern.css, add dark-box container, remove redundant DB function, delete unused FTP config
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
require '../../vendor/autoload.php';
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
$defPath = $_SESSION['defPath'] ?? '/';
|
||||
|
||||
// SFTP Configuration
|
||||
$host = 'localhost';
|
||||
$username = 'UNAME';
|
||||
$password = 'PSWD';
|
||||
$defaultPath = $defPath;
|
||||
|
||||
function initializeSFTP($host, $username, $password) {
|
||||
$sftp = new SFTP($host);
|
||||
if (!$sftp->login($username, $password)) {
|
||||
die('Login Failed');
|
||||
}
|
||||
return $sftp;
|
||||
}
|
||||
|
||||
function normalizePath($path) {
|
||||
$parts = array_filter(explode('/', $path), fn($part) => $part !== '' && $part !== '.');
|
||||
$stack = [];
|
||||
foreach ($parts as $part) {
|
||||
if ($part === '..') {
|
||||
array_pop($stack);
|
||||
} else {
|
||||
$stack[] = $part;
|
||||
}
|
||||
}
|
||||
return '/' . implode('/', $stack);
|
||||
}
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$currentPath = normalizePath($defaultPath);
|
||||
@@ -4,9 +4,9 @@
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'createDir') {
|
||||
$currentPath = isset($_POST['currentPath']) ? normalizePath($_POST['currentPath']) : $defaultPath;
|
||||
|
||||
@@ -18,9 +18,9 @@ if(!isset($_SESSION["upPer"]) || $_SESSION["upPer"] != true) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'createFile') {
|
||||
$currentPath = isset($_POST['currentPath']) ? normalizePath($_POST['currentPath']) : $defaultPath;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete'])) {
|
||||
$itemToDelete = $_POST['delete'];
|
||||
|
||||
@@ -9,14 +9,14 @@ error_reporting(0);
|
||||
ob_start();
|
||||
|
||||
try {
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
|
||||
$logFile = __DIR__ . '/download_log.txt';
|
||||
file_put_contents($logFile, "Download started: " . date('Y-m-d H:i:s') . "\n", FILE_APPEND);
|
||||
|
||||
$sftp = null;
|
||||
try {
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
file_put_contents($logFile, "SFTP connection established\n", FILE_APPEND);
|
||||
} catch (Exception $e) {
|
||||
file_put_contents($logFile, "SFTP connection failed: " . $e->getMessage() . "\n", FILE_APPEND);
|
||||
|
||||
@@ -16,10 +16,10 @@ if(!isset($_SESSION["upPer"]) || $_SESSION["upPer"] != true) {
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
// Process extraction request
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['archive'])) {
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
$currentPath = isset($_GET['path']) ? normalizePath($_GET['path']) : $defaultPath;
|
||||
if (strpos($currentPath, $defaultPath) !== 0) {
|
||||
@@ -39,7 +39,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -51,7 +51,7 @@
|
||||
<span id="themeText"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="custom-container">
|
||||
<div class="custom-container dark-box">
|
||||
<header class="row border-bottom m-5">
|
||||
<h1>USB RAID Array</h1>
|
||||
<div class="mb-3 p-3">
|
||||
|
||||
@@ -12,8 +12,8 @@ if(!isset($_SESSION['uname'])){
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'config.php';
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
$filePath = isset($_GET['file']) ? $_GET['file'] : '';
|
||||
|
||||
@@ -54,13 +54,13 @@ $showLineNumbers = in_array(strtolower($extension), ['php', 'js', 'html', 'css',
|
||||
$parentDir = dirname($filePath);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="<?= isset($_COOKIE['theme']) ? $_COOKIE['theme'] : 'light' ?>">
|
||||
<head>
|
||||
<title>Edit File - <?= htmlspecialchars($fileName) ?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/open.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -72,7 +72,7 @@ $parentDir = dirname($filePath);
|
||||
<span id="themeText"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="container mt-4">
|
||||
<div class="custom-container dark-box">
|
||||
<div class="header-container">
|
||||
<h1>Edit File: <?= htmlspecialchars($fileName) ?></h1>
|
||||
<a href="index.php?path=<?= urlencode($parentDir) ?>" class="btn btn-secondary">Back to File List</a>
|
||||
|
||||
@@ -7,8 +7,8 @@ if(!isset($_SESSION['uname'])){
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'config.php';
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if (!isset($_GET['file'])) {
|
||||
die("No file specified");
|
||||
@@ -111,14 +111,14 @@ if (isset($_GET['stream'])) {
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="<?= isset($_COOKIE['theme']) ? $_COOKIE['theme'] : 'light' ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PDF Viewer</title>
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/pdf.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -131,7 +131,7 @@ if (isset($_GET['stream'])) {
|
||||
<span id="themeText"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="custom-container">
|
||||
<div class="custom-container dark-box">
|
||||
<header class="text-center border-bottom m-5">
|
||||
<h1 class="mb-4">PDF Viewer</h1>
|
||||
<div class="mb-3">
|
||||
|
||||
@@ -14,8 +14,8 @@ if(!isset($_SESSION["upPer"]) || $_SESSION["upPer"] != true) {
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$oldPath = isset($_POST['path']) ? $_POST['path'] : '';
|
||||
|
||||
@@ -12,15 +12,15 @@ if (empty($_SESSION['admin']) || $_SESSION['admin'] !== true) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
|
||||
use phpseclib3\Net\SSH2;
|
||||
|
||||
$ssh_host = 'localhost';
|
||||
$ssh_username = 'uname';
|
||||
$ssh_password = 'pswd';
|
||||
// $ssh_host = 'localhost';
|
||||
// $ssh_username = 'uname';
|
||||
// $ssh_password = 'pswd';
|
||||
|
||||
$ssh = new SSH2($ssh_host);
|
||||
$ssh = getSSHConnection();
|
||||
if (!$ssh->login($ssh_username, $ssh_password)) {
|
||||
die('SSH login failed');
|
||||
}
|
||||
@@ -218,13 +218,13 @@ function formatBytes($bytes, $forceUnit = '') {
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="<?= isset($_COOKIE['theme']) ? $_COOKIE['theme'] : 'light' ?>">
|
||||
<head>
|
||||
<title>Server Status</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/serverstat.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -238,6 +238,7 @@ function formatBytes($bytes, $forceUnit = '') {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="custom-container dark-box">
|
||||
<header class="row border-bottom m-5">
|
||||
<h1>Server Status</h1>
|
||||
<div class="mb-3 p-3">
|
||||
@@ -417,6 +418,7 @@ function formatBytes($bytes, $forceUnit = '') {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<footer class="d-flex flex-column justify-content-center align-items-center p-3 border-top gap-3">
|
||||
<span class="text-muted">Developed by Michal Sedlák</span>
|
||||
<div class="d-flex gap-3">
|
||||
|
||||
@@ -4,20 +4,9 @@
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
|
||||
function getDatabaseConnection() {
|
||||
$servername = "localhost:3306";
|
||||
$username = "UNAME";
|
||||
$password = "PSWD";
|
||||
$db = "usbraidlogin";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $db);
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
return $conn;
|
||||
}
|
||||
// getDatabaseConnection relocated to central config
|
||||
|
||||
if (!isset($_GET['token'])) {
|
||||
die("Invalid request. No token provided.");
|
||||
@@ -42,7 +31,7 @@ $downloadAllowed = $share['download_allowed'] == 1;
|
||||
$stmt->close();
|
||||
|
||||
// Initialize SFTP
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if (!$sftp->stat($filePath)) {
|
||||
die("File not found: $filePath");
|
||||
@@ -235,7 +224,7 @@ function formatBytes($bytes, $precision = 2) {
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/view.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -247,7 +236,7 @@ function formatBytes($bytes, $precision = 2) {
|
||||
<span id="themeText"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="custom-container">
|
||||
<div class="custom-container dark-box">
|
||||
<header class="row border-bottom m-5">
|
||||
<h1>Shared Media</h1>
|
||||
<div class="mb-3">
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require 'config.php';
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
$currentPath = isset($_POST['currentPath']) ? normalizePath($_POST['currentPath']) : $defaultPath;
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('memory_limit', '512M');
|
||||
|
||||
require 'config.php';
|
||||
$sftp = initializeSFTP($host, $username, $password);
|
||||
require_once __DIR__ . '/../../config/config.php';
|
||||
$sftp = initializeSFTP();
|
||||
|
||||
if (!isset($_GET['file'])) {
|
||||
die("No file specified");
|
||||
@@ -70,19 +70,6 @@ if (isset($_GET['shared'])) {
|
||||
}
|
||||
}
|
||||
|
||||
function getDatabaseConnection() {
|
||||
$servername = "localhost:3306";
|
||||
$username = "UNAME";
|
||||
$password = "PSWD";
|
||||
$db = "usbraidlogin";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $db);
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
return $conn;
|
||||
}
|
||||
|
||||
$filePath = $_GET['file'];
|
||||
$fileName = basename($filePath);
|
||||
$fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
@@ -272,7 +259,7 @@ if (isset($_GET['stream'])) {
|
||||
<link rel="icon" href="../../img/favicon.ico" type="image/x-icon">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="../../css/bootstrap.css">
|
||||
<link rel="stylesheet" href="../../css/modern.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="css/view.css">
|
||||
<script src="../../js/bootstrap.bundle.js"></script>
|
||||
@@ -284,7 +271,7 @@ if (isset($_GET['stream'])) {
|
||||
<span id="themeText"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="custom-container">
|
||||
<div class="custom-container dark-box">
|
||||
<header class="row border-bottom m-5">
|
||||
<h1>Media Viewer</h1>
|
||||
<div class="mb-3 p-3">
|
||||
|
||||
Reference in New Issue
Block a user