Opening a database for SPF

This file may be required for SPF functions to work

<?php

  $FP7Data = str_replace('\\','/', getenv('FP7Data')); //De-windblowz path

  if($FP7Data == '') die('Please Fix your FP7Data Environment Variable'); //Make sure variable is set

  if(substr($FP7Data,-1,1) != '/') $FP7Data .= '/';  //Cleanup path

  if(!file_exists($FP7Data . 'Database.dsn')) die('Please open your database and click START'); // Makesure DSN exists

  $DSN = parse_ini_file(($FP7Data . 'Database.dsn'), true, INI_SCANNER_RAW);

  $DSN = array_change_key_case($DSN, CASE_UPPER);

  if(!array_key_exists('ODBC',$DSN)) die('Unrecoverable DSN File Error [ODBC]');

  if(!array_key_exists('DRIVER',$DSN['ODBC'])) {
    echo 'DSN File Error [DRIVER] "Microsoft Access Driver (*.mdb)" assumed' . "\n";
    $DSN['ODBC']['DRIVER'] = 'Microsoft Access Driver (*.mdb)';
  }
  if(!array_key_exists('UID',$DSN['ODBC'])) {
    echo "DSN File Error [UID] Admin assumed\n";
    $DSN['ODBC']['UID'] = 'Admin';
  }
  if(!array_key_exists('FIL',$DSN['ODBC'])) {
    echo 'DSN File Error [FIL] "MS Access" assumed' . "\n";
    $DSN['ODBC']['FIL'] = 'MS Access';
  }
  if(!array_key_exists('DBQ',$DSN['ODBC'])) die('Unrecoverable DSN File Error [DBQ]');

  $DSN['ODBC']['DBQ'] = str_replace('?',' ',$DSN['ODBC']['DBQ']);

  $PDODSN  = 'odbc:';

  foreach($DSN['ODBC'] as $key=>$value){
    $PDODSN .= $key . '=' . $DSN['ODBC'][$key] . ';';
  }

  try {
    $dbh = new PDO($PDODSN);
  } catch (PDOException $e) {
    die( 'Connection failed: ' . $e->getMessage());
  }

?>