示例#1
0
 function save_prefs($args)
 {
     if ($args['section'] == 'mailview') {
         $args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST);
     }
     return $args;
 }
 /**
  * Handler for submitted form (ajax request)
  *
  * Check fields and save to default identity if valid.
  * Afterwards the session flag is removed and we're done.
  */
 function save_data()
 {
     $rcmail = rcmail::get_instance();
     $identity = $rcmail->user->get_identity();
     $ident_level = intval($rcmail->config->get('identities_level', 0));
     $disabled = array();
     $save_data = array('name' => rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST), 'email' => rcube_utils::get_input_value('_email', rcube_utils::INPUT_POST), 'organization' => rcube_utils::get_input_value('_organization', rcube_utils::INPUT_POST), 'signature' => rcube_utils::get_input_value('_signature', rcube_utils::INPUT_POST));
     if ($ident_level == 4) {
         $disabled = array('name', 'email', 'organization');
     } else {
         if (in_array($ident_level, array(1, 3))) {
             $disabled = array('email');
         }
     }
     foreach ($disabled as $key) {
         $save_data[$key] = $identity[$key];
     }
     if (empty($save_data['name']) || empty($save_data['email'])) {
         $rcmail->output->show_message('formincomplete', 'error');
     } else {
         if (!rcube_utils::check_email($save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']))) {
             $rcmail->output->show_message('emailformaterror', 'error', array('email' => $save_data['email']));
         } else {
             // save data
             $rcmail->user->update_identity($identity['identity_id'], $save_data);
             $rcmail->session->remove('plugin.newuserdialog');
             // hide dialog
             $rcmail->output->command('new_user_dialog_close');
             $rcmail->output->show_message('successfullysaved', 'confirmation');
         }
     }
     $rcmail->output->send();
 }
示例#3
0
 public function ham(&$uids)
 {
     $rcmail = rcube::get_instance();
     $storage = $rcmail->storage;
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $new_uids = array();
     foreach (explode(",", $uids) as $uid) {
         $saved = false;
         $message = new rcube_message($uid);
         if (sizeof($message->attachments) > 0) {
             foreach ($message->attachments as $part) {
                 if ($part->ctype_primary == 'message' && $part->ctype_secondary == 'rfc822') {
                     $orig_message_raw = $storage->get_message_part($message->uid, $part->mime_id, $part);
                     $saved = $storage->save_message($mbox, $orig_message_raw);
                     if ($saved !== false) {
                         $rcmail->output->command('rcmail_markasjunk2_move', null, $uid);
                         array_push($new_uids, $saved);
                     }
                 }
             }
         }
     }
     if (sizeof($new_uids) > 0) {
         $uids = implode(',', $new_uids);
     }
 }
 function authenticate($args)
 {
     if (isset($_POST['_user']) && isset($_POST['_pass'])) {
         $args['host'] = $this->getHost(rcube_utils::get_input_value('_user', RCUBE_INPUT_POST));
     }
     return $args;
 }
示例#5
0
 function save_settings($args)
 {
     if ($args['section'] == 'mailbox') {
         $args['prefs']['preview_pane'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) == 'none' ? false : true;
         $args['prefs']['previewpane_layout'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) != 'none' ? rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) : rcube::get_instance()->config->get('previewpane_layout', 'below');
     }
     return $args;
 }
 public function messagecount()
 {
     $storage = rcube::get_instance()->storage;
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     // send output
     header("Content-Type: application/json; charset=" . RCUBE_CHARSET);
     echo json_encode(array('messagecount' => $storage->count($mbox, 'EXISTS')));
     exit;
 }
 function mark_notjunk()
 {
     $this->add_texts('localization');
     $this->_set_flags();
     $uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     if ($this->_ham($uids, $mbox, $this->ham_mbox)) {
         $this->api->output->command('display_message', $this->gettext('reportedasnotjunk'), 'confirmation');
     }
     $this->api->output->send();
 }
示例#8
0
 function request_action()
 {
     $this->add_texts('localization');
     $uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $rcmail = rcmail::get_instance();
     $storage = $rcmail->get_storage();
     $storage->unset_flag($uids, 'NONJUNK');
     $storage->set_flag($uids, 'JUNK');
     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
         $rcmail->output->command('move_messages', $junk_mbox);
     }
     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
     $rcmail->output->send();
 }
示例#9
0
 public function readfolder()
 {
     $storage = rcube::get_instance()->storage;
     $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $oact = rcube_utils::get_input_value('_oact', rcube_utils::INPUT_POST);
     $uids = $storage->search_once($mbox, 'ALL UNSEEN', true);
     if ($uids->is_empty()) {
         return false;
     }
     $storage->set_flag($uids->get(), 'SEEN', $mbox);
     if ($cbox == $mbox) {
         $this->api->output->command('toggle_read_status', 'read', $uids->get());
     }
     rcmail_send_unread_count($mbox, true);
     $this->api->output->send();
 }
