summaryrefslogtreecommitdiff
path: root/installer
diff options
context:
space:
mode:
Diffstat (limited to 'installer')
-rw-r--r--installer/check.php12
-rw-r--r--installer/config.php23
-rw-r--r--installer/rcube_install.php61
-rw-r--r--installer/test.php18
4 files changed, 74 insertions, 40 deletions
diff --git a/installer/check.php b/installer/check.php
index 14fc4f06e..fcf35025e 100644
--- a/installer/check.php
+++ b/installer/check.php
@@ -64,12 +64,12 @@ $source_urls = array(
'Intl' => 'http://www.php.net/manual/en/book.intl.php',
'Exif' => 'http://www.php.net/manual/en/book.exif.php',
'PDO' => 'http://www.php.net/manual/en/book.pdo.php',
- 'pdo_mysql' => 'http://www.php.net/manual/en/book.pdo-mysql.php',
- 'pdo_pgsql' => 'http://www.php.net/manual/en/book.pdo-pgsql.php',
- 'pdo_sqlite' => 'http://www.php.net/manual/en/book.pdo-sqlite.php',
- 'pdo_sqlite2' => 'http://www.php.net/manual/en/book.pdo-sqlite.php',
- 'pdo_sqlsrv' => 'http://www.php.net/manual/en/book.pdo-sqlsrv.php',
- 'pdo_dblib' => 'http://www.php.net/manual/en/book.pdo-dblib.php',
+ 'pdo_mysql' => 'http://www.php.net/manual/en/ref.pdo-mysql.php',
+ 'pdo_pgsql' => 'http://www.php.net/manual/en/ref.pdo-pgsql.php',
+ 'pdo_sqlite' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
+ 'pdo_sqlite2' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
+ 'pdo_sqlsrv' => 'http://www.php.net/manual/en/ref.pdo-sqlsrv.php',
+ 'pdo_dblib' => 'http://www.php.net/manual/en/ref.pdo-dblib.php',
'PEAR' => 'http://pear.php.net',
'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
diff --git a/installer/config.php b/installer/config.php
index d6846edc7..4fcf5b08e 100644
--- a/installer/config.php
+++ b/installer/config.php
@@ -15,7 +15,6 @@ $RCI->load_defaults();
// register these boolean fields
$RCI->bool_config_props = array(
'ip_check' => 1,
- 'enable_caching' => 1,
'enable_spellcheck' => 1,
'auto_create_user' => 1,
'smtp_log' => 1,
@@ -127,16 +126,6 @@ echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)
<p class="hint">This increases security but can cause sudden logouts when someone uses a proxy with changing IPs.</p>
</dd>
-<dt class="propname">enable_caching</dt>
-<dd>
-<?php
-
-$check_caching = new html_checkbox(array('name' => '_enable_caching', 'id' => "cfgcache"));
-echo $check_caching->show(intval($RCI->getprop('enable_caching')), array('value' => 1));
-
-?>
-<label for="cfgcache">Cache messages in local database</label><br />
-</dd>
<dt class="propname">enable_spellcheck</dt>
<dd>
@@ -301,6 +290,18 @@ echo '<label for="cfgdbpass">Database password (omit for sqlite)</label><br />';
?>
</dd>
+
+<dt class="propname">db_prefix</dt>
+<dd>
+<?php
+
+$input_prefix = new html_inputfield(array('name' => '_db_prefix', 'size' => 20, 'id' => "cfgdbprefix"));
+echo $input_prefix->show($RCI->getprop('db_prefix'));
+
+?>
+<div>Optional prefix that will be added to database object names (tables and sequences).</div>
+</dd>
+
</dl>
</fieldset>
diff --git a/installer/rcube_install.php b/installer/rcube_install.php
index 2805dc77e..c95d936d2 100644
--- a/installer/rcube_install.php
+++ b/installer/rcube_install.php
@@ -46,8 +46,7 @@ class rcube_install
// these config options are required for a working system
var $required_config = array(
- 'db_dsnw', 'db_table_contactgroups', 'db_table_contactgroupmembers',
- 'des_key', 'session_lifetime', 'support_url',
+ 'db_dsnw', 'des_key', 'session_lifetime',
);
// list of supported database drivers
@@ -288,7 +287,7 @@ class rcube_install
if ($this->config['log_driver'] == 'syslog') {
if (!function_exists('openlog')) {
$out['dependencies'][] = array('prop' => 'log_driver',
- 'explain' => 'This requires the <tt>sylog</tt> extension which could not be loaded.');
+ 'explain' => 'This requires the <tt>syslog</tt> extension which could not be loaded.');
}
if (empty($this->config['syslog_id'])) {
$out['dependencies'][] = array('prop' => 'syslog_id',
@@ -348,7 +347,7 @@ class rcube_install
$this->config = array_merge($this->config, $current);
- foreach ((array)$current['ldap_public'] as $key => $values) {
+ foreach (array_keys((array)$current['ldap_public']) as $key) {
$this->config['ldap_public'][$key] = $current['ldap_public'][$key];
}
}
@@ -357,10 +356,11 @@ class rcube_install
* Compare the local database schema with the reference schema
* required for this version of Roundcube
*
- * @param boolean True if the schema schould be updated
+ * @param rcube_db Database object
+ *
* @return boolean True if the schema is up-to-date, false if not or an error occured
*/
- function db_schema_check($DB, $update = false)
+ function db_schema_check($DB)
{
if (!$this->configured)
return false;
@@ -373,7 +373,7 @@ class rcube_install
$existing_tables = $DB->list_tables();
foreach ($db_schema as $table => $cols) {
- $table = !empty($this->config['db_table_'.$table]) ? $this->config['db_table_'.$table] : $table;
+ $table = $this->config['db_prefix'] . $table;
if (!in_array($table, $existing_tables)) {
$errors[] = "Missing table '".$table."'";
}
@@ -452,11 +452,12 @@ class rcube_install
'0.2-alpha', '0.2-beta', '0.2-stable',
'0.3-stable', '0.3.1',
'0.4-beta', '0.4.2',
- '0.5-beta', '0.5', '0.5.1',
+ '0.5-beta', '0.5', '0.5.1', '0.5.2', '0.5.3', '0.5.4',
'0.6-beta', '0.6',
- '0.7-beta', '0.7', '0.7.1', '0.7.2', '0.7.3',
- '0.8-beta', '0.8-rc', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4',
- '0.9-beta',
+ '0.7-beta', '0.7', '0.7.1', '0.7.2', '0.7.3', '0.7.4',
+ '0.8-beta', '0.8-rc', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6',
+ '0.9-beta', '0.9-rc', '0.9-rc2',
+ // Note: Do not add newer versions here
));
return $select;
}
@@ -584,7 +585,7 @@ class rcube_install
}
else { // check if all keys are numeric
$isnum = true;
- foreach ($var as $key => $value) {
+ foreach (array_keys($var) as $key) {
if (!is_numeric($key)) {
$isnum = false;
break;
@@ -638,8 +639,10 @@ class rcube_install
*/
function update_db($version)
{
- system(INSTALL_PATH . "bin/updatedb.sh --package=roundcube --version=" . $version
- . " --dir=" . INSTALL_PATH . "SQL", $result);
+ system(INSTALL_PATH . "bin/updatedb.sh --package=roundcube"
+ . " --version=" . escapeshellarg($version)
+ . " --dir=" . INSTALL_PATH . "SQL"
+ . " 2>&1", $result);
return !$result;
}
@@ -654,6 +657,7 @@ class rcube_install
*/
function exec_sql($sql, $DB)
{
+ $sql = $this->fix_table_names($sql, $DB);
$buff = '';
foreach (explode("\n", $sql) as $line) {
if (preg_match('/^--/', $line) || trim($line) == '')
@@ -673,6 +677,35 @@ class rcube_install
/**
+ * Parse SQL file and fix table names according to db_prefix
+ * Note: This need to be a complete database initial file
+ */
+ private function fix_table_names($sql, $DB)
+ {
+ if (empty($this->config['db_prefix'])) {
+ return $sql;
+ }
+
+ // replace table names
+ if (preg_match_all('/CREATE TABLE (\[dbo\]\.|IF NOT EXISTS )?[`"\[\]]*([^`"\[\] \r\n]+)/i', $sql, $matches)) {
+ foreach ($matches[2] as $table) {
+ $real_table = $this->config['db_prefix'] . $table;
+ $sql = preg_replace("/([^a-zA-Z0-9_])$table([^a-zA-Z0-9_])/", "\\1$real_table\\2", $sql);
+ }
+ }
+ // replace sequence names
+ if ($DB->db_provider == 'postgres' && preg_match_all('/CREATE SEQUENCE (IF NOT EXISTS )?"?([^" \n\r]+)/i', $sql, $matches)) {
+ foreach ($matches[2] as $sequence) {
+ $real_sequence = $this->config['db_prefix'] . $sequence;
+ $sql = preg_replace("/([^a-zA-Z0-9_])$sequence([^a-zA-Z0-9_])/", "\\1$real_sequence\\2", $sql);
+ }
+ }
+
+ return $sql;
+ }
+
+
+ /**
* Handler for Roundcube errors
*/
function raise_error($p)
diff --git a/installer/test.php b/installer/test.php
index bd49ac523..fb3e7e937 100644
--- a/installer/test.php
+++ b/installer/test.php
@@ -24,7 +24,7 @@ else if (!$read_main) {
}
echo '<br />';
-if ($read_db && !empty($RCI->config['db_table_users'])) {
+if ($read_db && !empty($RCI->config['db_dsnw'])) {
$RCI->pass('db.inc.php');
}
else if ($read_db) {
@@ -38,13 +38,13 @@ if ($RCI->configured && ($messages = $RCI->check_config())) {
if (is_array($messages['missing'])) {
echo '<h3 class="warning">Missing config options</h3>';
- echo '<p class="hint">The following config options are not present in the current configuration.<br/>';
- echo 'Please check the default config files and add the missing properties to your local config files.</p>';
-
- echo '<ul class="configwarings">';
+ echo '<p class="hint">The following config options are not set (not present or empty) in the current configuration.<br/>';
+ echo 'Please check the default config files and set the missing properties in your local config files.</p>';
+
+ echo '<ul class="configwarnings">';
foreach ($messages['missing'] as $msg) {
echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ':&nbsp;' . $msg['name'] : ''));
- }
+ }
echo '</ul>';
}
@@ -171,7 +171,7 @@ else if ($db_working && $_POST['updatedb']) {
// test database
if ($db_working) {
- $db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}");
+ $db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_prefix']}users");
if ($DB->is_error()) {
$RCI->fail('DB Schema', "Database not initialized");
echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
@@ -195,11 +195,11 @@ if ($db_working) {
if ($db_working) {
// write test
$insert_id = md5(uniqid());
- $db_write = $DB->query("INSERT INTO {$RCI->config['db_table_session']} (sess_id, created, ip, vars) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
+ $db_write = $DB->query("INSERT INTO {$RCI->config['db_prefix']}session (sess_id, created, ip, vars) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
if ($db_write) {
$RCI->pass('DB Write');
- $DB->query("DELETE FROM {$RCI->config['db_table_session']} WHERE sess_id=?", $insert_id);
+ $DB->query("DELETE FROM {$RCI->config['db_prefix']}session WHERE sess_id=?", $insert_id);
}
else {
$RCI->fail('DB Write', $RCI->get_error());