Call Recording unable to connect to DB on FreePBX 15

FreePBX moved the DB credentials out of etc/amportal.conf quite some time ago now.
But they left the file in place with other information still. Because of that, the logic in config.php is no longer valid.

    if(!$db->is_connected()) {
        // Database connection details from amportal
=begin comment
This logic is invalid on FreePBX 15 as /etc/amportal.conf still exists.

        if (is_readable("/etc/amportal.conf")) {
            $amp_conf = parse_amportal_conf("/etc/amportal.conf");
            $DBHOST = $amp_conf['AMPDBHOST'];
            $DBNAME = $amp_conf['AMPDBNAME'];
            $DBUSER = $amp_conf['AMPDBUSER'];
            $DBPASS = $amp_conf['AMPDBPASS'];

            if(!isset($amp_conf['AMPDBENGINE'])) {
                if(is_file("/etc/freepbx/freepbx.conf")) {
                    $amp_conf = parse_amportal_conf("/etc/freepbx/freepbx.conf");
                } else if(is_file("/etc/freepbx.conf")) {
                    $amp_conf = parse_amportal_conf("/etc/freepbx.conf");
                }
                $DBHOST = $amp_conf['AMPDBHOST'];
                $DBNAME = $amp_conf['AMPDBNAME'];
                $DBUSER = $amp_conf['AMPDBUSER'];
                $DBPASS = $amp_conf['AMPDBPASS'];
            }

    } else if (is_readable("/etc/freepbx/freepbx.conf")) {
            $amp_conf = parse_amportal_conf("/etc/freepbx/freepbx.conf");
            $DBHOST = $amp_conf['AMPDBHOST'];
            $DBNAME = $amp_conf['AMPDBNAME'];
            $DBUSER = $amp_conf['AMPDBUSER'];
            $DBPASS = $amp_conf['AMPDBPASS'];
        } else if (is_readable("/etc/freepbx.conf")) {
=end comment
=cut
        if (is_readable("/etc/freepbx.conf")) {
            $amp_conf = parse_amportal_conf("/etc/freepbx.conf");
            $DBHOST = $amp_conf['AMPDBHOST'];
            $DBNAME = $amp_conf['AMPDBNAME'];
            $DBUSER = $amp_conf['AMPDBUSER'];
            $DBPASS = $amp_conf['AMPDBPASS'];
        } else if (is_readable("/etc/asterisk/snep/snep-features.conf")) {
            $DBHOST = 'localhost';
            $DBNAME = 'snep';
            $DBUSER = 'snep';
            $DBPASS = 'sneppass';
            $CDRDBTABLE = "snep.cdr";
        }
    $db = new dbcon($DBHOST, $DBUSER, $DBPASS, $DBNAME, true, true, $FORCE_UTF8);

Comments

  • edited March 2021

    It seems something about the subsequent if logic to after the amportal check is not working. Going only to the /etc/freepbx.conf does work as I simply commented out the block and added the if because it does not apply to the install. but obviously, you need to actually fix the logic so it works for various systems.
    This is the error I was getting

Sign In or Register to comment.