示例#10
0
 function mark_message()
 {
     $this->add_texts('localization');
     $is_spam = rcube::get_instance()->action == 'plugin.markasjunk2.junk' ? true : false;
     $multi_folder = $_POST['_multifolder'] == 'true' ? true : false;
     $messageset = rcmail::get_uids();
     $mbox_name = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $dest_mbox = $is_spam ? $this->spam_mbox : $this->ham_mbox;
     $result = $is_spam ? $this->_spam($messageset, $dest_mbox) : $this->_ham($messageset, $dest_mbox);
     if ($result) {
         if ($dest_mbox && ($mbox_name !== $dest_mbox || $multi_folder)) {
             $this->api->output->command('rcmail_markasjunk2_move', $dest_mbox, $this->_messageset_to_uids($messageset, $multi_folder));
         } else {
             $this->api->output->command('command', 'list', $mbox_name);
         }
         $this->api->output->command('display_message', $is_spam ? $this->gettext('reportedasjunk') : $this->gettext('reportedasnotjunk'), 'confirmation');
     }
     $this->api->output->send();
 }
 function save()
 {
     $enabled = rcube_utils::get_input_value('_autoreplyenabled', RCUBE_INPUT_POST);
     $body = rcube_utils::get_input_value('_autoreplybody', RCUBE_INPUT_POST);
     $subject = rcube_utils::get_input_value('_autoreplysubject', RCUBE_INPUT_POST);
     $startdate = rcube_utils::get_input_value('_autoreplystarton', RCUBE_INPUT_POST);
     $enddate = rcube_utils::get_input_value('_autoreplyendby', RCUBE_INPUT_POST);
     $server_tz = new DateTimeZone(date_default_timezone_get());
     $server_offset = $server_tz->getOffset(new DateTime());
     $user_tz = new DateTimeZone($this->rcmail_inst->config->get('timezone'));
     $user_offset = $user_tz->getOffset(new DateTime());
     $startdate = strtotime($startdate) - ($user_offset - $server_offset);
     $enddate = strtotime($enddate) - ($user_offset - $server_offset);
     if ($enddate < $startdate) {
         $enddate = $startdate + 86400;
     }
     $startdate = array('year' => date("Y", $startdate), 'month' => date("m", $startdate), 'day' => date("d", $startdate), 'hour' => date("H", $startdate), 'minute' => date("i", $startdate));
     $enddate = array('year' => date("Y", $enddate), 'month' => date("m", $enddate), 'day' => date("d", $enddate), 'hour' => date("H", $enddate), 'minute' => date("i", $enddate));
     if (!$enabled) {
         $enabled = 'n';
     } else {
         $enabled = 'y';
     }
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
         $params = $mail_user[0];
         unset($params['password']);
         $params['autoresponder'] = $enabled;
         $params['autoresponder_text'] = $body;
         $params['autoresponder_subject'] = $subject;
         $params['autoresponder_start_date'] = $startdate;
         $params['autoresponder_end_date'] = $enddate;
         $update = $this->soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
         $this->soap->logout($session_id);
         $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
示例#12
0
 /**
  * Plugin initialization.
  */
 function init()
 {
     $rcmail = rcmail::get_instance();
     $this->rc = $rcmail;
     $section = rcube_utils::get_input_value('_section', rcube_utils::INPUT_GET);
     if ($this->rc->task == 'mail') {
         // message parse/display hooks
         $this->add_hook('message_part_structure', array($this, 'parse_structure'));
         $this->add_hook('message_body_prefix', array($this, 'status_message'));
         // message displaying
         if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
             $this->add_hook('message_load', array($this, 'message_load'));
             $this->add_hook('template_object_messagebody', array($this, 'message_output'));
             $this->register_action('plugin.enigmaimport', array($this, 'import_file'));
         } else {
             if ($rcmail->action == 'compose') {
                 $this->load_ui();
                 $this->ui->init($section);
             } else {
                 if ($rcmail->action == 'sendmail') {
                     //$this->add_hook('outgoing_message_body', array($this, 'msg_encode'));
                     //$this->add_hook('outgoing_message_body', array($this, 'msg_sign'));
                 }
             }
         }
     } else {
         if ($this->rc->task == 'settings') {
             // add hooks for Enigma settings
             $this->add_hook('preferences_sections_list', array($this, 'preferences_section'));
             $this->add_hook('preferences_list', array($this, 'preferences_list'));
             $this->add_hook('preferences_save', array($this, 'preferences_save'));
             // register handler for keys/certs management
             $this->register_action('plugin.enigma', array($this, 'preferences_ui'));
             // grab keys/certs management iframe requests
             if ($this->rc->action == 'edit-prefs' && preg_match('/^enigma(certs|keys)/', $section)) {
                 $this->load_ui();
                 $this->ui->init($section);
             }
         }
     }
 }
