| | |
| | | |
| | | // create new entry in users and identities table |
| | | function rcmail_create_user($user, $host) |
| | | { |
| | | { |
| | | global $DB, $CONFIG, $IMAP; |
| | | |
| | | $user_email = ''; |
| | |
| | | $_SESSION['user_lang']); |
| | | |
| | | if ($user_id = $DB->insert_id(get_sequence_name('users'))) |
| | | { |
| | | { |
| | | $mail_domain = rcmail_mail_domain($host); |
| | | |
| | | if ($user_email=='') |
| | |
| | | |
| | | // try to resolve the e-mail address from the virtuser table |
| | | if (!empty($CONFIG['virtuser_query']) && |
| | | ($sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']))) && |
| | | ($sql_result = $DB->query(preg_replace('/%u/', $DB->quote($user), $CONFIG['virtuser_query']))) && |
| | | ($DB->num_rows()>0)) |
| | | { |
| | | while ($sql_arr = $DB->fetch_array($sql_result)) |
| | | { |
| | | { |
| | | $DB->query("INSERT INTO ".get_table_name('identities')." |
| | | (user_id, del, standard, name, email) |
| | | VALUES (?, 0, 1, ?, ?)", |
| | | $user_id, |
| | | strip_newlines($user_name), |
| | | preg_replace('/^@/', $user . '@', $sql_arr[0])); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | { |
| | | // also create new identity records |
| | | $DB->query("INSERT INTO ".get_table_name('identities')." |
| | | (user_id, del, standard, name, email) |
| | |
| | | $user_id, |
| | | strip_newlines($user_name), |
| | | strip_newlines($user_email)); |
| | | } |
| | | } |
| | | |
| | | // get existing mailboxes |
| | | $a_mailboxes = $IMAP->list_mailboxes(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | raise_error(array('code' => 500, |
| | | 'type' => 'php', |
| | | 'line' => __LINE__, |
| | | 'file' => __FILE__, |
| | | 'message' => "Failed to create new user"), TRUE, FALSE); |
| | | } |
| | | { |
| | | raise_error(array( |
| | | 'code' => 500, |
| | | 'type' => 'php', |
| | | 'line' => __LINE__, |
| | | 'file' => __FILE__, |
| | | 'message' => "Failed to create new user"), TRUE, FALSE); |
| | | } |
| | | |
| | | return $user_id; |
| | | } |
| | | } |
| | | |
| | | |
| | | // load virtuser table in array |
| | |
| | | } |
| | | |
| | | |
| | | // compose a URL to the given action |
| | | function rcmail_self_url($action, $p=array(), $task=null) |
| | | /** |
| | | * Compose an URL for a specific action |
| | | * |
| | | * @param string Request action |
| | | * @param array More URL parameters |
| | | * @param string Request task (omit if the same) |
| | | * @return The application URL |
| | | */ |
| | | function rcmail_url($action, $p=array(), $task=null) |
| | | { |
| | | global $MAIN_TASKS, $COMM_PATH; |
| | | $qstring = ''; |
| | |
| | | function strip_newlines($str) |
| | | { |
| | | return preg_replace('/[\r\n]/', '', $str); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Compose an URL for a specific action |
| | | * |
| | | * @param string Request action |
| | | * @param array More URL parameters |
| | | * @return The application URL |
| | | */ |
| | | function rcmail_url($action, $param=NULL) |
| | | { |
| | | $url = $GLOBALS['COMM_PATH'] . '&'.$action; |
| | | |
| | | if (is_array($param)) |
| | | foreach ($param as $p => $val) |
| | | $url .= sprintf('&%s=%s', urlencode($p), urlencode($val)); |
| | | |
| | | return $url; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | function write_log($name, $line) |
| | | { |
| | | global $CONFIG; |
| | | global $CONFIG, $INSTALL_PATH; |
| | | |
| | | if (!is_string($line)) |
| | | $line = var_export($line, true); |