1
+ − 1
<?
+ − 2
47
+ − 3
/* PowerAdmin, a friendly web-based admin tool for PowerDNS.
+ − 4
* See <https://rejo.zenger.nl/poweradmin> for more details.
+ − 5
*
+ − 6
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl>
+ − 7
*
+ − 8
* This program is free software: you can redistribute it and/or modify
+ − 9
* it under the terms of the GNU General Public License as published by
+ − 10
* the Free Software Foundation, either version 3 of the License, or
+ − 11
* (at your option) any later version.
+ − 12
*
+ − 13
* This program is distributed in the hope that it will be useful,
+ − 14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ − 16
* GNU General Public License for more details.
+ − 17
*
+ − 18
* You should have received a copy of the GNU General Public License
+ − 19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ − 20
*/
+ − 21
8
+ − 22
require_once ( "MDB2.php" );
1
+ − 23
+ − 24
function dbError ( $msg )
+ − 25
{
+ − 26
// General function for printing critical errors.
+ − 27
include_once ( "header.inc.php" );
+ − 28
?>
13
+ − 29
<h2> <? echo _ ( 'Oops! An error occured!' ); ?> </h2>
+ − 30
<p class="error"> <? echo $msg -> getDebugInfo (); ?> </p>
+ − 31
<?
+ − 32
include_once ( "footer.inc.php" );
1
+ − 33
die ();
+ − 34
}
+ − 35
+ − 36
PEAR :: setErrorHandling ( PEAR_ERROR_CALLBACK , 'dbError' );
+ − 37
+ − 38
$dsn = " $dbdsntype :// $dbuser : $dbpass @ $dbhost / $dbdatabase " ;
8
+ − 39
$db = MDB2 :: connect ( $dsn );
1
+ − 40
8
+ − 41
if ( MDB2 :: isError ( $db ))
1
+ − 42
{
+ − 43
// Error handling should be put.
+ − 44
error ( MYSQL_ERROR_FATAL , $db -> getMessage ());
+ − 45
}
+ − 46
+ − 47
// Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
8
+ − 48
$db -> setFetchMode ( MDB2_FETCHMODE_ASSOC );
1
+ − 49
+ − 50
/* erase info */
+ − 51
$mysql_pass = $dsn = '' ;
+ − 52
55
+ − 53
// Add support for regular expressions in both MySQL and PostgreSQL
+ − 54
if ( $dbdsntype == "mysql" )
+ − 55
{
+ − 56
$sql_regexp = "REGEXP" ;
+ − 57
}
+ − 58
elseif ( $dbdsntype == "pgsql" )
+ − 59
{
+ − 60
$sql_regexp = "~" ;
+ − 61
}
+ − 62
else
+ − 63
{
+ − 64
error ( _ ( 'Unknown database type in inc/config.inc.php.' ));
+ − 65
};
1
+ − 66
+ − 67
?>