示例#13
0
 private function _edit_headers(&$uids, $spam)
 {
     $rcmail = rcube::get_instance();
     $args = $spam ? $rcmail->config->get('markasjunk2_spam_patterns') : $rcmail->config->get('markasjunk2_ham_patterns');
     if (sizeof($args['patterns']) == 0) {
         return;
     }
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $new_uids = array();
     foreach (explode(",", $uids) as $uid) {
         $raw_message = $rcmail->storage->get_raw_body($uid);
         $raw_headers = $rcmail->storage->get_raw_headers($uid);
         $updated_headers = preg_replace($args['patterns'], $args['replacements'], $raw_headers);
         $raw_message = str_replace($raw_headers, $updated_headers, $raw_message);
         $saved = $rcmail->storage->save_message($mbox, $raw_message);
         if ($saved !== false) {
             $rcmail->output->command('rcmail_markasjunk2_move', null, $uid);
             array_push($new_uids, $saved);
         }
     }
     if (sizeof($new_uids) > 0) {
         $uids = implode(',', $new_uids);
     }
 }
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // Disable autocapitalization on iPad/iPhone (#1488609)
     $attrib['autocapitalize'] = 'off';
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'required' => 'required') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'required' => 'required') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = key($default_host)) !== null) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => is_numeric($host) ? $default_host[$host] : $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show('mail@box'));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     if (rcube_utils::get_boolean($attrib['submit'])) {
         $submit = new html_inputfield(array('type' => 'submit', 'id' => 'rcmloginsubmit', 'class' => 'button mainaction', 'value' => $this->app->gettext('login')));
         $out .= html::p('formbuttons', $submit->show());
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     // include script for timezone detection
     $this->include_script('jstz.min.js');
     return $out;
 }
示例#15
0
 /**
  * Registers password for specified key/cert sent by the password prompt.
  */
 function password_handler()
 {
     $keyid = rcube_utils::get_input_value('_keyid', rcube_utils::INPUT_POST);
     $passwd = rcube_utils::get_input_value('_passwd', rcube_utils::INPUT_POST, true);
     if ($keyid && $passwd !== null && strlen($passwd)) {
         $this->save_password($keyid, $passwd);
     }
 }
示例#16
0
$incstep = null;
while ($redirects < 5) {
    // execute a plugin action
    if ($RCMAIL->plugins->is_plugin_task($RCMAIL->task)) {
        if (!$RCMAIL->action) {
            $RCMAIL->action = 'index';
        }
        $RCMAIL->plugins->exec_action($RCMAIL->task . '.' . $RCMAIL->action);
        break;
    } else {
        if (preg_match('/^plugin\\./', $RCMAIL->action)) {
            $RCMAIL->plugins->exec_action($RCMAIL->action);
            break;
        } else {
            if (($stepfile = $RCMAIL->get_action_file()) && is_file($incfile = INSTALL_PATH . 'program/steps/' . $RCMAIL->task . '/' . $stepfile)) {
                // include action file only once (in case it don't exit)
                include_once $incfile;
                $redirects++;
            } else {
                break;
            }
        }
    }
}
if ($RCMAIL->action == 'refresh') {
    $RCMAIL->plugins->exec_hook('refresh', array('last' => intval(rcube_utils::get_input_value('_last', rcube_utils::INPUT_GPC))));
}
// parse main template (default)
$OUTPUT->send($RCMAIL->task);
// if we arrive here, something went wrong
rcmail::raise_error(array('code' => 404, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Invalid request"), true, true);
示例#17
0
 /**
  * File upload progress handler.
  */
 public function upload_progress()
 {
     $prefix = ini_get('apc.rfc1867_prefix');
     $params = array('action' => $this->action, 'name' => rcube_utils::get_input_value('_progress', rcube_utils::INPUT_GET));
     if (function_exists('apc_fetch')) {
         $status = apc_fetch($prefix . $params['name']);
         if (!empty($status)) {
             $status['percent'] = round($status['current'] / $status['total'] * 100);
             $params = array_merge($status, $params);
         }
     }
     if (isset($params['percent'])) {
         $params['text'] = $this->gettext(array('name' => 'uploadprogress', 'vars' => array('percent' => $params['percent'] . '%', 'current' => $this->show_bytes($params['current']), 'total' => $this->show_bytes($params['total']))));
     }
     $this->output->command('upload_progress_update', $params);
     $this->output->send();
 }
示例#18
0
 /**
  * Plugin action handler
  */
 function managesieve_actions()
 {
     // handle fetching email headers for the new filter form
     if ($uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST)) {
         $uids = rcmail::get_uids();
         $mailbox = key($uids);
         $message = new rcube_message($uids[$mailbox][0], $mailbox);
         $headers = $this->parse_headers($message->headers);
         $this->rc->output->set_env('sieve_headers', $headers);
         $this->rc->output->command('managesieve_create', true);
         $this->rc->output->send();
     }
     // handle other actions
     $engine_type = $this->rc->action == 'plugin.managesieve-vacation' ? 'vacation' : '';
     $engine = $this->get_engine($engine_type);
     $this->init_ui();
     $engine->actions();
 }
示例#19
0
 /**
  * Handler for attendee group expansion requests
  */
 public function expand_attendee_group()
 {
     $id = rcube_utils::get_input_value('id', rcube_utils::INPUT_POST);
     $data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true);
     $result = array('id' => $id, 'members' => array());
     $maxnum = 500;
     // iterate over all autocomplete address books (we don't know the source of the group)
     foreach ((array) $this->rc->config->get('autocomplete_addressbooks', 'sql') as $abook_id) {
         if (($abook = $this->rc->get_address_book($abook_id)) && $abook->groups) {
             foreach ($abook->list_groups($data['name'], 1) as $group) {
                 // this is the matching group to expand
                 if (in_array($data['email'], (array) $group['email'])) {
                     $abook->set_pagesize($maxnum);
                     $abook->set_group($group['ID']);
                     // get all members
                     $res = $abook->list_records($this->rc->config->get('contactlist_fields'));
                     // handle errors (e.g. sizelimit, timelimit)
                     if ($abook->get_error()) {
                         $result['error'] = $this->rc->gettext('expandattendeegrouperror', 'libcalendaring');
                         $res = false;
                     } else {
                         if ($res->count > $maxnum) {
                             $result['error'] = $this->rc->gettext('expandattendeegroupsizelimit', 'libcalendaring');
                             $res = false;
                         }
                     }
                     while ($res && ($member = $res->iterate())) {
                         $emails = (array) $abook->get_col_values('email', $member, true);
                         if (!empty($emails) && ($email = array_shift($emails))) {
                             $result['members'][] = array('email' => $email, 'name' => rcube_addressbook::compose_list_name($member));
                         }
                     }
                     break 2;
                 }
             }
         }
     }
     $this->rc->output->command('plugin.expand_attendee_callback', $result);
 }
