summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc6
-rwxr-xr-xprogram/include/rcube_db.inc69
-rw-r--r--program/include/rcube_imap.inc9
3 files changed, 71 insertions, 13 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 7173917d4..0a63b685b 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -219,7 +219,7 @@ function load_gui()
$javascript = "var $JS_OBJECT_NAME = new rcube_webmail();\n";
$javascript .= "$JS_OBJECT_NAME.set_env('comm_path', '$COMM_PATH');\n";
- if ($_GET['_framed'] || $_POST['_framed'])
+ if (!empty($GLOBALS['_framed']))
$javascript .= "$JS_OBJECT_NAME.set_env('framed', true);\n";
$OUTPUT->add_script($javascript);
@@ -339,7 +339,7 @@ function show_message($message, $type='notice')
{
global $OUTPUT, $JS_OBJECT_NAME, $REMOTE_REQUEST;
- $framed = ($_GET['framed'] || $_POST['_framed']);
+ $framed = $GLOBALS['_framed'];
$command = sprintf("display_message('%s', '%s');",
addslashes(rep_specialchars_output(rcube_label($message))),
$type);
@@ -837,7 +837,7 @@ function rcmail_get_edit_field($col, $value, $attrib, $type='text')
$input = new textfield($attrib);
// use value from post
- if ($_POST[$fname])
+ if (!empty($_POST[$fname]))
$value = $_POST[$fname];
$out = $input->show($value);
diff --git a/program/include/rcube_db.inc b/program/include/rcube_db.inc
index fe838da4c..9c76cb340 100755
--- a/program/include/rcube_db.inc
+++ b/program/include/rcube_db.inc
@@ -51,8 +51,10 @@ class rcube_db
// Connect to specific database
function dsn_connect($dsn)
{
- // Use persistent connections if available
+ $dsn_array = DB::parseDSN($dsn);
+ $this->db_provider = $dsn_array['phptype'];
+ // Use persistent connections if available
$dbh = DB::connect($dsn, array('persistent' => $true));
if (DB::isError($dbh))
@@ -61,6 +63,12 @@ class rcube_db
'line' => __LINE__,
'file' => __FILE__,
'message' => $dbh->getMessage()), TRUE, FALSE);
+ else if ($this->db_provider=='sqlite')
+ {
+ if (!is_file($dsn_array['database']) || !filesize($dsn_array['database']))
+ $this->_sqlite_create_database($dbh, 'SQL/sqlite.initial.sql');
+ }
+
return $dbh;
}
@@ -96,22 +104,23 @@ class rcube_db
function query($query)
{
// Read or write ?
-
if (strtolower(trim(substr($query,0,6)))=='select')
$mode='r';
else
- {
$mode='w';
- }
- $this->db_connect($mode);
-
+ $this->db_connect($mode);
+
+ if ($this->db_provider == 'sqlite')
+ $query = $this->_sqlite_prepare_query($query);
+
$result = $this->db_handle->query($query);
if (DB::isError($result))
- raise_error( array('code' => 500, 'type' => 'db', 'line' => __LINE__,
- 'file' => __FILE__,
- 'message' => $result->getMessage()), TRUE, FALSE);
+ raise_error(array('code' => 500, 'type' => 'db',
+ 'line' => __LINE__,
+ 'file' => __FILE__,
+ 'message' => $result->getMessage()), TRUE, FALSE);
return $this->_add_result($result, $query);
}
@@ -120,6 +129,9 @@ class rcube_db
{
db_connect('w');
+ if ($this->db_provider == 'sqlite')
+ $query = $this->_sqlite_prepare_query($query);
+
$result = $this->db_handle->query($query);
}
@@ -162,7 +174,10 @@ class rcube_db
case 'mysql': // This is unfortuneate
return mysql_insert_id($this->db_handle);
-
+
+ case 'sqlite':
+ return sqlite_last_insert_rowid($this->db_handle->connection);
+
default:
die("portability issue with this database, please have the developer fix");
}
@@ -209,6 +224,40 @@ class rcube_db
return FALSE;
}
+
+ // create a sqlite database from a file
+ function _sqlite_create_database($dbh, $fileName)
+ {
+ if (empty($fileName) || !is_string($fileName))
+ return ;
+
+ $fd = fopen($fileName, 'r');
+ if (!$fd)
+ return ;
+
+ $data = '';
+ while ($line = fgets($fd, 4096))
+ $data .= $line;
+
+ fclose($fd);
+ sqlite_exec($dbh->connection, $data);
+ }
+
+ // transform a query so that it is sqlite2 compliant
+ function _sqlite_prepare_query($query)
+ {
+ if (!is_string($query))
+ return ($query);
+
+ $search = array('/NOW\(\)/',
+ '/`/');
+ $replace = array("datetime('now')",
+ '"');
+ $query = preg_replace($search, $replace, $query);
+
+ return ($query);
+ }
+
}
?> \ No newline at end of file
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index e74321418..127409dc8 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -35,6 +35,7 @@ class rcube_imap
var $mailbox = 'INBOX';
var $list_page = 1;
var $page_size = 10;
+ var $delimiter = NULL;
var $caching_enabled = FALSE;
var $default_folders = array('inbox', 'drafts', 'sent', 'junk', 'trash');
var $cache = array();
@@ -153,6 +154,14 @@ class rcube_imap
}
+ function get_hierarchy_delimiter()
+ {
+ if ($this->conn && empty($this->delimiter))
+ $this->delimiter = iil_C_GetHierarchyDelimiter($this->conn);
+
+ return $this->delimiter;
+ }
+
// public method for mailbox listing
// convert mailbox name with root dir first
function list_mailboxes($root='', $filter='*')