[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/install/module/obtain_data/task/ -> obtain_update_ftp_data.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\install\module\obtain_data\task;
  15  
  16  use phpbb\install\exception\user_interaction_required_exception;
  17  use phpbb\install\helper\config;
  18  use phpbb\install\helper\iohandler\iohandler_interface;
  19  use phpbb\install\helper\update_helper;
  20  use phpbb\install\task_base;
  21  
  22  class obtain_update_ftp_data extends task_base
  23  {
  24      /**
  25       * @var config
  26       */
  27      protected $installer_config;
  28  
  29      /**
  30       * @var iohandler_interface
  31       */
  32      protected $iohandler;
  33  
  34      /**
  35       * @var update_helper
  36       */
  37      protected $update_helper;
  38  
  39      /**
  40       * @var string
  41       */
  42      protected $php_ext;
  43  
  44      /**
  45       * Constructor
  46       *
  47       * @param config                $installer_config
  48       * @param iohandler_interface    $iohandler
  49       * @param update_helper            $update_helper
  50       * @param string                $php_ext
  51       */
  52  	public function __construct(config $installer_config, iohandler_interface $iohandler, update_helper $update_helper, $php_ext)
  53      {
  54          $this->installer_config    = $installer_config;
  55          $this->iohandler        = $iohandler;
  56          $this->update_helper    = $update_helper;
  57          $this->php_ext            = $php_ext;
  58  
  59          parent::__construct(false);
  60      }
  61  
  62      /**
  63       * {@inheritdoc}
  64       */
  65  	public function check_requirements()
  66      {
  67          return ($this->installer_config->get('do_update_files', false) &&
  68              ($this->installer_config->get('file_update_method', '') === 'ftp')
  69          );
  70      }
  71  
  72      /**
  73       * {@inheritdoc}
  74       */
  75  	public function run()
  76      {
  77          if ($this->iohandler->get_input('submit_ftp', false))
  78          {
  79              $this->update_helper->include_file('includes/functions_transfer.' . $this->php_ext);
  80  
  81              $method = 'ftp';
  82              $methods = \transfer::methods();
  83              if (!in_array($method, $methods, true))
  84              {
  85                  $method = $methods[0];
  86              }
  87  
  88              $ftp_host = $this->iohandler->get_input('ftp_host', '', true);
  89              $ftp_user = $this->iohandler->get_input('ftp_user', '', true);
  90              $ftp_pass = html_entity_decode($this->iohandler->get_input('ftp_pass', '', true), ENT_COMPAT);
  91              $ftp_path = $this->iohandler->get_input('ftp_path', '', true);
  92              $ftp_port = $this->iohandler->get_input('ftp_port', 21);
  93              $ftp_time = $this->iohandler->get_input('ftp_timeout', 10);
  94  
  95              $this->installer_config->set('ftp_host', $ftp_host);
  96              $this->installer_config->set('ftp_user', $ftp_user);
  97              $this->installer_config->set('ftp_pass', $ftp_pass);
  98              $this->installer_config->set('ftp_path', $ftp_path);
  99              $this->installer_config->set('ftp_port', (int) $ftp_port);
 100              $this->installer_config->set('ftp_timeout', (int) $ftp_time);
 101              $this->installer_config->set('ftp_method', $method);
 102          }
 103          else
 104          {
 105              $this->iohandler->add_user_form_group('FTP_SETTINGS', array(
 106                  'ftp_host'    => array(
 107                      'label'            => 'FTP_HOST',
 108                      'description'    => 'FTP_HOST_EXPLAIN',
 109                      'type'            => 'text',
 110                  ),
 111                  'ftp_user'    => array(
 112                      'label'            => 'FTP_USERNAME',
 113                      'description'    => 'FTP_USERNAME_EXPLAIN',
 114                      'type'            => 'text',
 115                  ),
 116                  'ftp_pass'    => array(
 117                      'label'            => 'FTP_PASSWORD',
 118                      'description'    => 'FTP_PASSWORD_EXPLAIN',
 119                      'type'            => 'password',
 120                  ),
 121                  'ftp_path'    => array(
 122                      'label'            => 'FTP_ROOT_PATH',
 123                      'description'    => 'FTP_ROOT_PATH_EXPLAIN',
 124                      'type'            => 'text',
 125                  ),
 126                  'ftp_port'    => array(
 127                      'label'            => 'FTP_PORT',
 128                      'description'    => 'FTP_PORT_EXPLAIN',
 129                      'type'            => 'text',
 130                      'default'        => 21,
 131                  ),
 132                  'ftp_timeout'    => array(
 133                      'label'            => 'FTP_TIMEOUT',
 134                      'description'    => 'FTP_TIMEOUT_EXPLAIN',
 135                      'type'            => 'text',
 136                      'default'        => 10,
 137                  ),
 138                  'submit_ftp'    => array(
 139                      'label'    => 'SUBMIT',
 140                      'type'    => 'submit',
 141                  ),
 142              ));
 143  
 144              throw new user_interaction_required_exception();
 145          }
 146      }
 147  
 148      /**
 149       * {@inheritdoc}
 150       */
 151  	static public function get_step_count()
 152      {
 153          return 0;
 154      }
 155  
 156      /**
 157       * {@inheritdoc}
 158       */
 159  	public function get_task_lang_name()
 160      {
 161          return '';
 162      }
 163  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1