示例#20
0
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_dst = new html_hiddenfield(array('name' => '_dstactive', 'id' => 'rcmlogindst', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = array_pop($default_host))) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC)));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_dst->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     return $out;
 }
 function filter_form($attrib)
 {
     if (!$attrib['id']) {
         $attrib['id'] = 'rcmfilterform';
     }
     $fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC);
     $scr = isset($this->form) ? $this->form : $this->script[$fid];
     $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $this->rc->task));
     $hiddenfields->add(array('name' => '_action', 'value' => 'plugin.managesieve-save'));
     $hiddenfields->add(array('name' => '_framed', 'value' => $_POST['_framed'] || $_GET['_framed'] ? 1 : 0));
     $hiddenfields->add(array('name' => '_fid', 'value' => $fid));
     $out = '<form name="filterform" action="./" method="post">' . "\n";
     $out .= $hiddenfields->show();
     // 'any' flag
     if (sizeof($scr['tests']) == 1 && $scr['tests'][0]['test'] == 'true' && !$scr['tests'][0]['not']) {
         $any = true;
     }
     // filter name input
     $field_id = '_name';
     $input_name = new html_inputfield(array('name' => '_name', 'id' => $field_id, 'size' => 30, 'class' => $this->errors['name'] ? 'error' : ''));
     if ($this->errors['name']) {
         $this->add_tip($field_id, $this->errors['name'], true);
     }
     if (isset($scr)) {
         $input_name = $input_name->show($scr['name']);
     } else {
         $input_name = $input_name->show();
     }
     $out .= sprintf("\n<label for=\"%s\"><b>%s:</b></label> %s\n", $field_id, rcube::Q($this->plugin->gettext('filtername')), $input_name);
     // filter set selector
     if ($this->rc->task == 'mail') {
         $out .= sprintf("\n&nbsp;<label for=\"%s\"><b>%s:</b></label> %s\n", $field_id, rcube::Q($this->plugin->gettext('filterset')), $this->filtersets_list(array('id' => 'sievescriptname'), true));
     }
     $out .= '<br /><br /><fieldset><legend>' . rcube::Q($this->plugin->gettext('messagesrules')) . "</legend>\n";
     // any, allof, anyof radio buttons
     $field_id = '_allof';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'allof', 'onclick' => 'rule_join_radio(\'allof\')', 'class' => 'radio'));
     if (isset($scr) && !$any) {
         $input_join = $input_join->show($scr['join'] ? 'allof' : '');
     } else {
         $input_join = $input_join->show();
     }
     $out .= sprintf("%s<label for=\"%s\">%s</label>&nbsp;\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filterallof')));
     $field_id = '_anyof';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'anyof', 'onclick' => 'rule_join_radio(\'anyof\')', 'class' => 'radio'));
     if (isset($scr) && !$any) {
         $input_join = $input_join->show($scr['join'] ? '' : 'anyof');
     } else {
         $input_join = $input_join->show('anyof');
     }
     // default
     $out .= sprintf("%s<label for=\"%s\">%s</label>\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filteranyof')));
     $field_id = '_any';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'any', 'onclick' => 'rule_join_radio(\'any\')', 'class' => 'radio'));
     $input_join = $input_join->show($any ? 'any' : '');
     $out .= sprintf("%s<label for=\"%s\">%s</label>\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filterany')));
     $rows_num = isset($scr) ? sizeof($scr['tests']) : 1;
     $out .= '<div id="rules"' . ($any ? ' style="display: none"' : '') . '>';
     for ($x = 0; $x < $rows_num; $x++) {
         $out .= $this->rule_div($fid, $x);
     }
     $out .= "</div>\n";
     $out .= "</fieldset>\n";
     // actions
     $out .= '<fieldset><legend>' . rcube::Q($this->plugin->gettext('messagesactions')) . "</legend>\n";
     $rows_num = isset($scr) ? sizeof($scr['actions']) : 1;
     $out .= '<div id="actions">';
     for ($x = 0; $x < $rows_num; $x++) {
         $out .= $this->action_div($fid, $x);
     }
     $out .= "</div>\n";
     $out .= "</fieldset>\n";
     $this->print_tips();
     if ($scr['disabled']) {
         $this->rc->output->set_env('rule_disabled', true);
     }
     $this->rc->output->add_label('managesieve.ruledeleteconfirm', 'managesieve.actiondeleteconfirm');
     $this->rc->output->add_gui_object('sieveform', 'filterform');
     return $out;
 }
