Viewing File: /usr/local/cpanel/base/3rdparty/roundcube/plugins/cpanellogin/cpanellogin.php

<?php

// Lock out roundcube during updates.
if ( file_exists('/var/cpanel/roundcube/updating') ) {
    // NB: this file is include()d from rcmail::startup() before $rcmail->output
    // exists, so raise_error() can only log here - it cannot render a page.
    rcube::raise_error(
        array (
            'code'    => 800,
            'type'    => 'php',
            'message' => 'Roundcube login unavailable during update.',
            'line'    => __LINE__,
            'file'    => __FILE__,
        ),
        true,
        false
    );

    header('HTTP/1.1 503 Service Unavailable');
    header('Retry-After: 30');
    header('Content-Type: text/html; charset=UTF-8');
    echo '<!DOCTYPE html><html><head><title>Roundcube</title></head>'
       . '<body><h1>Roundcube is in the process of being updated.</h1>'
       . '<p>Please try again shortly.</p></body></html>';
    exit;
}

/**
*  This plugin performs automated authentication for cPanel's Webmail
*/
class cpanellogin extends rcube_plugin
{
  public $task = 'login';

  function init()
  {
    $this->add_hook('startup', array($this, 'startup'));
    $this->add_hook('authenticate', array($this, 'authenticate'));
  } 

  function startup($args)
  {
    $rcmail = rcmail::get_instance();
    // change action to login
    if (empty($_SESSION['user_id']) )
      $args['action'] = 'login';
    return $args;
  }

  function authenticate($args)
  {
    $args['user'] = $_ENV['REMOTE_USER'];
    $args['pass'] = $_ENV['REMOTE_PASSWORD'];
    $args['host'] = 'localhost';
    return $args;
  }
}

?>
Back to Directory