| | |
| | | | | |
| | | | This file is part of the RoundCube Webmail client | |
| | | | Copyright (C) 2005, RoundCube Dev, - Switzerland | |
| | | | All rights reserved. | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | PURPOSE: | |
| | | | Provide basic functions for the webmail package | |
| | |
| | | |
| | | |
| | | // prepare DB connection |
| | | if (strtolower($CONFIG['db_type'])=='mysql') |
| | | $DB = new rcube_mysql($CONFIG['db_name'], $CONFIG['db_user'], $CONFIG['db_pass'], $CONFIG['db_host']); |
| | | |
| | | // database not supported |
| | | else |
| | | { |
| | | raise_error(array('code' => 500, |
| | | 'type' => 'php', |
| | | 'line' => __LINE__, |
| | | 'file' => __FILE__, |
| | | 'message' => "Database not supported"), TRUE, TRUE); |
| | | return; |
| | | } |
| | | |
| | | $DB = new rcube_db($CONFIG['db_dsnw'], $CONFIG['db_dsnr']); |
| | | |
| | | // we can use the database for storing session data |
| | | if (is_object($DB) && $DB->connect()) |
| | | if (is_object($DB)) |
| | | include_once('include/session.inc'); |
| | | |
| | | |
| | |
| | | function rcmail_imap_init($connect=FALSE) |
| | | { |
| | | global $CONFIG, $IMAP; |
| | | |
| | | |
| | | $IMAP = new rcube_imap(); |
| | | |
| | | // enable caching of imap data |
| | | if ($CONFIG['enable_caching']===TRUE) |
| | | $IMAP->set_caching(TRUE); |
| | | |
| | | // set root dir from config |
| | | if (strlen($CONFIG['imap_root'])) |
| | |
| | | |
| | | if ($user_id = $DB->insert_id()) |
| | | { |
| | | $user_email = strstr($user, '@') ? $user : sprintf('%s@%s', $user, $host); |
| | | $user_name = $user!=$user_email ? $user : ''; |
| | | |
| | | // also create a new identity record |
| | | $DB->query(sprintf("INSERT INTO %s |
| | | (user_id, `default`, name, email) |
| | | VALUES (%d, '1', '%s', '%s@%s')", |
| | | VALUES (%d, '1', '%s', '%s')", |
| | | get_table_name('identities'), |
| | | $user_id, |
| | | $user, |
| | | $user, |
| | | $host)); |
| | | $user_name, |
| | | $user_email)); |
| | | |
| | | // get existing mailboxes |
| | | $a_mailboxes = $IMAP->list_mailboxes(); |
| | |
| | | $week_secs = 60 * 60 * 24 * 7; |
| | | $diff = $now - $timestamp; |
| | | |
| | | // define daate format depending on current time |
| | | if (!$format && $diff < $day_secs) |
| | | // define date format depending on current time |
| | | if ($CONFIG['prettydate'] && !$format && $diff < $day_secs) |
| | | return sprintf('%s %s', rcube_label('today'), date('H:i', $timestamp)); |
| | | else if (!$format && $diff < $week_secs) |
| | | else if ($CONFIG['prettydate'] && !$format && $diff < $week_secs) |
| | | $format = $CONFIG['date_short'] ? $CONFIG['date_short'] : 'D H:i'; |
| | | else if (!$format) |
| | | $format = $CONFIG['date_long'] ? $CONFIG['date_long'] : 'd.m.Y H:i'; |