[ Index ]

PHP Cross Reference of MyBB 1.8.21

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          //"php" => $lang->php // Internal Use Only
 430      );
 431  
 432      $form_container->output_row($lang->type." <em>*</em>", "", $form->generate_select_box("type", $setting_types, $mybb->input['type'], array('id' => 'type')), 'type');
 433      $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'));
 434      $form_container->output_row($lang->value, "", $form->generate_text_area('value', $mybb->input['value'], array('id' => 'value')), 'value');
 435      $form_container->end();
 436  
 437      $buttons[] = $form->generate_submit_button($lang->insert_new_setting);
 438      $form->output_submit_wrapper($buttons);
 439      $form->end();
 440  
 441      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 442      <script type="text/javascript">
 443          $(function() {
 444              new Peeker($("#type"), $("#row_extra"), /^(select|radio|checkbox|php)$/, false);
 445          });
 446          // Add a star to the extra row since the "extra" is required if the box is shown
 447          add_star("row_extra");
 448      </script>';
 449  
 450      $page->output_footer();
 451  }
 452  
 453  // Editing a particular setting
 454  if($mybb->input['action'] == "edit")
 455  {
 456      $query = $db->simple_select("settings", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
 457      $setting = $db->fetch_array($query);
 458  
 459      // Does the setting not exist?
 460      if(!$setting['sid'])
 461      {
 462          flash_message($lang->error_invalid_sid, 'error');
 463          admin_redirect("index.php?module=config-settings");
 464      }
 465  
 466      // Prevent editing of default
 467      if($setting['isdefault'] == 1)
 468      {
 469          flash_message($lang->error_cannot_edit_default, 'error');
 470          admin_redirect("index.php?module=config-settings&action=manage");
 471      }
 472  
 473      $plugins->run_hooks("admin_config_settings_edit");
 474  
 475      $type = explode("\n", $setting['optionscode'], 2);
 476      $type = trim($type[0]);
 477      if($type == "php")
 478      {
 479          flash_message($lang->error_cannot_edit_php, 'error');
 480          admin_redirect("index.php?module=config-settings&action=manage");
 481      }
 482  
 483      if($mybb->request_method == "post")
 484      {
 485          if(!trim($mybb->input['title']))
 486          {
 487              $errors[] = $lang->error_missing_title;
 488          }
 489  
 490          if(!trim($mybb->input['name']))
 491          {
 492              $errors[] = $lang->error_missing_name;
 493          }
 494          $query = $db->simple_select("settings", "title", "name='".$db->escape_string($mybb->input['name'])."' AND sid != '{$setting['sid']}'");
 495          if($db->num_rows($query) > 0)
 496          {
 497              $dup_setting_title = $db->fetch_field($query, 'title');
 498              $errors[] = $lang->sprintf($lang->error_duplicate_name, $dup_setting_title);
 499          }
 500  
 501          // do some type filtering
 502          $mybb->input['type'] = str_replace("\n", "", $mybb->input['type']);
 503          if(strtolower(substr($mybb->input['type'], 0, 3)) == "php")
 504          {
 505              $mybb->input['type'] = "";
 506          }
 507  
 508          if(!$mybb->input['type'])
 509          {
 510              $errors[] = $lang->error_invalid_type;
 511          }
 512  
 513          if(!$errors)
 514          {
 515              if($mybb->input['type'] == "custom")
 516              {
 517                  $options_code = $mybb->input['extra'];
 518              }
 519              else if($mybb->input['extra'])
 520              {
 521                  $options_code = "{$mybb->input['type']}\n{$mybb->input['extra']}";
 522              }
 523              else
 524              {
 525                  $options_code = $mybb->input['type'];
 526              }
 527  
 528              $mybb->input['name'] = str_replace("\\", '', $mybb->input['name']);
 529              $mybb->input['name'] = str_replace('$', '', $mybb->input['name']);
 530              $mybb->input['name'] = str_replace("'", '', $mybb->input['name']);
 531  
 532              if($options_code == "numeric")
 533              {
 534                  $value = $mybb->get_input('value', MyBB::INPUT_INT);
 535              }
 536              else
 537              {
 538                  $value = $db->escape_string($mybb->input['value']);
 539              }
 540  
 541              $updated_setting = array(
 542                  "name" => $db->escape_string($mybb->input['name']),
 543                  "title" => $db->escape_string($mybb->input['title']),
 544                  "description" => $db->escape_string($mybb->input['description']),
 545                  "optionscode" => $db->escape_string($options_code),
 546                  "value" => $value,
 547                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
 548                  "gid" => $mybb->get_input('gid', MyBB::INPUT_INT)
 549              );
 550  
 551              $plugins->run_hooks("admin_config_settings_edit_commit");
 552  
 553              $db->update_query("settings", $updated_setting, "sid='{$setting['sid']}'");
 554              rebuild_settings();
 555  
 556              // Log admin action
 557              log_admin_action($setting['sid'], $mybb->input['title']);
 558  
 559              flash_message($lang->success_setting_updated, 'success');
 560              admin_redirect("index.php?module=config-settings&action=manage");
 561          }
 562      }
 563  
 564      $page->add_breadcrumb_item($lang->edit_setting);
 565      $page->output_header($lang->board_settings." - ".$lang->edit_setting);
 566  
 567      $sub_tabs['change_settings'] = array(
 568          'title' => $lang->change_settings,
 569          'link' => "index.php?module=config-settings",
 570      );
 571  
 572      $sub_tabs['add_setting'] = array(
 573          'title' => $lang->add_new_setting,
 574          'link' => "index.php?module=config-settings&amp;action=add"
 575      );
 576  
 577      $sub_tabs['add_setting_group'] = array(
 578          'title' => $lang->add_new_setting_group,
 579          'link' => "index.php?module=config-settings&amp;action=addgroup"
 580      );
 581  
 582      $sub_tabs['modify_setting'] = array(
 583          'title' => $lang->modify_existing_settings,
 584          'link' => "index.php?module=config-settings&amp;action=manage",
 585          'description' => $lang->modify_existing_settings_desc
 586      );
 587  
 588      $page->output_nav_tabs($sub_tabs, 'modify_setting');
 589  
 590      $form = new Form("index.php?module=config-settings&amp;action=edit", "post", "edit");
 591  
 592      echo $form->generate_hidden_field("sid", $setting['sid']);
 593  
 594      if($errors)
 595      {
 596          $setting_data = $mybb->input;
 597          $page->output_inline_error($errors);
 598      }
 599      else
 600      {
 601          $setting_data = $setting;
 602          $type = explode("\n", $setting['optionscode'], 2);
 603          $setting_data['type'] = trim($type[0]);
 604          $setting_data['extra'] = trim($type[1]);
 605      }
 606  
 607      $form_container = new FormContainer($lang->modify_setting);
 608      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $setting_data['title'], array('id' => 'title')), 'title');
 609      $form_container->output_row($lang->description, "", $form->generate_text_area('description', $setting_data['description'], array('id' => 'description')), 'description');
 610  
 611      $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
 612      while($group = $db->fetch_array($query))
 613      {
 614          $group_lang_var = "setting_group_{$group['name']}";
 615          if($lang->$group_lang_var)
 616          {
 617              $options[$group['gid']] = htmlspecialchars_uni($lang->$group_lang_var);
 618          }
 619          else
 620          {
 621              $options[$group['gid']] = htmlspecialchars_uni($group['title']);
 622          }
 623      }
 624      $form_container->output_row($lang->group." <em>*</em>", "", $form->generate_select_box("gid", $options, $setting_data['gid'], array('id' => 'gid')), 'gid');
 625      $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $setting_data['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 626      $form_container->end();
 627  
 628      $form_container = new FormContainer($lang->setting_configuration, 1);
 629      $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $setting_data['name'], array('id' => 'name')), 'name');
 630  
 631      $setting_types = array(
 632          "text" => $lang->text,
 633          "numeric" => $lang->numeric_text,
 634          "textarea" => $lang->textarea,
 635          "yesno" => $lang->yesno,
 636          "onoff" => $lang->onoff,
 637          "select" => $lang->select,
 638          "forumselect" => $lang->forum_selection_box,
 639          "forumselectsingle" => $lang->forum_selection_single,
 640          "groupselect" => $lang->group_selection_box,
 641          "groupselectsingle" => $lang->group_selection_single,
 642          "radio" => $lang->radio,
 643          "checkbox" => $lang->checkbox,
 644          "language" => $lang->language_selection_box,
 645          "adminlanguage" => $lang->adminlanguage,
 646          "cpstyle" => $lang->cpstyle
 647          //"php" => $lang->php // Internal Use Only
 648      );
 649  
 650      $form_container->output_row($lang->type." <em>*</em>", "", $form->generate_select_box("type", $setting_types, $setting_data['type'], array('id' => 'type')), 'type');
 651      $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'));
 652      $form_container->output_row($lang->value, '', $form->generate_text_area('value', $setting_data['value'], array('id' => 'value')), 'value');
 653      $form_container->end();
 654  
 655      $buttons[] = $form->generate_submit_button($lang->update_setting);
 656      $form->output_submit_wrapper($buttons);
 657      $form->end();
 658  
 659      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 660      <script type="text/javascript">
 661          $(function() {
 662              new Peeker($("#type"), $("#row_extra"), /^(select|radio|checkbox|php)$/, false);
 663          });
 664          // Add a star to the extra row since the "extra" is required if the box is shown
 665          add_star("row_extra");
 666      </script>';
 667  
 668      $page->output_footer();
 669  }
 670  
 671  // Delete Setting
 672  if($mybb->input['action'] == "delete")
 673  {
 674      $query = $db->simple_select("settings", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
 675      $setting = $db->fetch_array($query);
 676  
 677      // Does the setting not exist?
 678      if(!$setting['sid'])
 679      {
 680          flash_message($lang->error_invalid_sid, 'error');
 681          admin_redirect("index.php?module=config-settings&action=manage");
 682      }
 683  
 684      // Prevent editing of default
 685      if($setting['isdefault'] == 1)
 686      {
 687          flash_message($lang->error_cannot_edit_default, 'error');
 688          admin_redirect("index.php?module=config-settings&action=manage");
 689      }
 690  
 691      // User clicked no
 692      if($mybb->input['no'])
 693      {
 694          admin_redirect("index.php?module=config-settings&action=manage");
 695      }
 696  
 697      $plugins->run_hooks("admin_config_settings_delete");
 698  
 699      if($mybb->request_method == "post")
 700      {
 701          // Delete the setting
 702          $db->delete_query("settings", "sid='{$setting['sid']}'");
 703  
 704          rebuild_settings();
 705  
 706          $plugins->run_hooks("admin_config_settings_delete_commit");
 707  
 708          // Log admin action
 709          log_admin_action($setting['sid'], $setting['title']);
 710  
 711          flash_message($lang->success_setting_deleted, 'success');
 712          admin_redirect("index.php?module=config-settings&action=manage");
 713      }
 714      else
 715      {
 716          $page->output_confirm_action("index.php?module=config-settings&amp;action=delete&amp;sid={$setting['sid']}", $lang->confirm_setting_deletion);
 717      }
 718  }
 719  
 720  // Modify Existing Settings
 721  if($mybb->input['action'] == "manage")
 722  {
 723      $plugins->run_hooks("admin_config_settings_manage");
 724  
 725      // Update orders
 726      if($mybb->request_method == "post")
 727      {
 728          if(is_array($mybb->input['group_disporder']))
 729          {
 730              foreach($mybb->input['group_disporder'] as $gid => $new_order)
 731              {
 732                  $gid = (int)$gid;
 733                  $update_group = array('disporder' => (int)$new_order);
 734                  $db->update_query("settinggroups", $update_group, "gid={$gid}");
 735              }
 736          }
 737  
 738          if(is_array($mybb->input['setting_disporder']))
 739          {
 740              foreach($mybb->input['setting_disporder'] as $sid => $new_order)
 741              {
 742                  $sid = (int)$sid;
 743                  $update_setting = array('disporder' => (int)$new_order);
 744                  $db->update_query("settings", $update_setting, "sid={$sid}");
 745              }
 746          }
 747  
 748          $plugins->run_hooks("admin_config_settings_manage_commit");
 749  
 750          // Log admin action
 751          log_admin_action();
 752  
 753          flash_message($lang->success_display_orders_updated, 'success');
 754          admin_redirect("index.php?module=config-settings&action=manage");
 755      }
 756  
 757      $page->add_breadcrumb_item($lang->modify_existing_settings);
 758      $page->output_header($lang->board_settings." - ".$lang->modify_existing_settings);
 759  
 760      $sub_tabs['change_settings'] = array(
 761          'title' => $lang->change_settings,
 762          'link' => "index.php?module=config-settings",
 763      );
 764  
 765      $sub_tabs['add_setting'] = array(
 766          'title' => $lang->add_new_setting,
 767          'link' => "index.php?module=config-settings&amp;action=add"
 768      );
 769  
 770      $sub_tabs['add_setting_group'] = array(
 771          'title' => $lang->add_new_setting_group,
 772          'link' => "index.php?module=config-settings&amp;action=addgroup"
 773      );
 774  
 775      $sub_tabs['modify_setting'] = array(
 776          'title' => $lang->modify_existing_settings,
 777          'link' => "index.php?module=config-settings&amp;action=manage",
 778          'description' => $lang->modify_existing_settings_desc
 779      );
 780  
 781      $page->output_nav_tabs($sub_tabs, 'modify_setting');
 782  
 783      // Cache settings
 784      $settings_cache = array();
 785      $query = $db->simple_select("settings", "sid, name, title, disporder, gid, isdefault", "", array('order_by' => 'disporder', 'order_dir' => 'asc'));
 786      while($setting = $db->fetch_array($query))
 787      {
 788          $settings_cache[$setting['gid']][] = $setting;
 789      }
 790  
 791      $form = new Form("index.php?module=config-settings&amp;action=manage", "post", "edit");
 792  
 793      $table = new Table;
 794  
 795      $table->construct_header($lang->setting_group_setting);
 796      $table->construct_header($lang->order, array('class' => 'align_center', 'style' => 'width: 5%'));
 797      $table->construct_header($lang->controls, array('class' => 'align_center', 'style' => 'width: 200px'));
 798  
 799      // Generate table
 800      $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder', 'order_dir' => 'asc'));
 801      while($group = $db->fetch_array($query))
 802      {
 803          // Make setting group row
 804          // Translated?
 805          $group_lang_var = "setting_group_{$group['name']}";
 806          if($lang->$group_lang_var)
 807          {
 808              $group_title = htmlspecialchars_uni($lang->$group_lang_var);
 809          }
 810          else
 811          {
 812              $group_title = htmlspecialchars_uni($group['title']);
 813          }
 814          $table->construct_cell("<strong>{$group_title}</strong>", array('id' => "group{$group['gid']}"));
 815          $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)));
 816          // Only show options if not a default setting group
 817          if($group['isdefault'] != 1)
 818          {
 819              $popup = new PopupMenu("group_{$group['gid']}", $lang->options);
 820              $popup->add_item($lang->edit_setting_group, "index.php?module=config-settings&amp;action=editgroup&amp;gid={$group['gid']}");
 821              $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}')");
 822              $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
 823          }
 824          else
 825          {
 826              $table->construct_cell('');
 827          }
 828          $table->construct_row(array('class' => 'alt_row', 'no_alt_row' => 1));
 829  
 830          // Make rows for each setting in the group
 831          if(is_array($settings_cache[$group['gid']]))
 832          {
 833              foreach($settings_cache[$group['gid']] as $setting)
 834              {
 835                  $setting_lang_var = "setting_{$setting['name']}";
 836                  if($lang->$setting_lang_var)
 837                  {
 838                      $setting_title = htmlspecialchars_uni($lang->$setting_lang_var);
 839                  }
 840                  else
 841                  {
 842                      $setting_title = htmlspecialchars_uni($setting['title']);
 843                  }
 844                  $table->construct_cell($setting_title, array('style' => 'padding-left: 40px;'));
 845                  $table->construct_cell($form->generate_numeric_field("setting_disporder[{$setting['sid']}]", $setting['disporder'], array('style' => 'width: 80%', 'class' => 'align_center', 'min' => 0)));
 846                  // Only show options if not a default setting group or is a custom setting
 847                  if($group['isdefault'] != 1 || $setting['isdefault'] != 1)
 848                  {
 849                      $popup = new PopupMenu("setting_{$setting['sid']}", $lang->options);
 850                      $popup->add_item($lang->edit_setting, "index.php?module=config-settings&amp;action=edit&amp;sid={$setting['sid']}");
 851                      $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}')");
 852                      $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
 853                  }
 854                  else
 855                  {
 856                      $table->construct_cell('');
 857                  }
 858                  $table->construct_row(array('no_alt_row' => 1, 'class' => "group{$group['gid']}"));
 859              }
 860          }
 861      }
 862  
 863      $table->output($lang->modify_existing_settings);
 864  
 865      $buttons[] = $form->generate_submit_button($lang->save_display_orders);
 866      $form->output_submit_wrapper($buttons);
 867      $form->end();
 868  
 869      $page->output_footer();
 870  }
 871  
 872  // Change settings for a specified group.
 873  if($mybb->input['action'] == "change")
 874  {
 875      $plugins->run_hooks("admin_config_settings_change");
 876  
 877      if($mybb->request_method == "post")
 878      {
 879          if(!is_writable(MYBB_ROOT.'inc/settings.php'))
 880          {
 881              flash_message($lang->error_chmod_settings_file, 'error');
 882              admin_redirect("index.php?module=config-settings");
 883          }
 884  
 885          // Not allowed to be hidden captcha fields
 886          $disallowed_fields = array(
 887              'username',
 888              'password',
 889              'password2',
 890              'email',
 891              'email2',
 892              'imagestring',
 893              'imagehash',
 894              'answer',
 895              'question_id',
 896              'allownotices',
 897              'hideemail',
 898              'receivepms',
 899              'pmnotice',
 900              'emailpmnotify',
 901              'invisible',
 902              'subscriptionmethod',
 903              'timezoneoffset',
 904              'dstcorrection',
 905              'language',
 906              'step',
 907              'action',
 908              'agree',
 909              'regtime',
 910              'regcheck1',
 911              'regcheck2',
 912              'regsubmit'
 913          );
 914  
 915          $is_current_hiddencaptcha_wrong = in_array($mybb->settings['hiddencaptchaimagefield'], $disallowed_fields);
 916          if(in_array($mybb->input['upsetting']['hiddencaptchaimagefield'], $disallowed_fields) || $is_current_hiddencaptcha_wrong)
 917          {
 918              if(isset($mybb->input['upsetting']['hiddencaptchaimagefield']) && $mybb->input['upsetting']['hiddencaptchaimagefield'] != $mybb->settings['hiddencaptchaimagefield'] && !$is_current_hiddencaptcha_wrong)
 919              {
 920                  $wrong_value = $mybb->input['upsetting']['hiddencaptchaimagefield'];
 921                  $mybb->input['upsetting']['hiddencaptchaimagefield'] = $mybb->settings['hiddencaptchaimagefield'];
 922              }
 923              else
 924              {
 925                  $wrong_value = $mybb->settings['hiddencaptchaimagefield'];
 926                  $mybb->input['upsetting']['hiddencaptchaimagefield'] = 'email3';
 927              }
 928  
 929              $lang->success_settings_updated .= $lang->sprintf($lang->success_settings_updated_hiddencaptchaimage, htmlspecialchars_uni($mybb->input['upsetting']['hiddencaptchaimagefield']), htmlspecialchars_uni($wrong_value));
 930          }
 931  
 932          // Validate avatar dimension inputs
 933          $gid = (int)$mybb->input['gid'];
 934          $dimfields = array(
 935              8 => array('postmaxavatarsize'),
 936              10 => array('useravatardims', 'maxavatardims'),
 937              13 => array('memberlistmaxavatarsize')
 938          );
 939          if(in_array($gid, array_keys($dimfields)))
 940          {
 941              foreach($dimfields[$gid] as $field)
 942              {
 943                  if(isset($mybb->input['upsetting'][$field]))
 944                  {
 945                      if(preg_match("/\b\d+[|x]{1}\d+\b/i", $mybb->input['upsetting'][$field]) || ($field == 'maxavatardims' && trim($mybb->input['upsetting'][$field]) == ""))
 946                      {
 947                          // If pipe (|) is used normalize to 'x'
 948                          $mybb->input['upsetting'][$field] = str_replace('|', 'x', my_strtolower($mybb->input['upsetting'][$field]));
 949                      }
 950                      else
 951                      {
 952                          flash_message($lang->sprintf($lang->error_format_dimension, $lang->{'error_field_'.$field}), 'error');
 953                          admin_redirect("index.php?module=config-settings&action=change&gid=".$gid);
 954                      }
 955                  }
 956              }
 957          }
 958  
 959          // Have we opted for a reCAPTCHA and not set a public/private key?
 960          if((isset($mybb->input['upsetting']['captchaimage']) && in_array($mybb->input['upsetting']['captchaimage'], array(4, 5)) && (!$mybb->input['upsetting']['captchaprivatekey'] || !$mybb->input['upsetting']['captchapublickey']))
 961             || (in_array($mybb->settings['captchaimage'], array(4, 5)) && (!$mybb->settings['captchaprivatekey'] || !$mybb->settings['captchapublickey'])))
 962          {
 963              $mybb->input['upsetting']['captchaimage'] = 1;
 964              $lang->success_settings_updated .= $lang->success_settings_updated_captchaimage;
 965          }
 966  
 967          // Get settings which optionscode is a forum/group select, checkbox or numeric
 968          // We cannot rely on user input to decide this
 969          $checkbox_settings = $forum_group_select = array();
 970          $query = $db->simple_select('settings', 'name, optionscode', "optionscode IN('forumselect', 'groupselect') OR optionscode LIKE 'checkbox%' OR optionscode LIKE 'numeric%'");
 971  
 972          while($multisetting = $db->fetch_array($query))
 973          {
 974              $options = array();
 975  
 976              if(substr($multisetting['optionscode'], 0, 8) == 'checkbox')
 977              {
 978                  $checkbox_settings[] = $multisetting['name'];
 979  
 980                  // 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
 981                  if(empty($mybb->input['upsetting'][$multisetting['name']]) && isset($mybb->input["isvisible_{$multisetting['name']}"]))
 982                  {
 983                      $mybb->input['upsetting'][$multisetting['name']] = array();
 984                  }
 985              }
 986              elseif(substr($multisetting['optionscode'], 0, 7) == 'numeric')
 987              {
 988                  if(isset($mybb->input['upsetting'][$multisetting['name']]))
 989                  {
 990                      $type = explode("\n", $multisetting['optionscode']);
 991                      for($i=1; $i < count($type); $i++)
 992                      {
 993                          $optionsexp = explode("=", $type[$i]);
 994                          $opt = array_map('trim', $optionsexp);
 995                          if(in_array($opt[0], array('min', 'max', 'step')))
 996                          {
 997                              if($opt[0] != 'step' || $opt[1] != 'any')
 998                              {
 999                                  $opt[1] = (float)$opt[1];
1000                              }
1001                              $options[$opt[0]] = $opt[1];
1002                          }
1003                      }
1004  
1005                      $value = (float)$mybb->input['upsetting'][$multisetting['name']];
1006  
1007                      if(isset($options['min']))
1008                      {
1009                          $value = max($value, $options['min']);
1010                      }
1011  
1012                      if(isset($options['max']))
1013                      {
1014                          $value = min($value, $options['max']);
1015                      }
1016  
1017                      $mybb->input['upsetting'][$multisetting['name']] = $value;
1018                  }
1019              }
1020              else
1021              {
1022                  $forum_group_select[] = $multisetting['name'];
1023              }
1024          }
1025  
1026          // Administrator is changing the login method.
1027          if($mybb->settings['username_method'] == 1 || $mybb->settings['username_method'] == 2 || $mybb->input['upsetting']['username_method'] == 1 || $mybb->input['upsetting']['username_method'] == 2)
1028          {
1029              $query = $db->simple_select('users', 'email', "email != ''", array('group_by' => 'email HAVING COUNT(email)>1'));
1030              if($db->num_rows($query))
1031              {
1032                  $mybb->input['upsetting']['username_method'] = 0;
1033                  $lang->success_settings_updated .= $lang->success_settings_updated_username_method;
1034              }
1035              else
1036              {
1037                  $mybb->input['upsetting']['allowmultipleemails'] = 0;
1038                  $lang->success_settings_updated .= $lang->success_settings_updated_allowmultipleemails;
1039              }
1040          }
1041  
1042          $fields = array(
1043              'uploadspath',
1044              'cdnpath',
1045              'avataruploadpath',
1046          );
1047          
1048          foreach($fields as $field)
1049          {
1050              if(
1051                  isset($mybb->input['upsetting'][$field]) &&
1052                  is_string($mybb->input['upsetting'][$field]) &&
1053                  strpos($mybb->input['upsetting'][$field], '://') !== false)
1054              {
1055                  unset($mybb->input['upsetting'][$field]);
1056              }
1057          }
1058  
1059          if(is_array($mybb->input['upsetting']))
1060          {
1061              foreach($mybb->input['upsetting'] as $name => $value)
1062              {
1063                  if($forum_group_select && in_array($name, $forum_group_select))
1064                  {
1065                      if($value == 'all')
1066                      {
1067                          $value = -1;
1068                      }
1069                      elseif($value == 'custom')
1070                      {
1071                          if(isset($mybb->input['select'][$name]) && is_array($mybb->input['select'][$name]))
1072                          {
1073                              foreach($mybb->input['select'][$name] as &$val)
1074                              {
1075                                  $val = (int)$val;
1076                              }
1077                              unset($val);
1078  
1079                              $value = implode(',', $mybb->input['select'][$name]);
1080                          }
1081                          else
1082                          {
1083                              $value = '';
1084                          }
1085                      }
1086                      else
1087                      {
1088                          $value = '';
1089                      }
1090                  }
1091                  elseif($checkbox_settings && in_array($name, $checkbox_settings))
1092                  {
1093                      $value = '';
1094  
1095                      if(is_array($mybb->input['upsetting'][$name]))
1096                      {
1097                          $value = implode(',', $mybb->input['upsetting'][$name]);
1098                      }
1099                  }
1100  
1101                  $db->update_query("settings", array('value' => $db->escape_string($value)), "name='".$db->escape_string($name)."'");
1102              }
1103          }
1104  
1105          // Check if we need to create our fulltext index after changing the search mode
1106          if($mybb->settings['searchtype'] != $mybb->input['upsetting']['searchtype'] && $mybb->input['upsetting']['searchtype'] == "fulltext")
1107          {
1108              if(!$db->is_fulltext("posts") && $db->supports_fulltext_boolean("posts"))
1109              {
1110                  $db->create_fulltext_index("posts", "message");
1111              }
1112              if(!$db->is_fulltext("posts") && $db->supports_fulltext("threads"))
1113              {
1114                  $db->create_fulltext_index("threads", "subject");
1115              }
1116          }
1117  
1118          // If the delayedthreadviews setting was changed, enable or disable the tasks for it.
1119          if(isset($mybb->input['upsetting']['delayedthreadviews']) && $mybb->settings['delayedthreadviews'] != $mybb->input['upsetting']['delayedthreadviews'])
1120          {
1121              $db->update_query("tasks", array('enabled' => (int)$mybb->input['upsetting']['delayedthreadviews']), "file='threadviews'");
1122          }
1123  
1124          // Have we changed our cookie prefix? If so, update our adminsid so we're not logged out
1125          if(isset($mybb->input['upsetting']['cookieprefix']) && $mybb->input['upsetting']['cookieprefix'] != $mybb->settings['cookieprefix'])
1126          {
1127              my_unsetcookie("adminsid");
1128              $mybb->settings['cookieprefix'] = $mybb->input['upsetting']['cookieprefix'];
1129              my_setcookie("adminsid", $admin_session['sid'], '', true, "lax");
1130          }
1131  
1132          if(isset($mybb->input['upsetting']['statstopreferrer']) && $mybb->input['upsetting']['statstopreferrer'] != $mybb->settings['statstopreferrer'])
1133          {
1134              $cache->update_statistics();
1135          }
1136  
1137          $statslimit = $mybb->settings['statslimit'];
1138  
1139          rebuild_settings();
1140  
1141          if(isset($mybb->input['upsetting']['statslimit']) && $mybb->input['upsetting']['statslimit'] != $statslimit)
1142          {
1143              $cache->update_most_replied_threads();
1144              $cache->update_most_viewed_threads();
1145          }
1146  
1147          $plugins->run_hooks("admin_config_settings_change_commit");
1148  
1149          // Log admin action
1150          log_admin_action();
1151  
1152          flash_message($lang->success_settings_updated, 'success');
1153          admin_redirect("index.php?module=config-settings");
1154      }
1155  
1156      // What type of page
1157      $cache_groups = $cache_settings = array();
1158      if(isset($mybb->input['search']))
1159      {
1160          // Search
1161  
1162          // Search for settings
1163          $search = $db->escape_string_like($mybb->input['search']);
1164          $query = $db->query("
1165              SELECT s.* , g.name as gname, g.title as gtitle, g.description as gdescription
1166              FROM ".TABLE_PREFIX."settings s
1167              LEFT JOIN ".TABLE_PREFIX."settinggroups g ON(s.gid=g.gid)
1168              ORDER BY s.disporder
1169          ");
1170          while($setting = $db->fetch_array($query))
1171          {
1172              $lang_var = "setting_{$setting['name']}";
1173              if(isset($lang->$lang_var))
1174              {
1175                  $setting["title"] = $lang->$lang_var;
1176              }
1177              $lang_var = "setting_{$setting['name']}_desc";
1178              if(isset($lang->$lang_var))
1179              {
1180                  $setting["description"] = $lang->$lang_var;
1181              }
1182              $lang_var = "setting_group_{$setting['gname']}";
1183              if(isset($lang->$lang_var))
1184              {
1185                  $setting["gtitle"] = $lang->$lang_var;
1186              }
1187              $lang_var = "setting_group_{$setting['gname']}_desc";
1188              if(isset($lang->$lang_var))
1189              {
1190                  $setting["gdescription"] = $lang->$lang_var;
1191              }
1192              $lang_var = $setting["title"] . " " . $setting["description"] . " " . $setting["gtitle"] . " " . $setting["gdescription"];
1193              $search = mb_convert_encoding($search, mb_detect_encoding($setting["title"], "auto"));
1194              if (mb_stripos($lang_var, $search))
1195              {
1196                  $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1197              }
1198          }
1199          if(!count($cache_settings))
1200          {
1201              if(isset($mybb->input['ajax_search']))
1202              {
1203                  echo json_encode(array("errors" => array($lang->error_no_settings_found)));
1204                  exit;
1205              }
1206              else
1207              {
1208                  flash_message($lang->error_no_settings_found, 'error');
1209                  admin_redirect("index.php?module=config-settings");
1210              }
1211          }
1212  
1213          // Cache groups
1214          $groups = array_keys($cache_settings);
1215          $groups = implode(',', $groups);
1216          $query = $db->simple_select("settinggroups", "*", "gid IN ({$groups})", array('order_by' => 'disporder'));
1217          while($group = $db->fetch_array($query))
1218          {
1219              $cache_groups[$group['gid']] = $group;
1220          }
1221  
1222          // Page header only if not AJAX
1223          if(!isset($mybb->input['ajax_search']))
1224          {
1225              $page->add_breadcrumb_item($lang->settings_search);
1226              $page->output_header($lang->board_settings." - {$lang->settings_search}");
1227          }
1228      }
1229      elseif($mybb->input['gid'])
1230      {
1231          // Group listing
1232          // Cache groups
1233          $query = $db->simple_select("settinggroups", "*", "gid = '".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
1234          $groupinfo = $db->fetch_array($query);
1235          $cache_groups[$groupinfo['gid']] = $groupinfo;
1236  
1237          if(!$db->num_rows($query))
1238          {
1239              $page->output_error($lang->error_invalid_gid2);
1240          }
1241  
1242          // Cache settings
1243          $query = $db->simple_select("settings", "*", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'", array('order_by' => 'disporder'));
1244          while($setting = $db->fetch_array($query))
1245          {
1246              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1247          }
1248  
1249          if(!$db->num_rows($query))
1250          {
1251              flash_message($lang->error_no_settings_found, 'error');
1252              admin_redirect("index.php?module=config-settings");
1253          }
1254  
1255          $group_lang_var = "setting_group_{$groupinfo['name']}";
1256          if(isset($lang->$group_lang_var))
1257          {
1258              $groupinfo['title'] = $lang->$group_lang_var;
1259          }
1260  
1261          // Page header
1262          $page->add_breadcrumb_item($groupinfo['title']);
1263          $page->output_header($lang->board_settings." - {$groupinfo['title']}");
1264      }
1265      else
1266      {
1267          // All settings list
1268          // Cache groups
1269          $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
1270          while($group = $db->fetch_array($query))
1271          {
1272              $cache_groups[$group['gid']] = $group;
1273          }
1274  
1275          if(!$db->num_rows($query))
1276          {
1277              $page->output_error($lang->error_invalid_gid2);
1278          }
1279  
1280          // Cache settings
1281          $query = $db->simple_select("settings", "*", "", array('order_by' => 'disporder'));
1282          while($setting = $db->fetch_array($query))
1283          {
1284              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1285          }
1286  
1287          // Page header
1288          $page->add_breadcrumb_item($lang->show_all_settings);
1289          $page->output_header($lang->board_settings." - {$lang->show_all_settings}");
1290      }
1291  
1292      // Build individual forms as per settings group
1293      foreach($cache_groups as $groupinfo)
1294      {
1295          $form = new Form("index.php?module=config-settings&amp;action=change", "post", "change");
1296          echo $form->generate_hidden_field("gid", $groupinfo['gid']);
1297          $buttons = array($form->generate_submit_button($lang->save_settings));
1298          $group_lang_var = "setting_group_{$groupinfo['name']}";
1299          if(isset($lang->$group_lang_var))
1300          {
1301              $groupinfo['title'] = $lang->$group_lang_var;
1302          }
1303  
1304          $form_container = new FormContainer($groupinfo['title']);
1305  
1306          if(empty($cache_settings[$groupinfo['gid']]))
1307          {
1308              $form_container->output_cell($lang->error_no_settings_found);
1309              $form_container->construct_row();
1310  
1311              $form_container->end();
1312              echo '<br />';
1313  
1314              continue;
1315          }
1316  
1317          foreach($cache_settings[$groupinfo['gid']] as $setting)
1318          {
1319              $options = "";
1320              $type = explode("\n", $setting['optionscode']);
1321              $type[0] = trim($type[0]);
1322              $element_name = "upsetting[{$setting['name']}]";
1323              $element_id = "setting_{$setting['name']}";
1324              if($type[0] == "text" || $type[0] == "")
1325              {
1326                  $setting_code = $form->generate_text_box($element_name, $setting['value'], array('id' => $element_id));
1327              }
1328              else if($type[0] == "numeric")
1329              {
1330                  $field_options = array('id' => $element_id);
1331                  if(count($type) > 1)
1332                  {
1333                      for($i=1; $i < count($type); $i++)
1334                      {
1335                          $optionsexp = explode("=", $type[$i]);
1336                          $opt = array_map('trim', $optionsexp);
1337                          if(in_array($opt[0], array('min', 'max', 'step')))
1338                          {
1339                              if($opt[0] != 'step' || $opt[1] != 'any')
1340                              {
1341                                  $opt[1] = (float)$opt[1];
1342                              }
1343                              $field_options[$opt[0]] = $opt[1];
1344                          }
1345                      }
1346                  }
1347                  $setting_code = $form->generate_numeric_field($element_name, $setting['value'], $field_options);
1348              }
1349              else if($type[0] == "textarea")
1350              {
1351                  $setting_code = $form->generate_text_area($element_name, $setting['value'], array('id' => $element_id));
1352              }
1353              else if($type[0] == "yesno")
1354              {
1355                  $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));
1356              }
1357              else if($type[0] == "onoff")
1358              {
1359                  $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));
1360              }
1361              else if($type[0] == "cpstyle")
1362              {
1363                  $dir = @opendir(MYBB_ROOT.$config['admin_dir']."/styles");
1364  
1365                  $folders = array();
1366                  while($folder = readdir($dir))
1367                  {
1368                      if($file != "." && $file != ".." && @file_exists(MYBB_ROOT.$config['admin_dir']."/styles/$folder/main.css"))
1369                      {
1370                          $folders[$folder] = ucfirst($folder);
1371                      }
1372                  }
1373                  closedir($dir);
1374                  ksort($folders);
1375                  $setting_code = $form->generate_select_box($element_name, $folders, $setting['value'], array('id' => $element_id));
1376              }
1377              else if($type[0] == "language")
1378              {
1379                  $languages = $lang->get_languages();
1380                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1381              }
1382              else if($type[0] == "adminlanguage")
1383              {
1384                  $languages = $lang->get_languages(1);
1385                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1386              }
1387              else if($type[0] == "passwordbox")
1388              {
1389                  $setting_code = $form->generate_password_box($element_name, $setting['value'], array('id' => $element_id));
1390              }
1391              else if($type[0] == "php")
1392              {
1393                  $setting['optionscode'] = substr($setting['optionscode'], 3);
1394                  eval("\$setting_code = \"".$setting['optionscode']."\";");
1395              }
1396              else if($type[0] == "forumselect")
1397              {
1398                  $selected_values = '';
1399                  if($setting['value'] != '' && $setting['value'] != -1)
1400                  {
1401                      $selected_values = explode(',', (string)$setting['value']);
1402  
1403                      foreach($selected_values as &$value)
1404                      {
1405                          $value = (int)$value;
1406                      }
1407                      unset($value);
1408                  }
1409  
1410                  $forum_checked = array('all' => '', 'custom' => '', 'none' => '');
1411                  if($setting['value'] == -1)
1412                  {
1413                      $forum_checked['all'] = 'checked="checked"';
1414                  }
1415                  elseif($setting['value'] != '')
1416                  {
1417                      $forum_checked['custom'] = 'checked="checked"';
1418                  }
1419                  else
1420                  {
1421                      $forum_checked['none'] = 'checked="checked"';
1422                  }
1423  
1424                  print_selection_javascript();
1425  
1426                  $setting_code = "
1427                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1428                      <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>
1429                      <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>
1430                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1431                          <table cellpadding=\"4\">
1432                              <tr>
1433                                  <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
1434                                  <td>".$form->generate_forum_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1435                              </tr>
1436                          </table>
1437                      </dd>
1438                      <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>
1439                  </dl>
1440                  <script type=\"text/javascript\">
1441                      checkAction('{$element_id}');
1442                  </script>";
1443              }
1444              else if($type[0] == "forumselectsingle")
1445              {
1446                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1447                  $setting_code = $form->generate_forum_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1448              }
1449              else if($type[0] == "groupselect")
1450              {
1451                  $selected_values = '';
1452                  if($setting['value'] != '' && $setting['value'] != -1)
1453                  {
1454                      $selected_values = explode(',', (string)$setting['value']);
1455  
1456                      foreach($selected_values as &$value)
1457                      {
1458                          $value = (int)$value;
1459                      }
1460                      unset($value);
1461                  }
1462  
1463                  $group_checked = array('all' => '', 'custom' => '', 'none' => '');
1464                  if($setting['value'] == -1)
1465                  {
1466                      $group_checked['all'] = 'checked="checked"';
1467                  }
1468                  elseif($setting['value'] != '')
1469                  {
1470                      $group_checked['custom'] = 'checked="checked"';
1471                  }
1472                  else
1473                  {
1474                      $group_checked['none'] = 'checked="checked"';
1475                  }
1476  
1477                  print_selection_javascript();
1478  
1479                  $setting_code = "
1480                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1481                      <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>
1482                      <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>
1483                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1484                          <table cellpadding=\"4\">
1485                              <tr>
1486                                  <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
1487                                  <td>".$form->generate_group_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1488                              </tr>
1489                          </table>
1490                      </dd>
1491                      <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>
1492                  </dl>
1493                  <script type=\"text/javascript\">
1494                      checkAction('{$element_id}');
1495                  </script>";
1496              }
1497              else if($type[0] == "groupselectsingle")
1498              {
1499                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1500                  $setting_code = $form->generate_group_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1501              }
1502              else
1503              {
1504                  $typecount = count($type);
1505  
1506                  if($type[0] == 'checkbox')
1507                  {
1508                      $multivalue = explode(',', $setting['value']);
1509                  }
1510  
1511                  for($i = 0; $i < $typecount; $i++)
1512                  {
1513                      $optionsexp = explode("=", $type[$i]);
1514                      if(!isset($optionsexp[1]))
1515                      {
1516                          continue;
1517                      }
1518                      $title_lang = "setting_{$setting['name']}_{$optionsexp[0]}";
1519                      if(isset($lang->$title_lang))
1520                      {
1521                          $optionsexp[1] = $lang->$title_lang;
1522                      }
1523  
1524                      if($type[0] == "select")
1525                      {
1526                          $option_list[$optionsexp[0]] = htmlspecialchars_uni($optionsexp[1]);
1527                      }
1528                      else if($type[0] == "radio")
1529                      {
1530                          if($setting['value'] == $optionsexp[0])
1531                          {
1532                              $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));
1533                          }
1534                          else
1535                          {
1536                              $option_list[$i] = $form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1537                          }
1538                      }
1539                      else if($type[0] == "checkbox")
1540                      {
1541                          if(in_array($optionsexp[0], $multivalue))
1542                          {
1543                              $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));
1544                          }
1545                          else
1546                          {
1547                              $option_list[$i] = $form->generate_check_box("{$element_name}[]", $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1548                          }
1549                      }
1550                  }
1551  
1552                  if($type[0] == "select")
1553                  {
1554                      $setting_code = $form->generate_select_box($element_name, $option_list, $setting['value'], array('id' => $element_id));
1555                  }
1556                  else
1557                  {
1558                      $setting_code = implode("<br />", $option_list);
1559  
1560                      if($type[0] == 'checkbox')
1561                      {
1562                          $setting_code .= $form->generate_hidden_field("isvisible_{$setting['name']}", 1);
1563                      }
1564                  }
1565                  $option_list = array();
1566              }
1567  
1568              // Do we have a custom language variable for this title or description?
1569              $title_lang = "setting_".$setting['name'];
1570              $desc_lang = $title_lang."_desc";
1571              if(isset($lang->$title_lang))
1572              {
1573                  $setting['title'] = $lang->$title_lang;
1574              }
1575              if(isset($lang->$desc_lang))
1576              {
1577                  $setting['description'] = $lang->$desc_lang;
1578              }
1579              $form_container->output_row(htmlspecialchars_uni($setting['title']), $setting['description'], $setting_code, '', array(), array('id' => 'row_'.$element_id));
1580          }
1581          $form_container->end();
1582  
1583          $form->output_submit_wrapper($buttons);
1584          $form->end();
1585          echo '<br />';
1586      }
1587  
1588      print_setting_peekers();
1589  
1590      if(!isset($mybb->input['ajax_search']))
1591      {
1592          $page->output_footer();
1593      }
1594  }
1595  
1596  if(!$mybb->input['action'])
1597  {
1598      $plugins->run_hooks("admin_config_settings_start");
1599  
1600      $page->extra_header .= <<<EOF
1601      <script type="text/javascript">
1602      <!--
1603      lang.searching = "{$lang->searching}";
1604      lang.search_error = "{$lang->search_error}";
1605      lang.search_done = "{$lang->search_done}";
1606      // -->
1607      </script>
1608  EOF;
1609  
1610      $page->output_header($lang->board_settings);
1611      if(isset($message))
1612      {
1613          $page->output_inline_message($message);
1614      }
1615  
1616      $sub_tabs['change_settings'] = array(
1617          'title' => $lang->change_settings,
1618          'link' => "index.php?module=config-settings",
1619          'description' => $lang->change_settings_desc
1620      );
1621  
1622      $sub_tabs['add_setting'] = array(
1623          'title' => $lang->add_new_setting,
1624          'link' => "index.php?module=config-settings&amp;action=add"
1625      );
1626  
1627      $sub_tabs['add_setting_group'] = array(
1628          'title' => $lang->add_new_setting_group,
1629          'link' => "index.php?module=config-settings&amp;action=addgroup"
1630      );
1631  
1632      $sub_tabs['modify_setting'] = array(
1633          'title' => $lang->modify_existing_settings,
1634          'link' => "index.php?module=config-settings&amp;action=manage",
1635      );
1636  
1637      $page->output_nav_tabs($sub_tabs, 'change_settings');
1638  
1639      // Search form
1640      echo "<div style=\"text-align: right; margin-bottom: 3px;\">";
1641      $search = new Form("index.php", 'get', 'settings_search', 0, 'settings_search');
1642      echo $search->generate_hidden_field('module', 'config/settings');
1643      echo $search->generate_hidden_field('action', 'change');
1644      echo $search->generate_text_box('search', $lang->settings_search, array('id' => 'search', 'class' => 'search_default field150 field_small'));
1645      echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />";
1646      $search->end();
1647      echo "</div>\n";
1648  
1649      echo '<div id="search_results">&nbsp;</div><div id="group_list">';
1650      $table = new Table;
1651      $table->construct_header($lang->setting_groups);
1652  
1653      switch($db->type)
1654      {
1655          case "pgsql":
1656          $query = $db->query("
1657              SELECT g.*, COUNT(s.sid) AS settingcount
1658              FROM ".TABLE_PREFIX."settinggroups g
1659              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1660              WHERE g.isdefault = 1
1661              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1662              ORDER BY g.disporder
1663          ");
1664          break;
1665          default:
1666          $query = $db->query("
1667              SELECT g.*, COUNT(s.sid) AS settingcount
1668              FROM ".TABLE_PREFIX."settinggroups g
1669              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1670              WHERE g.isdefault = 1
1671              GROUP BY g.gid
1672              ORDER BY g.disporder
1673          ");
1674      }
1675      while($group = $db->fetch_array($query))
1676      {
1677          $group_lang_var = "setting_group_{$group['name']}";
1678          if(isset($lang->$group_lang_var))
1679          {
1680              $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1681          }
1682          else
1683          {
1684              $group_title = htmlspecialchars_uni($group['title']);
1685          }
1686  
1687          $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1688          if(isset($lang->$group_desc_lang_var))
1689          {
1690              $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1691          }
1692          else
1693          {
1694              $group_desc = htmlspecialchars_uni($group['description']);
1695          }
1696  
1697          $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>");
1698          $table->construct_row();
1699      }
1700  
1701      $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}");
1702  
1703      // Plugin Settings
1704      switch($db->type)
1705      {
1706          case "pgsql":
1707          $query = $db->query("
1708              SELECT g.*, COUNT(s.sid) AS settingcount
1709              FROM ".TABLE_PREFIX."settinggroups g
1710              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1711              WHERE g.isdefault <> 1
1712              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1713              ORDER BY g.disporder
1714          ");
1715          break;
1716          default:
1717          $query = $db->query("
1718              SELECT g.*, COUNT(s.sid) AS settingcount
1719              FROM ".TABLE_PREFIX."settinggroups g
1720              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1721              WHERE g.isdefault <> 1
1722              GROUP BY g.gid
1723              ORDER BY g.disporder
1724          ");
1725      }
1726  
1727      if($db->num_rows($query))
1728      {
1729          $table = new Table;
1730          $table->construct_header($lang->setting_groups);
1731  
1732          while($group = $db->fetch_array($query))
1733          {
1734              $group_lang_var = "setting_group_{$group['name']}";
1735              if($lang->$group_lang_var)
1736              {
1737                  $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1738              }
1739              else
1740              {
1741                  $group_title = htmlspecialchars_uni($group['title']);
1742              }
1743  
1744              $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1745              if($lang->$group_desc_lang_var)
1746              {
1747                  $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1748              }
1749              else
1750              {
1751                  $group_desc = htmlspecialchars_uni($group['description']);
1752              }
1753  
1754              $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>");
1755              $table->construct_row();
1756          }
1757  
1758          $table->output($lang->plugin_settings);
1759      }
1760  
1761      echo '</div>';
1762  
1763      echo '
1764  <script type="text/javascript" src="./jscripts/search.js?ver=1821"></script>
1765  <script type="text/javascript">
1766  //<!--
1767  $(function(){
1768      SettingSearch.init("'.$lang->settings_search.'","'.$lang->error_ajax_unknown.'");
1769  });
1770  //-->
1771  </script>';
1772  
1773      print_setting_peekers();
1774      $page->output_footer();
1775  }
1776  
1777  /**
1778   * Print all the peekers for all of the default settings
1779   */
1780  function print_setting_peekers()
1781  {
1782      global $plugins;
1783  
1784      $peekers = array(
1785          'new Peeker($(".setting_boardclosed"), $("#row_setting_boardclosed_reason"), 1, true)',
1786          'new Peeker($(".setting_gzipoutput"), $("#row_setting_gziplevel"), 1, true)',
1787          'new Peeker($(".setting_useerrorhandling"), $("#row_setting_errorlogmedium, #row_setting_errortypemedium, #row_setting_errorloglocation"), 1, true)',
1788          'new Peeker($("#setting_subforumsindex"), $("#row_setting_subforumsstatusicons"), /[^0+|]/, false)',
1789          'new Peeker($(".setting_showsimilarthreads"), $("#row_setting_similarityrating, #row_setting_similarlimit"), 1, true)',
1790          'new Peeker($(".setting_disableregs"), $("#row_setting_regtype, #row_setting_securityquestion, #row_setting_regtime, #row_setting_allowmultipleemails, #row_setting_hiddencaptchaimage, #row_setting_betweenregstime"), 0, true)',
1791          'new Peeker($(".setting_hiddencaptchaimage"), $("#row_setting_hiddencaptchaimagefield"), 1, true)',
1792          'new Peeker($("#setting_failedlogincount"), $("#row_setting_failedlogintime, #row_setting_failedlogintext"), /[^0+|]/, false)',
1793          'new Peeker($(".setting_postfloodcheck"), $("#row_setting_postfloodsecs"), 1, true)',
1794          'new Peeker($("#setting_postmergemins"), $("#row_setting_postmergefignore, #row_setting_postmergeuignore, #row_setting_postmergesep"), /[^0+|]/, false)',
1795          'new Peeker($(".setting_enablememberlist"), $("#row_setting_membersperpage, #row_setting_default_memberlist_sortby, #row_setting_default_memberlist_order, #row_setting_memberlistmaxavatarsize"), 1, true)',
1796          '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)',
1797          'new Peeker($(".setting_enablewarningsystem"), $("#row_setting_allowcustomwarnings, #row_setting_canviewownwarning, #row_setting_maxwarningpoints, #row_setting_allowanonwarningpms"), 1, true)',
1798          '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)',
1799          'new Peeker($(".setting_smilieinserter"), $("#row_setting_smilieinsertertot, #row_setting_smilieinsertercols"), 1, true)',
1800          '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)',
1801          'new Peeker($("#setting_mail_handler"), $("#row_setting_mail_parameters"), "mail", false)',
1802          'new Peeker($("#setting_captchaimage"), $("#row_setting_captchapublickey, #row_setting_captchaprivatekey"), /(4|5)/, false)',
1803          '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)',
1804          'new Peeker($(".setting_enablepruning"), $("#row_setting_enableprunebyposts, #row_setting_pruneunactived, #row_setting_prunethreads"), 1, true)',
1805          'new Peeker($(".setting_enableprunebyposts"), $("#row_setting_prunepostcount, #row_setting_dayspruneregistered, #row_setting_prunepostcountall"), 1, true)',
1806          'new Peeker($(".setting_pruneunactived"), $("#row_setting_dayspruneunactivated"), 1, true)',
1807          'new Peeker($(".setting_statsenabled"), $("#row_setting_statscachetime, #row_setting_statslimit, #row_setting_statstopreferrer"), 1, true)',
1808          'new Peeker($(".setting_purgespammergroups_forums_groups_check"), $("#row_setting_purgespammerpostlimit, #row_setting_purgespammerbandelete, #row_setting_purgespammerapikey"), /^(?!none)/, true)',
1809          'new Peeker($(".setting_purgespammerbandelete"),$("#row_setting_purgespammerbangroup, #row_setting_purgespammerbanreason"), "ban", true)',
1810          'new Peeker($("#setting_maxloginattempts"), $("#row_setting_loginattemptstimeout"), /[^0+|]/, false)',
1811          'new Peeker($(".setting_bbcodeinserter"), $("#row_setting_partialmode, #row_setting_smilieinserter"), 1, true)',
1812          '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)',
1813          'new Peeker($(".setting_portal_announcementsfid_forums_groups_check"), $("#row_setting_portal_numannouncements"), /^(?!none)/, true)',
1814          'new Peeker($(".setting_portal_showdiscussions"), $("#row_setting_portal_showdiscussionsnum, #row_setting_portal_excludediscussion"), 1, true)',
1815          'new Peeker($(".setting_enableattachments"), $("#row_setting_maxattachments, #row_setting_attachthumbnails"), 1, true)',
1816          'new Peeker($(".setting_attachthumbnails"), $("#row_setting_attachthumbh, #row_setting_attachthumbw"), "yes", true)',
1817          'new Peeker($(".setting_showbirthdays"), $("#row_setting_showbirthdayspostlimit"), 1, true)',
1818          'new Peeker($("#setting_betweenregstime"), $("#row_setting_maxregsbetweentime"), /[^0+|]/, false)',
1819          'new Peeker($(".setting_usecdn"), $("#row_setting_cdnurl, #row_setting_cdnpath"), 1, true)',
1820          'new Peeker($("#setting_errorlogmedium"), $("#row_setting_errortypemedium"), /^(log|email|both)/, false)',
1821          'new Peeker($("#setting_errorlogmedium"), $("#row_setting_errorloglocation"), /^(log|both)/, false)',
1822          'new Peeker($(".setting_sigmycode"), $("#row_setting_sigcountmycode, #row_setting_sigimgcode"), 1, true)',
1823          'new Peeker($(".setting_pmsallowmycode"), $("#row_setting_pmsallowimgcode, #row_setting_pmsallowvideocode"), 1, true)',
1824          'new Peeker($(".setting_enableshowteam"), $("#row_setting_showaddlgroups, #row_setting_showgroupleaders"), 1, true)',
1825          'new Peeker($(".setting_usereferrals"), $("#row_setting_referralsperpage"), 1, true)',
1826      );
1827  
1828      $peekers = $plugins->run_hooks("admin_settings_print_peekers", $peekers);
1829  
1830      $setting_peekers = implode("\n            ", $peekers);
1831  
1832      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
1833      <script type="text/javascript">
1834          $(function() {
1835              ' . $setting_peekers . '
1836          });
1837      </script>';
1838  }


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