[ Index ]

PHP Cross Reference of MyBB 1.8.33

title

Body

[close]

/admin/modules/config/ -> languages.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $languages = $lang->get_languages();
  18  
  19  $page->add_breadcrumb_item($lang->languages, "index.php?module=config-languages");
  20  
  21  $plugins->run_hooks("admin_config_languages_begin");
  22  
  23  if($mybb->input['action'] == "edit_properties")
  24  {
  25      $editlang = basename($mybb->input['lang']);
  26      $file = MYBB_ROOT."inc/languages/".$editlang.".php";
  27      if(!file_exists($file))
  28      {
  29          flash_message($lang->error_invalid_file, 'error');
  30          admin_redirect("index.php?module=config-languages");
  31      }
  32  
  33      $plugins->run_hooks("admin_config_languages_edit_properties");
  34  
  35      if($mybb->request_method == "post")
  36      {
  37          if(!is_writable($file))
  38          {
  39              flash_message($lang->error_cannot_write_to_file, 'error');
  40              admin_redirect("index.php?module=config-languages");
  41          }
  42  
  43          foreach($mybb->input['info'] as $key => $info)
  44          {
  45              $info = str_replace("\\", "\\\\", $info);
  46              $info = str_replace('$', '\$', $info);
  47  
  48              if($key == 'admin' || $key == 'rtl')
  49              {
  50                  $info = (int)$info;
  51              }
  52  
  53              $newlanginfo[$key] = str_replace("\"", '\"', $info);
  54          }
  55  
  56          // Get contents of existing file
  57          require $file;
  58  
  59          // Make the contents of the new file
  60          $newfile = "<?php
  61  // The friendly name of the language
  62  \$langinfo['name'] = \"{$newlanginfo['name']}\";
  63  
  64  // The author of the language
  65  \$langinfo['author'] = \"{$langinfo['author']}\";
  66  
  67  // The language authors website
  68  \$langinfo['website'] = \"{$langinfo['website']}\";
  69  
  70  // Compatible version of MyBB
  71  \$langinfo['version'] = \"{$langinfo['version']}\";
  72  
  73  // Sets if the translation includes the Admin CP (1 = yes, 0 = no)
  74  \$langinfo['admin'] = {$newlanginfo['admin']};
  75  
  76  // Sets if the language is RTL (Right to Left) (1 = yes, 0 = no)
  77  \$langinfo['rtl'] = {$newlanginfo['rtl']};
  78  
  79  // Sets the lang in the <html> on all pages
  80  \$langinfo['htmllang'] = \"{$newlanginfo['htmllang']}\";
  81  
  82  // Sets the character set, blank uses the default.
  83  \$langinfo['charset'] = \"{$newlanginfo['charset']}\";\n";
  84  
  85          // Put it in!
  86          if($file = fopen($file, "w"))
  87          {
  88              fwrite($file, $newfile);
  89              fclose($file);
  90  
  91              $plugins->run_hooks("admin_config_languages_edit_properties_commit");
  92  
  93              // Log admin action
  94              log_admin_action($editlang);
  95  
  96              flash_message($lang->success_langprops_updated, 'success');
  97              admin_redirect("index.php?module=config-languages&action=edit&lang=".htmlspecialchars_uni($editlang)."&editwith=".htmlspecialchars_uni($editlang));
  98          }
  99          else
 100          {
 101              $errors[] = $lang->error_cannot_write_to_file;
 102          }
 103      }
 104  
 105      $page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])), "index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang));
 106      $page->add_breadcrumb_item($lang->nav_editing_set);
 107  
 108      $page->output_header($lang->languages);
 109  
 110      $sub_tabs['edit_properties'] = array(
 111          "title" => $lang->edit_properties,
 112          "link" => "index.php?module=config-languages",
 113          "description" => $lang->edit_properties_desc
 114      );
 115      $page->output_nav_tabs($sub_tabs, "edit_properties");
 116  
 117      // Get language info
 118      require $file;
 119  
 120      $form = new Form("index.php?module=config-languages&amp;action=edit_properties", "post", "editset");
 121      echo $form->generate_hidden_field("lang", $editlang);
 122      echo $form->generate_hidden_field("info[author]", $langinfo['author']);
 123      echo $form->generate_hidden_field("info[website]", $langinfo['website']);
 124      echo $form->generate_hidden_field("info[version]", $langinfo['version']);
 125  
 126      if($errors)
 127      {
 128          $page->output_inline_error($errors);
 129      }
 130      else
 131      {
 132          if($langinfo['admin'])
 133          {
 134              $mybb->input['info']['admin'] = 1;
 135          }
 136          else
 137          {
 138              $mybb->input['info']['admin'] = 0;
 139          }
 140  
 141          if($langinfo['rtl'])
 142          {
 143              $mybb->input['info']['rtl'] = 1;
 144          }
 145          else
 146          {
 147              $mybb->input['info']['rtl'] = 0;
 148          }
 149  
 150          $mybb->input['info']['name'] = $langinfo['name'];
 151          $mybb->input['info']['htmllang'] = $langinfo['htmllang'];
 152          $mybb->input['info']['charset'] = $langinfo['charset'];
 153      }
 154  
 155      $form_container = new FormContainer($lang->edit_properties);
 156  
 157      $form_container->output_row($lang->friendly_name." <em>*</em>", "", $form->generate_text_box('info[name]', $mybb->input['info']['name'], array('id' => 'name')), 'name');
 158      $form_container->output_row($lang->language_in_html." <em>*</em>", "", $form->generate_text_box('info[htmllang]', $mybb->input['info']['htmllang'], array('id' => 'htmllang')), 'htmllang');
 159      $form_container->output_row($lang->charset." <em>*</em>", "", $form->generate_text_box('info[charset]', $mybb->input['info']['charset'], array('id' => 'charset')), 'charset');
 160      $form_container->output_row($lang->rtl." <em>*</em>", "", $form->generate_yes_no_radio('info[rtl]', $mybb->input['info']['rtl'], array('id' => 'rtl')), 'rtl');
 161      $form_container->output_row($lang->admin." <em>*</em>", "", $form->generate_yes_no_radio('info[admin]', $mybb->input['info']['admin'], array('id' => 'admin')), 'admin');
 162  
 163      // Check if file is writable, before allowing submission
 164      if(!is_writable($file))
 165      {
 166          $no_write = 1;
 167          $page->output_alert($lang->alert_note_cannot_write);
 168      }
 169  
 170      $form_container->end();
 171  
 172      $buttons[] = $form->generate_submit_button($lang->save_language_file, array('disabled' => $no_write));
 173  
 174      $form->output_submit_wrapper($buttons);
 175      $form->end();
 176  
 177      $page->output_footer();
 178  }
 179  
 180  if($mybb->input['action'] == "quick_phrases")
 181  {
 182      // Validate input
 183      $editlang = basename($mybb->input['lang']);
 184  
 185      if(in_array($editlang, array('.', '..')))
 186      {
 187          flash_message($lang->error_folders_fail, 'error');
 188          admin_redirect("index.php?module=config-languages");
 189      }
 190  
 191      $folder = MYBB_ROOT."inc/languages/".$editlang."/";
 192  
 193      $page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])), "index.php?module=config-languages&amp;action=quick_edit&amp;lang=".htmlspecialchars_uni($editlang));
 194  
 195      // Validate that this language pack really exists
 196      if(file_exists(MYBB_ROOT."inc/languages/".$editlang.".php"))
 197      {
 198          // Then validate language pack folders (and try to fix them if missing)
 199          if(!is_dir($folder))
 200          {
 201              @mkdir($folder);
 202          }
 203          if(!is_dir($folder."admin"))
 204          {
 205              @mkdir($folder."admin");
 206          }
 207      }
 208  
 209      if(!file_exists($folder) || !file_exists($folder."admin"))
 210      {
 211          flash_message($lang->error_folders_fail, 'error');
 212          admin_redirect("index.php?module=config-languages");
 213      }
 214  
 215      $plugins->run_hooks("admin_config_languages_quick_phrases");
 216  
 217      $quick_phrases = array(
 218          'member.lang.php' => array(
 219              'agreement' => $lang->quickphrases_agreement,
 220              'agreement_1' => $lang->quickphrases_agreement_1,
 221              'agreement_2' => $lang->quickphrases_agreement_2,
 222              'agreement_3' => $lang->quickphrases_agreement_3,
 223              'agreement_4' => $lang->quickphrases_agreement_4,
 224              'agreement_5' => $lang->quickphrases_agreement_5
 225          ),
 226          'messages.lang.php' => array(
 227              'error_nopermission_guest_1' => $lang->quickphrases_error_nopermission_guest_1,
 228              'error_nopermission_guest_2' => $lang->quickphrases_error_nopermission_guest_2,
 229              'error_nopermission_guest_3' => $lang->quickphrases_error_nopermission_guest_3,
 230              'error_nopermission_guest_4' => $lang->quickphrases_error_nopermission_guest_4
 231          )
 232      );
 233  
 234      if($mybb->request_method == 'post')
 235      {
 236          if($mybb->request_method == 'post')
 237          {
 238              // We have more than one file to edit, lets set flag for all of them.
 239              $editsuccess = true;
 240              foreach($quick_phrases as $file => $phrases)
 241              {
 242                  @include $folder.$file;
 243                  $contents_file = (array)$l;
 244                  unset($l);
 245  
 246                  foreach($phrases as $key => $value)
 247                  {
 248                      // validation - we fetch from input only variables that are defined in $quick_phrases array
 249                      $contents_file[$key] = $mybb->input['edit'][$key];
 250                  }
 251                  // Save edited language file
 252                  if($fp = @fopen($folder.$file, "w"))
 253                  {
 254                      // We need info about edited language files to generate credits for our file
 255                      require MYBB_ROOT."inc/languages/".$editlang.".php";
 256  
 257                      // Lets make nice credits header in language file
 258                      $lang_file_credits  = "<?php\n/**\n";
 259                      $lang_file_credits .= " * MyBB Copyright 2014 MyBB Group, All Rights Reserved\n *\n";
 260                      $lang_file_credits .= " * Website: https://mybb.com\n";
 261                      $lang_file_credits .= " * License: https://mybb.com/about/license\n *\n */\n\n";
 262                      $lang_file_credits .= "// ".str_repeat('-',80)."\n";
 263                      $lang_file_credits .= "// MyBB Language Pack File.\n";
 264                      $lang_file_credits .= "// This file has been generated by MyBB - buildin language pack editor.\n";
 265                      $lang_file_credits .= "// ".str_repeat('=',80)."\n";
 266                      $lang_file_credits .= "// Friendly name of the language : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['name'])."\n";
 267                      $lang_file_credits .= "// Author of the language pack : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['author'])."\n";
 268                      $lang_file_credits .= "// Language pack translators website : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['website'])."\n";
 269                      $lang_file_credits .= "// Compatible version of MyBB : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['version'])."\n";
 270                      $lang_file_credits .= "// Last edited in MyBB Editor by : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $mybb->user['username'])."\n";
 271                      $lang_file_credits .= "// Last edited date : ".gmdate("r")."\n";
 272                      $lang_file_credits .= "// ".str_repeat('-',80)."\n\n";
 273  
 274                      $contents_wfile = $lang_file_credits;
 275                      foreach($contents_file as $key => $value)
 276                      {
 277                          $contents_wfile .= "\$l['".$key."'] = ".var_export($value, true).";\n";
 278                      }
 279  
 280                      flock($fp, LOCK_EX);
 281                      fwrite($fp, $contents_wfile);
 282                      flock($fp, LOCK_UN);
 283                      fclose($fp);
 284                  }
 285                  else
 286                  {
 287                      // One of files failed
 288                      $editsuccess = false;
 289                  }
 290              }
 291  
 292              if($editsuccess == true)
 293              {
 294                  // Log admin action
 295                  log_admin_action($editlang);
 296  
 297                  flash_message($lang->success_quickphrases_updated, 'success');
 298                  admin_redirect('index.php?module=config-languages&amp;action=edit&amp;lang='.$editlang);
 299              }
 300          }
 301      }
 302  
 303      $page->output_header($lang->languages);
 304  
 305      $sub_tabs['language_files'] = array(
 306          'title' => $lang->language_files,
 307          'link' => "index.php?module=config-languages&amp;action=edit&amp;lang=".$editlang,
 308          'description' => $lang->language_files_desc
 309      );
 310  
 311      $sub_tabs['quick_phrases'] = array(
 312          'title' => $lang->quick_phrases,
 313          'link' => "index.php?module=config-languages&amp;action=quick_phrases&amp;lang=".$editlang,
 314          'description' => $lang->quick_phrases_desc
 315      );
 316  
 317      $page->output_nav_tabs($sub_tabs, 'quick_phrases');
 318  
 319      $form = new Form('index.php?module=config-languages&amp;action=quick_phrases&amp;lang='.$editlang, 'post', 'quick_phrases');
 320  
 321      if($errors)
 322      {
 323          $page->output_inline_error($errors);
 324      }
 325  
 326      $table = new Table;
 327  
 328      // Check if files are writable, before allowing submission
 329      $no_write = null;
 330      foreach($quick_phrases as $file => $phrases)
 331      {
 332          if(file_exists($folder.$file) && !is_writable($folder.$file) || !is_writable($folder))
 333          {
 334              $no_write = 1;
 335          }
 336      }
 337  
 338      if($no_write)
 339      {
 340          $page->output_alert($lang->alert_note_cannot_write);
 341      }
 342  
 343      $form_container = new FormContainer($lang->quick_phrases);
 344  
 345      foreach($quick_phrases as $file => $phrases)
 346      {
 347          unset($langinfo);
 348          @include MYBB_ROOT."inc/languages/".$editlang.".php";
 349          $quickphrases_dir_class = " langeditor_ltr";
 350          if((int)$langinfo['rtl'] > 0)
 351          {
 352              $quickphrases_dir_class = " langeditor_rtl";
 353          }
 354  
 355          @include $folder.$file;
 356          foreach($phrases as $phrase => $description)
 357          {
 358              $value = $l[$phrase];
 359              if(my_strtolower($langinfo['charset']) == "utf-8")
 360              {
 361                  $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $value);
 362              }
 363              else
 364              {
 365                  $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string', $value);
 366              }
 367  
 368              $form_container->output_row($description, $phrase, $form->generate_text_area("edit[$phrase]", $value, array('id' => 'lang_'.$phrase, 'rows' => 2, 'class' => "langeditor_textarea_edit {$quickphrases_dir_class}")), 'lang_'.$phrase, array('width' => '50%'));
 369          }
 370      }
 371  
 372      $form_container->end();
 373  
 374      $buttons[] = $form->generate_submit_button($lang->save_language_file, array('disabled' => $no_write));
 375  
 376      $form->output_submit_wrapper($buttons);
 377      $form->end();
 378  
 379      $page->output_footer();
 380  }
 381  
 382  if($mybb->input['action'] == "edit")
 383  {
 384      // Validate input
 385      $editlang = basename($mybb->input['lang']);
 386  
 387      if(in_array($editlang, array('.', '..')))
 388      {
 389          flash_message($lang->error_folders_fail, 'error');
 390          admin_redirect("index.php?module=config-languages");
 391      }
 392  
 393      $folder = MYBB_ROOT."inc/languages/".$editlang."/";
 394  
 395      $page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])), "index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang));
 396  
 397      $editwith = basename($mybb->get_input('editwith'));
 398  
 399      if(in_array($editwith, array('.', '..')))
 400      {
 401          flash_message($lang->error_folders_fail, 'error');
 402          admin_redirect("index.php?module=config-languages");
 403      }
 404  
 405  
 406      $editwithfolder = '';
 407  
 408      if($editwith)
 409      {
 410          $editwithfolder = MYBB_ROOT."inc/languages/".$editwith."/";
 411      }
 412  
 413      // Validate that edited language pack really exists
 414      if(file_exists(MYBB_ROOT."inc/languages/".$editlang.".php"))
 415      {
 416          // Then validate edited language pack folders (and try to fix them if missing)
 417          if(!is_dir($folder))
 418          {
 419              @mkdir($folder);
 420          }
 421          if(!is_dir($folder."admin"))
 422          {
 423              @mkdir($folder."admin");
 424          }
 425      }
 426  
 427      if(!file_exists($folder) || !file_exists($folder."admin"))
 428      {
 429          flash_message($lang->error_folders_fail, 'error');
 430          admin_redirect("index.php?module=config-languages");
 431      }
 432  
 433      // If we edit in compare mode, verify that at least folders of compared language exists
 434      if($editwithfolder && (!file_exists($editwithfolder) || !file_exists($editwithfolder)))
 435      {
 436          flash_message($lang->error_invalid_set, 'error');
 437          admin_redirect("index.php?module=config-languages");
 438      }
 439  
 440      $plugins->run_hooks("admin_config_languages_edit");
 441  
 442      if(isset($mybb->input['file']))
 443      {
 444          // Validate input
 445          $file = basename($mybb->input['file']);
 446  
 447          if(in_array($file, array('.', '..')))
 448          {
 449              flash_message($lang->error_folders_fail, 'error');
 450              admin_redirect("index.php?module=config-languages");
 451          }
 452  
 453          if($mybb->get_input('inadmin') == 1)
 454          {
 455              $file = 'admin/'.$file;
 456          }
 457          $page->add_breadcrumb_item(htmlspecialchars_uni($file));
 458  
 459          $editfile = $folder.$file;
 460          $withfile = '';
 461  
 462          $editwithfile = '';
 463          if($editwithfolder)
 464          {
 465              $editwithfile = $editwithfolder.$file;
 466          }
 467  
 468          if($mybb->request_method == "post")
 469          {
 470              // Save edited phrases to language file
 471  
 472              // To validate input - build array of keys that allready exist in files
 473              @include $editfile;
 474              $valid_keys = (array)$l;
 475              unset($l);
 476  
 477              if(!empty($editwithfile))
 478              {
 479                  @include $editwithfile;
 480              }
 481              if(!empty($l))
 482              {
 483                  $valid_keys = array_merge($valid_keys, (array)$l);
 484              }
 485              unset($l);
 486  
 487              $contents_wfile = null;
 488  
 489              // Then fetch from input only valid keys
 490              foreach($valid_keys as $key => $value)
 491              {
 492                  $contents_wfile .= "\$l['".$key."'] = ".var_export($mybb->input['edit'][$key], true).";\n";
 493              }
 494  
 495              // Save edited language file
 496              if($fp = @fopen($editfile, "w"))
 497              {
 498                  // We need info about edited language files to generate credits for our file
 499                  require MYBB_ROOT."inc/languages/".$editlang.".php";
 500  
 501                  // Lets make nice credits header in language file
 502                  $lang_file_credits  = "<?php\n/**\n";
 503                  $lang_file_credits .= " * MyBB Copyright 2014 MyBB Group, All Rights Reserved\n *\n";
 504                  $lang_file_credits .= " * Website: https://mybb.com\n";
 505                  $lang_file_credits .= " * License: https://mybb.com/about/license\n *\n */\n\n";
 506                  $lang_file_credits .= "// ".str_repeat('-',80)."\n";
 507                  $lang_file_credits .= "// MyBB Language Pack File.\n";
 508                  $lang_file_credits .= "// This file has been generated by MyBB - buildin language pack editor.\n";
 509                  $lang_file_credits .= "// ".str_repeat('=',80)."\n";
 510                  $lang_file_credits .= "// Friendly name of the language : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['name'])."\n";
 511                  $lang_file_credits .= "// Author of the language pack : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['author'])."\n";
 512                  $lang_file_credits .= "// Language pack translators website : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['website'])."\n";
 513                  $lang_file_credits .= "// Compatible version of MyBB : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $langinfo['version'])."\n";
 514                  $lang_file_credits .= "// Last edited in MyBB Editor by : ".preg_replace("#<\?|\?>|\r|\n#i", " ", $mybb->user['username'])."\n";
 515                  $lang_file_credits .= "// Last edited date : ".gmdate("r")."\n";
 516                  $lang_file_credits .= "// ".str_repeat('-',80)."\n\n";
 517  
 518                  $contents_wfile = $lang_file_credits.$contents_wfile;
 519  
 520                  flock($fp, LOCK_EX);
 521                  fwrite($fp, $contents_wfile);
 522                  flock($fp, LOCK_UN);
 523                  fclose($fp);
 524  
 525                  $plugins->run_hooks("admin_config_languages_edit_commit");
 526  
 527                  // Log admin action
 528                  log_admin_action($editlang, $editfile, $mybb->get_input('inadmin', MyBB::INPUT_INT));
 529  
 530                  flash_message($lang->success_langfile_updated, 'success');
 531                  admin_redirect("index.php?module=config-languages&action=edit&lang=".htmlspecialchars_uni($editlang)."&editwith=".htmlspecialchars_uni($editwith));
 532              }
 533              else
 534              {
 535                  $errors[] = $lang->error_cannot_write_to_file;
 536              }
 537          }
 538  
 539          if(!empty($editwith))
 540          {
 541              unset($langinfo);
 542              @include MYBB_ROOT."inc/languages/".$editwith.".php";
 543              $editwith_dir_class = " langeditor_ltr";
 544              if((int)$langinfo['rtl'] > 0)
 545              {
 546                  $editwith_dir_class = " langeditor_rtl";
 547              }
 548          }
 549          unset($langinfo);
 550          @include MYBB_ROOT."inc/languages/".$editlang.".php";
 551          $editlang_dir_class = " langeditor_ltr";
 552          if((int)$langinfo['rtl'] > 0)
 553          {
 554              $editlang_dir_class = " langeditor_rtl";
 555          }
 556  
 557          // Build and output form with edited phrases
 558  
 559          // Get file being edited in an array
 560          $editvars = array();
 561          unset($l);
 562          @include $editfile;
 563          if(isset($l))
 564          {
 565              $editvars = (array)$l;
 566              unset($l);
 567          }
 568  
 569          $withvars = array();
 570          // Get edit with file in an array if exists
 571          if($editwithfile)
 572          {
 573              // File we will compare to, may not exists, but dont worry we will auto switch to solo mode later if so
 574              @include $editwithfile;
 575              $withvars = (array)$l;
 576              unset($l);
 577          }
 578  
 579          // Start output
 580          $page->output_header($lang->languages);
 581  
 582          $sub_tabs['edit_language_variables'] = array(
 583              "title" => $lang->edit_language_variables,
 584              "link" => "index.php?module=config-languages",
 585              "description" => $lang->edit_language_variables_desc
 586          );
 587          $page->output_nav_tabs($sub_tabs, "edit_language_variables");
 588  
 589          $form = new Form("index.php?module=config-languages&amp;action=edit", "post", "edit");
 590          echo $form->generate_hidden_field("file", $file);
 591          echo $form->generate_hidden_field("lang", $editlang);
 592          echo $form->generate_hidden_field("editwith", $editwith);
 593          echo $form->generate_hidden_field("inadmin", $mybb->get_input('inadmin', MyBB::INPUT_INT));
 594          if($errors)
 595          {
 596              $page->output_inline_error($errors);
 597          }
 598  
 599          // Check if file is writable, before allowing submission
 600          $no_write = null;
 601          if(file_exists($editfile) && !is_writable($editfile) || !is_writable($folder))
 602          {
 603              $no_write = 1;
 604              $page->output_alert($lang->alert_note_cannot_write);
 605          }
 606  
 607          $form_container = new FormContainer(htmlspecialchars_uni($file));
 608          if($editwithfile && $withvars)
 609          {
 610              // Editing with another file
 611  
 612              $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editwith])));
 613              $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 614  
 615              foreach($withvars as $key => $value)
 616              {
 617                  if(my_strtolower($langinfo['charset']) == "utf-8")
 618                  {
 619                      $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $withvars[$key]);
 620                      $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $editvars[$key]);
 621                  }
 622                  else
 623                  {
 624                      $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $withvars[$key]);
 625                      $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string', $editvars[$key]);
 626                  }
 627  
 628                  // Find problems and differences in editfile in comparision to editwithfile
 629  
 630                  // Count {x} in left and right variable
 631                  $withvars_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $withvars[$key], $matches);
 632                  $editvars_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars[$key], $matches);
 633  
 634                  // If left contain something but right is empty or only spaces || count of {x} are different betwin left and right
 635                  if($withvars[$key] && !$editvars[$key] || $withvars_value_cbvCount != $editvars_value_cbvCount)
 636                  {
 637                      $textarea_issue_class = " langeditor_textarea_issue";
 638                  }
 639                  else
 640                  {
 641                      $textarea_issue_class = "";
 642                  }
 643  
 644                  $form_container->output_row($key, "", $form->generate_text_area("", $withvars[$key], array('readonly' => true,  'rows' => 2, 'class' => "langeditor_textarea_editwith {$editwith_dir_class}")), "", array('width' => '50%', 'skip_construct' => true));
 645                  $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $editvars[$key], array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$textarea_issue_class} {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%'));
 646              }
 647  
 648              // Create form fields for extra variables that are present only in edited file
 649              $present_in_edit_vars_only = (array)array_diff_key($editvars, $withvars);
 650              if($present_in_edit_vars_only)
 651              {
 652                  foreach($present_in_edit_vars_only as $key => $value)
 653                  {
 654                      if(my_strtolower($langinfo['charset']) == "utf-8")
 655                      {
 656                          $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $editvars[$key]);
 657                      }
 658                      else
 659                      {
 660                          $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string', $editvars[$key]);
 661                      }
 662  
 663                      $form_container->output_row("", "", "", "", array('width' => '50%', 'skip_construct' => true));
 664                      $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $editvars[$key], array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%'));
 665                  }
 666              }
 667  
 668          }
 669          else
 670          {
 671              // Editing individually
 672              $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 673  
 674              // Make each editing row from current file that we edit
 675              foreach($editvars as $key => $value)
 676              {
 677                  if(my_strtolower($langinfo['charset']) == "utf-8")
 678                  {
 679                      $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string_utf8', $value);
 680                  }
 681                  else
 682                  {
 683                      $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", 'encode_language_string', $value);
 684                  }
 685                  $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $value, array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%'));
 686              }
 687          }
 688          $form_container->end();
 689  
 690          if(!count($editvars))
 691          {
 692              $no_write = 1;
 693          }
 694  
 695          $buttons[] = $form->generate_submit_button($lang->save_language_file, array('disabled' => $no_write));
 696  
 697          $form->output_submit_wrapper($buttons);
 698          $form->end();
 699      }
 700      else
 701      {
 702          // Build and output list of available language files
 703  
 704          $page->output_header($lang->languages);
 705  
 706          $sub_tabs['language_files'] = array(
 707              'title' => $lang->language_files,
 708              'link' => "index.php?module=config-languages&amp;action=edit&amp;lang=".$editlang,
 709              'description' => $lang->language_files_desc
 710          );
 711  
 712          $sub_tabs['quick_phrases'] = array(
 713              'title' => $lang->quick_phrases,
 714              'link' => "index.php?module=config-languages&amp;action=quick_phrases&amp;lang=".$editlang,
 715              'description' => $lang->quick_phrases_desc
 716          );
 717  
 718          $page->output_nav_tabs($sub_tabs, 'language_files');
 719  
 720          if(!file_exists(MYBB_ROOT."inc/languages/".$editlang.".php"))
 721          {
 722              flash_message($lang->error_invalid_set, 'error');
 723              admin_redirect("index.php?module=config-languages");
 724          }
 725          require MYBB_ROOT."inc/languages/".$editlang.".php";
 726  
 727          $table = new Table;
 728          if($editwithfolder)
 729          {
 730              $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editwith])));
 731              $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100));
 732              $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 733              $table->construct_header($lang->issues, array("class" => "align_center", "width" => 100));
 734              $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
 735          }
 736          else
 737          {
 738              $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 739              $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100));
 740              $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
 741          }
 742  
 743          // Get files in main folder
 744          $filenames = array();
 745          if($handle = opendir($folder))
 746          {
 747              while(false !== ($file = readdir($handle)))
 748              {
 749                  if(preg_match("#\.lang\.php$#", $file))
 750                  {
 751                      $filenames[] = $file;
 752                  }
 753              }
 754              closedir($handle);
 755              sort($filenames);
 756          }
 757  
 758          $edit_colspan = 3;
 759          // Get files from folder we want to peek at (if possible)
 760          if($editwithfolder)
 761          {
 762              $edit_colspan = 5;
 763              $filenameswith = array();
 764              if($handle = opendir($editwithfolder))
 765              {
 766                  while(false !== ($file = readdir($handle)))
 767                  {
 768                      if(preg_match("#\.lang\.php$#", $file))
 769                      {
 770                          $filenameswith[] = $file;
 771                      }
 772                  }
 773                  closedir($handle);
 774                  sort($filenameswith);
 775              }
 776          }
 777  
 778          if($editwithfolder)
 779          {
 780              $files_left = array_diff($filenameswith, $filenames);
 781              $files_right = array_diff($filenames, $filenameswith);
 782              $files_both = array_intersect($filenameswith, $filenames);
 783  
 784              foreach($files_left as $key => $file)
 785              {
 786                  $editvars_left = array();
 787  
 788                  unset($l);
 789                  @include $editwithfolder.$file;
 790                  if(isset($l))
 791                  {
 792                      $editvars_left = (array)$l;
 793                      unset($l);
 794                  }
 795  
 796                  $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
 797                  if(count($editvars_left) > 0)
 798                  {
 799                      $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>";
 800                  }
 801  
 802                  $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editwithfile"));
 803                  $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases"));
 804                  $table->construct_cell("", array("class" => "langeditor_editfile"));
 805                  $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
 806                  $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file=".htmlspecialchars_uni($file)."\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
 807                  $table->construct_row();
 808              }
 809              foreach($files_right as $key => $file)
 810              {
 811                  $editvars_right = array();
 812  
 813                  unset($l);
 814                  @include $folder.$file;
 815                  if(isset($l))
 816                  {
 817                      $editvars_right = (array)$l;
 818                      unset($l);
 819                  }
 820  
 821                  $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
 822                  if(count($editvars_right) > 0)
 823                  {
 824                      $icon_issues = "<span class='langeditor_nothingtocompare' title='".$lang->issues_nothingtocompare."'></span>";
 825                  }
 826  
 827                  $table->construct_cell("", array("class" => "langeditor_editwithfile"));
 828                  $table->construct_cell("", array("class" => "langeditor_phrases"));
 829                  $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
 830                  $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
 831                  $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file=".htmlspecialchars_uni($file)."\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
 832                  $table->construct_row();
 833              }
 834              foreach($files_both as $key => $file)
 835              {
 836                  $editvars_right = $editvars_left = array();
 837  
 838                  unset($l);
 839                  @include $editwithfolder.$file;
 840                  if(isset($l))
 841                  {
 842                      $editvars_left = (array)$l;
 843                      unset($l);
 844                  }
 845                  @include $folder.$file;
 846                  if(isset($l))
 847                  {
 848                      $editvars_right = (array)$l;
 849                      unset($l);
 850                  }
 851  
 852                  $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editwithfile"));
 853                  $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases"));
 854                  $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
 855  
 856                  $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
 857  
 858                  // Find problems and differences in editfile in comparision to editwithfile
 859                  foreach($editvars_left as $editvars_left_key => $editvars_left_value)
 860                  {
 861                      // Count {x} in left and right variable
 862                      $editvars_left_value_cbvCount  = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_left_value, $matches);
 863                      $editvars_right_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_right[$editvars_left_key], $matches);
 864                      // If left contain something but right is empty || count of {x} are different betwin left and right
 865                      if($editvars_left_value && !$editvars_right[$editvars_left_key] || $editvars_left_value_cbvCount != $editvars_right_value_cbvCount)
 866                      {
 867                          $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>";
 868                          // One difference is enought, so lets abort checking for more.
 869                          break;
 870                      }
 871                  }
 872  
 873                  $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
 874                  $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file=".htmlspecialchars_uni($file)."\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
 875                  $table->construct_row();
 876              }
 877          }
 878          else
 879          {
 880              foreach($filenames as $key => $file)
 881              {
 882                  unset($l);
 883                  @include $folder.$file;
 884                  $editvars_count = array();
 885                  if(isset($l))
 886                  {
 887                      $editvars_count = (array)$l;
 888                  }
 889                  unset($l);
 890  
 891                  $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
 892                  $table->construct_cell(count($editvars_count), array("class" => "langeditor_phrases"));
 893                  $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file=".htmlspecialchars_uni($file)."\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
 894                  $table->construct_row();
 895              }
 896          }
 897  
 898          if($table->num_rows() == 0)
 899          {
 900              $table->construct_cell($lang->no_language_files_front_end, array('colspan' => $edit_colspan));
 901              $table->construct_row();
 902          }
 903  
 904          $table->output($lang->front_end);
 905  
 906          if($langinfo['admin'] != 0)
 907          {
 908              $table = new Table;
 909              if($editwithfolder)
 910              {
 911                  $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editwith])));
 912                  $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100));
 913                  $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 914                  $table->construct_header($lang->issues, array("class" => "align_center", "width" => 100));
 915                  $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
 916              }
 917              else
 918              {
 919                  $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($languages[$editlang])));
 920                  $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100));
 921                  $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
 922              }
 923  
 924              // Get files in admin folder
 925              $adminfilenames = array();
 926              if($handle = opendir($folder."admin"))
 927              {
 928                  while(false !== ($file = readdir($handle)))
 929                  {
 930                      if(preg_match("#\.lang\.php$#", $file))
 931                      {
 932                          $adminfilenames[] = $file;
 933                      }
 934                  }
 935                  closedir($handle);
 936                  sort($adminfilenames);
 937              }
 938  
 939              $edit_colspan = 3;
 940              // Get files from admin folder we want to peek at (if possible)
 941              if($editwithfolder)
 942              {
 943                  $edit_colspan = 5;
 944                  $adminfilenameswith = array();
 945                  if($handle = opendir($editwithfolder."admin"))
 946                  {
 947                      while(false !== ($file = readdir($handle)))
 948                      {
 949                          if(preg_match("#\.lang\.php$#", $file))
 950                          {
 951                              $adminfilenameswith[] = $file;
 952                          }
 953                      }
 954                      closedir($handle);
 955                      sort($adminfilenameswith);
 956                  }
 957              }
 958  
 959              if($editwithfolder)
 960              {
 961                  $files_left = array_diff($adminfilenameswith, $adminfilenames);
 962                  $files_right = array_diff($adminfilenames, $adminfilenameswith);
 963                  $files_both = array_intersect($adminfilenameswith, $adminfilenames);
 964  
 965                  foreach($files_left as $key => $file)
 966                  {
 967                      @include $editwithfolder."admin/".$file;
 968                      $editvars_left = (array)$l;
 969                      unset($l);
 970  
 971                      $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
 972                      if(count($editvars_left) >0)
 973                      {
 974                          $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>";
 975                      }
 976  
 977                      $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editwithfile"));
 978                      $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases"));
 979                      $table->construct_cell("", array("class" => "langeditor_editfile"));
 980                      $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
 981                      $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file={$config['admindir']}/".htmlspecialchars_uni($file)."&amp;inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
 982                      $table->construct_row();
 983                  }
 984                  foreach($files_right as $key => $file)
 985                  {
 986                      @include $folder."admin/".$file;
 987                      $editvars_right = (array)$l;
 988                      unset($l);
 989  
 990                      $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
 991                      if(count($editvars_right) >0)
 992                      {
 993                          $icon_issues = "<span class='langeditor_nothingtocompare' title='".$lang->issues_nothingtocompare."'></span>";
 994                      }
 995  
 996                      $table->construct_cell("", array("class" => "langeditor_editwithfile"));
 997                      $table->construct_cell("", array("class" => "langeditor_phrases"));
 998                      $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
 999                      $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
1000                      $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file={$config['admindir']}/".htmlspecialchars_uni($file)."&amp;inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
1001                      $table->construct_row();
1002                  }
1003                  foreach($files_both as $key => $file)
1004                  {
1005                      @include $editwithfolder."admin/".$file;
1006                      $editvars_left = (array)$l;
1007                      unset($l);
1008                      @include $folder."admin/".$file;
1009                      $editvars_right = (array)$l;
1010                      unset($l);
1011  
1012                      $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editwithfile"));
1013                      $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases"));
1014                      $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
1015  
1016                      $icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
1017  
1018                      // Find problems and differences in editfile in comparision to editwithfile
1019                      foreach($editvars_left as $editvars_left_key => $editvars_left_value)
1020                      {
1021                          // Count {x} in left and right variable
1022                          $editvars_left_value_cbvCount  = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_left_value, $matches);
1023                          $editvars_right_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_right[$editvars_left_key], $matches);
1024                          // If left contain something but right is empty || count of {x} are different betwin left and right
1025                          if($editvars_left_value && !$editvars_right[$editvars_left_key] || $editvars_left_value_cbvCount != $editvars_right_value_cbvCount)
1026                          {
1027                              $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>";
1028                              // One difference is enought.
1029                              break;
1030                          }
1031                      }
1032  
1033                      $table->construct_cell($icon_issues, array("class" => "langeditor_issues"));
1034                      $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file={$config['admindir']}/".htmlspecialchars_uni($file)."&amp;inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
1035                      $table->construct_row();
1036                  }
1037              }
1038              else
1039              {
1040                  foreach($adminfilenames as $key => $file)
1041                  {
1042                      @include $folder."admin/".$file;
1043                      $editvars_count = (array)$l;
1044                      unset($l);
1045  
1046                      $table->construct_cell(htmlspecialchars_uni($file), array("class" => "langeditor_editfile"));
1047                      $table->construct_cell(count($editvars_count), array("class" => "langeditor_phrases"));
1048                      $table->construct_cell("<a href=\"index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($editlang)."&amp;editwith=".htmlspecialchars_uni($editwith)."&amp;file=/".htmlspecialchars_uni($file)."&amp;inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit"));
1049                      $table->construct_row();
1050                  }
1051              }
1052  
1053              if($table->num_rows() == 0)
1054              {
1055                  $table->construct_cell($lang->no_language_files_admin_cp, array('colspan' => $edit_colspan));
1056                  $table->construct_row();
1057              }
1058  
1059              $table->output($lang->admin_cp);
1060          }
1061      }
1062  
1063      $page->output_footer();
1064  }
1065  
1066  if(!$mybb->input['action'])
1067  {
1068      $page->output_header($lang->languages);
1069  
1070      $sub_tabs['languages'] = array(
1071          'title' => $lang->languages,
1072          'link' => "index.php?module=config-languages",
1073          'description' => $lang->languages_desc
1074      );
1075      $sub_tabs['find_language'] = array(
1076          'title' => $lang->find_language_packs,
1077          'link' => "https://community.mybb.com/mods.php?action=browse&category=19",
1078          'link_target' => "_blank",
1079          'link_rel' => "noopener"
1080      );
1081  
1082      $plugins->run_hooks("admin_config_languages_start");
1083  
1084      $page->output_nav_tabs($sub_tabs, 'languages');
1085  
1086      $table = new Table;
1087      $table->construct_header($lang->languagevar);
1088      $table->construct_header($lang->version, array("class" => "align_center", "width" => 100));
1089      $table->construct_header($lang->controls, array("class" => "align_center", "width" => 155));
1090  
1091      asort($languages);
1092  
1093      foreach($languages as $key1 => $langname1)
1094      {
1095          $langselectlangs[$key1] = $lang->sprintf($lang->edit_with, preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($langname1)));
1096      }
1097  
1098      foreach($languages as $key => $langname)
1099      {
1100          include MYBB_ROOT."inc/languages/".$key.".php";
1101  
1102          if(!empty($langinfo['website']))
1103          {
1104              $author = "<a href=\"".htmlspecialchars_uni($langinfo['website'])."\" target=\"_blank\" rel=\"noopener\">".htmlspecialchars_uni($langinfo['author'])."</a>";
1105          }
1106          else
1107          {
1108              $author = htmlspecialchars_uni($langinfo['author']);
1109          }
1110  
1111          $table->construct_cell("<span class='langeditor_info_name'>".preg_replace("<\?|\?>", "<span>?</span>", htmlspecialchars_uni($langinfo['name']))."</span><br /><span class='langeditor_info_author'>".$author."</span>");
1112          $table->construct_cell(htmlspecialchars_uni($langinfo['version']), array("class" => "align_center"));
1113  
1114          $popup = new PopupMenu("language_".htmlspecialchars_uni($key), $lang->options);
1115          $popup->add_item($lang->edit_language_variables, "index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($key));
1116          foreach($langselectlangs as $key1 => $langname1)
1117          {
1118              if($key != $key1)
1119              {
1120                  $popup->add_item($langname1, "index.php?module=config-languages&amp;action=edit&amp;lang=".htmlspecialchars_uni($key)."&amp;editwith=".htmlspecialchars_uni($key1));
1121              }
1122          }
1123          $popup->add_item($lang->edit_properties, "index.php?module=config-languages&amp;action=edit_properties&amp;lang=".htmlspecialchars_uni($key));
1124          $table->construct_cell($popup->fetch(), array("class" => "align_center"));
1125          $table->construct_row();
1126      }
1127  
1128      if($table->num_rows() == 0)
1129      {
1130          $table->construct_cell($lang->no_language, array('colspan' => 3));
1131          $table->construct_row();
1132      }
1133  
1134      $table->output($lang->installed_language_packs);
1135  
1136      $page->output_footer();
1137  }
1138  
1139  /**
1140   * Fixes url encoded unicode characters
1141   *
1142   * @param string $string The string to encode.
1143   * @return string The encoded string.
1144   */
1145  function encode_language_string_utf8($matches)
1146  {
1147      return dec_to_utf8(hexdec($matches[1]));
1148  }
1149  
1150  /**
1151   * Fixes url encoded unicode characters
1152   *
1153   * @param string $string The string to encode.
1154   * @return string The encoded string.
1155   */
1156  function encode_language_string($matches)
1157  {
1158      return "&#".hexdec($matches[1]).";";
1159  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref