Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import

  • Loading branch information...
commit bf8668538c9f24b255fdd3e644f078e3cc13db45 0 parents
scambra authored
3  README
@@ -0,0 +1,3 @@
+Rouncube plugin to add a remember_me checkbox in login.
+
+When remember me is checked, it stores user, password and host encrypted in a cookie, and it will be used to login in a future time, even if you close the browser.
5 localization/cs_CZ.inc
@@ -0,0 +1,5 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Zapamatovat';
+?>
6 localization/de_DE.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Passwort Cookie';
+
+?>
6 localization/en_US.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Remember me';
+
+?>
6 localization/es_ES.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Recuerdame';
+
+?>
6 localization/fr_FR.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Enregistrer le mot de passe';
+
+?>
6 localization/pl_PL.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Zapamiętaj mnie';
+
+?>
6 localization/ru_RU.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Запомнить меня';
+
+?>
6 localization/sv_SE.inc
@@ -0,0 +1,6 @@
+<?php
+
+$labels = array();
+$labels['rememberme'] = 'Kom ihåg mig';
+
+?>
149 remember_me.php
@@ -0,0 +1,149 @@
+<?php
+
+/**
+ * remember_me plugin
+ * Simplified version of remember_me plugin of valsily0 (Roland 'rosali' Liebl) from http://myroundcube.googlecode.com
+ *
+ *
+ * @version 1.4.1 - 2.08.2010
+ * @author scambra / Sergio Cambra
+ * @website http://github.com/scambra/remember_me
+ * @licence GNU GPL
+ *
+ **/
+
+class remember_me extends rcube_plugin {
+
+ function init() {
+
+ $this->add_hook('template_object_loginform', array($this,'rememberme_loginform'));
+ $this->add_hook('startup', array($this, 'startup'));
+ $this->add_hook('authenticate', array($this, 'authenticate'));
+ $this->add_hook('login_after', array($this, 'login_after'));
+ $this->add_hook('login_failed', array($this, 'login_failed'));
+ $this->add_hook('kill_session', array($this, 'logout'));
+ }
+
+ function rememberme_loginform($before) {
+
+ $this->add_texts('localization/');
+ $this->include_stylesheet('skins/'.$this->api->output->config['skin'].'/remember_me.css');
+ $checked = "";
+ if($_COOKIE['rememberme_checked'] == 1)
+ $checked = 'checked="checked"';
+ $b = $before['content'];
+ $b = str_ireplace ('</tbody>',
+ '<tr><td class="title"><label for="rcmrememberme">' . $this->gettext('rememberme','remember_me') . '</label></td><td><input id="rcmrememberme" ' . $checked . ' name="_rememberme" value="1" type="checkbox" /></td>
+ </tr></tbody>',$b);
+ $before['content']=$b;;
+ return ($before);
+ }
+
+ function startup($args) {
+
+ if ($args['task'] == 'settings')
+ return $args; // do not login on pwtools request
+
+ if(isset($_SESSION['temp'])&&
+ !empty($_COOKIE['rememberme_user']) &&
+ !empty($_COOKIE['rememberme_pass']) &&
+ !empty($_COOKIE['rememberme_host']) &&
+ !empty($_COOKIE['rememberme_timezone'])
+ ){
+ $rcmail = rcmail::get_instance();
+ $user = $rcmail->decrypt($_COOKIE['rememberme_user']);
+ $pass = $rcmail->decrypt($_COOKIE['rememberme_pass']);
+ $host = $rcmail->decrypt($_COOKIE['rememberme_host']);
+ $timezone = $_COOKIE['rememberme_timezone'];
+
+ if($user != "" && $pass != "" && $host != "" && $timezone != ""){
+ $args['action'] = 'login';
+ }
+ }
+
+ return $args;
+ }
+
+ function authenticate($args) {
+ if(!empty($_COOKIE['rememberme_user']) &&
+ !empty($_COOKIE['rememberme_pass']) &&
+ !empty($_COOKIE['rememberme_host']) &&
+ !empty($_COOKIE['rememberme_timezone'])
+ ){
+ $rcmail = rcmail::get_instance();
+ $user = $rcmail->decrypt($_COOKIE['rememberme_user']);
+ $pass = $rcmail->decrypt($_COOKIE['rememberme_pass']);
+ $host = $rcmail->decrypt($_COOKIE['rememberme_host']);
+ $timezone = $_COOKIE['rememberme_timezone'];
+
+ if($user != "" && $pass != "" && $host != "" && $timezone != ""){
+ $args['user']= $user;
+ $args['pass']= $pass;
+ $args['host']= $host;
+
+ $_REQUEST['_timezone'] = $timezone;
+
+ //Detect DST change
+ if(date('I',time()) != date('I',time()-86400)){
+ rcmail::setcookie ('rememberme_user','',time()-3600);
+ rcmail::setcookie ('rememberme_pass','',time()-3600);
+ rcmail::setcookie ('rememberme_host','',time()-3600);
+ rcmail::setcookie ('rememberme_timezone','',time()-3600);
+ }
+ else{
+ //Update cookie time
+ $rcmail = rcmail::get_instance();
+ rcmail::setcookie ('rememberme_user',$rcmail->encrypt($user),time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_pass',$rcmail->encrypt($pass),time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_host',$rcmail->encrypt($host),time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_checked',1,time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_timezone',$timezone,time()+60*60*24*365);
+ }
+ }
+ }
+ return $args;
+ }
+
+ function login_after($args) {
+ if (($_POST['_rememberme'] == 1) && !empty($_POST['_user']) && !empty($_POST['_pass'])) {
+ $rcmail = rcmail::get_instance();
+ rcmail::setcookie ('rememberme_user',$rcmail->encrypt(trim($_POST['_user'])),time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_pass',$rcmail->encrypt(trim($_POST['_pass'])),time()+60*60*24*365);
+ $timezone = $_POST['_timezone'];
+ if(empty($timezone) || $timezone == '_default_')
+ $timezone = date('Z') / 3600;
+ if(!empty($_POST['_host']))
+ $host = trim($_POST['_host']);
+ else
+ $host = $_SESSION['imap_host'];
+ rcmail::setcookie ('rememberme_host',$rcmail->encrypt($host),time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_checked',1,time()+60*60*24*365);
+ rcmail::setcookie ('rememberme_timezone',$timezone,time()+60*60*24*365);
+ }
+ return $args;
+ }
+
+ function login_failed($args) {
+ rcmail::setcookie ('rememberme_user','',time()-3600);
+ rcmail::setcookie ('rememberme_pass','',time()-3600);
+ rcmail::setcookie ('rememberme_host','',time()-3600);
+ rcmail::setcookie ('rememberme_timezone','',time()-3600);
+ return $args;
+ }
+
+ function logout($args) {
+ $this->add_texts('localization/');
+ $rcmail = rcmail::get_instance();
+ if($rcmail->task == "logout" && isset($_COOKIE['rememberme_user']) && isset($_COOKIE['rememberme_pass'])){
+ rcmail::setcookie ('rememberme_user','',time()-3600);
+ rcmail::setcookie ('rememberme_pass','',time()-3600);
+ rcmail::setcookie ('rememberme_host','',time()-3600);
+ rcmail::setcookie ('rememberme_checked','',time()-3600);
+ rcmail::setcookie ('rememberme_timezone','',time()-3600);
+ unset($_COOKIE['rememberme_checked']);
+ }
+ return $args;
+ }
+
+}
+?>
4 skins/default/remember_me.css
@@ -0,0 +1,4 @@
+#login-form
+{
+ width: 450px;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.