Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  /**
   3   * Copyright 2014-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2014-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Base class for stream connection to remote mail server.
  16   *
  17   * NOTE: This class is NOT intended to be accessed outside of the package.
  18   * There is NO guarantees that the API of this class will not change across
  19   * versions.
  20   *
  21   * @author    Michael Slusarz <slusarz@horde.org>
  22   * @category  Horde
  23   * @copyright 2014-2017 Horde LLC
  24   * @internal
  25   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  26   * @package   Imap_Client
  27   */
  28  class Horde_Imap_Client_Socket_Connection_Base extends Horde\Socket\Client
  29  {
  30      /**
  31       * Protocol type.
  32       *
  33       * @var string
  34       */
  35      protected $_protocol = 'imap';
  36  
  37      /**
  38       */
  39      protected function _connect($host, $port, $timeout, $secure, $context, $retries = 0)
  40      {
  41          if ($retries || !$this->_params['debug']->debug) {
  42              $timer = null;
  43          } else {
  44              $url = ($this->_protocol == 'imap')
  45                  ? new Horde_Imap_Client_Url_Imap()
  46                  : new Horde_Imap_Client_Url_Pop3();
  47              $url->host = $host;
  48              $url->port = $port;
  49              $this->_params['debug']->info(sprintf(
  50                  'Connection to: %s',
  51                  strval($url)
  52              ));
  53  
  54              $timer = new Horde_Support_Timer();
  55              $timer->push();
  56          }
  57  
  58          try {
  59              parent::_connect($host, $port, $timeout, $secure, $context, $retries);
  60          } catch (Horde\Socket\Client\Exception $e) {
  61              $this->_params['debug']->info(sprintf(
  62                  'Connection failed: %s',
  63                  $e->getMessage()
  64              ));
  65              throw $e;
  66          }
  67  
  68          if ($timer) {
  69              $this->_params['debug']->info(sprintf(
  70                  'Server connection took %s seconds.',
  71                  round($timer->pop(), 4)
  72              ));
  73          }
  74      }
  75  
  76  }