mirror of
https://github.com/michalcz10/USB-RAID-Array.git
synced 2026-11-11 07:59:04 +00:00
Use portable POSIX parent paths instead of platform-dependent dirname() for remote navigation, previews, uploads, file operations and shared URLs. Normalize browser paths, avoid doubled root separators and preserve top-level directory names in ZIP downloads. Add regression coverage for root navigation, generated links, relative paths and ZIP members, and document the new test command. Verified with PHP syntax checks and all three regression suites.
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
||
// Central configuration for DB, SFTP, and SSH connections
|
||
|
||
// Autoload dependencies (phpseclib)
|
||
require_once __DIR__ . '/../vendor/autoload.php';
|
||
require_once __DIR__ . '/../includes/remotepaths.php';
|
||
|
||
use phpseclib3\Net\SFTP;
|
||
use phpseclib3\Net\SSH2;
|
||
|
||
// Database credentials (placeholders – replace with real values in production)
|
||
$DB_HOST = 'localhost:3306';
|
||
$DB_USER = 'usbraid';
|
||
$DB_PASS = 'usbraid';
|
||
$DB_NAME = 'usbraid';
|
||
|
||
// SFTP credentials (placeholders)
|
||
$SFTP_HOST = '172.16.1.11';
|
||
$SFTP_USER = 'usbraid';
|
||
$SFTP_PASS = 'usbraid';
|
||
// Default remote path – uses session value if set
|
||
$defaultPath = $_SESSION['defPath'] ?? '/';
|
||
|
||
// SSH credentials (placeholders)
|
||
$SSH_HOST = '172.16.1.11';
|
||
$SSH_USER = 'usbraid';
|
||
$SSH_PASS = 'usbraid';
|
||
|
||
/** Helper: Get a MySQLi connection */
|
||
function getDatabaseConnection(): mysqli {
|
||
global $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME;
|
||
$conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
|
||
if ($conn->connect_error) {
|
||
die('Connection failed: ' . $conn->connect_error);
|
||
}
|
||
$conn->set_charset('utf8');
|
||
return $conn;
|
||
}
|
||
|
||
/** Helper: Initialise SFTP connection */
|
||
function initializeSFTP(): SFTP {
|
||
global $SFTP_HOST, $SFTP_USER, $SFTP_PASS;
|
||
$sftp = new SFTP($SFTP_HOST);
|
||
if (!$sftp->login($SFTP_USER, $SFTP_PASS)) {
|
||
die('Login Failed');
|
||
}
|
||
return $sftp;
|
||
}
|
||
|
||
/** Helper: Initialise SSH connection */
|
||
function getSSHConnection(): SSH2 {
|
||
global $SSH_HOST, $SSH_USER, $SSH_PASS;
|
||
$ssh = new SSH2($SSH_HOST);
|
||
if (!$ssh->login($SSH_USER, $SSH_PASS)) {
|
||
die('SSH login failed');
|
||
}
|
||
return $ssh;
|
||
}
|
||
|
||
?>
|