commit 3e5cde2ecc5274c55476c90c2e08d0cfcd103451
parent 9322ac0a5c45a496ababc48ade3a2192ec34a846
Author: Jan Dankert <devnull@localhost>
Date: Sat, 27 Oct 2012 04:04:50 +0200
Vorbelegung für Datenbank-Parameter.
Diffstat:
6 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/db/db.class.php b/db/db.class.php
@@ -146,7 +146,7 @@ class DB
// SQL nach Verbindungsaufbau ausfuehren.
- if ( isset($this->conf['connection_sql']) && ! empty($this->conf['connection_sql']) )
+ if ( ! empty($this->conf['connection_sql']) )
{
$cmd = $this->conf['connection_sql'];
$ok = $this->client->query($cmd);
@@ -178,7 +178,7 @@ class DB
die('SQL-Query must be an object');
// Vorbereitete Datenbankabfrage ("Prepared Statement")
- if ( isset($this->conf['prepare']) && $this->conf['prepare'] )
+ if ( $this->conf['prepare'] )
{
$this->client->clear();
@@ -228,7 +228,7 @@ class DB
}
}
- if ( isset($this->conf['autocommit']) && @$this->conf['autocommit'])
+ if ( $this->conf['autocommit'] )
if ( method_exists($this->client,'commit') )
$this->client->commit();
diff --git a/db/mysql.class.php b/db/mysql.class.php
@@ -49,7 +49,7 @@ class DB_mysql
$pw = $conf['password'];
$db = $conf['database'];
- if ( isset($conf['port']) )
+ if ( !empty($conf['port']) )
$host .= ':'.$conf['port'];
if ( $conf['persistent'] )
@@ -81,6 +81,13 @@ class DB_mysql
}
}
+ // Falls es sich um eine UTF-8-Datenbank handelt, dann setzen wir
+ // hier explizit den Zeichensatz für alle Anfragen.
+ $dbCharset = $conf['charset'];
+ if ( empty($dbCharset) || $dbCharset == 'UTF-8' )
+ @mysql_query("SET NAMES 'utf8';",$this->connection);
+
+
return true;
}
diff --git a/db/mysqli.class.php b/db/mysqli.class.php
@@ -59,7 +59,7 @@ class DB_mysqli
$db = $conf['database'];
$host = '127.0.0.1';
- if ( isset($conf['port']) )
+ if ( !empty($conf['port']) )
$host .= ':'.$conf['port'];
// 5.3.0 - Added the ability of persistent connections.
diff --git a/db/pdo.class.php b/db/pdo.class.php
@@ -53,7 +53,7 @@ class DB_pdo
$user = $conf['user' ];
$pw = $conf['password'];
- if ( isset($conf['convert_to_lowercase']) && $conf['convert_to_lowercase'] )
+ if ( !empty($conf['convert_to_lowercase']) )
$this->lowercase = true;
$options = array();
diff --git a/db/postgresql.class.php b/db/postgresql.class.php
@@ -51,7 +51,7 @@ class DB_postgresql
$pw = $conf['password'];
$db = $conf['database'];
- if ( isset($conf['port']) )
+ if ( !empty($conf['port']) )
$host .= ':'.$conf['port'];
if ( $conf['persistent'] )
@@ -64,7 +64,9 @@ class DB_postgresql
$this->error = 'Function does not exist: '.$connect_function.' Postgresql is not available';
return false;
}
-
+
+ Logger::debug('postgresql: connecting to: '."host=$host, dbname=$db");
+
if ( $pw != '' )
$this->connection = @$connect_function( "host=$host dbname=$db user=$user password=$pw" );
elseif ( $user != '' )
diff --git a/util/Preferences.class.php b/util/Preferences.class.php
@@ -106,7 +106,60 @@ class Preferences
$conf['config']['last_modification'] = filemtime($filename);
$conf['config']['file_modification'] = date('r',filemtime($filename));
$conf['config']['read' ] = date('r');
+
+ Preferences::fixConfiguration( &$conf );
+
return $conf;
}
+
+
+ public static function fixConfiguration( &$conf )
+ {
+ $defaultStyleConfig = array(
+ 'name'=>'Unnamed',
+ 'title_background_color'=>'grey',
+ 'title_text_color'=>'white',
+ 'text_color' => 'black',
+ 'background_color' => '#d9d9d9',
+ 'inactive_background_color' => 'silver'
+ );
+
+ $defaultDatabaseConfig = array(
+ 'enabled' =>true,
+ 'comment2' =>'',
+ 'user' =>'',
+ 'password' => '',
+ 'host' =>'localhost',
+ 'port' => '',
+ 'database' => '',
+ 'base64' => false,
+ 'prefix' => 'or_',
+ 'persistent' => true,
+ 'charset' => 'UTF-8',
+ 'connection_sql'=> '',
+ 'cmd' => '',
+ 'prepare' => false,
+ 'transaction' => false,
+ 'autocommit' => false,
+ 'readonly' => false
+ );
+
+ $dbconfig = &$conf['database'];
+ if ( is_array($dbconfig) )
+ foreach( $dbconfig as &$db )
+ {
+ if ( is_array($db))
+ $db = array_merge( $defaultDatabaseConfig,$db );
+ }
+
+ $styleconfig = &$conf['style'];
+ if ( is_array($styleconfig) )
+ foreach( $styleconfig as &$style )
+ {
+ if ( is_array($style))
+ $style = array_merge( $defaultStyleConfig, $style );
+ }
+
+ }
}
?>
\ No newline at end of file