<?php
// Pin the open_basedir allow-list before any code that reads /root/.my.cnf,
// shells out, or does filesystem work. CLI scripts that follow the
// `require_once('/docker/whp/web/configs/config.php')` convention get this
// for free; HTTP requests get it through auto-prepend.php (which loads the
// same file). Either path lands here at-most once thanks to require_once.
require_once('/docker/whp/web/includes/safety-net.php');

//Set INC FLAG, and should be called as a part of the prepend
define('WHP',TRUE);
define('NONCE_SALT','FJ192kJKcf8fk389K3fk3929dkf4434Fa9O9#89jk@493ps394k23');
//Get MySQL Password from /root/.my.cnf
$root_mysql_password = shell_exec('cat /root/.my.cnf |grep password |cut -f2- -d=');
define('MYSQL_PASS',$root_mysql_password);

//Get PostgreSQL Password from /root/.pgpass if it exists
if (file_exists('/root/.pgpass')) {
    $pgpass_content = shell_exec('cat /root/.pgpass | head -1');
    if ($pgpass_content) {
        // Format: hostname:port:database:username:password
        $pgpass_parts = explode(':', trim($pgpass_content));
        if (count($pgpass_parts) >= 5) {
            define('POSTGRES_PASS', $pgpass_parts[4]);
        }
    }
}
// Fallback for environments without .pgpass
if (!defined('POSTGRES_PASS')) {
    define('POSTGRES_PASS', '');
}