<?php /********************************************************************** * Copyright (C) 2006 L'Équipe Wikigraphe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * See also http://www.fsf.org *********************************************************************/ require_once('conf/conf.php'); require_once("DB.php"); $dsn = "mysql://".DB_USER.":".DB_PASSWORD."@".DB_HOST."/".DB_NAME; $DB =& DB::connect($dsn); if (PEAR::isError($DB)) { /* XXX: better error handling: detect wrong username password and offer setup dialog, detect down database and offer readonly thing or something */ echo "<html><head><title>Connection failed</title><body>\n"; echo "<h1>Could not connect to database server</h1>\n"; echo '<p><code>'.$DB->getMessage() . "</code></p>\n"; echo "<p>The database server might be down or you forgot to configure a proper username/password combination in <code>conf/conf.php</code></p>\n"; echo "<p>Full error message: <code>"; echo preg_replace('/^.*\[nativecode=(.*)\].*$/', '\1', $DB->getUserInfo()); echo "</code></p></body></html>"; exit; } $DB->setFetchMode(DB_FETCHMODE_ASSOC); ?>