| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/webmail/plugins/reconnect/ |
Upload File : |
<?php
/**
* RoundCube Reconnect Plugin
*
* @version 0.1
* @author Sandro Knauß <hefee@debian.org>
* @license GPLv3+
*/
class reconnect extends rcube_plugin
{
private $max_attempts;
function init()
{
$rcmail = rcmail::get_instance();
$this->load_config();
$this->imap_max_attempts = $rcmail->config->get('reconnect_imap_max_attempts', 5);
$this->add_hook('storage_connect', array($this, 'storage_connect'));
}
function storage_connect($args)
{
$args['retry'] = ($args['attempt'] <= $this->imap_max_attempts);
if ($args['attempt'] == 1) {
return $args;
}
$storage = rcmail::get_instance()->get_storage();
switch ($storage->get_error_code()) {
case rcube_imap_generic::ERROR_NO:
case rcube_imap_generic::ERROR_BAD:
case rcube_imap_generic::ERROR_BYE:
$args['retry'] = false;
break;
}
if ($args['retry']) {
// if we do a new attempt, sleep 50 to 150ms before retry.
usleep(rand(50*1000, 150*1000));
}
return $args;
}
}