示例#22
0
 /**
  * Read email message and return contents for a new event based on that message
  */
 public function mail_message2event()
 {
     $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $event = array();
     // establish imap connection
     $imap = $this->rc->get_storage();
     $imap->set_mailbox($mbox);
     $message = new rcube_message($uid);
     if ($message->headers) {
         $event['title'] = trim($message->subject);
         $event['description'] = trim($message->first_text_part());
         $this->load_driver();
         // add a reference to the email message
         if ($msgref = $this->driver->get_message_reference($message->headers, $mbox)) {
             $event['links'] = array($msgref);
         } else {
             if ($message->attachments) {
                 $eventid = 'cal-';
                 if (!is_array($_SESSION[self::SESSION_KEY]) || $_SESSION[self::SESSION_KEY]['id'] != $eventid) {
                     $_SESSION[self::SESSION_KEY] = array();
                     $_SESSION[self::SESSION_KEY]['id'] = $eventid;
                     $_SESSION[self::SESSION_KEY]['attachments'] = array();
                 }
                 foreach ((array) $message->attachments as $part) {
                     $attachment = array('data' => $imap->get_message_part($uid, $part->mime_id, $part), 'size' => $part->size, 'name' => $part->filename, 'mimetype' => $part->mimetype, 'group' => $eventid);
                     $attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
                     if ($attachment['status'] && !$attachment['abort']) {
                         $id = $attachment['id'];
                         $attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
                         // store new attachment in session
                         unset($attachment['status'], $attachment['abort'], $attachment['data']);
                         $_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment;
                         $attachment['id'] = 'rcmfile' . $attachment['id'];
                         // add prefix to consider it 'new'
                         $event['attachments'][] = $attachment;
                     }
                 }
             }
         }
         $this->rc->output->command('plugin.mail2event_dialog', $event);
     } else {
         $this->rc->output->command('display_message', $this->gettext('messageopenerror'), 'error');
     }
     $this->rc->output->send();
 }
 function prefs_save($args)
 {
     if ($args['section'] == 'mailbox') {
         $args['prefs']['html5_notifier_only_new'] = !empty($_POST['_html5_notifier_only_new']);
         $args['prefs']['html5_notifier_duration'] = rcube_utils::get_input_value('_html5_notifier_duration', rcube_utils::INPUT_POST);
         $args['prefs']['html5_notifier_smbox'] = rcube_utils::get_input_value('_html5_notifier_smbox', rcube_utils::INPUT_POST);
         $args['prefs']['html5_notifier_excluded_directories'] = rcube_utils::get_input_value('_html5_notifier_excluded_directories', rcube_utils::INPUT_POST);
         $args['prefs']['html5_notifier_popuptype'] = rcube_utils::get_input_value('_html5_notifier_popuptype', rcube_utils::INPUT_POST);
         return $args;
     }
 }
