| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/roundcube/public_html/plugins/autologout/ |
Upload File : |
<?php
/**
* Plugin to auto log out users with a POST request sent from an external site.
*
* @license GNU GPLv3+
* @author Cover Tower LLC
*
* First enable this plugin by setting $config['plugins'] = array(..., 'autologout')
* in the Roundcube configuration file (config.inc.php). To use it, embed
* a form like the following in a web page:
*
* <form id="rcLogoutForm" method="POST" action="https://mail.example.com/">
* <input type="hidden" name="_action" value="logout" />
* <input type="hidden" name="_task" value="logout" />
* <input type="hidden" name="_autologout" value="1" />
* <input id="loSubmitButton" type="submit" value="Logout" />
* </form>
*
* This plugin won't work if the POST request is made using CURL or other
* methods. It will only work if the POST request is made by submitting a
* form similar to the one from above. The form can be hidden and it can
* be sent automatically using JavaScript or JQuery (for example by using:
* $("#loSubmitButton").click();)
*/
class autologout extends rcube_plugin
{
public $task = 'logout';
/**
* Plugin initialization
*/
public function init()
{
$this->add_hook('startup', [$this, 'startup']);
}
/**
* Request handler
*/
public function startup($args)
{
$rcmail = rcmail::get_instance();
// Change task and action to logout
if (!empty($_SESSION['user_id']) && !empty($_POST['_autologout']) && $this->known_client()) {
$rcmail->logout_actions();
$rcmail->kill_session();
}
return $args;
}
/**
* Checks if the request came from an allowed client IP
*/
private function known_client()
{
/*
* If you want to restrict the use of this plugin to specific
* remote clients, you can verify the remote client's IP like this:
*
* return in_array(rcube_utils::remote_addr(), ['123.123.123.123', '124.124.124.124']);
*/
return true;
}
}