Ported the original passman PHP/MySQL application to a Docker-based setup using Apache and MariaDB. Fixed compatibility issues with modern PHP/MariaDB versions (HTTP header handling and database collation) using minimal, targeted changes. Preserved the original application logic and structure while ensuring correct execution in a contemporary containerized environment.
17 lines
532 B
PHP
17 lines
532 B
PHP
<?php
|
|
// Database configuration (Docker Compose friendly).
|
|
// NOTE: In Docker, the DB host is the service name (e.g., "db"), not "localhost".
|
|
|
|
$DB_HOST = getenv('DB_HOST') ?: 'db';
|
|
$DB_USER = getenv('DB_USER') ?: 'root';
|
|
$DB_PASS = getenv('DB_PASS') ?: 'rootpass';
|
|
$DB_NAME = getenv('DB_NAME') ?: 'pwd_mgr';
|
|
|
|
// Create a DB connection.
|
|
$conn = mysqli_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
|
|
|
|
if (!$conn) {
|
|
// Fail fast if the DB is not reachable.
|
|
die("Database connection failed: " . mysqli_connect_error());
|
|
}
|
|
//?>
|