示例#24
0
文件: acl.php 项目: BIGGANI/zpanelx
 /**
  * Handler for ACL list update action (with display mode change)
  */
 private function action_list()
 {
     if (in_array('acl_advanced_mode', (array) $this->rc->config->get('dont_override'))) {
         return;
     }
     $this->mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true));
     // UTF7-IMAP
     $advanced = trim(rcube_utils::get_input_value('_mode', rcube_utils::INPUT_GPC));
     $advanced = $advanced == 'advanced' ? true : false;
     // Save state in user preferences
     $this->rc->user->save_prefs(array('acl_advanced_mode' => $advanced));
     $out = $this->list_rights();
     $out = preg_replace(array('/^<table[^>]+>/', '/<\\/table>$/'), '', $out);
     $this->rc->output->command('acl_list_update', $out);
 }
 function save()
 {
     $confirm = $this->rcmail_inst->config->get('password_confirm_current');
     if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) {
         $this->rcmail_inst->output->command('display_message', $this->gettext('nopassword'), 'error');
     } else {
         $curpwd = rcube_utils::get_input_value('_curpasswd', RCUBE_INPUT_POST);
         $newpwd = rcube_utils::get_input_value('_newpasswd', RCUBE_INPUT_POST);
         $pwl = $this->rcmail_inst->config->get('password_min_length');
         $checkUpper = $this->rcmail_inst->config->get('password_check_upper');
         $checkLower = $this->rcmail_inst->config->get('password_check_lower');
         $checkSymbol = $this->rcmail_inst->config->get('password_check_symbol');
         $checkNumber = $this->rcmail_inst->config->get('password_check_number');
         $error = false;
         if (!empty($pwl)) {
             $pwl = max(6, $pwl);
         } else {
             $pwl = 6;
         }
         if ($confirm && $this->rcmail_inst->decrypt($_SESSION['password']) != $curpwd) {
             $this->rcmail_inst->output->command('display_message', $this->gettext('passwordincorrect'), 'error');
         } else {
             if (strlen($newpwd) < $pwl) {
                 $error = true;
                 $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwl, $this->gettext('passwordminlength')), 'error');
             }
             if (!$error && $checkNumber && !preg_match("#[0-9]+#", $newpwd)) {
                 $error = true;
                 $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecknumber'), 'error');
             }
             if (!$error && $checkLower && !preg_match("#[a-z]+#", $newpwd)) {
                 $error = true;
                 $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecklower'), 'error');
             }
             if (!$error && $checkUpper && !preg_match("#[A-Z]+#", $newpwd)) {
                 $error = true;
                 $this->rcmail_inst->output->command('display_message', $this->gettext('passwordcheckupper'), 'error');
             }
             if (!$error && $checkSymbol && !preg_match("#\\W+#", $newpwd)) {
                 $error = true;
                 $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecksymbol'), 'error');
             }
             if (!$error) {
                 try {
                     $soap = new SoapClient(null, array('location' => $this->rcmail_inst->config->get('soap_url') . 'index.php', 'uri' => $this->rcmail_inst->config->get('soap_url')));
                     $session_id = $soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
                     $mail_user = $soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
                     $params = $mail_user[0];
                     $startdate = array('year' => substr($params['autoresponder_start_date'], 0, 4), 'month' => substr($params['autoresponder_start_date'], 5, 2), 'day' => substr($params['autoresponder_start_date'], 8, 2), 'hour' => substr($params['autoresponder_start_date'], 11, 2), 'minute' => substr($params['autoresponder_start_date'], 14, 2));
                     $enddate = array('year' => substr($params['autoresponder_end_date'], 0, 4), 'month' => substr($params['autoresponder_end_date'], 5, 2), 'day' => substr($params['autoresponder_end_date'], 8, 2), 'hour' => substr($params['autoresponder_end_date'], 11, 2), 'minute' => substr($params['autoresponder_end_date'], 14, 2));
                     $params['password'] = $newpwd;
                     $params['autoresponder_end_date'] = $enddate;
                     $params['autoresponder_start_date'] = $startdate;
                     $uid = $soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
                     $update = $soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
                     $soap->logout($session_id);
                     $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                     $_SESSION['password'] = $this->rcmail_inst->encrypt($newpwd);
                     $this->rcmail_inst->user->data['password'] = $_SESSION['password'];
                 } catch (SoapFault $e) {
                     $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
                 }
             }
         }
     }
     $this->init_html();
 }
示例#26
0
 /**
  * Returns message UID(s) and IMAP folder(s) from GET/POST data
  *
  * @param string UID value to decode
  * @param string Default mailbox value (if not encoded in UIDs)
  * @param bool   Will be set to True if multi-folder request
  *
  * @return array  List of message UIDs per folder
  */
 public static function get_uids($uids = null, $mbox = null, &$is_multifolder = false)
 {
     // message UID (or comma-separated list of IDs) is provided in
     // the form of <ID>-<MBOX>[,<ID>-<MBOX>]*
     $_uid = $uids ?: rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GPC);
     $_mbox = $mbox ?: (string) rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC);
     // already a hash array
     if (is_array($_uid) && !isset($_uid[0])) {
         return $_uid;
     }
     $result = array();
     // special case: *
     if ($_uid == '*' && is_object($_SESSION['search'][1]) && $_SESSION['search'][1]->multi) {
         $is_multifolder = true;
         // extract the full list of UIDs per folder from the search set
         foreach ($_SESSION['search'][1]->sets as $subset) {
             $mbox = $subset->get_parameters('MAILBOX');
             $result[$mbox] = $subset->get();
         }
     } else {
         if (is_string($_uid)) {
             $_uid = explode(',', $_uid);
         }
         // create a per-folder UIDs array
         foreach ((array) $_uid as $uid) {
             list($uid, $mbox) = explode('-', $uid, 2);
             if (!strlen($mbox)) {
                 $mbox = $_mbox;
             } else {
                 $is_multifolder = true;
             }
             if ($uid == '*') {
                 $result[$mbox] = $uid;
             } else {
                 $result[$mbox][] = $uid;
             }
         }
     }
     return $result;
 }
