Aleksander Machniak
2015-06-07 58c2798fae7749cf7b4aee471a696aed389d0941
plugins/enigma/lib/enigma_engine.php
@@ -1,5 +1,6 @@
<?php
/*
/**
 +-------------------------------------------------------------------------+
 | Engine of the Enigma Plugin                                             |
 |                                                                         |
@@ -14,12 +15,13 @@
 +-------------------------------------------------------------------------+
*/
/*
    RFC2440: OpenPGP Message Format
    RFC3156: MIME Security with OpenPGP
    RFC3851: S/MIME
/**
 * Enigma plugin engine.
 *
 * RFC2440: OpenPGP Message Format
 * RFC3156: MIME Security with OpenPGP
 * RFC3851: S/MIME
*/
class enigma_engine
{
    private $rc;
@@ -49,7 +51,7 @@
        $this->rc     = rcmail::get_instance();
        $this->enigma = $enigma;
        $this->password_time = $this->rc->config->get('enigma_password_time');
        $this->password_time = $this->rc->config->get('enigma_password_time') * 60;
        // this will remove passwords from session after some time
        if ($this->password_time) {
@@ -503,8 +505,10 @@
            return;
        }
        // Verify signature
        if ($this->rc->action == 'show' || $this->rc->action == 'preview') {
        if ($this->rc->action != 'show' && $this->rc->action != 'preview') {
            return;
        }
            $this->load_pgp_driver();
            $struct = $p['structure'];
@@ -530,7 +534,6 @@
            }
            else {
                $this->signed_parts[$msg_part->mime_id] = $struct->mime_id;
            }
        }
    }
@@ -976,6 +979,9 @@
        $this->rc->output->send();
    }
    /**
     * 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);
@@ -986,6 +992,9 @@
        }
    }
    /**
     * Saves key/cert password in user session
     */
    function save_password($keyid, $password)
    {
        // we store passwords in session for specified time
@@ -999,6 +1008,9 @@
        $_SESSION['enigma_pass'] = $this->rc->encrypt(serialize($config));
    }
    /**
     * Returns currently stored passwords
     */
    function get_passwords()
    {
        if ($config = $_SESSION['enigma_pass']) {
@@ -1011,7 +1023,7 @@
        // delete expired passwords
        foreach ((array) $config as $key => $value) {
            if ($pass_time && $value[1] < $threshold) {
            if ($threshold && $value[1] < $threshold) {
                unset($config[$key]);
                $modified = true;
            }