inc/database.inc.php
author rejo
Tue, 17 Apr 2007 19:43:24 +0000
changeset 4 55ed92aa7cf5
parent 1 58094faf794d
child 8 47dd15d8bb8c
permissions -rwxr-xr-x
[feladat @ 5] - Second half of translation framework. - Several small typo's in code fixed. - Removed comments on a todo in leveldescription(), already done. - Replaced dal.inc.php with DB.php from package DB-1.7.6 from pear.php.net to fix problems using poweradmin 1.2.7-patched with php5/pear. The DB package has already been superseded by MDB2, but that version is incompatible with current code.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
// | PowerAdmin								|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
// | Copyright (c) 1997-2002 The PowerAdmin Team			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
// | This source file is subject to the license carried by the overal	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
// | program PowerAdmin as found on http://poweradmin.sf.net		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
// | The PowerAdmin program falls under the QPL License:		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
// | http://www.trolltech.com/developer/licensing/qpl.html		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
// Filename: auth.inc.php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
// Startdate: 26-10-2002
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
// Description: Constructs the database class.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
// $Id: database.inc.php,v 1.3 2002/12/27 02:45:08 azurazu Exp $
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
require_once("dal.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
function dbError($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
        // General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
        include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
        ?>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 1
diff changeset
    31
        <P><TABLE CLASS="error"><TR><TD CLASS="error"><H2><? echo _('Oops! An error occured!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
        <BR>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 1
diff changeset
    33
        <FONT STYLE="font-weight: Bold"><?= $msg->getDebugInfo(); ?><BR><BR><a href="javascript:history.go(-1)">&lt;&lt; <? echo _('back'); ?></a></FONT><BR></TD></TR></TABLE></P>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
        die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
// Setup error handling.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'dbError');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
//$dsn = "mysql://padev:blapadev@localhost/padev" ;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
$dsn = "$dbdsntype://$dbuser:$dbpass@$dbhost/$dbdatabase";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
$db = DB::connect($dsn);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
if (DB::isError($db))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
	// Error handling should be put.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
        error(MYSQL_ERROR_FATAL, $db->getMessage());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
// Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
$db->setFetchMode(DB_FETCHMODE_ASSOC);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
/* erase info */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
$mysql_pass = $dsn = '';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
?>