|
|
@ -413,7 +413,7 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!$this->configured)
|
|
|
|
if (!$this->configured)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
$options = array(
|
|
|
|
$options = array(
|
|
|
|
'use_transactions' => false,
|
|
|
|
'use_transactions' => false,
|
|
|
|
'log_line_break' => "\n",
|
|
|
|
'log_line_break' => "\n",
|
|
|
@ -423,11 +423,11 @@ class rcube_install
|
|
|
|
'force_defaults' => false,
|
|
|
|
'force_defaults' => false,
|
|
|
|
'portability' => true
|
|
|
|
'portability' => true
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$dsnw = $this->config['db_dsnw'];
|
|
|
|
$dsnw = $this->config['db_dsnw'];
|
|
|
|
$schema = MDB2_Schema::factory($dsnw, $options);
|
|
|
|
$schema = MDB2_Schema::factory($dsnw, $options);
|
|
|
|
$schema->db->supported['transactions'] = false;
|
|
|
|
$schema->db->supported['transactions'] = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (PEAR::isError($schema)) {
|
|
|
|
if (PEAR::isError($schema)) {
|
|
|
|
$this->raise_error(array('code' => $schema->getCode(), 'message' => $schema->getMessage() . ' ' . $schema->getUserInfo()));
|
|
|
|
$this->raise_error(array('code' => $schema->getCode(), 'message' => $schema->getMessage() . ' ' . $schema->getUserInfo()));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -435,33 +435,33 @@ class rcube_install
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
$definition = $schema->getDefinitionFromDatabase();
|
|
|
|
$definition = $schema->getDefinitionFromDatabase();
|
|
|
|
$definition['charset'] = 'utf8';
|
|
|
|
$definition['charset'] = 'utf8';
|
|
|
|
|
|
|
|
|
|
|
|
if (PEAR::isError($definition)) {
|
|
|
|
if (PEAR::isError($definition)) {
|
|
|
|
$this->raise_error(array('code' => $definition->getCode(), 'message' => $definition->getMessage() . ' ' . $definition->getUserInfo()));
|
|
|
|
$this->raise_error(array('code' => $definition->getCode(), 'message' => $definition->getMessage() . ' ' . $definition->getUserInfo()));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// load reference schema
|
|
|
|
// load reference schema
|
|
|
|
$dsn_arr = MDB2::parseDSN($this->config['db_dsnw']);
|
|
|
|
$dsn_arr = MDB2::parseDSN($this->config['db_dsnw']);
|
|
|
|
|
|
|
|
|
|
|
|
$ref_schema = INSTALL_PATH . 'SQL/' . $dsn_arr['phptype'] . '.schema.xml';
|
|
|
|
$ref_schema = INSTALL_PATH . 'SQL/' . $dsn_arr['phptype'] . '.schema.xml';
|
|
|
|
|
|
|
|
|
|
|
|
if (is_readable($ref_schema)) {
|
|
|
|
if (is_readable($ref_schema)) {
|
|
|
|
$reference = $schema->parseDatabaseDefinition($ref_schema, false, array(), $schema->options['fail_on_invalid_names']);
|
|
|
|
$reference = $schema->parseDatabaseDefinition($ref_schema, false, array(), $schema->options['fail_on_invalid_names']);
|
|
|
|
|
|
|
|
|
|
|
|
if (PEAR::isError($reference)) {
|
|
|
|
if (PEAR::isError($reference)) {
|
|
|
|
$this->raise_error(array('code' => $reference->getCode(), 'message' => $reference->getMessage() . ' ' . $reference->getUserInfo()));
|
|
|
|
$this->raise_error(array('code' => $reference->getCode(), 'message' => $reference->getMessage() . ' ' . $reference->getUserInfo()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
$diff = $schema->compareDefinitions($reference, $definition);
|
|
|
|
$diff = $schema->compareDefinitions($reference, $definition);
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($diff)) {
|
|
|
|
if (empty($diff)) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($update) {
|
|
|
|
else if ($update) {
|
|
|
|
// update database schema with the diff from the above check
|
|
|
|
// update database schema with the diff from the above check
|
|
|
|
$success = $schema->alterDatabase($reference, $definition, $diff);
|
|
|
|
$success = $schema->alterDatabase($reference, $definition, $diff);
|
|
|
|
|
|
|
|
|
|
|
|
if (PEAR::isError($success)) {
|
|
|
|
if (PEAR::isError($success)) {
|
|
|
|
$this->raise_error(array('code' => $success->getCode(), 'message' => $success->getMessage() . ' ' . $success->getUserInfo()));
|
|
|
|
$this->raise_error(array('code' => $success->getCode(), 'message' => $success->getMessage() . ' ' . $success->getUserInfo()));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -476,11 +476,11 @@ class rcube_install
|
|
|
|
$this->raise_error(array('message' => "Could not find reference schema file ($ref_schema)"));
|
|
|
|
$this->raise_error(array('message' => "Could not find reference schema file ($ref_schema)"));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Getter for the last error message
|
|
|
|
* Getter for the last error message
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -490,8 +490,8 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return $this->last_error['message'];
|
|
|
|
return $this->last_error['message'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return a list with all imap hosts configured
|
|
|
|
* Return a list with all imap hosts configured
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -501,12 +501,12 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$default_hosts = (array)$this->getprop('default_host');
|
|
|
|
$default_hosts = (array)$this->getprop('default_host');
|
|
|
|
$out = array();
|
|
|
|
$out = array();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($default_hosts as $key => $name) {
|
|
|
|
foreach ($default_hosts as $key => $name) {
|
|
|
|
if (!empty($name))
|
|
|
|
if (!empty($name))
|
|
|
|
$out[] = rcube_parse_host(is_numeric($key) ? $name : $key);
|
|
|
|
$out[] = rcube_parse_host(is_numeric($key) ? $name : $key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -524,7 +524,7 @@ class rcube_install
|
|
|
|
'0.5-beta', '0.5', '0.5.1',
|
|
|
|
'0.5-beta', '0.5', '0.5.1',
|
|
|
|
'0.6-beta', '0.6',
|
|
|
|
'0.6-beta', '0.6',
|
|
|
|
'0.7-beta', '0.7', '0.7.1', '0.7.2',
|
|
|
|
'0.7-beta', '0.7', '0.7.1', '0.7.2',
|
|
|
|
'0.8-beta',
|
|
|
|
'0.8-beta', '0.8-rc',
|
|
|
|
));
|
|
|
|
));
|
|
|
|
return $select;
|
|
|
|
return $select;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -543,7 +543,7 @@ class rcube_install
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $skins;
|
|
|
|
return $skins;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Display OK status
|
|
|
|
* Display OK status
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -555,8 +555,8 @@ class rcube_install
|
|
|
|
echo Q($name) . ': <span class="success">OK</span>';
|
|
|
|
echo Q($name) . ': <span class="success">OK</span>';
|
|
|
|
$this->_showhint($message);
|
|
|
|
$this->_showhint($message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Display an error status and increase failure count
|
|
|
|
* Display an error status and increase failure count
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -567,7 +567,7 @@ class rcube_install
|
|
|
|
function fail($name, $message = '', $url = '')
|
|
|
|
function fail($name, $message = '', $url = '')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->failures++;
|
|
|
|
$this->failures++;
|
|
|
|
|
|
|
|
|
|
|
|
echo Q($name) . ': <span class="fail">NOT OK</span>';
|
|
|
|
echo Q($name) . ': <span class="fail">NOT OK</span>';
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -585,8 +585,8 @@ class rcube_install
|
|
|
|
echo Q($name) . ': <span class="na">NOT OK</span>';
|
|
|
|
echo Q($name) . ': <span class="na">NOT OK</span>';
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Display warning status
|
|
|
|
* Display warning status
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -599,24 +599,24 @@ class rcube_install
|
|
|
|
echo Q($name) . ': <span class="na">NOT AVAILABLE</span>';
|
|
|
|
echo Q($name) . ': <span class="na">NOT AVAILABLE</span>';
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
$this->_showhint($message, $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _showhint($message, $url = '')
|
|
|
|
function _showhint($message, $url = '')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$hint = Q($message);
|
|
|
|
$hint = Q($message);
|
|
|
|
|
|
|
|
|
|
|
|
if ($url)
|
|
|
|
if ($url)
|
|
|
|
$hint .= ($hint ? '; ' : '') . 'See <a href="' . Q($url) . '" target="_blank">' . Q($url) . '</a>';
|
|
|
|
$hint .= ($hint ? '; ' : '') . 'See <a href="' . Q($url) . '" target="_blank">' . Q($url) . '</a>';
|
|
|
|
|
|
|
|
|
|
|
|
if ($hint)
|
|
|
|
if ($hint)
|
|
|
|
echo '<span class="indent">(' . $hint . ')</span>';
|
|
|
|
echo '<span class="indent">(' . $hint . ')</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static function _clean_array($arr)
|
|
|
|
static function _clean_array($arr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$out = array();
|
|
|
|
$out = array();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (array_unique($arr) as $k => $val) {
|
|
|
|
foreach (array_unique($arr) as $k => $val) {
|
|
|
|
if (!empty($val)) {
|
|
|
|
if (!empty($val)) {
|
|
|
|
if (is_numeric($k))
|
|
|
|
if (is_numeric($k))
|
|
|
@ -625,11 +625,11 @@ class rcube_install
|
|
|
|
$out[$k] = $val;
|
|
|
|
$out[$k] = $val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static function _dump_var($var, $name=null) {
|
|
|
|
static function _dump_var($var, $name=null) {
|
|
|
|
// special values
|
|
|
|
// special values
|
|
|
|
switch ($name) {
|
|
|
|
switch ($name) {
|
|
|
@ -658,16 +658,16 @@ class rcube_install
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($isnum)
|
|
|
|
if ($isnum)
|
|
|
|
return 'array(' . join(', ', array_map(array('rcube_install', '_dump_var'), $var)) . ')';
|
|
|
|
return 'array(' . join(', ', array_map(array('rcube_install', '_dump_var'), $var)) . ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return var_export($var, true);
|
|
|
|
return var_export($var, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initialize the database with the according schema
|
|
|
|
* Initialize the database with the according schema
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -677,7 +677,7 @@ class rcube_install
|
|
|
|
function init_db($DB)
|
|
|
|
function init_db($DB)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
|
|
|
|
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
|
|
|
|
|
|
|
|
|
|
|
|
// read schema file from /SQL/*
|
|
|
|
// read schema file from /SQL/*
|
|
|
|
$fname = INSTALL_PATH . "SQL/$engine.initial.sql";
|
|
|
|
$fname = INSTALL_PATH . "SQL/$engine.initial.sql";
|
|
|
|
if ($sql = @file_get_contents($fname)) {
|
|
|
|
if ($sql = @file_get_contents($fname)) {
|
|
|
@ -687,7 +687,7 @@ class rcube_install
|
|
|
|
$this->fail('DB Schema', "Cannot read the schema file: $fname");
|
|
|
|
$this->fail('DB Schema', "Cannot read the schema file: $fname");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($err = $this->get_error()) {
|
|
|
|
if ($err = $this->get_error()) {
|
|
|
|
$this->fail('DB Schema', "Error creating database schema: $err");
|
|
|
|
$this->fail('DB Schema', "Error creating database schema: $err");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -695,8 +695,8 @@ class rcube_install
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Update database with SQL statements from SQL/*.update.sql
|
|
|
|
* Update database with SQL statements from SQL/*.update.sql
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -708,7 +708,7 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$version = strtolower($version);
|
|
|
|
$version = strtolower($version);
|
|
|
|
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
|
|
|
|
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
|
|
|
|
|
|
|
|
|
|
|
|
// read schema file from /SQL/*
|
|
|
|
// read schema file from /SQL/*
|
|
|
|
$fname = INSTALL_PATH . "SQL/$engine.update.sql";
|
|
|
|
$fname = INSTALL_PATH . "SQL/$engine.update.sql";
|
|
|
|
if ($lines = @file($fname, FILE_SKIP_EMPTY_LINES)) {
|
|
|
|
if ($lines = @file($fname, FILE_SKIP_EMPTY_LINES)) {
|
|
|
@ -723,7 +723,7 @@ class rcube_install
|
|
|
|
if ($from && !$is_comment)
|
|
|
|
if ($from && !$is_comment)
|
|
|
|
$sql .= $line. "\n";
|
|
|
|
$sql .= $line. "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sql)
|
|
|
|
if ($sql)
|
|
|
|
$this->exec_sql($sql, $DB);
|
|
|
|
$this->exec_sql($sql, $DB);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -731,7 +731,7 @@ class rcube_install
|
|
|
|
$this->fail('DB Schema', "Cannot read the update file: $fname");
|
|
|
|
$this->fail('DB Schema', "Cannot read the update file: $fname");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($err = $this->get_error()) {
|
|
|
|
if ($err = $this->get_error()) {
|
|
|
|
$this->fail('DB Schema', "Error updating database: $err");
|
|
|
|
$this->fail('DB Schema', "Error updating database: $err");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -739,8 +739,8 @@ class rcube_install
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Execute the given SQL queries on the database connection
|
|
|
|
* Execute the given SQL queries on the database connection
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -754,7 +754,7 @@ class rcube_install
|
|
|
|
foreach (explode("\n", $sql) as $line) {
|
|
|
|
foreach (explode("\n", $sql) as $line) {
|
|
|
|
if (preg_match('/^--/', $line) || trim($line) == '')
|
|
|
|
if (preg_match('/^--/', $line) || trim($line) == '')
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
$buff .= $line . "\n";
|
|
|
|
$buff .= $line . "\n";
|
|
|
|
if (preg_match('/(;|^GO)$/', trim($line))) {
|
|
|
|
if (preg_match('/(;|^GO)$/', trim($line))) {
|
|
|
|
$DB->query($buff);
|
|
|
|
$DB->query($buff);
|
|
|
@ -763,11 +763,11 @@ class rcube_install
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return !$DB->is_error();
|
|
|
|
return !$DB->is_error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Handler for Roundcube errors
|
|
|
|
* Handler for Roundcube errors
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -775,8 +775,8 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->last_error = $p;
|
|
|
|
$this->last_error = $p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Generarte a ramdom string to be used as encryption key
|
|
|
|
* Generarte a ramdom string to be used as encryption key
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -788,12 +788,12 @@ class rcube_install
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$alpha = 'ABCDEFGHIJKLMNOPQERSTUVXYZabcdefghijklmnopqrtsuvwxyz0123456789+*%&?!$-_=';
|
|
|
|
$alpha = 'ABCDEFGHIJKLMNOPQERSTUVXYZabcdefghijklmnopqrtsuvwxyz0123456789+*%&?!$-_=';
|
|
|
|
$out = '';
|
|
|
|
$out = '';
|
|
|
|
|
|
|
|
|
|
|
|
for ($i=0; $i < $length; $i++)
|
|
|
|
for ($i=0; $i < $length; $i++)
|
|
|
|
$out .= $alpha{rand(0, strlen($alpha)-1)};
|
|
|
|
$out .= $alpha{rand(0, strlen($alpha)-1)};
|
|
|
|
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|