<?php 

$db = "";		// Connection zu DB
$error = "";		// Fehlermeldung beim Verbinden mit DB
	if( $_SERVER['SERVER_NAME'] == "klausfriese.local" ) {
		$fulldir = "/homepage/klausfriese.de/";
		$dbhost = "localhost";
		$dbuser = "root";
		$dbname = "panoramicum";
		$dbpassword = "";
	} else {
		$fulldir = "/var/www/html/";
        $dbhost = getenv('DB_HOST');
        $dbuser = getenv('DB_USER');
        $dbname = getenv('DB_NAME');
        $dbpassword = getenv('DB_PASSWORD');
	}

// ----------------------------------------------------------------------------
// Verbindung aufbauen readwrite
// IN:
// OUT:
//  Error-string
function DBConnect() {
	global $dbhost,$dbuser,$dbpassword,$dbname,$db;

	try {
	    $db = new PDO('mysql:host=' . $dbhost. ';dbname=' . $dbname . ';charset=utf8', $dbuser, $dbpassword);
	} catch (PDOException $ex) {
	    die('Die Datenbank ist momentan nicht erreichbar. ($dbhost/$dbuser/'.$_SERVER['SERVER_NAME'].')' . htmlspecialchars($ex->getMessage() ) );
	}
}

// ----------------------------------------------------------------------------
// Verbindungen schliessen
// IN: -
// OUT: -
function DBClose() {
  // Freigeben des Resultsets
}

function repl( $txt , $in , $out ) {
	return preg_replace( $in, $out, $txt , 1 );
}

function br2nl($str) {
    return preg_replace("=<br(>|([\s/][^>]*)>)\r?\n?=i", "\n", $str);
}