mirror of
https://github.com/michalcz10/USB-RAID-Array.git
synced 2025-12-10 03:22:19 +00:00
WebApp production ver
This commit is contained in:
35
Web/betatest/content/ftp/config.php
Normal file
35
Web/betatest/content/ftp/config.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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);
|
||||
Reference in New Issue
Block a user