示例#27
0
 function password_save()
 {
     $this->register_handler('plugin.body', array($this, 'password_form'));
     $rcmail = rcmail::get_instance();
     $rcmail->output->set_pagetitle($this->gettext('changepasswd'));
     $confirm = $rcmail->config->get('password_confirm_current');
     $required_length = intval($rcmail->config->get('password_minimum_length'));
     $check_strength = $rcmail->config->get('password_require_nonalpha');
     if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) {
         $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
     } else {
         $charset = strtoupper($rcmail->config->get('password_charset', 'ISO-8859-1'));
         $rc_charset = strtoupper($rcmail->output->get_charset());
         $sespwd = $rcmail->decrypt($_SESSION['password']);
         $curpwd = $confirm ? rcube_utils::get_input_value('_curpasswd', rcube_utils::INPUT_POST, true, $charset) : $sespwd;
         $newpwd = rcube_utils::get_input_value('_newpasswd', rcube_utils::INPUT_POST, true);
         $conpwd = rcube_utils::get_input_value('_confpasswd', rcube_utils::INPUT_POST, true);
         // check allowed characters according to the configured 'password_charset' option
         // by converting the password entered by the user to this charset and back to UTF-8
         $orig_pwd = $newpwd;
         $chk_pwd = rcube_charset::convert($orig_pwd, $rc_charset, $charset);
         $chk_pwd = rcube_charset::convert($chk_pwd, $charset, $rc_charset);
         // WARNING: Default password_charset is ISO-8859-1, so conversion will
         // change national characters. This may disable possibility of using
         // the same password in other MUA's.
         // We're doing this for consistence with Roundcube core
         $newpwd = rcube_charset::convert($newpwd, $rc_charset, $charset);
         $conpwd = rcube_charset::convert($conpwd, $rc_charset, $charset);
         if ($chk_pwd != $orig_pwd) {
             $rcmail->output->command('display_message', $this->gettext('passwordforbidden'), 'error');
         } else {
             if ($conpwd != $newpwd) {
                 $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error');
             } else {
                 if ($confirm && $sespwd != $curpwd) {
                     $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error');
                 } else {
                     if ($required_length && strlen($newpwd) < $required_length) {
                         $rcmail->output->command('display_message', $this->gettext(array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error');
                     } else {
                         if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) {
                             $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error');
                         } else {
                             if ($sespwd == $newpwd && !$rcmail->config->get('password_force_save')) {
                                 $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                             } else {
                                 if (!($res = $this->_save($curpwd, $newpwd))) {
                                     $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                                     // allow additional actions after password change (e.g. reset some backends)
                                     $plugin = $rcmail->plugins->exec_hook('password_change', array('old_pass' => $curpwd, 'new_pass' => $newpwd));
                                     // Reset session password
                                     $_SESSION['password'] = $rcmail->encrypt($plugin['new_pass']);
                                     // Log password change
                                     if ($rcmail->config->get('password_log')) {
                                         rcube::write_log('password', sprintf('Password changed for user %s (ID: %d) from %s', $rcmail->get_user_name(), $rcmail->user->ID, rcube_utils::remote_ip()));
                                     }
                                 } else {
                                     $rcmail->output->command('display_message', $res, 'error');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $rcmail->overwrite_action('plugin.password');
     $rcmail->output->send('plugin');
 }
示例#28
0
 /**
  * Handle message_ready hook (encryption/signing)
  */
 function message_ready($p)
 {
     $savedraft = !empty($_POST['_draft']) && empty($_GET['_saveonly']);
     if (!$savedraft && rcube_utils::get_input_value('_enigma_sign', rcube_utils::INPUT_POST)) {
         $this->enigma->load_engine();
         $status = $this->enigma->engine->sign_message($p['message']);
         $mode = 'sign';
     }
     if (!$status instanceof enigma_error && rcube_utils::get_input_value('_enigma_encrypt', rcube_utils::INPUT_POST)) {
         $this->enigma->load_engine();
         $status = $this->enigma->engine->encrypt_message($p['message'], null, $savedraft);
         $mode = 'encrypt';
     }
     if ($mode && $status instanceof enigma_error) {
         $code = $status->getCode();
         if ($code == enigma_error::KEYNOTFOUND) {
             $vars = array('email' => $status->getData('missing'));
             $msg = 'enigma.' . $mode . 'nokey';
         } else {
             if ($code == enigma_error::BADPASS) {
                 $msg = 'enigma.' . $mode . 'badpass';
                 $type = 'warning';
                 $this->password_prompt($status);
             } else {
                 $msg = 'enigma.' . $mode . 'error';
             }
         }
         $this->rc->output->show_message($msg, $type ?: 'error', $vars);
         $this->rc->output->send('iframe');
     }
     return $p;
 }
 function save_data()
 {
     $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
     $COMPOSE = null;
     if ($COMPOSE_ID && $_SESSION['compose_data_' . $COMPOSE_ID]) {
         $SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
         $COMPOSE =& $_SESSION[$SESSION_KEY];
     }
     if (!$COMPOSE) {
         die("Invalid session var!");
     }
     $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_POST);
     $files = rcube_utils::get_input_value('files', rcube_utils::INPUT_POST);
     $RCMAIL = rcmail::get_instance();
     $RCMAIL->output->reset();
     //rcube::write_log('dropbox_attachments', $files);
     if (is_array($files)) {
         $multiple = count($files) > 1;
         foreach ($files as $i => $file) {
             /*File checks*/
             $err = false;
             if ($file['is_dir'] == 'true') {
                 $err = "UPLOAD_ERR_DIRECTORY";
             }
             // Fetch file
             $filepath = $this->download_fopen($file['link']);
             //rcube::write_log('dropbox_attachments', link);
             //rcube::write_log('dropbox_attachments', $filepath);
             rcube::write_log('dropbox_attachments', $file['link']);
             if (!$filepath) {
                 $err = "UPLOAD_ERR_FETCH";
             }
             if (!$err) {
                 $attachment = $this->move_file(array('path' => $filepath, 'size' => $file['bytes'], 'name' => $file['name'], 'mimetype' => rcube_mime::file_content_type($filepath, $file['name']), 'group' => $COMPOSE_ID));
             }
             //rcube::write_log('dropbox_attachments', $attachment);
             if (!$err && $attachment['status'] && !$attachment['abort']) {
                 $id = $attachment['id'];
                 // store new attachment in session
                 unset($attachment['status'], $attachment['abort']);
                 $RCMAIL->session->append($SESSION_KEY . '.attachments', $id, $attachment);
                 if (($icon = $COMPOSE['deleteicon']) && is_file($icon)) {
                     $button = html::img(array('src' => $icon, 'alt' => $RCMAIL->gettext('delete')));
                 } else {
                     if ($COMPOSE['textbuttons']) {
                         $button = rcube::Q($RCMAIL->gettext('delete'));
                     } else {
                         $button = '';
                     }
                 }
                 $content = html::a(array('href' => "#delete", 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $RCMAIL->gettext('delete'), 'class' => 'delete'), $button);
                 $content .= rcube::Q($attachment['name']);
                 $RCMAIL->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid);
             } else {
                 // upload failed
                 if ($err == "UPLOAD_ERR_DIRECTORY") {
                     $msg = "Directory upload not allowed.";
                 } else {
                     if ($err == "UPLOAD_ERR_FETCH") {
                         $msg = "Failed to download file from Dropbox";
                     } else {
                         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                             $size = $RCMAIL->show_bytes(parse_bytes(ini_get('upload_max_filesize')));
                             $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $size)));
                         } else {
                             if ($attachment['error']) {
                                 $msg = $attachment['error'];
                             } else {
                                 $msg = $RCMAIL->gettext('fileuploaderror');
                             }
                         }
                     }
                 }
                 if ($attachment['error'] || $err != UPLOAD_ERR_NO_FILE) {
                     $RCMAIL->output->command('display_message', $msg, 'error');
                     $RCMAIL->output->command('remove_from_attachment_list', $uploadid);
                 }
             }
         }
     }
     $RCMAIL->output->command('auto_save_start', 'false');
     $RCMAIL->output->send();
 }
示例#30
0
 /**
  * Handler for request action
  */
 function save_vcard()
 {
     $this->add_texts('localization', true);
     $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);
     $rcmail = rcmail::get_instance();
     $storage = $rcmail->get_storage();
     $storage->set_folder($mbox);
     if ($uid && $mime_id) {
         list($mime_id, $index) = explode(':', $mime_id);
         $part = $storage->get_message_part($uid, $mime_id, null, null, null, true);
     }
     $error_msg = $this->gettext('vcardsavefailed');
     if ($part && ($vcards = rcube_vcard::import($part)) && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email) {
         $CONTACTS = $this->get_address_book();
         $email = $vcard->email[0];
         $contact = $vcard->get_assoc();
         $valid = true;
         // skip entries without an e-mail address or invalid
         if (empty($email) || !$CONTACTS->validate($contact, true)) {
             $valid = false;
         } else {
             // We're using UTF8 internally
             $email = rcube_utils::idn_to_utf8($email);
             // compare e-mail address
             $existing = $CONTACTS->search('email', $email, 1, false);
             // compare display name
             if (!$existing->count && $vcard->displayname) {
                 $existing = $CONTACTS->search('name', $vcard->displayname, 1, false);
             }
             if ($existing->count) {
                 $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning');
                 $valid = false;
             }
         }
         if ($valid) {
             $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null));
             $contact = $plugin['record'];
             if (!$plugin['abort'] && $CONTACTS->insert($contact)) {
                 $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation');
             } else {
                 $rcmail->output->command('display_message', $error_msg, 'error');
             }
         }
     } else {
         $rcmail->output->command('display_message', $error_msg, 'error');
     }
     $rcmail->output->send();
 }