inc/database.inc.php
author rejo
Tue, 25 Dec 2007 15:02:25 +0000
changeset 50 ed18c8317cff
parent 47 ae140472d97c
child 55 a885f557678f
permissions -rwxr-xr-x
[feladat @ 97] Removed superflucious includes of inc/i18n.inc.php.
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
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    22
require_once("MDB2.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
function dbError($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
        // General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
        include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
        ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    29
	<h2><? echo _('Oops! An error occured!'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    30
	<p class="error"><? echo $msg->getDebugInfo(); ?></p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    31
	<?        
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    32
	include_once("footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
        die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'dbError');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
$dsn = "$dbdsntype://$dbuser:$dbpass@$dbhost/$dbdatabase";
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    39
$db = MDB2::connect($dsn);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    41
if (MDB2::isError($db))
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
	// Error handling should be put.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
        error(MYSQL_ERROR_FATAL, $db->getMessage());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
// Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    48
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
/* erase info */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
$mysql_pass = $dsn = '';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
?>