<?php

/*
** CBLM
** $Id: db.php,v 1.1 2008/02/04 04:40:02 sella Exp $
** Copyright (c) 2008 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

function connect() {
	global $config;

	/* Connect to database */
	$server = $config['databaseServer'];
	if (isset($config['databasePort']) && strlen($config['databasePort']) > 1) {
		$server .= ':' . $config['databasePort'];
	}
	$dbase = $config['databaseName'];
	$username = $config['databaseUsername'];
	$password = $config['databasePassword'];
	$persistent = $config['databasePersistent'];

	if ($persistent) {
		$con = @mysql_pconnect($server, $username, $password);
	} else {
		$con = @mysql_connect($server, $username, $password);
	}

	if ($con) {
		mysql_select_db($dbase);
	} else {
		die(sprintf("<CENTER><B>Failed to connect to database '%s' on server '%s'. Check your configuration file.</B></CENTER>", $dbase, $server));
	}

	return $con;
}

/*
 * Local Variables:
 * c-basic-offset: 3
 * tab-width: 3
 * End:
 * vim: noet ts=3 sw=3 sts=3
 */

?>
