[ Index ]

PHP Cross Reference of MyBB 1.8.24

title

Body

[close]

/admin/modules/config/ -> settings.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  $page->add_breadcrumb_item($lang->board_settings, "index.php?module=config-settings");
  18  
  19  $plugins->run_hooks("admin_config_settings_begin");
  20  
  21  // Creating a new setting group
  22  if($mybb->input['action'] == "addgroup")
  23  {
  24      $plugins->run_hooks("admin_config_settings_addgroup");
  25  
  26      if($mybb->request_method == "post")
  27      {
  28          // Validate title
  29          if(!trim($mybb->input['title']))
  30          {
  31              $errors[] = $lang->error_missing_group_title;
  32          }
  33  
  34          // Validate identifier
  35          if(!trim($mybb->input['name']))
  36          {
  37              $errors[] = $lang->error_missing_group_name;
  38          }
  39          $query = $db->simple_select("settinggroups", "title", "name='".$db->escape_string($mybb->input['name'])."'");
  40          if($db->num_rows($query) > 0)
  41          {
  42              $dup_group_title = $db->fetch_field($query, 'title');
  43              $errors[] = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title);
  44          }
  45  
  46          if(!$errors)
  47          {
  48              $new_setting_group = array(
  49                  "name" => $db->escape_string($mybb->input['name']),
  50                  "title" => $db->escape_string($mybb->input['title']),
  51                  "description" => $db->escape_string($mybb->input['description']),
  52                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
  53                  "isdefault" => 0
  54              );
  55              $gid = $db->insert_query("settinggroups", $new_setting_group);
  56  
  57              $plugins->run_hooks("admin_config_settings_addgroup_commit");
  58  
  59              // Log admin action
  60              log_admin_action($gid, $mybb->input['name']);
  61  
  62              flash_message($lang->success_setting_group_added, 'success');
  63              admin_redirect("index.php?module=config-settings&action=manage");
  64          }
  65      }
  66  
  67      $page->add_breadcrumb_item($lang->add_new_setting_group);
  68      $page->output_header($lang->board_settings." - ".$lang->add_new_setting_group);
  69  
  70      $sub_tabs['change_settings'] = array(
  71          'title' => $lang->change_settings,
  72          'link' => "index.php?module=config-settings"
  73      );
  74  
  75      $sub_tabs['add_setting'] = array(
  76          'title' => $lang->add_new_setting,
  77          'link' => "index.php?module=config-settings&amp;action=add"
  78      );
  79  
  80      $sub_tabs['add_setting_group'] = array(
  81          'title' => $lang->add_new_setting_group,
  82          'link' => "index.php?module=config-settings&amp;action=addgroup",
  83          'description' => $lang->add_new_setting_group_desc
  84      );
  85  
  86      $sub_tabs['modify_setting'] = array(
  87          'title' => $lang->modify_existing_settings,
  88          'link' => "index.php?module=config-settings&amp;action=manage"
  89      );
  90  
  91      $page->output_nav_tabs($sub_tabs, 'add_setting_group');
  92  
  93      $form = new Form("index.php?module=config-settings&amp;action=addgroup", "post", "add");
  94  
  95      if($errors)
  96      {
  97          $page->output_inline_error($errors);
  98      }
  99  
 100      $form_container = new FormContainer($lang->add_new_setting_group);
 101      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 102      $form_container->output_row($lang->description, "", $form->generate_text_area('description', $mybb->input['description'], array('id' => 'description')), 'description');
 103      $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 104      $form_container->output_row($lang->name." <em>*</em>", $lang->group_name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 105      $form_container->end();
 106  
 107      $buttons[] = $form->generate_submit_button($lang->insert_new_setting_group);
 108      $form->output_submit_wrapper($buttons);
 109      $form->end();
 110  
 111      $page->output_footer();
 112  }
 113  
 114  // Edit setting group
 115  if($mybb->input['action'] == "editgroup")
 116  {
 117      $query = $db->simple_select("settinggroups", "*", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
 118      $group = $db->fetch_array($query);
 119  
 120      // Does the setting not exist?
 121      if(!$group['gid'])
 122      {
 123          flash_message($lang->error_invalid_gid2, 'error');
 124          admin_redirect("index.php?module=config-settings&action=manage");
 125      }
 126      // Prevent editing of default
 127      if($group['isdefault'] == 1)
 128      {
 129          flash_message($lang->error_cannot_edit_default, 'error');
 130          admin_redirect("index.php?module=config-settings&action=manage");
 131      }
 132  
 133      $plugins->run_hooks("admin_config_settings_editgroup");
 134  
 135      // Do edit?
 136      if($mybb->request_method == "post")
 137      {
 138          // Validate title
 139          if(!trim($mybb->input['title']))
 140          {
 141              $errors[] = $lang->error_missing_group_title;
 142          }
 143  
 144          // Validate identifier
 145          if(!trim($mybb->input['name']))
 146          {
 147              $errors[] = $lang->error_missing_group_name;
 148          }
 149          $query = $db->simple_select("settinggroups", "title", "name='".$db->escape_string($mybb->input['name'])."' AND gid != '{$group['gid']}'");
 150          if($db->num_rows($query) > 0)
 151          {
 152              $dup_group_title = $db->fetch_field($query, 'title');
 153              $errors[] = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title);
 154          }
 155  
 156          if(!$errors)
 157          {
 158              $update_setting_group = array(
 159                  "name" => $db->escape_string($mybb->input['name']),
 160                  "title" => $db->escape_string($mybb->input['title']),
 161                  "description" => $db->escape_string($mybb->input['description']),
 162                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
 163              );
 164  
 165              $plugins->run_hooks("admin_config_settings_editgroup_commit");
 166  
 167              $db->update_query("settinggroups", $update_setting_group, "gid='{$group['gid']}'");
 168  
 169              // Log admin action
 170              log_admin_action($group['gid'], $mybb->input['name']);
 171  
 172              flash_message($lang->success_setting_group_updated, 'success');
 173              admin_redirect("index.php?module=config-settings&action=manage");
 174          }
 175      }
 176  
 177      $page->add_breadcrumb_item($lang->edit_setting_group);
 178      $page->output_header($lang->board_settings." - ".$lang->edit_setting_group);
 179  
 180      $sub_tabs['edit_setting_group'] = array(
 181          'title' => $lang->edit_setting_group,
 182          'link' => "index.php?module=config-settings&amp;action=editgroup&amp;gid={$group['gid']}",
 183          'description' => $lang->edit_setting_group_desc
 184      );
 185  
 186      $page->output_nav_tabs($sub_tabs, 'edit_setting_group');
 187  
 188      $form = new Form("index.php?module=config-settings&amp;action=editgroup", "post", "editgroup");
 189  
 190      echo $form->generate_hidden_field("gid", $group['gid']);
 191  
 192      if($errors)
 193      {
 194          $group_data = $mybb->input;
 195          $page->output_inline_error($errors);
 196      }
 197      else
 198      {
 199          $group_data = $group;
 200      }
 201  
 202      $form_container = new FormContainer($lang->edit_setting_group);
 203      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $group_data['title'], array('id' => 'title')), 'title');
 204      $form_container->output_row($lang->description, "", $form->generate_text_area('description', $group_data['description'], array('id' => 'description')), 'description');
 205      $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $group_data['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 206      $form_container->output_row($lang->name." <em>*</em>", $lang->group_name_desc, $form->generate_text_box('name', $group_data['name'], array('id' => 'name')), 'name');
 207      $form_container->end();
 208  
 209      $buttons[] = $form->generate_submit_button($lang->update_setting_group);
 210      $form->output_submit_wrapper($buttons);
 211      $form->end();
 212  
 213      $page->output_footer();
 214  }
 215  
 216  // Delete Setting Group
 217  if($mybb->input['action'] == "deletegroup")
 218  {
 219      $query = $db->simple_select("settinggroups", "*", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
 220      $group = $db->fetch_array($query);
 221  
 222      // Does the setting group not exist?
 223      if(!$group['gid'])
 224      {
 225          flash_message($lang->error_invalid_gid2, 'error');
 226          admin_redirect("index.php?module=config-settings&action=manage");
 227      }
 228      // Prevent deletion of default
 229      if($group['isdefault'] == 1)
 230      {
 231          flash_message($lang->error_cannot_edit_default, 'error');
 232          admin_redirect("index.php?module=config-settings&action=manage");
 233      }
 234  
 235      // User clicked no
 236      if($mybb->input['no'])
 237      {
 238          admin_redirect("index.php?module=config-settings&action=manage");
 239      }
 240  
 241      $plugins->run_hooks("admin_config_settings_deletegroup");
 242  
 243      if($mybb->request_method == "post")
 244      {
 245          // Delete the setting group and its settings
 246          $db->delete_query("settinggroups", "gid='{$group['gid']}'");
 247          $db->delete_query("settings", "gid='{$group['gid']}'");
 248  
 249          rebuild_settings();
 250  
 251          $plugins->run_hooks("admin_config_settings_deletegroup_commit");
 252  
 253          // Log admin action
 254          log_admin_action($group['gid'], $group['name']);
 255  
 256          flash_message($lang->success_setting_group_deleted, 'success');
 257          admin_redirect("index.php?module=config-settings&action=manage");
 258      }
 259      else
 260      {
 261          $page->output_confirm_action("index.php?module=config-settings&amp;action=deletegroup&amp;gid={$group['gid']}", $lang->confirm_setting_group_deletion);
 262      }
 263  }
 264  
 265  // Creating a new setting
 266  if($mybb->input['action'] == "add")
 267  {
 268      $plugins->run_hooks("admin_config_settings_add");
 269  
 270      if($mybb->request_method == "post")
 271      {
 272          if(!trim($mybb->input['title']))
 273          {
 274              $errors[] = $lang->error_missing_title;
 275          }
 276  
 277          $query = $db->simple_select("settinggroups", "gid", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
 278          $gid = $db->fetch_field($query, 'gid');
 279          if(!$gid)
 280          {
 281              $errors[] = $lang->error_invalid_gid;
 282          }
 283  
 284          if(!trim($mybb->input['name']))
 285          {
 286              $errors[] = $lang->error_missing_name;
 287          }
 288          $query = $db->simple_select("settings", "title", "name='".$db->escape_string($mybb->input['name'])."'");
 289          if($db->num_rows($query) > 0)
 290          {
 291              $dup_setting_title = $db->fetch_field($query, 'title');
 292              $errors[] = $lang->sprintf($lang->error_duplicate_name, $dup_setting_title);
 293          }
 294  
 295          // do some type filtering
 296          $mybb->input['type'] = str_replace("\n", "", $mybb->input['type']);
 297          if(strtolower(substr($mybb->input['type'], 0, 3)) == "php")
 298          {
 299              $mybb->input['type'] = "";
 300          }
 301  
 302          if(!$mybb->input['type'])
 303          {
 304              $errors[] = $lang->error_invalid_type;
 305          }
 306  
 307          if(!$errors)
 308          {
 309              if($mybb->input['type'] == "custom")
 310              {
 311                  $options_code = $mybb->input['extra'];
 312              }
 313              else if($mybb->input['extra'])
 314              {
 315                  $options_code = "{$mybb->input['type']}\n{$mybb->input['extra']}";
 316              }
 317              else
 318              {
 319                  $options_code = $mybb->input['type'];
 320              }
 321  
 322              $mybb->input['name'] = str_replace("\\", '', $mybb->input['name']);
 323              $mybb->input['name'] = str_replace('$', '', $mybb->input['name']);
 324              $mybb->input['name'] = str_replace("'", '', $mybb->input['name']);
 325  
 326              if($options_code == "numeric")
 327              {
 328                  $value = $mybb->get_input('value', MyBB::INPUT_INT);
 329              }
 330              else
 331              {
 332                  $value = $db->escape_string($mybb->input['value']);
 333              }
 334  
 335              $new_setting = array(
 336                  "name" => $db->escape_string($mybb->input['name']),
 337                  "title" => $db->escape_string($mybb->input['title']),
 338                  "description" => $db->escape_string($mybb->input['description']),
 339                  "optionscode" => $db->escape_string($options_code),
 340                  "value" => $value,
 341                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
 342                  "gid" => $mybb->get_input('gid', MyBB::INPUT_INT)
 343              );
 344  
 345              $sid = $db->insert_query("settings", $new_setting);
 346              rebuild_settings();
 347  
 348              $plugins->run_hooks("admin_config_settings_add_commit");
 349  
 350              // Log admin action
 351              log_admin_action($sid, $mybb->input['title']);
 352  
 353              flash_message($lang->success_setting_added, 'success');
 354              admin_redirect("index.php?module=config-settings&action=manage");
 355          }
 356      }
 357  
 358      $page->add_breadcrumb_item($lang->add_new_setting);
 359      $page->output_header($lang->board_settings." - ".$lang->add_new_setting);
 360  
 361      $sub_tabs['change_settings'] = array(
 362          'title' => $lang->change_settings,
 363          'link' => "index.php?module=config-settings"
 364      );
 365  
 366      $sub_tabs['add_setting'] = array(
 367          'title' => $lang->add_new_setting,
 368          'link' => "index.php?module=config-settings&amp;action=add",
 369          'description' => $lang->add_new_setting_desc
 370      );
 371  
 372      $sub_tabs['add_setting_group'] = array(
 373          'title' => $lang->add_new_setting_group,
 374          'link' => "index.php?module=config-settings&amp;action=addgroup"
 375      );
 376  
 377      $sub_tabs['modify_setting'] = array(
 378          'title' => $lang->modify_existing_settings,
 379          'link' => "index.php?module=config-settings&amp;action=manage"
 380      );
 381  
 382      $page->output_nav_tabs($sub_tabs, 'add_setting');
 383  
 384      $form = new Form("index.php?module=config-settings&amp;action=add", "post", "add");
 385  
 386      if($errors)
 387      {
 388          $page->output_inline_error($errors);
 389      }
 390  
 391      $form_container = new FormContainer($lang->add_new_setting);
 392      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 393      $form_container->output_row($lang->description, "", $form->generate_text_area('description', $mybb->input['description'], array('id' => 'description')), 'description');
 394  
 395      $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
 396      while($group = $db->fetch_array($query))
 397      {
 398          $group_lang_var = "setting_group_{$group['name']}";
 399          if($lang->$group_lang_var)
 400          {
 401              $options[$group['gid']] = htmlspecialchars_uni($lang->$group_lang_var);
 402          }
 403          else
 404          {
 405              $options[$group['gid']] = htmlspecialchars_uni($group['title']);
 406          }
 407      }
 408      $form_container->output_row($lang->group." <em>*</em>", "", $form->generate_select_box("gid", $options, $mybb->input['gid'], array('id' => 'gid')), 'gid');
 409      $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 410  
 411      $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 412  
 413      $setting_types = array(
 414          "text" => $lang->text,
 415          "numeric" => $lang->numeric_text,
 416          "textarea" => $lang->textarea,
 417          "yesno" => $lang->yesno,
 418          "onoff" => $lang->onoff,
 419          "select" => $lang->select,
 420          "forumselect" => $lang->forum_selection_box,
 421          "forumselectsingle" => $lang->forum_selection_single,
 422          "groupselect" => $lang->group_selection_box,
 423          "groupselectsingle" => $lang->group_selection_single,
 424          "radio" => $lang->radio,
 425          "checkbox" => $lang->checkbox,
 426          "language" => $lang->language_selection_box,
 427          "adminlanguage" => $lang->adminlanguage,
 428          "cpstyle" => $lang->cpstyle,
 429          "prefixselect" => $lang->prefix_selection_box
 430          //"php" => $lang->php // Internal Use Only
 431      );
 432  
 433      $form_container->output_row($lang->type." <em>*</em>", "", $form->generate_select_box("type", $setting_types, $mybb->input['type'], array('id' => 'type')), 'type');
 434      $form_container->output_row($lang->extra, $lang->extra_desc, $form->generate_text_area('extra', $mybb->input['extra'], array('id' => 'extra')), 'extra', array(), array('id' => 'row_extra'));
 435      $form_container->output_row($lang->value, "", $form->generate_text_area('value', $mybb->input['value'], array('id' => 'value')), 'value');
 436      $form_container->end();
 437  
 438      $buttons[] = $form->generate_submit_button($lang->insert_new_setting);
 439      $form->output_submit_wrapper($buttons);
 440      $form->end();
 441  
 442      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 443      <script type="text/javascript">
 444          $(function() {
 445              new Peeker($("#type"), $("#row_extra"), /^(select|radio|checkbox|php)$/, false);
 446          });
 447          // Add a star to the extra row since the "extra" is required if the box is shown
 448          add_star("row_extra");
 449      </script>';
 450  
 451      $page->output_footer();
 452  }
 453  
 454  // Editing a particular setting
 455  if($mybb->input['action'] == "edit")
 456  {
 457      $query = $db->simple_select("settings", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
 458      $setting = $db->fetch_array($query);
 459  
 460      // Does the setting not exist?
 461      if(!$setting['sid'])
 462      {
 463          flash_message($lang->error_invalid_sid, 'error');
 464          admin_redirect("index.php?module=config-settings");
 465      }
 466  
 467      // Prevent editing of default
 468      if($setting['isdefault'] == 1)
 469      {
 470          flash_message($lang->error_cannot_edit_default, 'error');
 471          admin_redirect("index.php?module=config-settings&action=manage");
 472      }
 473  
 474      $plugins->run_hooks("admin_config_settings_edit");
 475  
 476      $type = explode("\n", $setting['optionscode'], 2);
 477      $type = trim($type[0]);
 478      if($type == "php")
 479      {
 480          flash_message($lang->error_cannot_edit_php, 'error');
 481          admin_redirect("index.php?module=config-settings&action=manage");
 482      }
 483  
 484      if($mybb->request_method == "post")
 485      {
 486          if(!trim($mybb->input['title']))
 487          {
 488              $errors[] = $lang->error_missing_title;
 489          }
 490  
 491          if(!trim($mybb->input['name']))
 492          {
 493              $errors[] = $lang->error_missing_name;
 494          }
 495          $query = $db->simple_select("settings", "title", "name='".$db->escape_string($mybb->input['name'])."' AND sid != '{$setting['sid']}'");
 496          if($db->num_rows($query) > 0)
 497          {
 498              $dup_setting_title = $db->fetch_field($query, 'title');
 499              $errors[] = $lang->sprintf($lang->error_duplicate_name, $dup_setting_title);
 500          }
 501  
 502          // do some type filtering
 503          $mybb->input['type'] = str_replace("\n", "", $mybb->input['type']);
 504          if(strtolower(substr($mybb->input['type'], 0, 3)) == "php")
 505          {
 506              $mybb->input['type'] = "";
 507          }
 508  
 509          if(!$mybb->input['type'])
 510          {
 511              $errors[] = $lang->error_invalid_type;
 512          }
 513  
 514          if(!$errors)
 515          {
 516              if($mybb->input['type'] == "custom")
 517              {
 518                  $options_code = $mybb->input['extra'];
 519              }
 520              else if($mybb->input['extra'])
 521              {
 522                  $options_code = "{$mybb->input['type']}\n{$mybb->input['extra']}";
 523              }
 524              else
 525              {
 526                  $options_code = $mybb->input['type'];
 527              }
 528  
 529              $mybb->input['name'] = str_replace("\\", '', $mybb->input['name']);
 530              $mybb->input['name'] = str_replace('$', '', $mybb->input['name']);
 531              $mybb->input['name'] = str_replace("'", '', $mybb->input['name']);
 532  
 533              if($options_code == "numeric")
 534              {
 535                  $value = $mybb->get_input('value', MyBB::INPUT_INT);
 536              }
 537              else
 538              {
 539                  $value = $db->escape_string($mybb->input['value']);
 540              }
 541  
 542              $updated_setting = array(
 543                  "name" => $db->escape_string($mybb->input['name']),
 544                  "title" => $db->escape_string($mybb->input['title']),
 545                  "description" => $db->escape_string($mybb->input['description']),
 546                  "optionscode" => $db->escape_string($options_code),
 547                  "value" => $value,
 548                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
 549                  "gid" => $mybb->get_input('gid', MyBB::INPUT_INT)
 550              );
 551  
 552              $plugins->run_hooks("admin_config_settings_edit_commit");
 553  
 554              $db->update_query("settings", $updated_setting, "sid='{$setting['sid']}'");
 555              rebuild_settings();
 556  
 557              // Log admin action
 558              log_admin_action($setting['sid'], $mybb->input['title']);
 559  
 560              flash_message($lang->success_setting_updated, 'success');
 561              admin_redirect("index.php?module=config-settings&action=manage");
 562          }
 563      }
 564  
 565      $page->add_breadcrumb_item($lang->edit_setting);
 566      $page->output_header($lang->board_settings." - ".$lang->edit_setting);
 567  
 568      $sub_tabs['change_settings'] = array(
 569          'title' => $lang->change_settings,
 570          'link' => "index.php?module=config-settings",
 571      );
 572  
 573      $sub_tabs['add_setting'] = array(
 574          'title' => $lang->add_new_setting,
 575          'link' => "index.php?module=config-settings&amp;action=add"
 576      );
 577  
 578      $sub_tabs['add_setting_group'] = array(
 579          'title' => $lang->add_new_setting_group,
 580          'link' => "index.php?module=config-settings&amp;action=addgroup"
 581      );
 582  
 583      $sub_tabs['modify_setting'] = array(
 584          'title' => $lang->modify_existing_settings,
 585          'link' => "index.php?module=config-settings&amp;action=manage",
 586          'description' => $lang->modify_existing_settings_desc
 587      );
 588  
 589      $page->output_nav_tabs($sub_tabs, 'modify_setting');
 590  
 591      $form = new Form("index.php?module=config-settings&amp;action=edit", "post", "edit");
 592  
 593      echo $form->generate_hidden_field("sid", $setting['sid']);
 594  
 595      if($errors)
 596      {
 597          $setting_data = $mybb->input;
 598          $page->output_inline_error($errors);
 599      }
 600      else
 601      {
 602          $setting_data = $setting;
 603          $type = explode("\n", $setting['optionscode'], 2);
 604          $setting_data['type'] = trim($type[0]);
 605          $setting_data['extra'] = trim($type[1]);
 606      }
 607  
 608      $form_container = new FormContainer($lang->modify_setting);
 609      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $setting_data['title'], array('id' => 'title')), 'title');
 610      $form_container->output_row($lang->description, "", $form->generate_text_area('description', $setting_data['description'], array('id' => 'description')), 'description');
 611  
 612      $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
 613      while($group = $db->fetch_array($query))
 614      {
 615          $group_lang_var = "setting_group_{$group['name']}";
 616          if($lang->$group_lang_var)
 617          {
 618              $options[$group['gid']] = htmlspecialchars_uni($lang->$group_lang_var);
 619          }
 620          else
 621          {
 622              $options[$group['gid']] = htmlspecialchars_uni($group['title']);
 623          }
 624      }
 625      $form_container->output_row($lang->group." <em>*</em>", "", $form->generate_select_box("gid", $options, $setting_data['gid'], array('id' => 'gid')), 'gid');
 626      $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $setting_data['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 627      $form_container->end();
 628  
 629      $form_container = new FormContainer($lang->setting_configuration, 1);
 630      $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $setting_data['name'], array('id' => 'name')), 'name');
 631  
 632      $setting_types = array(
 633          "text" => $lang->text,
 634          "numeric" => $lang->numeric_text,
 635          "textarea" => $lang->textarea,
 636          "yesno" => $lang->yesno,
 637          "onoff" => $lang->onoff,
 638          "select" => $lang->select,
 639          "forumselect" => $lang->forum_selection_box,
 640          "forumselectsingle" => $lang->forum_selection_single,
 641          "groupselect" => $lang->group_selection_box,
 642          "groupselectsingle" => $lang->group_selection_single,
 643          "radio" => $lang->radio,
 644          "checkbox" => $lang->checkbox,
 645          "language" => $lang->language_selection_box,
 646          "adminlanguage" => $lang->adminlanguage,
 647          "cpstyle" => $lang->cpstyle,
 648          "prefixselect" => $lang->prefix_selection_box
 649          //"php" => $lang->php // Internal Use Only
 650      );
 651  
 652      $form_container->output_row($lang->type." <em>*</em>", "", $form->generate_select_box("type", $setting_types, $setting_data['type'], array('id' => 'type')), 'type');
 653      $form_container->output_row($lang->extra, $lang->extra_desc, $form->generate_text_area('extra', $setting_data['extra'], array('id' => 'extra')), 'extra', array(), array('id' => 'row_extra'));
 654      $form_container->output_row($lang->value, '', $form->generate_text_area('value', $setting_data['value'], array('id' => 'value')), 'value');
 655      $form_container->end();
 656  
 657      $buttons[] = $form->generate_submit_button($lang->update_setting);
 658      $form->output_submit_wrapper($buttons);
 659      $form->end();
 660  
 661      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 662      <script type="text/javascript">
 663          $(function() {
 664              new Peeker($("#type"), $("#row_extra"), /^(select|radio|checkbox|php)$/, false);
 665          });
 666          // Add a star to the extra row since the "extra" is required if the box is shown
 667          add_star("row_extra");
 668      </script>';
 669  
 670      $page->output_footer();
 671  }
 672  
 673  // Delete Setting
 674  if($mybb->input['action'] == "delete")
 675  {
 676      $query = $db->simple_select("settings", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
 677      $setting = $db->fetch_array($query);
 678  
 679      // Does the setting not exist?
 680      if(!$setting['sid'])
 681      {
 682          flash_message($lang->error_invalid_sid, 'error');
 683          admin_redirect("index.php?module=config-settings&action=manage");
 684      }
 685  
 686      // Prevent editing of default
 687      if($setting['isdefault'] == 1)
 688      {
 689          flash_message($lang->error_cannot_edit_default, 'error');
 690          admin_redirect("index.php?module=config-settings&action=manage");
 691      }
 692  
 693      // User clicked no
 694      if($mybb->input['no'])
 695      {
 696          admin_redirect("index.php?module=config-settings&action=manage");
 697      }
 698  
 699      $plugins->run_hooks("admin_config_settings_delete");
 700  
 701      if($mybb->request_method == "post")
 702      {
 703          // Delete the setting
 704          $db->delete_query("settings", "sid='{$setting['sid']}'");
 705  
 706          rebuild_settings();
 707  
 708          $plugins->run_hooks("admin_config_settings_delete_commit");
 709  
 710          // Log admin action
 711          log_admin_action($setting['sid'], $setting['title']);
 712  
 713          flash_message($lang->success_setting_deleted, 'success');
 714          admin_redirect("index.php?module=config-settings&action=manage");
 715      }
 716      else
 717      {
 718          $page->output_confirm_action("index.php?module=config-settings&amp;action=delete&amp;sid={$setting['sid']}", $lang->confirm_setting_deletion);
 719      }
 720  }
 721  
 722  // Modify Existing Settings
 723  if($mybb->input['action'] == "manage")
 724  {
 725      $plugins->run_hooks("admin_config_settings_manage");
 726  
 727      // Update orders
 728      if($mybb->request_method == "post")
 729      {
 730          if(is_array($mybb->input['group_disporder']))
 731          {
 732              foreach($mybb->input['group_disporder'] as $gid => $new_order)
 733              {
 734                  $gid = (int)$gid;
 735                  $update_group = array('disporder' => (int)$new_order);
 736                  $db->update_query("settinggroups", $update_group, "gid={$gid}");
 737              }
 738          }
 739  
 740          if(is_array($mybb->input['setting_disporder']))
 741          {
 742              foreach($mybb->input['setting_disporder'] as $sid => $new_order)
 743              {
 744                  $sid = (int)$sid;
 745                  $update_setting = array('disporder' => (int)$new_order);
 746                  $db->update_query("settings", $update_setting, "sid={$sid}");
 747              }
 748          }
 749  
 750          $plugins->run_hooks("admin_config_settings_manage_commit");
 751  
 752          // Log admin action
 753          log_admin_action();
 754  
 755          flash_message($lang->success_display_orders_updated, 'success');
 756          admin_redirect("index.php?module=config-settings&action=manage");
 757      }
 758  
 759      $page->add_breadcrumb_item($lang->modify_existing_settings);
 760      $page->output_header($lang->board_settings." - ".$lang->modify_existing_settings);
 761  
 762      $sub_tabs['change_settings'] = array(
 763          'title' => $lang->change_settings,
 764          'link' => "index.php?module=config-settings",
 765      );
 766  
 767      $sub_tabs['add_setting'] = array(
 768          'title' => $lang->add_new_setting,
 769          'link' => "index.php?module=config-settings&amp;action=add"
 770      );
 771  
 772      $sub_tabs['add_setting_group'] = array(
 773          'title' => $lang->add_new_setting_group,
 774          'link' => "index.php?module=config-settings&amp;action=addgroup"
 775      );
 776  
 777      $sub_tabs['modify_setting'] = array(
 778          'title' => $lang->modify_existing_settings,
 779          'link' => "index.php?module=config-settings&amp;action=manage",
 780          'description' => $lang->modify_existing_settings_desc
 781      );
 782  
 783      $page->output_nav_tabs($sub_tabs, 'modify_setting');
 784  
 785      // Cache settings
 786      $settings_cache = array();
 787      $query = $db->simple_select("settings", "sid, name, title, disporder, gid, isdefault", "", array('order_by' => 'disporder', 'order_dir' => 'asc'));
 788      while($setting = $db->fetch_array($query))
 789      {
 790          $settings_cache[$setting['gid']][] = $setting;
 791      }
 792  
 793      $form = new Form("index.php?module=config-settings&amp;action=manage", "post", "edit");
 794  
 795      $table = new Table;
 796  
 797      $table->construct_header($lang->setting_group_setting);
 798      $table->construct_header($lang->order, array('class' => 'align_center', 'style' => 'width: 5%'));
 799      $table->construct_header($lang->controls, array('class' => 'align_center', 'style' => 'width: 200px'));
 800  
 801      // Generate table
 802      $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder', 'order_dir' => 'asc'));
 803      while($group = $db->fetch_array($query))
 804      {
 805          // Make setting group row
 806          // Translated?
 807          $group_lang_var = "setting_group_{$group['name']}";
 808          if($lang->$group_lang_var)
 809          {
 810              $group_title = htmlspecialchars_uni($lang->$group_lang_var);
 811          }
 812          else
 813          {
 814              $group_title = htmlspecialchars_uni($group['title']);
 815          }
 816          $table->construct_cell("<strong>{$group_title}</strong>", array('id' => "group{$group['gid']}"));
 817          $table->construct_cell($form->generate_numeric_field("group_disporder[{$group['gid']}]", $group['disporder'], array('style' => 'width: 80%; font-weight: bold', 'class' => 'align_center', 'min' => 0)));
 818          // Only show options if not a default setting group
 819          if($group['isdefault'] != 1)
 820          {
 821              $popup = new PopupMenu("group_{$group['gid']}", $lang->options);
 822              $popup->add_item($lang->edit_setting_group, "index.php?module=config-settings&amp;action=editgroup&amp;gid={$group['gid']}");
 823              $popup->add_item($lang->delete_setting_group, "index.php?module=config-settings&amp;action=deletegroup&amp;gid={$group['gid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_setting_group_deletion}')");
 824              $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
 825          }
 826          else
 827          {
 828              $table->construct_cell('');
 829          }
 830          $table->construct_row(array('class' => 'alt_row', 'no_alt_row' => 1));
 831  
 832          // Make rows for each setting in the group
 833          if(is_array($settings_cache[$group['gid']]))
 834          {
 835              foreach($settings_cache[$group['gid']] as $setting)
 836              {
 837                  $setting_lang_var = "setting_{$setting['name']}";
 838                  if($lang->$setting_lang_var)
 839                  {
 840                      $setting_title = htmlspecialchars_uni($lang->$setting_lang_var);
 841                  }
 842                  else
 843                  {
 844                      $setting_title = htmlspecialchars_uni($setting['title']);
 845                  }
 846                  $table->construct_cell($setting_title, array('style' => 'padding-left: 40px;'));
 847                  $table->construct_cell($form->generate_numeric_field("setting_disporder[{$setting['sid']}]", $setting['disporder'], array('style' => 'width: 80%', 'class' => 'align_center', 'min' => 0)));
 848                  // Only show options if not a default setting group or is a custom setting
 849                  if($group['isdefault'] != 1 || $setting['isdefault'] != 1)
 850                  {
 851                      $popup = new PopupMenu("setting_{$setting['sid']}", $lang->options);
 852                      $popup->add_item($lang->edit_setting, "index.php?module=config-settings&amp;action=edit&amp;sid={$setting['sid']}");
 853                      $popup->add_item($lang->delete_setting, "index.php?module=config-settings&amp;action=delete&amp;sid={$setting['sid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_setting_deletion}')");
 854                      $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
 855                  }
 856                  else
 857                  {
 858                      $table->construct_cell('');
 859                  }
 860                  $table->construct_row(array('no_alt_row' => 1, 'class' => "group{$group['gid']}"));
 861              }
 862          }
 863      }
 864  
 865      $table->output($lang->modify_existing_settings);
 866  
 867      $buttons[] = $form->generate_submit_button($lang->save_display_orders);
 868      $form->output_submit_wrapper($buttons);
 869      $form->end();
 870  
 871      $page->output_footer();
 872  }
 873  
 874  // Change settings for a specified group.
 875  if($mybb->input['action'] == "change")
 876  {
 877      $plugins->run_hooks("admin_config_settings_change");
 878  
 879      if($mybb->request_method == "post")
 880      {
 881          if(!is_writable(MYBB_ROOT.'inc/settings.php'))
 882          {
 883              flash_message($lang->error_chmod_settings_file, 'error');
 884              admin_redirect("index.php?module=config-settings");
 885          }
 886  
 887          // Not allowed to be hidden captcha fields
 888          $disallowed_fields = array(
 889              'username',
 890              'password',
 891              'password2',
 892              'email',
 893              'email2',
 894              'imagestring',
 895              'imagehash',
 896              'answer',
 897              'question_id',
 898              'allownotices',
 899              'hideemail',
 900              'receivepms',
 901              'pmnotice',
 902              'emailpmnotify',
 903              'invisible',
 904              'subscriptionmethod',
 905              'timezoneoffset',
 906              'dstcorrection',
 907              'language',
 908              'step',
 909              'action',
 910              'agree',
 911              'regtime',
 912              'regcheck1',
 913              'regcheck2',
 914              'regsubmit'
 915          );
 916  
 917          $is_current_hiddencaptcha_wrong = in_array($mybb->settings['hiddencaptchaimagefield'], $disallowed_fields);
 918          if(in_array($mybb->input['upsetting']['hiddencaptchaimagefield'], $disallowed_fields) || $is_current_hiddencaptcha_wrong)
 919          {
 920              if(isset($mybb->input['upsetting']['hiddencaptchaimagefield']) && $mybb->input['upsetting']['hiddencaptchaimagefield'] != $mybb->settings['hiddencaptchaimagefield'] && !$is_current_hiddencaptcha_wrong)
 921              {
 922                  $wrong_value = $mybb->input['upsetting']['hiddencaptchaimagefield'];
 923                  $mybb->input['upsetting']['hiddencaptchaimagefield'] = $mybb->settings['hiddencaptchaimagefield'];
 924              }
 925              else
 926              {
 927                  $wrong_value = $mybb->settings['hiddencaptchaimagefield'];
 928                  $mybb->input['upsetting']['hiddencaptchaimagefield'] = 'email3';
 929              }
 930  
 931              $lang->success_settings_updated .= $lang->sprintf($lang->success_settings_updated_hiddencaptchaimage, htmlspecialchars_uni($mybb->input['upsetting']['hiddencaptchaimagefield']), htmlspecialchars_uni($wrong_value));
 932          }
 933  
 934          // Validate avatar dimension inputs
 935          $gid = (int)$mybb->input['gid'];
 936          $dimfields = array(
 937              8 => array('postmaxavatarsize'),
 938              10 => array('useravatardims', 'maxavatardims'),
 939              13 => array('memberlistmaxavatarsize')
 940          );
 941          if(in_array($gid, array_keys($dimfields)))
 942          {
 943              foreach($dimfields[$gid] as $field)
 944              {
 945                  if(isset($mybb->input['upsetting'][$field]))
 946                  {
 947                      if(preg_match("/\b\d+[|x]{1}\d+\b/i", $mybb->input['upsetting'][$field]) || ($field == 'maxavatardims' && trim($mybb->input['upsetting'][$field]) == ""))
 948                      {
 949                          // If pipe (|) is used normalize to 'x'
 950                          $mybb->input['upsetting'][$field] = str_replace('|', 'x', my_strtolower($mybb->input['upsetting'][$field]));
 951                      }
 952                      else
 953                      {
 954                          flash_message($lang->sprintf($lang->error_format_dimension, $lang->{'error_field_'.$field}), 'error');
 955                          admin_redirect("index.php?module=config-settings&action=change&gid=".$gid);
 956                      }
 957                  }
 958              }
 959          }
 960  
 961          // Have we opted for a reCAPTCHA or hCaptcha and not set a public/private key?
 962          if((isset($mybb->input['upsetting']['captchaimage']) && in_array($mybb->input['upsetting']['captchaimage'], array(4, 5)) && (!$mybb->input['upsetting']['recaptchaprivatekey'] || !$mybb->input['upsetting']['recaptchapublickey']))
 963             || (in_array($mybb->settings['captchaimage'], array(4, 5)) && (!$mybb->settings['recaptchaprivatekey'] || !$mybb->settings['recaptchapublickey']))
 964             || (isset($mybb->input['upsetting']['captchaimage']) && in_array($mybb->input['upsetting']['captchaimage'], array(8)) && (!$mybb->input['upsetting']['recaptchaprivatekey'] || !$mybb->input['upsetting']['recaptchapublickey'] || !$mybb->input['upsetting']['recaptchascore']))
 965             || (in_array($mybb->settings['captchaimage'], array(8)) && (!$mybb->settings['recaptchaprivatekey'] || !$mybb->settings['recaptchapublickey'] || !$mybb->settings['recaptchascore']))
 966             || (isset($mybb->input['upsetting']['captchaimage']) && in_array($mybb->input['upsetting']['captchaimage'], array(6, 7)) && (!$mybb->input['upsetting']['hcaptchaprivatekey'] || !$mybb->input['upsetting']['hcaptchapublickey']))
 967             || (in_array($mybb->settings['captchaimage'], array(6, 7)) && (!$mybb->settings['hcaptchaprivatekey'] || !$mybb->settings['hcaptchapublickey'])))
 968          {
 969              $mybb->input['upsetting']['captchaimage'] = 1;
 970              $lang->success_settings_updated .= $lang->success_settings_updated_captchaimage;
 971          }
 972  
 973          // If using fulltext then enforce minimum word length given by database
 974          if(isset($mybb->input['upsetting']['minsearchword']) && $mybb->input['upsetting']['minsearchword'] > 0 && $mybb->input['upsetting']['searchtype'] == "fulltext" && $db->supports_fulltext_boolean("posts") && $db->supports_fulltext("threads"))
 975          {
 976              // Attempt to determine minimum word length from MySQL for fulltext searches
 977              $query = $db->query("SHOW VARIABLES LIKE 'ft_min_word_len';");
 978              $min_length = $db->fetch_field($query, 'Value');
 979              if(is_numeric($min_length) && $mybb->input['upsetting']['minsearchword'] < $min_length)
 980              {
 981                  $mybb->input['upsetting']['minsearchword'] = $min_length;
 982                  $lang->success_settings_updated .= $lang->success_settings_updated_minsearchword;
 983              }
 984          }
 985  
 986          // Get settings which optionscode is a forum/group select, checkbox or numeric
 987          // We cannot rely on user input to decide this
 988          $checkbox_settings = $forum_group_select = $prefix_select = array();
 989          $query = $db->simple_select('settings', 'name, optionscode', "optionscode IN('forumselect', 'groupselect', 'prefixselect') OR optionscode LIKE 'checkbox%' OR optionscode LIKE 'numeric%'");
 990  
 991          while($multisetting = $db->fetch_array($query))
 992          {
 993              $options = array();
 994  
 995              if(substr($multisetting['optionscode'], 0, 8) == 'checkbox')
 996              {
 997                  $checkbox_settings[] = $multisetting['name'];
 998  
 999                  // All checkboxes deselected = no $mybb->input['upsetting'] for them, we need to initialize it manually then, but only on pages where the setting is shown
1000                  if(empty($mybb->input['upsetting'][$multisetting['name']]) && isset($mybb->input["isvisible_{$multisetting['name']}"]))
1001                  {
1002                      $mybb->input['upsetting'][$multisetting['name']] = array();
1003                  }
1004              }
1005              elseif(substr($multisetting['optionscode'], 0, 7) == 'numeric')
1006              {
1007                  if(isset($mybb->input['upsetting'][$multisetting['name']]))
1008                  {
1009                      $type = explode("\n", $multisetting['optionscode']);
1010                      for($i=1; $i < count($type); $i++)
1011                      {
1012                          $optionsexp = explode("=", $type[$i]);
1013                          $opt = array_map('trim', $optionsexp);
1014                          if(in_array($opt[0], array('min', 'max', 'step')))
1015                          {
1016                              if($opt[0] != 'step' || $opt[1] != 'any')
1017                              {
1018                                  $opt[1] = (float)$opt[1];
1019                              }
1020                              $options[$opt[0]] = $opt[1];
1021                          }
1022                      }
1023  
1024                      $value = (float)$mybb->input['upsetting'][$multisetting['name']];
1025  
1026                      if(isset($options['min']))
1027                      {
1028                          $value = max($value, $options['min']);
1029                      }
1030  
1031                      if(isset($options['max']))
1032                      {
1033                          $value = min($value, $options['max']);
1034                      }
1035  
1036                      $mybb->input['upsetting'][$multisetting['name']] = $value;
1037                  }
1038              }
1039              else
1040              {
1041                  $forum_group_select[] = $multisetting['name'];
1042              }
1043          }
1044  
1045          // Verify for admin email that can't be empty
1046          if(isset($mybb->input['upsetting']['adminemail']) && !validate_email_format($mybb->input['upsetting']['adminemail']))
1047          {
1048              unset($mybb->input['upsetting']['adminemail']);
1049              $lang->success_settings_updated .= $lang->error_admin_email_settings_empty;
1050          }
1051  
1052          // Administrator is changing the login method.
1053          if($mybb->settings['username_method'] == 1 || $mybb->settings['username_method'] == 2 || $mybb->input['upsetting']['username_method'] == 1 || $mybb->input['upsetting']['username_method'] == 2)
1054          {
1055              $query = $db->simple_select('users', 'email', "email != ''", array('group_by' => 'email HAVING COUNT(email)>1'));
1056              if($db->num_rows($query))
1057              {
1058                  $mybb->input['upsetting']['username_method'] = 0;
1059                  $lang->success_settings_updated .= $lang->success_settings_updated_username_method;
1060              }
1061              else
1062              {
1063                  $mybb->input['upsetting']['allowmultipleemails'] = 0;
1064                  $lang->success_settings_updated .= $lang->success_settings_updated_allowmultipleemails;
1065              }
1066          }
1067  
1068          // reject dangerous/unsupported upload paths
1069          $fields = array(
1070              'uploadspath',
1071              'cdnpath',
1072              'avataruploadpath',
1073          );
1074  
1075          $dynamic_include_directories = array(
1076              MYBB_ROOT.'cache/',
1077              MYBB_ROOT.'inc/plugins/',
1078              MYBB_ROOT.'inc/languages/',
1079              MYBB_ROOT.'inc/tasks/',
1080          );
1081          $dynamic_include_directories_realpath = array_map('realpath', $dynamic_include_directories);
1082  
1083          foreach($fields as $field)
1084          {
1085              if(
1086                  isset($mybb->input['upsetting'][$field]) &&
1087                  is_string($mybb->input['upsetting'][$field]) &&
1088                  strpos($mybb->input['upsetting'][$field], '://') !== false)
1089              {
1090                  unset($mybb->input['upsetting'][$field]);
1091                  continue;
1092              }
1093  
1094              $realpath = realpath(MYBB_ROOT.$mybb->input['upsetting'][$field]);
1095  
1096              if ($realpath === false) {
1097                  unset($mybb->input['upsetting'][$field]);
1098                  continue;
1099              }
1100  
1101              foreach ($dynamic_include_directories_realpath as $forbidden_realpath)
1102              {
1103                  if ($realpath === $forbidden_realpath || strpos($realpath, $forbidden_realpath.DIRECTORY_SEPARATOR) === 0)
1104                  {
1105                      unset($mybb->input['upsetting'][$field]);
1106                      continue 2;
1107                  }
1108              }
1109          }
1110  
1111  
1112          if(is_array($mybb->input['upsetting']))
1113          {
1114              foreach($mybb->input['upsetting'] as $name => $value)
1115              {
1116                  if($forum_group_select && in_array($name, $forum_group_select))
1117                  {
1118                      if($value == 'all')
1119                      {
1120                          $value = -1;
1121                      }
1122                      elseif($value == 'custom')
1123                      {
1124                          if(isset($mybb->input['select'][$name]) && is_array($mybb->input['select'][$name]))
1125                          {
1126                              foreach($mybb->input['select'][$name] as &$val)
1127                              {
1128                                  $val = (int)$val;
1129                              }
1130                              unset($val);
1131  
1132                              $value = implode(',', $mybb->input['select'][$name]);
1133                          }
1134                          else
1135                          {
1136                              $value = '';
1137                          }
1138                      }
1139                      else
1140                      {
1141                          $value = '';
1142                      }
1143                  }
1144                  elseif($checkbox_settings && in_array($name, $checkbox_settings))
1145                  {
1146                      $value = '';
1147  
1148                      if(is_array($mybb->input['upsetting'][$name]))
1149                      {
1150                          $value = implode(',', $mybb->input['upsetting'][$name]);
1151                      }
1152                  }
1153  
1154                  $db->update_query("settings", array('value' => $db->escape_string($value)), "name='".$db->escape_string($name)."'");
1155              }
1156          }
1157  
1158          // Check if we need to create our fulltext index after changing the search mode
1159          if($mybb->settings['searchtype'] != $mybb->input['upsetting']['searchtype'] && $mybb->input['upsetting']['searchtype'] == "fulltext")
1160          {
1161              if(!$db->is_fulltext("posts") && $db->supports_fulltext_boolean("posts"))
1162              {
1163                  $db->create_fulltext_index("posts", "message");
1164              }
1165              if(!$db->is_fulltext("threads") && $db->supports_fulltext("threads"))
1166              {
1167                  $db->create_fulltext_index("threads", "subject");
1168              }
1169          }
1170  
1171          // If the delayedthreadviews setting was changed, enable or disable the tasks for it.
1172          if(isset($mybb->input['upsetting']['delayedthreadviews']) && $mybb->settings['delayedthreadviews'] != $mybb->input['upsetting']['delayedthreadviews'])
1173          {
1174              $db->update_query("tasks", array('enabled' => (int)$mybb->input['upsetting']['delayedthreadviews']), "file='threadviews'");
1175          }
1176  
1177          // Have we changed our cookie prefix? If so, update our adminsid so we're not logged out
1178          if(isset($mybb->input['upsetting']['cookieprefix']) && $mybb->input['upsetting']['cookieprefix'] != $mybb->settings['cookieprefix'])
1179          {
1180              my_unsetcookie("adminsid");
1181              $mybb->settings['cookieprefix'] = $mybb->input['upsetting']['cookieprefix'];
1182              my_setcookie("adminsid", $admin_session['sid'], '', true, "lax");
1183          }
1184  
1185          if(isset($mybb->input['upsetting']['statstopreferrer']) && $mybb->input['upsetting']['statstopreferrer'] != $mybb->settings['statstopreferrer'])
1186          {
1187              $cache->update_statistics();
1188          }
1189  
1190          $statslimit = $mybb->settings['statslimit'];
1191  
1192          rebuild_settings();
1193  
1194          if(isset($mybb->input['upsetting']['statslimit']) && $mybb->input['upsetting']['statslimit'] != $statslimit)
1195          {
1196              $cache->update_most_replied_threads();
1197              $cache->update_most_viewed_threads();
1198          }
1199  
1200          $plugins->run_hooks("admin_config_settings_change_commit");
1201  
1202          // Log admin action
1203          log_admin_action();
1204  
1205          flash_message($lang->success_settings_updated, 'success');
1206          admin_redirect("index.php?module=config-settings");
1207      }
1208  
1209      // What type of page
1210      $cache_groups = $cache_settings = array();
1211      if(isset($mybb->input['search']))
1212      {
1213          // Search
1214  
1215          // Search for settings
1216          $search = trim($mybb->input['search']);
1217          if(!empty($search))
1218          {
1219              $query = $db->query("
1220                  SELECT s.* , g.name as gname, g.title as gtitle, g.description as gdescription
1221                  FROM ".TABLE_PREFIX."settings s
1222                  LEFT JOIN ".TABLE_PREFIX."settinggroups g ON(s.gid=g.gid)
1223                  ORDER BY s.disporder
1224              ");
1225              while($setting = $db->fetch_array($query))
1226              {
1227                  $search_in = $setting['name'] . ' ' . $setting['title'] . ' ' . $setting['description'] . ' ' . $setting['gname'] . ' ' . $setting['gtitle'] . ' ' . $setting['gdescription'];
1228                  foreach(array("setting_{$setting['name']}", "setting_{$setting['name']}_desc", "setting_group_{$setting['gname']}", "setting_group_{$setting['gname']}_desc") as $search_in_lang_key)
1229                  {
1230                      if(!empty($lang->$search_in_lang_key))
1231                      {
1232                          $search_in .= ' ' . $lang->$search_in_lang_key;
1233                      }
1234                  }
1235                  if(my_stripos($search_in, $search) !== false)
1236                  {
1237                      $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1238                  }
1239              }
1240          }
1241          if(!count($cache_settings))
1242          {
1243              if(isset($mybb->input['ajax_search']))
1244              {
1245                  echo json_encode(array("errors" => array($lang->error_no_settings_found)));
1246                  exit;
1247              }
1248              else
1249              {
1250                  flash_message($lang->error_no_settings_found, 'error');
1251                  admin_redirect("index.php?module=config-settings");
1252              }
1253          }
1254  
1255          // Cache groups
1256          $groups = array_keys($cache_settings);
1257          $groups = implode(',', $groups);
1258          $query = $db->simple_select("settinggroups", "*", "gid IN ({$groups})", array('order_by' => 'disporder'));
1259          while($group = $db->fetch_array($query))
1260          {
1261              $cache_groups[$group['gid']] = $group;
1262          }
1263  
1264          // Page header only if not AJAX
1265          if(!isset($mybb->input['ajax_search']))
1266          {
1267              $page->add_breadcrumb_item($lang->settings_search);
1268              $page->output_header($lang->board_settings." - {$lang->settings_search}");
1269          }
1270      }
1271      elseif($mybb->input['gid'])
1272      {
1273          // Group listing
1274          // Cache groups
1275          $query = $db->simple_select("settinggroups", "*", "gid = '".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
1276          $groupinfo = $db->fetch_array($query);
1277          $cache_groups[$groupinfo['gid']] = $groupinfo;
1278  
1279          if(!$db->num_rows($query))
1280          {
1281              $page->output_error($lang->error_invalid_gid2);
1282          }
1283  
1284          // Cache settings
1285          $query = $db->simple_select("settings", "*", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'", array('order_by' => 'disporder'));
1286          while($setting = $db->fetch_array($query))
1287          {
1288              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1289          }
1290  
1291          if(!$db->num_rows($query))
1292          {
1293              flash_message($lang->error_no_settings_found, 'error');
1294              admin_redirect("index.php?module=config-settings");
1295          }
1296  
1297          $group_lang_var = "setting_group_{$groupinfo['name']}";
1298          if(isset($lang->$group_lang_var))
1299          {
1300              $groupinfo['title'] = $lang->$group_lang_var;
1301          }
1302  
1303          // Page header
1304          $page->add_breadcrumb_item($groupinfo['title']);
1305          $page->output_header($lang->board_settings." - {$groupinfo['title']}");
1306      }
1307      else
1308      {
1309          // All settings list
1310          // Cache groups
1311          $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
1312          while($group = $db->fetch_array($query))
1313          {
1314              $cache_groups[$group['gid']] = $group;
1315          }
1316  
1317          if(!$db->num_rows($query))
1318          {
1319              $page->output_error($lang->error_invalid_gid2);
1320          }
1321  
1322          // Cache settings
1323          $query = $db->simple_select("settings", "*", "", array('order_by' => 'disporder'));
1324          while($setting = $db->fetch_array($query))
1325          {
1326              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1327          }
1328  
1329          // Page header
1330          $page->add_breadcrumb_item($lang->show_all_settings);
1331          $page->output_header($lang->board_settings." - {$lang->show_all_settings}");
1332      }
1333  
1334      // Build individual forms as per settings group
1335      foreach($cache_groups as $groupinfo)
1336      {
1337          $form = new Form("index.php?module=config-settings&amp;action=change", "post", "change");
1338          echo $form->generate_hidden_field("gid", $groupinfo['gid']);
1339          $buttons = array($form->generate_submit_button($lang->save_settings));
1340          $group_lang_var = "setting_group_{$groupinfo['name']}";
1341          if(isset($lang->$group_lang_var))
1342          {
1343              $groupinfo['title'] = $lang->$group_lang_var;
1344          }
1345  
1346          $form_container = new FormContainer($groupinfo['title']);
1347  
1348          if(empty($cache_settings[$groupinfo['gid']]))
1349          {
1350              $form_container->output_cell($lang->error_no_settings_found);
1351              $form_container->construct_row();
1352  
1353              $form_container->end();
1354              echo '<br />';
1355  
1356              continue;
1357          }
1358  
1359          foreach($cache_settings[$groupinfo['gid']] as $setting)
1360          {
1361              $options = "";
1362              $type = explode("\n", $setting['optionscode']);
1363              $type[0] = trim($type[0]);
1364              $element_name = "upsetting[{$setting['name']}]";
1365              $element_id = "setting_{$setting['name']}";
1366              if($type[0] == "text" || $type[0] == "")
1367              {
1368                  $setting_code = $form->generate_text_box($element_name, $setting['value'], array('id' => $element_id));
1369              }
1370              else if($type[0] == "numeric")
1371              {
1372                  $field_options = array('id' => $element_id);
1373                  if(count($type) > 1)
1374                  {
1375                      for($i=1; $i < count($type); $i++)
1376                      {
1377                          $optionsexp = explode("=", $type[$i]);
1378                          $opt = array_map('trim', $optionsexp);
1379                          if(in_array($opt[0], array('min', 'max', 'step')))
1380                          {
1381                              if($opt[0] != 'step' || $opt[1] != 'any')
1382                              {
1383                                  $opt[1] = (float)$opt[1];
1384                              }
1385                              $field_options[$opt[0]] = $opt[1];
1386                          }
1387                      }
1388                  }
1389                  $setting_code = $form->generate_numeric_field($element_name, $setting['value'], $field_options);
1390              }
1391              else if($type[0] == "textarea")
1392              {
1393                  $setting_code = $form->generate_text_area($element_name, $setting['value'], array('id' => $element_id));
1394              }
1395              else if($type[0] == "yesno")
1396              {
1397                  $setting_code = $form->generate_yes_no_radio($element_name, $setting['value'], true, array('id' => $element_id.'_yes', 'class' => $element_id), array('id' => $element_id.'_no', 'class' => $element_id));
1398              }
1399              else if($type[0] == "onoff")
1400              {
1401                  $setting_code = $form->generate_on_off_radio($element_name, $setting['value'], true, array('id' => $element_id.'_on', 'class' => $element_id), array('id' => $element_id.'_off', 'class' => $element_id));
1402              }
1403              else if($type[0] == "cpstyle")
1404              {
1405                  $dir = @opendir(MYBB_ROOT.$config['admin_dir']."/styles");
1406  
1407                  $folders = array();
1408                  while($folder = readdir($dir))
1409                  {
1410                      if($file != "." && $file != ".." && @file_exists(MYBB_ROOT.$config['admin_dir']."/styles/$folder/main.css"))
1411                      {
1412                          $folders[$folder] = ucfirst($folder);
1413                      }
1414                  }
1415                  closedir($dir);
1416                  ksort($folders);
1417                  $setting_code = $form->generate_select_box($element_name, $folders, $setting['value'], array('id' => $element_id));
1418              }
1419              else if($type[0] == "language")
1420              {
1421                  $languages = $lang->get_languages();
1422                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1423              }
1424              else if($type[0] == "adminlanguage")
1425              {
1426                  $languages = $lang->get_languages(1);
1427                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1428              }
1429              else if($type[0] == "passwordbox")
1430              {
1431                  $setting_code = $form->generate_password_box($element_name, $setting['value'], array('id' => $element_id));
1432              }
1433              else if($type[0] == "php")
1434              {
1435                  $setting['optionscode'] = substr($setting['optionscode'], 3);
1436                  eval("\$setting_code = \"".$setting['optionscode']."\";");
1437              }
1438              else if($type[0] == "forumselect")
1439              {
1440                  $selected_values = '';
1441                  if($setting['value'] != '' && $setting['value'] != -1)
1442                  {
1443                      $selected_values = explode(',', (string)$setting['value']);
1444  
1445                      foreach($selected_values as &$value)
1446                      {
1447                          $value = (int)$value;
1448                      }
1449                      unset($value);
1450                  }
1451  
1452                  $forum_checked = array('all' => '', 'custom' => '', 'none' => '');
1453                  if($setting['value'] == -1)
1454                  {
1455                      $forum_checked['all'] = 'checked="checked"';
1456                  }
1457                  elseif($setting['value'] != '')
1458                  {
1459                      $forum_checked['custom'] = 'checked="checked"';
1460                  }
1461                  else
1462                  {
1463                      $forum_checked['none'] = 'checked="checked"';
1464                  }
1465  
1466                  print_selection_javascript();
1467  
1468                  $setting_code = "
1469                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1470                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"all\" {$forum_checked['all']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
1471                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"custom\" {$forum_checked['custom']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
1472                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1473                          <table cellpadding=\"4\">
1474                              <tr>
1475                                  <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
1476                                  <td>".$form->generate_forum_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1477                              </tr>
1478                          </table>
1479                      </dd>
1480                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"none\" {$forum_checked['none']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
1481                  </dl>
1482                  <script type=\"text/javascript\">
1483                      checkAction('{$element_id}');
1484                  </script>";
1485              }
1486              else if($type[0] == "forumselectsingle")
1487              {
1488                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1489                  $setting_code = $form->generate_forum_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1490              }
1491              else if($type[0] == "groupselect")
1492              {
1493                  $selected_values = '';
1494                  if($setting['value'] != '' && $setting['value'] != -1)
1495                  {
1496                      $selected_values = explode(',', (string)$setting['value']);
1497  
1498                      foreach($selected_values as &$value)
1499                      {
1500                          $value = (int)$value;
1501                      }
1502                      unset($value);
1503                  }
1504  
1505                  $group_checked = array('all' => '', 'custom' => '', 'none' => '');
1506                  if($setting['value'] == -1)
1507                  {
1508                      $group_checked['all'] = 'checked="checked"';
1509                  }
1510                  elseif($setting['value'] != '')
1511                  {
1512                      $group_checked['custom'] = 'checked="checked"';
1513                  }
1514                  else
1515                  {
1516                      $group_checked['none'] = 'checked="checked"';
1517                  }
1518  
1519                  print_selection_javascript();
1520  
1521                  $setting_code = "
1522                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1523                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"all\" {$group_checked['all']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
1524                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"custom\" {$group_checked['custom']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
1525                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1526                          <table cellpadding=\"4\">
1527                              <tr>
1528                                  <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
1529                                  <td>".$form->generate_group_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1530                              </tr>
1531                          </table>
1532                      </dd>
1533                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"none\" {$group_checked['none']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
1534                  </dl>
1535                  <script type=\"text/javascript\">
1536                      checkAction('{$element_id}');
1537                  </script>";
1538              }
1539              else if($type[0] == "groupselectsingle")
1540              {
1541                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1542                  $setting_code = $form->generate_group_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1543              }
1544              else if($type[0] == "prefixselect")
1545              {
1546                  $selected_values = '';
1547                  if($setting['value'] != '' && $setting['value'] != -1)
1548                  {
1549                      $selected_values = explode(',', (string)$setting['value']);
1550                      foreach($selected_values as &$value)
1551                      {
1552                          $value = (int)$value;
1553                      }
1554                      unset($value);
1555                  }
1556                  $prefix_checked = array('all' => '', 'custom' => '', 'none' => '');
1557                  if($setting['value'] == -1)
1558                  {
1559                      $prefix_checked['all'] = 'checked="checked"';
1560                  }
1561                  elseif($setting['value'] != '')
1562                  {
1563                      $prefix_checked['custom'] = 'checked="checked"';
1564                  }
1565                  else
1566                  {
1567                      $prefix_checked['none'] = 'checked="checked"';
1568                  }
1569                  print_selection_javascript();
1570                  $setting_code = "
1571                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1572                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"all\" {$prefix_checked['all']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_prefix}</strong></label></dt>
1573                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"custom\" {$prefix_checked['custom']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_prefix}</strong></label></dt>
1574                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1575                          <table cellpadding=\"4\">
1576                              <tr>
1577                                  <td valign=\"top\"><small>{$lang->prefix_colon}</small></td>
1578                                  <td>".$form->generate_prefix_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1579                              </tr>
1580                          </table>
1581                      </dd>
1582                      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"none\" {$prefix_checked['none']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
1583                  </dl>
1584                  <script type=\"text/javascript\">
1585                      checkAction('{$element_id}');
1586                  </script>";
1587              }
1588              else
1589              {
1590                  $typecount = count($type);
1591  
1592                  if($type[0] == 'checkbox')
1593                  {
1594                      $multivalue = explode(',', $setting['value']);
1595                  }
1596  
1597                  for($i = 0; $i < $typecount; $i++)
1598                  {
1599                      $optionsexp = explode("=", $type[$i]);
1600                      if(!isset($optionsexp[1]))
1601                      {
1602                          continue;
1603                      }
1604                      $title_lang = "setting_{$setting['name']}_{$optionsexp[0]}";
1605                      if(isset($lang->$title_lang))
1606                      {
1607                          $optionsexp[1] = $lang->$title_lang;
1608                      }
1609  
1610                      if($type[0] == "select")
1611                      {
1612                          $option_list[$optionsexp[0]] = htmlspecialchars_uni($optionsexp[1]);
1613                      }
1614                      else if($type[0] == "radio")
1615                      {
1616                          if($setting['value'] == $optionsexp[0])
1617                          {
1618                              $option_list[$i] = $form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, "checked" => 1, 'class' => $element_id));
1619                          }
1620                          else
1621                          {
1622                              $option_list[$i] = $form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1623                          }
1624                      }
1625                      else if($type[0] == "checkbox")
1626                      {
1627                          if(in_array($optionsexp[0], $multivalue))
1628                          {
1629                              $option_list[$i] = $form->generate_check_box("{$element_name}[]", $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, "checked" => 1, 'class' => $element_id));
1630                          }
1631                          else
1632                          {
1633                              $option_list[$i] = $form->generate_check_box("{$element_name}[]", $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1634                          }
1635                      }
1636                  }
1637  
1638                  if($type[0] == "select")
1639                  {
1640                      $setting_code = $form->generate_select_box($element_name, $option_list, $setting['value'], array('id' => $element_id));
1641                  }
1642                  else
1643                  {
1644                      $setting_code = implode("<br />", $option_list);
1645  
1646                      if($type[0] == 'checkbox')
1647                      {
1648                          $setting_code .= $form->generate_hidden_field("isvisible_{$setting['name']}", 1);
1649                      }
1650                  }
1651                  $option_list = array();
1652              }
1653  
1654              // Do we have a custom language variable for this title or description?
1655              $title_lang = "setting_".$setting['name'];
1656              $desc_lang = $title_lang."_desc";
1657              if(isset($lang->$title_lang))
1658              {
1659                  $setting['title'] = $lang->$title_lang;
1660              }
1661              if(isset($lang->$desc_lang))
1662              {
1663                  $setting['description'] = $lang->$desc_lang;
1664              }
1665              $form_container->output_row(htmlspecialchars_uni($setting['title']), $setting['description'], $setting_code, '', array(), array('id' => 'row_'.$element_id));
1666          }
1667          $form_container->end();
1668  
1669          $form->output_submit_wrapper($buttons);
1670          $form->end();
1671          echo '<br />';
1672      }
1673  
1674      print_setting_peekers();
1675  
1676      if(!isset($mybb->input['ajax_search']))
1677      {
1678          $page->output_footer();
1679      }
1680  }
1681  
1682  if(!$mybb->input['action'])
1683  {
1684      $plugins->run_hooks("admin_config_settings_start");
1685  
1686      $page->extra_header .= <<<EOF
1687      <script type="text/javascript">
1688      <!--
1689      lang.searching = "{$lang->searching}";
1690      lang.search_error = "{$lang->search_error}";
1691      lang.search_done = "{$lang->search_done}";
1692      // -->
1693      </script>
1694  EOF;
1695  
1696      $page->output_header($lang->board_settings);
1697      if(isset($message))
1698      {
1699          $page->output_inline_message($message);
1700      }
1701  
1702      $sub_tabs['change_settings'] = array(
1703          'title' => $lang->change_settings,
1704          'link' => "index.php?module=config-settings",
1705          'description' => $lang->change_settings_desc
1706      );
1707  
1708      $sub_tabs['add_setting'] = array(
1709          'title' => $lang->add_new_setting,
1710          'link' => "index.php?module=config-settings&amp;action=add"
1711      );
1712  
1713      $sub_tabs['add_setting_group'] = array(
1714          'title' => $lang->add_new_setting_group,
1715          'link' => "index.php?module=config-settings&amp;action=addgroup"
1716      );
1717  
1718      $sub_tabs['modify_setting'] = array(
1719          'title' => $lang->modify_existing_settings,
1720          'link' => "index.php?module=config-settings&amp;action=manage",
1721      );
1722  
1723      $page->output_nav_tabs($sub_tabs, 'change_settings');
1724  
1725      // Search form
1726      echo "<div style=\"text-align: right; margin-bottom: 3px;\">";
1727      $search = new Form("index.php", 'get', 'settings_search', 0, 'settings_search');
1728      echo $search->generate_hidden_field('module', 'config/settings');
1729      echo $search->generate_hidden_field('action', 'change');
1730      echo $search->generate_text_box('search', $lang->settings_search, array('id' => 'search', 'class' => 'search_default field150 field_small'));
1731      echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />";
1732      $search->end();
1733      echo "</div>\n";
1734  
1735      echo '<div id="search_results">&nbsp;</div><div id="group_list">';
1736      $table = new Table;
1737      $table->construct_header($lang->setting_groups);
1738  
1739      switch($db->type)
1740      {
1741          case "pgsql":
1742          $query = $db->query("
1743              SELECT g.*, COUNT(s.sid) AS settingcount
1744              FROM ".TABLE_PREFIX."settinggroups g
1745              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1746              WHERE g.isdefault = 1
1747              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1748              ORDER BY g.disporder
1749          ");
1750          break;
1751          default:
1752          $query = $db->query("
1753              SELECT g.*, COUNT(s.sid) AS settingcount
1754              FROM ".TABLE_PREFIX."settinggroups g
1755              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1756              WHERE g.isdefault = 1
1757              GROUP BY g.gid
1758              ORDER BY g.disporder
1759          ");
1760      }
1761      while($group = $db->fetch_array($query))
1762      {
1763          $group_lang_var = "setting_group_{$group['name']}";
1764          if(isset($lang->$group_lang_var))
1765          {
1766              $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1767          }
1768          else
1769          {
1770              $group_title = htmlspecialchars_uni($group['title']);
1771          }
1772  
1773          $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1774          if(isset($lang->$group_desc_lang_var))
1775          {
1776              $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1777          }
1778          else
1779          {
1780              $group_desc = htmlspecialchars_uni($group['description']);
1781          }
1782  
1783          $table->construct_cell("<strong><a href=\"index.php?module=config-settings&amp;action=change&amp;gid={$group['gid']}\">{$group_title}</a></strong> ({$group['settingcount']} {$lang->bbsettings})<br /><small>{$group_desc}</small>");
1784          $table->construct_row();
1785      }
1786  
1787      $table->output("<span style=\"float: right;\"><small><a href=\"index.php?module=config-settings&amp;action=change\">{$lang->show_all_settings}</a></small></span>{$lang->board_settings}");
1788  
1789      // Plugin Settings
1790      switch($db->type)
1791      {
1792          case "pgsql":
1793          $query = $db->query("
1794              SELECT g.*, COUNT(s.sid) AS settingcount
1795              FROM ".TABLE_PREFIX."settinggroups g
1796              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1797              WHERE g.isdefault <> 1
1798              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1799              ORDER BY g.disporder
1800          ");
1801          break;
1802          default:
1803          $query = $db->query("
1804              SELECT g.*, COUNT(s.sid) AS settingcount
1805              FROM ".TABLE_PREFIX."settinggroups g
1806              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1807              WHERE g.isdefault <> 1
1808              GROUP BY g.gid
1809              ORDER BY g.disporder
1810          ");
1811      }
1812  
1813      if($db->num_rows($query))
1814      {
1815          $table = new Table;
1816          $table->construct_header($lang->setting_groups);
1817  
1818          while($group = $db->fetch_array($query))
1819          {
1820              $group_lang_var = "setting_group_{$group['name']}";
1821              if($lang->$group_lang_var)
1822              {
1823                  $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1824              }
1825              else
1826              {
1827                  $group_title = htmlspecialchars_uni($group['title']);
1828              }
1829  
1830              $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1831              if($lang->$group_desc_lang_var)
1832              {
1833                  $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1834              }
1835              else
1836              {
1837                  $group_desc = htmlspecialchars_uni($group['description']);
1838              }
1839  
1840              $table->construct_cell("<strong><a href=\"index.php?module=config-settings&amp;action=change&amp;gid={$group['gid']}\">{$group_title}</a></strong> ({$group['settingcount']} {$lang->bbsettings})<br /><small>{$group_desc}</small>");
1841              $table->construct_row();
1842          }
1843  
1844          $table->output($lang->plugin_settings);
1845      }
1846  
1847      echo '</div>';
1848  
1849      echo '
1850  <script type="text/javascript" src="./jscripts/search.js?ver=1821"></script>
1851  <script type="text/javascript">
1852  //<!--
1853  $(function(){
1854      SettingSearch.init("'.$lang->settings_search.'","'.$lang->error_ajax_unknown.'");
1855  });
1856  //-->
1857  </script>';
1858  
1859      print_setting_peekers();
1860      $page->output_footer();
1861  }
1862  
1863  /**
1864   * Print all the peekers for all of the default settings
1865   */
1866  function print_setting_peekers()
1867  {
1868      global $plugins;
1869  
1870      $peekers = array(
1871          'new Peeker($(".setting_boardclosed"), $("#row_setting_boardclosed_reason"), 1, true)',
1872          'new Peeker($(".setting_gzipoutput"), $("#row_setting_gziplevel"), 1, true)',
1873          'new Peeker($(".setting_useerrorhandling"), $("#row_setting_errorlogmedium, #row_setting_errorloglocation"), 1, true)',
1874          'new Peeker($("#setting_subforumsindex"), $("#row_setting_subforumsstatusicons"), /[^0+|]/, false)',
1875          'new Peeker($(".setting_showsimilarthreads"), $("#row_setting_similarityrating, #row_setting_similarlimit"), 1, true)',
1876          'new Peeker($(".setting_disableregs"), $("#row_setting_regtype, #row_setting_securityquestion, #row_setting_regtime, #row_setting_allowmultipleemails, #row_setting_hiddencaptchaimage, #row_setting_betweenregstime"), 0, true)',
1877          'new Peeker($(".setting_hiddencaptchaimage"), $("#row_setting_hiddencaptchaimagefield"), 1, true)',
1878          'new Peeker($("#setting_failedlogincount"), $("#row_setting_failedlogintime, #row_setting_failedlogintext"), /[^0+|]/, false)',
1879          'new Peeker($(".setting_postfloodcheck"), $("#row_setting_postfloodsecs"), 1, true)',
1880          'new Peeker($("#setting_postmergemins"), $("#row_setting_postmergefignore, #row_setting_postmergeuignore, #row_setting_postmergesep"), /[^0+|]/, false)',
1881          'new Peeker($(".setting_enablememberlist"), $("#row_setting_membersperpage, #row_setting_default_memberlist_sortby, #row_setting_default_memberlist_order, #row_setting_memberlistmaxavatarsize"), 1, true)',
1882          'new Peeker($(".setting_enablereputation"), $("#row_setting_repsperpage, #row_setting_posrep, #row_setting_neurep, #row_setting_negrep, #row_setting_postrep, #row_setting_multirep, #row_setting_maxreplength, #row_setting_minreplength"), 1, true)',
1883          'new Peeker($(".setting_enablewarningsystem"), $("#row_setting_allowcustomwarnings, #row_setting_canviewownwarning, #row_setting_maxwarningpoints, #row_setting_allowanonwarningpms"), 1, true)',
1884          'new Peeker($(".setting_enablepms"), $("#row_setting_pmsallowhtml, #row_setting_pmsallowmycode, #row_setting_pmsallowsmilies, #row_setting_pmsallowimgcode, #row_setting_pmsallowvideocode, #row_setting_pmquickreply, #row_setting_pmfloodsecs, #row_setting_showpmip, #row_setting_maxpmquotedepth"), 1, true)',
1885          'new Peeker($(".setting_smilieinserter"), $("#row_setting_smilieinsertertot, #row_setting_smilieinsertercols"), 1, true)',
1886          'new Peeker($("#setting_mail_handler"), $("#row_setting_smtp_host, #row_setting_smtp_port, #row_setting_smtp_user, #row_setting_smtp_pass, #row_setting_secure_smtp"), "smtp", false)',
1887          'new Peeker($("#setting_mail_handler"), $("#row_setting_mail_parameters"), "mail", false)',
1888          'new Peeker($("#setting_captchaimage"), $("#row_setting_recaptchapublickey, #row_setting_recaptchaprivatekey"), /(4|5|8)/, false)',
1889          'new Peeker($("#setting_captchaimage"), $("#row_setting_recaptchascore"), /(8)/, false)',
1890          'new Peeker($("#setting_captchaimage"), $("#row_setting_hcaptchapublickey, #row_setting_hcaptchaprivatekey"), /(6|7)/, false)',
1891          'new Peeker($("#setting_captchaimage"), $("#row_setting_hcaptchaprivatekey, #row_setting_hcaptchaprivatekey"), /(6|7)/, false)',
1892          'new Peeker($("#setting_captchaimage"), $("#row_setting_hcaptchatheme"), 6, false)',
1893          'new Peeker($("#setting_captchaimage"), $("#row_setting_hcaptchasize"), 6, false)',
1894          'new Peeker($(".setting_contact"), $("#row_setting_contact_guests, #row_setting_contact_badwords, #row_setting_contact_maxsubjectlength, #row_setting_contact_minmessagelength, #row_setting_contact_maxmessagelength"), 1, true)',
1895          'new Peeker($(".setting_enablepruning"), $("#row_setting_enableprunebyposts, #row_setting_pruneunactived, #row_setting_prunethreads"), 1, true)',
1896          'new Peeker($(".setting_enableprunebyposts"), $("#row_setting_prunepostcount, #row_setting_dayspruneregistered, #row_setting_prunepostcountall"), 1, true)',
1897          'new Peeker($(".setting_pruneunactived"), $("#row_setting_dayspruneunactivated"), 1, true)',
1898          'new Peeker($(".setting_statsenabled"), $("#row_setting_statscachetime, #row_setting_statslimit, #row_setting_statstopreferrer"), 1, true)',
1899          'new Peeker($(".setting_purgespammergroups_forums_groups_check"), $("#row_setting_purgespammerpostlimit, #row_setting_purgespammerbandelete, #row_setting_purgespammerapikey"), /^(?!none)/, true)',
1900          'new Peeker($(".setting_purgespammerbandelete"),$("#row_setting_purgespammerbangroup, #row_setting_purgespammerbanreason"), "ban", true)',
1901          'new Peeker($("#setting_maxloginattempts"), $("#row_setting_loginattemptstimeout"), /[^0+|]/, false)',
1902          'new Peeker($(".setting_bbcodeinserter"), $("#row_setting_partialmode, #row_setting_smilieinserter"), 1, true)',
1903          'new Peeker($(".setting_portal"), $("#row_setting_portal_announcementsfid, #row_setting_portal_showwelcome, #row_setting_portal_showpms, #row_setting_portal_showstats, #row_setting_portal_showwol, #row_setting_portal_showsearch, #row_setting_portal_showdiscussions"), 1, true)',
1904          'new Peeker($(".setting_portal_announcementsfid_forums_groups_check"), $("#row_setting_portal_numannouncements"), /^(?!none)/, true)',
1905          'new Peeker($(".setting_portal_showdiscussions"), $("#row_setting_portal_showdiscussionsnum, #row_setting_portal_excludediscussion"), 1, true)',
1906          'new Peeker($(".setting_enableattachments"), $("#row_setting_maxattachments, #row_setting_attachthumbnails"), 1, true)',
1907          'new Peeker($(".setting_attachthumbnails"), $("#row_setting_attachthumbh, #row_setting_attachthumbw"), "yes", true)',
1908          'new Peeker($(".setting_showbirthdays"), $("#row_setting_showbirthdayspostlimit"), 1, true)',
1909          'new Peeker($("#setting_betweenregstime"), $("#row_setting_maxregsbetweentime"), /[^0+|]/, false)',
1910          'new Peeker($(".setting_usecdn"), $("#row_setting_cdnurl, #row_setting_cdnpath"), 1, true)',
1911          'new Peeker($("#setting_errorlogmedium"), $("#row_setting_errorloglocation"), /^(log|both)/, false)',
1912          'new Peeker($(".setting_sigmycode"), $("#row_setting_sigcountmycode, #row_setting_sigimgcode"), 1, true)',
1913          'new Peeker($(".setting_pmsallowmycode"), $("#row_setting_pmsallowimgcode, #row_setting_pmsallowvideocode"), 1, true)',
1914          'new Peeker($(".setting_enableshowteam"), $("#row_setting_showaddlgroups, #row_setting_showgroupleaders"), 1, true)',
1915          'new Peeker($(".setting_usereferrals"), $("#row_setting_referralsperpage"), 1, true)',
1916      );
1917  
1918      $peekers = $plugins->run_hooks("admin_settings_print_peekers", $peekers);
1919  
1920      $setting_peekers = implode("\n            ", $peekers);
1921  
1922      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
1923      <script type="text/javascript">
1924          $(function() {
1925              ' . $setting_peekers . '
1926          });
1927      </script>';
1928  }


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