Files
2026-10-18 15:55:34 +02:00

61 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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 = normalizePath($_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;
$database = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if ($database->connect_error) {
die('Connection failed: ' . $database->connect_error);
}
$database->set_charset('utf8');
return $database;
}
/** 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;
}
?>