Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ajax_iohandler.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 10.42 KiB


 001  <?php
 002  /**
 003   *
 004   * This file is part of the phpBB Forum Software package.
 005   *
 006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007   * @license GNU General Public License, version 2 (GPL-2.0)
 008   *
 009   * For full copyright and license information, please see
 010   * the docs/CREDITS.txt file.
 011   *
 012   */
 013   
 014  namespace phpbb\install\helper\iohandler;
 015   
 016  use phpbb\path_helper;
 017  use phpbb\routing\router;
 018   
 019  /**
 020   * Input-Output handler for the AJAX frontend
 021   */
 022  class ajax_iohandler extends iohandler_base
 023  {
 024      /**
 025       * @var path_helper
 026       */
 027      protected $path_helper;
 028   
 029      /**
 030       * @var \phpbb\request\request_interface
 031       */
 032      protected $request;
 033   
 034      /**
 035       * @var \phpbb\template\template
 036       */
 037      protected $template;
 038   
 039      /**
 040       * @var router
 041       */
 042      protected $router;
 043   
 044      /**
 045       * @var string
 046       */
 047      protected $phpbb_root_path;
 048   
 049      /**
 050       * @var string
 051       */
 052      protected $file_status;
 053   
 054      /**
 055       * @var string
 056       */
 057      protected $form;
 058   
 059      /**
 060       * @var bool
 061       */
 062      protected $request_client_refresh;
 063   
 064      /**
 065       * @var array
 066       */
 067      protected $nav_data;
 068   
 069      /**
 070       * @var array
 071       */
 072      protected $cookies;
 073   
 074      /**
 075       * @var array
 076       */
 077      protected $download;
 078   
 079      /**
 080       * @var array
 081       */
 082      protected $redirect_url;
 083   
 084      /**
 085       * @var resource
 086       */
 087      protected $file_lock_pointer;
 088   
 089      /**
 090       * Constructor
 091       *
 092       * @param path_helper                        $path_helper
 093       * @param \phpbb\request\request_interface    $request    HTTP request interface
 094       * @param \phpbb\template\template            $template    Template engine
 095       * @param router                             $router        Router
 096       * @param string                             $root_path    Path to phpBB's root
 097       */
 098      public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path)
 099      {
 100          $this->path_helper = $path_helper;
 101          $this->request    = $request;
 102          $this->router    = $router;
 103          $this->template    = $template;
 104          $this->form        = '';
 105          $this->nav_data    = array();
 106          $this->cookies    = array();
 107          $this->download    = array();
 108          $this->redirect_url = array();
 109          $this->file_status = '';
 110          $this->phpbb_root_path = $root_path;
 111   
 112          parent::__construct();
 113      }
 114   
 115      /**
 116       * {@inheritdoc}
 117       */
 118      public function get_input($name, $default, $multibyte = false)
 119      {
 120          return $this->request->variable($name, $default, $multibyte);
 121      }
 122   
 123      /**
 124       * {@inheritdoc}
 125       */
 126      public function get_raw_input($name, $default)
 127      {
 128          return $this->request->raw_variable($name, $default);
 129      }
 130   
 131      /**
 132       * {@inheritdoc}
 133       */
 134      public function get_server_variable($name, $default = '')
 135      {
 136          return $this->request->server($name, $default);
 137      }
 138   
 139      /**
 140       * {@inheritdoc}
 141       */
 142      public function get_header_variable($name, $default = '')
 143      {
 144          return $this->request->header($name, $default);
 145      }
 146   
 147      /**
 148       * {@inheritdoc}
 149       */
 150      public function is_secure()
 151      {
 152          return $this->request->is_secure();
 153      }
 154   
 155      /**
 156       * {@inheritdoc}
 157       */
 158      public function add_user_form_group($title, $form)
 159      {
 160          $this->form = $this->generate_form_render_data($title, $form);
 161      }
 162   
 163      /**
 164       * {@inheritdoc}
 165       */
 166      public function generate_form_render_data($title, $form)
 167      {
 168          $this->template->assign_block_vars('options', array(
 169              'LEGEND'    => $this->language->lang($title),
 170              'S_LEGEND'    => true,
 171          ));
 172   
 173          $not_button_form = false;
 174   
 175          foreach ($form as $input_name => $input_options)
 176          {
 177              if (!isset($input_options['type']))
 178              {
 179                  continue;
 180              }
 181   
 182              $tpl_ary = array();
 183              $not_button_form = ($input_options['type'] !== 'submit' || $not_button_form);
 184   
 185              $tpl_ary['TYPE'] = $input_options['type'];
 186              $tpl_ary['TITLE'] = $this->language->lang($input_options['label']);
 187              $tpl_ary['KEY'] = $input_name;
 188              $tpl_ary['S_EXPLAIN'] = false;
 189              $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false;
 190              $tpl_ary['IS_SECONDARY'] = isset($input_options['is_secondary']) ? $input_options['is_secondary'] : false;
 191   
 192              if (isset($input_options['default']))
 193              {
 194                  $default = $input_options['default'];
 195                  $default = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $default);
 196                  $tpl_ary['DEFAULT'] = $default;
 197              }
 198   
 199              if (isset($input_options['description']))
 200              {
 201                  $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']);
 202                  $tpl_ary['S_EXPLAIN'] = true;
 203              }
 204   
 205              if (in_array($input_options['type'], array('select', 'radio'), true))
 206              {
 207                  for ($i = 0, $total = count($input_options['options']); $i < $total; $i++)
 208                  {
 209                      if (isset($input_options['options'][$i]['label']))
 210                      {
 211                          $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']);
 212                      }
 213                  }
 214   
 215                  $tpl_ary['OPTIONS'] = $input_options['options'];
 216              }
 217   
 218              $block_name = ($input_options['type'] === 'submit') ? 'submit_buttons' : 'options';
 219              $this->template->assign_block_vars($block_name, $tpl_ary);
 220          }
 221   
 222          if (isset($form['database_update_submit']) && !$form['database_update_submit']['disabled'])
 223          {
 224              $this->template->assign_var('FORM_TITLE', $this->language->lang('UPDATE_CONTINUE_UPDATE_PROCESS'));
 225          }
 226   
 227          $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form);
 228   
 229          if (!$not_button_form)
 230          {
 231              $this->template->destroy_block_vars('options');
 232          }
 233   
 234          $this->template->set_filenames(array(
 235              'form_install' => 'installer_form.html',
 236          ));
 237   
 238          return $this->template->assign_display('form_install');
 239      }
 240   
 241      /**
 242       * {@inheritdoc}
 243       */
 244      public function send_response($no_more_output = false)
 245      {
 246          $json_data_array = $this->prepare_json_array($no_more_output);
 247   
 248          if (empty($json_data_array))
 249          {
 250              return;
 251          }
 252   
 253          $json_data = json_encode($json_data_array);
 254   
 255          // Try to push content to the browser
 256          print(str_pad(' ', 4096) . "\n");
 257          print($json_data . "\n\n");
 258          flush();
 259      }
 260   
 261      /**
 262       * Prepares iohandler's data to be sent out to the client.
 263       *
 264       * @param bool    $no_more_output    Whether or not there will be more output in this response
 265       *
 266       * @return array
 267       */
 268      protected function prepare_json_array($no_more_output = false)
 269      {
 270          $json_array = array();
 271   
 272          if (!empty($this->errors))
 273          {
 274              $json_array['errors'] = $this->errors;
 275              $this->errors = array();
 276          }
 277   
 278          if (!empty($this->warnings))
 279          {
 280              $json_array['warnings'] = $this->warnings;
 281              $this->warnings = array();
 282          }
 283   
 284          if (!empty($this->logs))
 285          {
 286              $json_array['logs'] = $this->logs;
 287              $this->logs = array();
 288          }
 289   
 290          if (!empty($this->success))
 291          {
 292              $json_array['success'] = $this->success;
 293              $this->success = array();
 294          }
 295   
 296          if (!empty($this->download))
 297          {
 298              $json_array['download'] = $this->download;
 299              $this->download = array();
 300          }
 301   
 302          if (!empty($this->form))
 303          {
 304              $json_array['form'] = $this->form;
 305              $this->form = '';
 306          }
 307   
 308          if (!empty($this->file_status))
 309          {
 310              $json_array['file_status'] = $this->file_status;
 311              $this->file_status = '';
 312          }
 313   
 314          // If current task name is set, we push progress message to the client side
 315          if (!empty($this->current_task_name))
 316          {
 317              $json_array['progress'] = array(
 318                  'task_name'        => $this->current_task_name,
 319                  'task_num'        => $this->current_task_progress,
 320                  'task_count'    => $this->task_progress_count,
 321              );
 322   
 323              if ($this->restart_progress_bar)
 324              {
 325                  $json_array['progress']['restart'] = 1;
 326                  $this->restart_progress_bar = false;
 327              }
 328          }
 329   
 330          if (!empty($this->nav_data))
 331          {
 332              $json_array['nav'] = $this->nav_data;
 333              $this->nav_data = array();
 334          }
 335   
 336          if ($this->request_client_refresh)
 337          {
 338              $json_array['refresh'] = true;
 339              $this->request_client_refresh = false;
 340          }
 341   
 342          if (!empty($this->cookies))
 343          {
 344              $json_array['cookies'] = $this->cookies;
 345              $this->cookies = array();
 346          }
 347   
 348          if (!empty($this->redirect_url))
 349          {
 350              $json_array['redirect'] = $this->redirect_url;
 351              $this->redirect_url = array();
 352          }
 353   
 354          if ($no_more_output)
 355          {
 356              $json_array['over'] = true;
 357          }
 358   
 359          return $json_array;
 360      }
 361   
 362      /**
 363       * {@inheritdoc}
 364       */
 365      public function set_progress($task_lang_key, $task_number)
 366      {
 367          parent::set_progress($task_lang_key, $task_number);
 368          $this->send_response();
 369      }
 370   
 371      /**
 372       * {@inheritdoc}
 373       */
 374      public function request_refresh()
 375      {
 376          $this->request_client_refresh = true;
 377      }
 378   
 379      /**
 380       * {@inheritdoc}
 381       */
 382      public function set_active_stage_menu($menu_path)
 383      {
 384          $this->nav_data['active'] = $menu_path[count($menu_path) - 1];
 385          $this->send_response();
 386      }
 387   
 388      /**
 389       * {@inheritdoc}
 390       */
 391      public function set_finished_stage_menu($menu_path)
 392      {
 393          $this->nav_data['finished'][] = $menu_path[count($menu_path) - 1];
 394          $this->send_response();
 395      }
 396   
 397      /**
 398       * {@inheritdoc}
 399       */
 400      public function set_cookie($cookie_name, $cookie_value)
 401      {
 402          $this->cookies[] = array(
 403              'name' => $cookie_name,
 404              'value' => $cookie_value
 405          );
 406      }
 407   
 408      /**
 409       * {@inheritdoc}
 410       */
 411      public function add_download_link($route, $title, $msg = null)
 412      {
 413          $link_properties = array(
 414              'href'    => $this->router->generate($route),
 415              'title'    => $this->language->lang($title),
 416              'download' => $this->language->lang('DOWNLOAD'),
 417          );
 418   
 419          if ($msg !== null)
 420          {
 421              $link_properties['msg'] = html_entity_decode($this->language->lang($msg), ENT_COMPAT);
 422          }
 423   
 424          $this->download[] = $link_properties;
 425      }
 426   
 427      /**
 428       * {@inheritdoc}
 429       */
 430      public function render_update_file_status($status_array)
 431      {
 432          $this->template->assign_vars(array(
 433              'T_IMAGE_PATH'    => $this->path_helper->get_web_root_path() . 'adm/images/',
 434          ));
 435   
 436          foreach ($status_array as $block => $list)
 437          {
 438              foreach ($list as $filename)
 439              {
 440                  $dirname = dirname($filename);
 441   
 442                  $this->template->assign_block_vars($block, array(
 443                      'STATUS'            => $block,
 444                      'FILENAME'            => $filename,
 445                      'DIR_PART'            => (!empty($dirname) && $dirname !== '.') ? dirname($filename) . '/' : false,
 446                      'FILE_PART'            => basename($filename),
 447                  ));
 448              }
 449          }
 450   
 451          $this->template->set_filenames(array(
 452              'file_status' => 'installer_update_file_status.html',
 453          ));
 454   
 455          $this->file_status = $this->template->assign_display('file_status');
 456      }
 457   
 458      /**
 459       * {@inheritdoc}
 460       */
 461      public function redirect($url, $use_ajax = false)
 462      {
 463          $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax);
 464          $this->send_response(true);
 465      }
 466   
 467      /**
 468       * Acquires a file lock
 469       */
 470      public function acquire_lock()
 471      {
 472          $lock_file = $this->phpbb_root_path . 'store/io_lock.lock';
 473          $this->file_lock_pointer = @fopen($lock_file, 'w+');
 474   
 475          if ($this->file_lock_pointer)
 476          {
 477              flock($this->file_lock_pointer, LOCK_EX);
 478          }
 479      }
 480   
 481      /**
 482       * Release file lock
 483       */
 484      public function release_lock()
 485      {
 486          if ($this->file_lock_pointer)
 487          {
 488              fwrite($this->file_lock_pointer, 'ok');
 489              flock($this->file_lock_pointer, LOCK_UN);
 490              fclose($this->file_lock_pointer);
 491          }
 492      }
 493   
 494      /**
 495       * Callback function for language replacing
 496       *
 497       * @param array    $matches
 498       * @return string
 499       */
 500      public function lang_replace_callback($matches)
 501      {
 502          if (!empty($matches[1]))
 503          {
 504              return $this->language->lang($matches[1]);
 505          }
 506   
 507          return '';
 508      }
 509  }
 510