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

acp_language.php

Zuletzt modifiziert: 01.05.2026, 11:25 - Dateigröße: 14.35 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  /**
 015  * @ignore
 016  */
 017  if (!defined('IN_PHPBB'))
 018  {
 019      exit;
 020  }
 021   
 022  class acp_language
 023  {
 024      var $u_action;
 025      var $main_files;
 026      var $language_header = '';
 027      var $lang_header = '';
 028   
 029      var $language_file = '';
 030      var $language_directory = '';
 031   
 032      function main($id, $mode)
 033      {
 034          global $config, $db, $user, $template, $phpbb_log, $phpbb_container;
 035          global $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
 036   
 037          if (!function_exists('validate_language_iso_name'))
 038          {
 039              include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 040          }
 041   
 042          // Check and set some common vars
 043          $action        = (isset($_POST['update_details'])) ? 'update_details' : '';
 044          $action        = (isset($_POST['remove_store'])) ? 'details' : $action;
 045   
 046          $submit = (empty($action) && !isset($_POST['update']) && !isset($_POST['test_connection'])) ? false : true;
 047          $action = (empty($action)) ? $request->variable('action', '') : $action;
 048   
 049          $form_name = 'acp_lang';
 050          add_form_key('acp_lang');
 051   
 052          $lang_id = $request->variable('id', 0);
 053   
 054          $selected_lang_file = $request->variable('language_file', '|common.' . $phpEx);
 055   
 056          list($this->language_directory, $this->language_file) = explode('|', $selected_lang_file);
 057   
 058          $this->language_directory = basename($this->language_directory);
 059          $this->language_file = basename($this->language_file);
 060   
 061          $user->add_lang('acp/language');
 062          $this->tpl_name = 'acp_language';
 063          $this->page_title = 'ACP_LANGUAGE_PACKS';
 064   
 065          switch ($action)
 066          {
 067              case 'update_details':
 068   
 069                  if (!$submit || !check_form_key($form_name))
 070                  {
 071                      trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
 072                  }
 073   
 074                  if (!$lang_id)
 075                  {
 076                      trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
 077                  }
 078   
 079                  $sql = 'SELECT *
 080                      FROM ' . LANG_TABLE . "
 081                      WHERE lang_id = $lang_id";
 082                  $result = $db->sql_query($sql);
 083                  $row = $db->sql_fetchrow($result);
 084                  $db->sql_freeresult($result);
 085   
 086                  $sql_ary    = array(
 087                      'lang_english_name'        => $request->variable('lang_english_name', $row['lang_english_name']),
 088                      'lang_local_name'        => $request->variable('lang_local_name', $row['lang_local_name'], true),
 089                      'lang_author'            => $request->variable('lang_author', $row['lang_author'], true),
 090                  );
 091   
 092                  $db->sql_query('UPDATE ' . LANG_TABLE . '
 093                      SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
 094                      WHERE lang_id = ' . $lang_id);
 095   
 096                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_UPDATED', false, array($sql_ary['lang_english_name']));
 097   
 098                  trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action));
 099              break;
 100   
 101              case 'details':
 102   
 103                  if (!$lang_id)
 104                  {
 105                      trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
 106                  }
 107   
 108                  $this->page_title = 'LANGUAGE_PACK_DETAILS';
 109   
 110                  $sql = 'SELECT *
 111                      FROM ' . LANG_TABLE . '
 112                      WHERE lang_id = ' . $lang_id;
 113                  $result = $db->sql_query($sql);
 114                  $lang_entries = $db->sql_fetchrow($result);
 115                  $db->sql_freeresult($result);
 116   
 117                  if (!$lang_entries)
 118                  {
 119                      trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
 120                  }
 121   
 122                  $lang_iso = $lang_entries['lang_iso'];
 123   
 124                  $template->assign_vars(array(
 125                      'S_DETAILS'            => true,
 126                      'U_ACTION'            => $this->u_action . "&amp;action=details&amp;id=$lang_id",
 127                      'U_BACK'            => $this->u_action,
 128   
 129                      'LANG_LOCAL_NAME'    => $lang_entries['lang_local_name'],
 130                      'LANG_ENGLISH_NAME'    => $lang_entries['lang_english_name'],
 131                      'LANG_ISO'            => $lang_iso,
 132                      'LANG_AUTHOR'        => $lang_entries['lang_author'],
 133                      'L_MISSING_FILES'            => $user->lang('THOSE_MISSING_LANG_FILES', $lang_entries['lang_local_name']),
 134                      'L_MISSING_VARS_EXPLAIN'    => $user->lang('THOSE_MISSING_LANG_VARIABLES', $lang_entries['lang_local_name']),
 135                  ));
 136   
 137                  // If current lang is different from the default lang, then highlight missing files and variables
 138                  if ($lang_iso != $config['default_lang'])
 139                  {
 140                      try
 141                      {
 142                          $iterator = new \RecursiveIteratorIterator(
 143                              new \phpbb\recursive_dot_prefix_filter_iterator(
 144                                  new \RecursiveDirectoryIterator(
 145                                      $phpbb_root_path . 'language/' . $config['default_lang'] . '/',
 146                                      \FilesystemIterator::SKIP_DOTS
 147                                  )
 148                              ),
 149                              \RecursiveIteratorIterator::LEAVES_ONLY
 150                          );
 151                      }
 152                      catch (\Exception $e)
 153                      {
 154                          return array();
 155                      }
 156   
 157                      foreach ($iterator as $file_info)
 158                      {
 159                          /** @var \RecursiveDirectoryIterator $file_info */
 160                          $relative_path = $iterator->getInnerIterator()->getSubPathname();
 161                          $relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
 162   
 163                          if (file_exists($phpbb_root_path . 'language/' . $lang_iso . '/' . $relative_path))
 164                          {
 165                              if (substr($relative_path, 0 - strlen($phpEx)) === $phpEx)
 166                              {
 167                                  $missing_vars = $this->compare_language_files($config['default_lang'], $lang_iso, $relative_path);
 168   
 169                                  if (!empty($missing_vars))
 170                                  {
 171                                      $template->assign_block_vars('missing_varfile', array(
 172                                          'FILE_NAME'            => $relative_path,
 173                                      ));
 174   
 175                                      foreach ($missing_vars as $var)
 176                                      {
 177                                          $template->assign_block_vars('missing_varfile.variable', array(
 178                                                  'VAR_NAME'            => $var,
 179                                          ));
 180                                      }
 181                                  }
 182                              }
 183                          }
 184                          else
 185                          {
 186                              $template->assign_block_vars('missing_files', array(
 187                                  'FILE_NAME' => $relative_path,
 188                              ));
 189                          }
 190                      }
 191                  }
 192                  return;
 193              break;
 194   
 195              case 'delete':
 196   
 197                  if (!$lang_id)
 198                  {
 199                      trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
 200                  }
 201   
 202                  $sql = 'SELECT *
 203                      FROM ' . LANG_TABLE . '
 204                      WHERE lang_id = ' . $lang_id;
 205                  $result = $db->sql_query($sql);
 206                  $row = $db->sql_fetchrow($result);
 207                  $db->sql_freeresult($result);
 208   
 209                  if ($row['lang_iso'] == $config['default_lang'])
 210                  {
 211                      trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING);
 212                  }
 213   
 214                  if (confirm_box(true))
 215                  {
 216                      $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id);
 217   
 218                      $sql = 'UPDATE ' . USERS_TABLE . "
 219                          SET user_lang = '" . $db->sql_escape($config['default_lang']) . "'
 220                          WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
 221                      $db->sql_query($sql);
 222   
 223                      // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we?
 224                      $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
 225                      $db->sql_query($sql);
 226   
 227                      $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
 228                      $db->sql_query($sql);
 229   
 230                      $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_DELETED', false, array($row['lang_english_name']));
 231   
 232                      $delete_message = sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']);
 233                      $lang_iso = $row['lang_iso'];
 234                      /**
 235                       * Run code after language deleted
 236                       *
 237                       * @event core.acp_language_after_delete
 238                       * @var    string     lang_iso         Language ISO code
 239                       * @var    string  delete_message  Delete message appear to user
 240                       * @since 3.2.2-RC1
 241                       */
 242                      $vars = array('lang_iso', 'delete_message');
 243                      extract($phpbb_dispatcher->trigger_event('core.acp_language_after_delete', compact($vars)));
 244   
 245                      trigger_error($delete_message . adm_back_link($this->u_action));
 246                  }
 247                  else
 248                  {
 249                      $s_hidden_fields = array(
 250                          'i'            => $id,
 251                          'mode'        => $mode,
 252                          'action'    => $action,
 253                          'id'        => $lang_id,
 254                      );
 255                      confirm_box(false, $user->lang('DELETE_LANGUAGE_CONFIRM', $row['lang_english_name']), build_hidden_fields($s_hidden_fields));
 256                  }
 257              break;
 258   
 259              case 'install':
 260                  if (!check_link_hash($request->variable('hash', ''), 'acp_language'))
 261                  {
 262                      trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
 263                  }
 264   
 265                  $lang_iso = $request->variable('iso', '');
 266                  $lang_iso = basename($lang_iso);
 267   
 268                  if (!$lang_iso || !file_exists("{$phpbb_root_path}language/$lang_iso/iso.txt"))
 269                  {
 270                      trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
 271                  }
 272   
 273                  $file = file("{$phpbb_root_path}language/$lang_iso/iso.txt");
 274   
 275                  $lang_pack = array(
 276                      'iso'        => $lang_iso,
 277                      'name'        => trim(htmlspecialchars($file[0], ENT_COMPAT)),
 278                      'local_name'=> trim(htmlspecialchars($file[1], ENT_COMPAT, 'UTF-8')),
 279                      'author'    => trim(htmlspecialchars($file[2], ENT_COMPAT, 'UTF-8'))
 280                  );
 281                  unset($file);
 282   
 283                  $sql = 'SELECT lang_iso
 284                      FROM ' . LANG_TABLE . "
 285                      WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
 286                  $result = $db->sql_query($sql);
 287                  $row = $db->sql_fetchrow($result);
 288                  $db->sql_freeresult($result);
 289   
 290                  if ($row)
 291                  {
 292                      trigger_error($user->lang['LANGUAGE_PACK_ALREADY_INSTALLED'] . adm_back_link($this->u_action), E_USER_WARNING);
 293                  }
 294   
 295                  if (!$lang_pack['name'] || !$lang_pack['local_name'])
 296                  {
 297                      trigger_error($user->lang['INVALID_LANGUAGE_PACK'] . adm_back_link($this->u_action), E_USER_WARNING);
 298                  }
 299   
 300                  // Add language pack
 301                  $sql_ary = array(
 302                      'lang_iso'            => $lang_pack['iso'],
 303                      'lang_dir'            => $lang_pack['iso'],
 304                      'lang_english_name'    => $lang_pack['name'],
 305                      'lang_local_name'    => $lang_pack['local_name'],
 306                      'lang_author'        => $lang_pack['author']
 307                  );
 308   
 309                  $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
 310                  $lang_id = $db->sql_nextid();
 311   
 312                  // Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
 313                  $sql = 'SELECT lang_id
 314                      FROM ' . LANG_TABLE . "
 315                      WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
 316                  $result = $db->sql_query($sql);
 317                  $default_lang_id = (int) $db->sql_fetchfield('lang_id');
 318                  $db->sql_freeresult($result);
 319   
 320                  // We want to notify the admin that custom profile fields need to be updated for the new language.
 321                  $notify_cpf_update = false;
 322   
 323                  // From the mysql documentation:
 324                  // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
 325                  // Due to this we stay on the safe side if we do the insertion "the manual way"
 326   
 327                  $sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value
 328                      FROM ' . PROFILE_LANG_TABLE . '
 329                      WHERE lang_id = ' . $default_lang_id;
 330                  $result = $db->sql_query($sql);
 331   
 332                  while ($row = $db->sql_fetchrow($result))
 333                  {
 334                      $row['lang_id'] = $lang_id;
 335                      $db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
 336                      $notify_cpf_update = true;
 337                  }
 338                  $db->sql_freeresult($result);
 339   
 340                  $sql = 'SELECT field_id, option_id, field_type, lang_value
 341                      FROM ' . PROFILE_FIELDS_LANG_TABLE . '
 342                      WHERE lang_id = ' . $default_lang_id;
 343                  $result = $db->sql_query($sql);
 344   
 345                  while ($row = $db->sql_fetchrow($result))
 346                  {
 347                      $row['lang_id'] = $lang_id;
 348                      $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
 349                      $notify_cpf_update = true;
 350                  }
 351                  $db->sql_freeresult($result);
 352   
 353                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_INSTALLED', false, array($lang_pack['name']));
 354   
 355                  $message = sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']);
 356                  $message .= ($notify_cpf_update) ? '<br /><br />' . $user->lang['LANGUAGE_PACK_CPF_UPDATE'] : '';
 357                  trigger_error($message . adm_back_link($this->u_action));
 358   
 359              break;
 360          }
 361   
 362          $sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count
 363              FROM ' . USERS_TABLE . '
 364              GROUP BY user_lang';
 365          $result = $db->sql_query($sql);
 366   
 367          $lang_count = array();
 368          while ($row = $db->sql_fetchrow($result))
 369          {
 370              $lang_count[$row['user_lang']] = $row['lang_count'];
 371          }
 372          $db->sql_freeresult($result);
 373   
 374          $sql = 'SELECT *
 375              FROM ' . LANG_TABLE . '
 376              ORDER BY lang_english_name';
 377          $result = $db->sql_query($sql);
 378   
 379          $installed = array();
 380   
 381          while ($row = $db->sql_fetchrow($result))
 382          {
 383              $installed[] = $row['lang_iso'];
 384              $tagstyle = ($row['lang_iso'] == $config['default_lang']) ? '*' : '';
 385   
 386              $template->assign_block_vars('lang', array(
 387                  'U_DETAILS'            => $this->u_action . "&amp;action=details&amp;id={$row['lang_id']}",
 388                  'U_DOWNLOAD'        => $this->u_action . "&amp;action=download&amp;id={$row['lang_id']}",
 389                  'U_DELETE'            => $this->u_action . "&amp;action=delete&amp;id={$row['lang_id']}",
 390   
 391                  'ENGLISH_NAME'        => $row['lang_english_name'],
 392                  'TAG'                => $tagstyle,
 393                  'LOCAL_NAME'        => $row['lang_local_name'],
 394                  'ISO'                => $row['lang_iso'],
 395                  'USED_BY'            => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0,
 396              ));
 397          }
 398          $db->sql_freeresult($result);
 399   
 400          $new_ary = $iso = array();
 401   
 402          /** @var \phpbb\language\language_file_helper $language_helper */
 403          $language_helper = $phpbb_container->get('language.helper.language_file');
 404          $iso = $language_helper->get_available_languages();
 405   
 406          foreach ($iso as $lang_array)
 407          {
 408              $lang_iso = $lang_array['iso'];
 409   
 410              if (!in_array($lang_iso, $installed))
 411              {
 412                  $new_ary[$lang_iso] = $lang_array;
 413              }
 414          }
 415   
 416          unset($installed);
 417   
 418          if (count($new_ary))
 419          {
 420              foreach ($new_ary as $iso => $lang_ary)
 421              {
 422                  $template->assign_block_vars('notinst', array(
 423                      'ISO'            => htmlspecialchars($lang_ary['iso'], ENT_COMPAT),
 424                      'LOCAL_NAME'    => htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'),
 425                      'NAME'            => htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'),
 426                      'U_INSTALL'        => $this->u_action . '&amp;action=install&amp;iso=' . urlencode($lang_ary['iso']) . '&amp;hash=' . generate_link_hash('acp_language'))
 427                  );
 428              }
 429          }
 430   
 431          unset($new_ary);
 432      }
 433   
 434      /**
 435      * Compare two language files
 436      */
 437      function compare_language_files($source_lang, $dest_lang, $file)
 438      {
 439          global $phpbb_root_path;
 440   
 441          $source_file = $phpbb_root_path . 'language/' . $source_lang . '/' . $file;
 442          $dest_file = $phpbb_root_path . 'language/' . $dest_lang . '/' . $file;
 443   
 444          if (!file_exists($dest_file))
 445          {
 446              return array();
 447          }
 448   
 449          $lang = array();
 450          include($source_file);
 451          $lang_entry_src = $lang;
 452   
 453          $lang = array();
 454          include($dest_file);
 455          $lang_entry_dst = $lang;
 456   
 457          unset($lang);
 458   
 459          return array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst));
 460      }
 461  }
 462