protected function startup()
    {
        $this->init(self::INIT_WITH_DB | self::INIT_WITH_PLUGINS);

        // set filename if not index.php
        if (($basename = basename($_SERVER['SCRIPT_FILENAME'])) && $basename != 'index.php') {
            $this->filename = $basename;
        }

        // load all configured plugins
        $plugins          = (array) $this->config->get('plugins', array());
        $required_plugins = array('filesystem_attachments', 'jqueryui');
        $this->plugins->load_plugins($plugins, $required_plugins);

        // start session
        $this->session_init();

        // create user object
        $this->set_user(new rcube_user($_SESSION['user_id']));

        // set task and action properties
        $this->set_task(rcube_utils::get_input_value('_task', rcube_utils::INPUT_GPC));
        $this->action = asciiwords(rcube_utils::get_input_value('_action', rcube_utils::INPUT_GPC));

        // reset some session parameters when changing task
        if ($this->task != 'utils') {
            // we reset list page when switching to another task
            // but only to the main task interface - empty action (#1489076, #1490116)
            // this will prevent from unintentional page reset on cross-task requests
            if ($this->session && $_SESSION['task'] != $this->task && empty($this->action)) {
                $this->session->remove('page');

                // set current task to session
                $_SESSION['task'] = $this->task;
            }
        }

        // init output class (not in CLI mode)
        if (!empty($_REQUEST['_remote'])) {
            $GLOBALS['OUTPUT'] = $this->json_init();
        }
        else if ($_SERVER['REMOTE_ADDR']) {
            $GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
        }

        // run init method on all the plugins
        $this->plugins->init($this, $this->task);
    }