[ Index ]

PHP Cross Reference of MyBB 1.8.22

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 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']['captchaprivatekey'] || !$mybb->input['upsetting']['captchapublickey']))
 963             || (in_array($mybb->settings['captchaimage'], array(4, 5)) && (!$mybb->settings['captchaprivatekey'] || !$mybb->settings['captchapublickey'])))
 964          {
 965              $mybb->input['upsetting']['captchaimage'] = 1;
 966              $lang->success_settings_updated .= $lang->success_settings_updated_captchaimage;
 967          }
 968  
 969          // Get settings which optionscode is a forum/group select, checkbox or numeric
 970          // We cannot rely on user input to decide this
 971          $checkbox_settings = $forum_group_select = $prefix_select = array();
 972          $query = $db->simple_select('settings', 'name, optionscode', "optionscode IN('forumselect', 'groupselect', 'prefixselect') OR optionscode LIKE 'checkbox%' OR optionscode LIKE 'numeric%'");
 973  
 974          while($multisetting = $db->fetch_array($query))
 975          {
 976              $options = array();
 977  
 978              if(substr($multisetting['optionscode'], 0, 8) == 'checkbox')
 979              {
 980                  $checkbox_settings[] = $multisetting['name'];
 981  
 982                  // 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
 983                  if(empty($mybb->input['upsetting'][$multisetting['name']]) && isset($mybb->input["isvisible_{$multisetting['name']}"]))
 984                  {
 985                      $mybb->input['upsetting'][$multisetting['name']] = array();
 986                  }
 987              }
 988              elseif(substr($multisetting['optionscode'], 0, 7) == 'numeric')
 989              {
 990                  if(isset($mybb->input['upsetting'][$multisetting['name']]))
 991                  {
 992                      $type = explode("\n", $multisetting['optionscode']);
 993                      for($i=1; $i < count($type); $i++)
 994                      {
 995                          $optionsexp = explode("=", $type[$i]);
 996                          $opt = array_map('trim', $optionsexp);
 997                          if(in_array($opt[0], array('min', 'max', 'step')))
 998                          {
 999                              if($opt[0] != 'step' || $opt[1] != 'any')
1000                              {
1001                                  $opt[1] = (float)$opt[1];
1002                              }
1003                              $options[$opt[0]] = $opt[1];
1004                          }
1005                      }
1006  
1007                      $value = (float)$mybb->input['upsetting'][$multisetting['name']];
1008  
1009                      if(isset($options['min']))
1010                      {
1011                          $value = max($value, $options['min']);
1012                      }
1013  
1014                      if(isset($options['max']))
1015                      {
1016                          $value = min($value, $options['max']);
1017                      }
1018  
1019                      $mybb->input['upsetting'][$multisetting['name']] = $value;
1020                  }
1021              }
1022              else
1023              {
1024                  $forum_group_select[] = $multisetting['name'];
1025              }
1026          }
1027  
1028          // Administrator is changing the login method.
1029          if($mybb->settings['username_method'] == 1 || $mybb->settings['username_method'] == 2 || $mybb->input['upsetting']['username_method'] == 1 || $mybb->input['upsetting']['username_method'] == 2)
1030          {
1031              $query = $db->simple_select('users', 'email', "email != ''", array('group_by' => 'email HAVING COUNT(email)>1'));
1032              if($db->num_rows($query))
1033              {
1034                  $mybb->input['upsetting']['username_method'] = 0;
1035                  $lang->success_settings_updated .= $lang->success_settings_updated_username_method;
1036              }
1037              else
1038              {
1039                  $mybb->input['upsetting']['allowmultipleemails'] = 0;
1040                  $lang->success_settings_updated .= $lang->success_settings_updated_allowmultipleemails;
1041              }
1042          }
1043  
1044          // reject dangerous/unsupported upload paths
1045          $fields = array(
1046              'uploadspath',
1047              'cdnpath',
1048              'avataruploadpath',
1049          );
1050  
1051          $dynamic_include_directories = array(
1052              MYBB_ROOT.'cache/',
1053              MYBB_ROOT.'inc/plugins/',
1054              MYBB_ROOT.'inc/languages/',
1055              MYBB_ROOT.'inc/tasks/',
1056          );
1057          $dynamic_include_directories_realpath = array_map('realpath', $dynamic_include_directories);
1058  
1059          foreach($fields as $field)
1060          {
1061              if(
1062                  isset($mybb->input['upsetting'][$field]) &&
1063                  is_string($mybb->input['upsetting'][$field]) &&
1064                  strpos($mybb->input['upsetting'][$field], '://') !== false)
1065              {
1066                  unset($mybb->input['upsetting'][$field]);
1067                  continue;
1068              }
1069  
1070              $realpath = realpath(MYBB_ROOT.$mybb->input['upsetting'][$field]);
1071  
1072              if ($realpath === false) {
1073                  unset($mybb->input['upsetting'][$field]);
1074                  continue;
1075              }
1076  
1077              foreach ($dynamic_include_directories_realpath as $forbidden_realpath)
1078              {
1079                  if ($realpath === $forbidden_realpath || strpos($realpath, $forbidden_realpath.DIRECTORY_SEPARATOR) === 0)
1080                  {
1081                      unset($mybb->input['upsetting'][$field]);
1082                      continue 2;
1083                  }
1084              }
1085          }
1086  
1087  
1088          if(is_array($mybb->input['upsetting']))
1089          {
1090              foreach($mybb->input['upsetting'] as $name => $value)
1091              {
1092                  if($forum_group_select && in_array($name, $forum_group_select))
1093                  {
1094                      if($value == 'all')
1095                      {
1096                          $value = -1;
1097                      }
1098                      elseif($value == 'custom')
1099                      {
1100                          if(isset($mybb->input['select'][$name]) && is_array($mybb->input['select'][$name]))
1101                          {
1102                              foreach($mybb->input['select'][$name] as &$val)
1103                              {
1104                                  $val = (int)$val;
1105                              }
1106                              unset($val);
1107  
1108                              $value = implode(',', $mybb->input['select'][$name]);
1109                          }
1110                          else
1111                          {
1112                              $value = '';
1113                          }
1114                      }
1115                      else
1116                      {
1117                          $value = '';
1118                      }
1119                  }
1120                  elseif($checkbox_settings && in_array($name, $checkbox_settings))
1121                  {
1122                      $value = '';
1123  
1124                      if(is_array($mybb->input['upsetting'][$name]))
1125                      {
1126                          $value = implode(',', $mybb->input['upsetting'][$name]);
1127                      }
1128                  }
1129  
1130                  $db->update_query("settings", array('value' => $db->escape_string($value)), "name='".$db->escape_string($name)."'");
1131              }
1132          }
1133  
1134          // Check if we need to create our fulltext index after changing the search mode
1135          if($mybb->settings['searchtype'] != $mybb->input['upsetting']['searchtype'] && $mybb->input['upsetting']['searchtype'] == "fulltext")
1136          {
1137              if(!$db->is_fulltext("posts") && $db->supports_fulltext_boolean("posts"))
1138              {
1139                  $db->create_fulltext_index("posts", "message");
1140              }
1141              if(!$db->is_fulltext("posts") && $db->supports_fulltext("threads"))
1142              {
1143                  $db->create_fulltext_index("threads", "subject");
1144              }
1145          }
1146  
1147          // If the delayedthreadviews setting was changed, enable or disable the tasks for it.
1148          if(isset($mybb->input['upsetting']['delayedthreadviews']) && $mybb->settings['delayedthreadviews'] != $mybb->input['upsetting']['delayedthreadviews'])
1149          {
1150              $db->update_query("tasks", array('enabled' => (int)$mybb->input['upsetting']['delayedthreadviews']), "file='threadviews'");
1151          }
1152  
1153          // Have we changed our cookie prefix? If so, update our adminsid so we're not logged out
1154          if(isset($mybb->input['upsetting']['cookieprefix']) && $mybb->input['upsetting']['cookieprefix'] != $mybb->settings['cookieprefix'])
1155          {
1156              my_unsetcookie("adminsid");
1157              $mybb->settings['cookieprefix'] = $mybb->input['upsetting']['cookieprefix'];
1158              my_setcookie("adminsid", $admin_session['sid'], '', true, "lax");
1159          }
1160  
1161          if(isset($mybb->input['upsetting']['statstopreferrer']) && $mybb->input['upsetting']['statstopreferrer'] != $mybb->settings['statstopreferrer'])
1162          {
1163              $cache->update_statistics();
1164          }
1165  
1166          $statslimit = $mybb->settings['statslimit'];
1167  
1168          rebuild_settings();
1169  
1170          if(isset($mybb->input['upsetting']['statslimit']) && $mybb->input['upsetting']['statslimit'] != $statslimit)
1171          {
1172              $cache->update_most_replied_threads();
1173              $cache->update_most_viewed_threads();
1174          }
1175  
1176          $plugins->run_hooks("admin_config_settings_change_commit");
1177  
1178          // Log admin action
1179          log_admin_action();
1180  
1181          flash_message($lang->success_settings_updated, 'success');
1182          admin_redirect("index.php?module=config-settings");
1183      }
1184  
1185      // What type of page
1186      $cache_groups = $cache_settings = array();
1187      if(isset($mybb->input['search']))
1188      {
1189          // Search
1190  
1191          // Search for settings
1192          $search = $db->escape_string_like($mybb->input['search']);
1193          $query = $db->query("
1194              SELECT s.* , g.name as gname, g.title as gtitle, g.description as gdescription
1195              FROM ".TABLE_PREFIX."settings s
1196              LEFT JOIN ".TABLE_PREFIX."settinggroups g ON(s.gid=g.gid)
1197              ORDER BY s.disporder
1198          ");
1199          while($setting = $db->fetch_array($query))
1200          {
1201              $lang_var = "setting_{$setting['name']}";
1202              if(isset($lang->$lang_var))
1203              {
1204                  $setting["title"] = $lang->$lang_var;
1205              }
1206              $lang_var = "setting_{$setting['name']}_desc";
1207              if(isset($lang->$lang_var))
1208              {
1209                  $setting["description"] = $lang->$lang_var;
1210              }
1211              $lang_var = "setting_group_{$setting['gname']}";
1212              if(isset($lang->$lang_var))
1213              {
1214                  $setting["gtitle"] = $lang->$lang_var;
1215              }
1216              $lang_var = "setting_group_{$setting['gname']}_desc";
1217              if(isset($lang->$lang_var))
1218              {
1219                  $setting["gdescription"] = $lang->$lang_var;
1220              }
1221              $lang_var = $setting["title"] . " " . $setting["description"] . " " . $setting["gtitle"] . " " . $setting["gdescription"];
1222              $search = mb_convert_encoding($search, mb_detect_encoding($setting["title"], "auto"));
1223              if (mb_stripos($lang_var, $search))
1224              {
1225                  $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1226              }
1227          }
1228          if(!count($cache_settings))
1229          {
1230              if(isset($mybb->input['ajax_search']))
1231              {
1232                  echo json_encode(array("errors" => array($lang->error_no_settings_found)));
1233                  exit;
1234              }
1235              else
1236              {
1237                  flash_message($lang->error_no_settings_found, 'error');
1238                  admin_redirect("index.php?module=config-settings");
1239              }
1240          }
1241  
1242          // Cache groups
1243          $groups = array_keys($cache_settings);
1244          $groups = implode(',', $groups);
1245          $query = $db->simple_select("settinggroups", "*", "gid IN ({$groups})", array('order_by' => 'disporder'));
1246          while($group = $db->fetch_array($query))
1247          {
1248              $cache_groups[$group['gid']] = $group;
1249          }
1250  
1251          // Page header only if not AJAX
1252          if(!isset($mybb->input['ajax_search']))
1253          {
1254              $page->add_breadcrumb_item($lang->settings_search);
1255              $page->output_header($lang->board_settings." - {$lang->settings_search}");
1256          }
1257      }
1258      elseif($mybb->input['gid'])
1259      {
1260          // Group listing
1261          // Cache groups
1262          $query = $db->simple_select("settinggroups", "*", "gid = '".$mybb->get_input('gid', MyBB::INPUT_INT)."'");
1263          $groupinfo = $db->fetch_array($query);
1264          $cache_groups[$groupinfo['gid']] = $groupinfo;
1265  
1266          if(!$db->num_rows($query))
1267          {
1268              $page->output_error($lang->error_invalid_gid2);
1269          }
1270  
1271          // Cache settings
1272          $query = $db->simple_select("settings", "*", "gid='".$mybb->get_input('gid', MyBB::INPUT_INT)."'", array('order_by' => 'disporder'));
1273          while($setting = $db->fetch_array($query))
1274          {
1275              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1276          }
1277  
1278          if(!$db->num_rows($query))
1279          {
1280              flash_message($lang->error_no_settings_found, 'error');
1281              admin_redirect("index.php?module=config-settings");
1282          }
1283  
1284          $group_lang_var = "setting_group_{$groupinfo['name']}";
1285          if(isset($lang->$group_lang_var))
1286          {
1287              $groupinfo['title'] = $lang->$group_lang_var;
1288          }
1289  
1290          // Page header
1291          $page->add_breadcrumb_item($groupinfo['title']);
1292          $page->output_header($lang->board_settings." - {$groupinfo['title']}");
1293      }
1294      else
1295      {
1296          // All settings list
1297          // Cache groups
1298          $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder'));
1299          while($group = $db->fetch_array($query))
1300          {
1301              $cache_groups[$group['gid']] = $group;
1302          }
1303  
1304          if(!$db->num_rows($query))
1305          {
1306              $page->output_error($lang->error_invalid_gid2);
1307          }
1308  
1309          // Cache settings
1310          $query = $db->simple_select("settings", "*", "", array('order_by' => 'disporder'));
1311          while($setting = $db->fetch_array($query))
1312          {
1313              $cache_settings[$setting['gid']][$setting['sid']] = $setting;
1314          }
1315  
1316          // Page header
1317          $page->add_breadcrumb_item($lang->show_all_settings);
1318          $page->output_header($lang->board_settings." - {$lang->show_all_settings}");
1319      }
1320  
1321      // Build individual forms as per settings group
1322      foreach($cache_groups as $groupinfo)
1323      {
1324          $form = new Form("index.php?module=config-settings&amp;action=change", "post", "change");
1325          echo $form->generate_hidden_field("gid", $groupinfo['gid']);
1326          $buttons = array($form->generate_submit_button($lang->save_settings));
1327          $group_lang_var = "setting_group_{$groupinfo['name']}";
1328          if(isset($lang->$group_lang_var))
1329          {
1330              $groupinfo['title'] = $lang->$group_lang_var;
1331          }
1332  
1333          $form_container = new FormContainer($groupinfo['title']);
1334  
1335          if(empty($cache_settings[$groupinfo['gid']]))
1336          {
1337              $form_container->output_cell($lang->error_no_settings_found);
1338              $form_container->construct_row();
1339  
1340              $form_container->end();
1341              echo '<br />';
1342  
1343              continue;
1344          }
1345  
1346          foreach($cache_settings[$groupinfo['gid']] as $setting)
1347          {
1348              $options = "";
1349              $type = explode("\n", $setting['optionscode']);
1350              $type[0] = trim($type[0]);
1351              $element_name = "upsetting[{$setting['name']}]";
1352              $element_id = "setting_{$setting['name']}";
1353              if($type[0] == "text" || $type[0] == "")
1354              {
1355                  $setting_code = $form->generate_text_box($element_name, $setting['value'], array('id' => $element_id));
1356              }
1357              else if($type[0] == "numeric")
1358              {
1359                  $field_options = array('id' => $element_id);
1360                  if(count($type) > 1)
1361                  {
1362                      for($i=1; $i < count($type); $i++)
1363                      {
1364                          $optionsexp = explode("=", $type[$i]);
1365                          $opt = array_map('trim', $optionsexp);
1366                          if(in_array($opt[0], array('min', 'max', 'step')))
1367                          {
1368                              if($opt[0] != 'step' || $opt[1] != 'any')
1369                              {
1370                                  $opt[1] = (float)$opt[1];
1371                              }
1372                              $field_options[$opt[0]] = $opt[1];
1373                          }
1374                      }
1375                  }
1376                  $setting_code = $form->generate_numeric_field($element_name, $setting['value'], $field_options);
1377              }
1378              else if($type[0] == "textarea")
1379              {
1380                  $setting_code = $form->generate_text_area($element_name, $setting['value'], array('id' => $element_id));
1381              }
1382              else if($type[0] == "yesno")
1383              {
1384                  $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));
1385              }
1386              else if($type[0] == "onoff")
1387              {
1388                  $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));
1389              }
1390              else if($type[0] == "cpstyle")
1391              {
1392                  $dir = @opendir(MYBB_ROOT.$config['admin_dir']."/styles");
1393  
1394                  $folders = array();
1395                  while($folder = readdir($dir))
1396                  {
1397                      if($file != "." && $file != ".." && @file_exists(MYBB_ROOT.$config['admin_dir']."/styles/$folder/main.css"))
1398                      {
1399                          $folders[$folder] = ucfirst($folder);
1400                      }
1401                  }
1402                  closedir($dir);
1403                  ksort($folders);
1404                  $setting_code = $form->generate_select_box($element_name, $folders, $setting['value'], array('id' => $element_id));
1405              }
1406              else if($type[0] == "language")
1407              {
1408                  $languages = $lang->get_languages();
1409                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1410              }
1411              else if($type[0] == "adminlanguage")
1412              {
1413                  $languages = $lang->get_languages(1);
1414                  $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
1415              }
1416              else if($type[0] == "passwordbox")
1417              {
1418                  $setting_code = $form->generate_password_box($element_name, $setting['value'], array('id' => $element_id));
1419              }
1420              else if($type[0] == "php")
1421              {
1422                  $setting['optionscode'] = substr($setting['optionscode'], 3);
1423                  eval("\$setting_code = \"".$setting['optionscode']."\";");
1424              }
1425              else if($type[0] == "forumselect")
1426              {
1427                  $selected_values = '';
1428                  if($setting['value'] != '' && $setting['value'] != -1)
1429                  {
1430                      $selected_values = explode(',', (string)$setting['value']);
1431  
1432                      foreach($selected_values as &$value)
1433                      {
1434                          $value = (int)$value;
1435                      }
1436                      unset($value);
1437                  }
1438  
1439                  $forum_checked = array('all' => '', 'custom' => '', 'none' => '');
1440                  if($setting['value'] == -1)
1441                  {
1442                      $forum_checked['all'] = 'checked="checked"';
1443                  }
1444                  elseif($setting['value'] != '')
1445                  {
1446                      $forum_checked['custom'] = 'checked="checked"';
1447                  }
1448                  else
1449                  {
1450                      $forum_checked['none'] = 'checked="checked"';
1451                  }
1452  
1453                  print_selection_javascript();
1454  
1455                  $setting_code = "
1456                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1457                      <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>
1458                      <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>
1459                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1460                          <table cellpadding=\"4\">
1461                              <tr>
1462                                  <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
1463                                  <td>".$form->generate_forum_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1464                              </tr>
1465                          </table>
1466                      </dd>
1467                      <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>
1468                  </dl>
1469                  <script type=\"text/javascript\">
1470                      checkAction('{$element_id}');
1471                  </script>";
1472              }
1473              else if($type[0] == "forumselectsingle")
1474              {
1475                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1476                  $setting_code = $form->generate_forum_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1477              }
1478              else if($type[0] == "groupselect")
1479              {
1480                  $selected_values = '';
1481                  if($setting['value'] != '' && $setting['value'] != -1)
1482                  {
1483                      $selected_values = explode(',', (string)$setting['value']);
1484  
1485                      foreach($selected_values as &$value)
1486                      {
1487                          $value = (int)$value;
1488                      }
1489                      unset($value);
1490                  }
1491  
1492                  $group_checked = array('all' => '', 'custom' => '', 'none' => '');
1493                  if($setting['value'] == -1)
1494                  {
1495                      $group_checked['all'] = 'checked="checked"';
1496                  }
1497                  elseif($setting['value'] != '')
1498                  {
1499                      $group_checked['custom'] = 'checked="checked"';
1500                  }
1501                  else
1502                  {
1503                      $group_checked['none'] = 'checked="checked"';
1504                  }
1505  
1506                  print_selection_javascript();
1507  
1508                  $setting_code = "
1509                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1510                      <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>
1511                      <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>
1512                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1513                          <table cellpadding=\"4\">
1514                              <tr>
1515                                  <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
1516                                  <td>".$form->generate_group_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1517                              </tr>
1518                          </table>
1519                      </dd>
1520                      <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>
1521                  </dl>
1522                  <script type=\"text/javascript\">
1523                      checkAction('{$element_id}');
1524                  </script>";
1525              }
1526              else if($type[0] == "groupselectsingle")
1527              {
1528                  $selected_value = (int)$setting['value']; // No need to check if empty, int will give 0
1529                  $setting_code = $form->generate_group_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none));
1530              }
1531              else if($type[0] == "prefixselect")
1532              {
1533                  $selected_values = '';
1534                  if($setting['value'] != '' && $setting['value'] != -1)
1535                  {
1536                      $selected_values = explode(',', (string)$setting['value']);
1537                      foreach($selected_values as &$value)
1538                      {
1539                          $value = (int)$value;
1540                      }
1541                      unset($value);
1542                  }
1543                  $prefix_checked = array('all' => '', 'custom' => '', 'none' => '');
1544                  if($setting['value'] == -1)
1545                  {
1546                      $prefix_checked['all'] = 'checked="checked"';
1547                  }
1548                  elseif($setting['value'] != '')
1549                  {
1550                      $prefix_checked['custom'] = 'checked="checked"';
1551                  }
1552                  else
1553                  {
1554                      $prefix_checked['none'] = 'checked="checked"';
1555                  }
1556                  print_selection_javascript();
1557                  $setting_code = "
1558                  <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
1559                      <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>
1560                      <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>
1561                      <dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">
1562                          <table cellpadding=\"4\">
1563                              <tr>
1564                                  <td valign=\"top\"><small>{$lang->prefix_colon}</small></td>
1565                                  <td>".$form->generate_prefix_select('select['.$setting['name'].'][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5))."</td>
1566                              </tr>
1567                          </table>
1568                      </dd>
1569                      <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>
1570                  </dl>
1571                  <script type=\"text/javascript\">
1572                      checkAction('{$element_id}');
1573                  </script>";
1574              }
1575              else
1576              {
1577                  $typecount = count($type);
1578  
1579                  if($type[0] == 'checkbox')
1580                  {
1581                      $multivalue = explode(',', $setting['value']);
1582                  }
1583  
1584                  for($i = 0; $i < $typecount; $i++)
1585                  {
1586                      $optionsexp = explode("=", $type[$i]);
1587                      if(!isset($optionsexp[1]))
1588                      {
1589                          continue;
1590                      }
1591                      $title_lang = "setting_{$setting['name']}_{$optionsexp[0]}";
1592                      if(isset($lang->$title_lang))
1593                      {
1594                          $optionsexp[1] = $lang->$title_lang;
1595                      }
1596  
1597                      if($type[0] == "select")
1598                      {
1599                          $option_list[$optionsexp[0]] = htmlspecialchars_uni($optionsexp[1]);
1600                      }
1601                      else if($type[0] == "radio")
1602                      {
1603                          if($setting['value'] == $optionsexp[0])
1604                          {
1605                              $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));
1606                          }
1607                          else
1608                          {
1609                              $option_list[$i] = $form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1610                          }
1611                      }
1612                      else if($type[0] == "checkbox")
1613                      {
1614                          if(in_array($optionsexp[0], $multivalue))
1615                          {
1616                              $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));
1617                          }
1618                          else
1619                          {
1620                              $option_list[$i] = $form->generate_check_box("{$element_name}[]", $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id));
1621                          }
1622                      }
1623                  }
1624  
1625                  if($type[0] == "select")
1626                  {
1627                      $setting_code = $form->generate_select_box($element_name, $option_list, $setting['value'], array('id' => $element_id));
1628                  }
1629                  else
1630                  {
1631                      $setting_code = implode("<br />", $option_list);
1632  
1633                      if($type[0] == 'checkbox')
1634                      {
1635                          $setting_code .= $form->generate_hidden_field("isvisible_{$setting['name']}", 1);
1636                      }
1637                  }
1638                  $option_list = array();
1639              }
1640  
1641              // Do we have a custom language variable for this title or description?
1642              $title_lang = "setting_".$setting['name'];
1643              $desc_lang = $title_lang."_desc";
1644              if(isset($lang->$title_lang))
1645              {
1646                  $setting['title'] = $lang->$title_lang;
1647              }
1648              if(isset($lang->$desc_lang))
1649              {
1650                  $setting['description'] = $lang->$desc_lang;
1651              }
1652              $form_container->output_row(htmlspecialchars_uni($setting['title']), $setting['description'], $setting_code, '', array(), array('id' => 'row_'.$element_id));
1653          }
1654          $form_container->end();
1655  
1656          $form->output_submit_wrapper($buttons);
1657          $form->end();
1658          echo '<br />';
1659      }
1660  
1661      print_setting_peekers();
1662  
1663      if(!isset($mybb->input['ajax_search']))
1664      {
1665          $page->output_footer();
1666      }
1667  }
1668  
1669  if(!$mybb->input['action'])
1670  {
1671      $plugins->run_hooks("admin_config_settings_start");
1672  
1673      $page->extra_header .= <<<EOF
1674      <script type="text/javascript">
1675      <!--
1676      lang.searching = "{$lang->searching}";
1677      lang.search_error = "{$lang->search_error}";
1678      lang.search_done = "{$lang->search_done}";
1679      // -->
1680      </script>
1681  EOF;
1682  
1683      $page->output_header($lang->board_settings);
1684      if(isset($message))
1685      {
1686          $page->output_inline_message($message);
1687      }
1688  
1689      $sub_tabs['change_settings'] = array(
1690          'title' => $lang->change_settings,
1691          'link' => "index.php?module=config-settings",
1692          'description' => $lang->change_settings_desc
1693      );
1694  
1695      $sub_tabs['add_setting'] = array(
1696          'title' => $lang->add_new_setting,
1697          'link' => "index.php?module=config-settings&amp;action=add"
1698      );
1699  
1700      $sub_tabs['add_setting_group'] = array(
1701          'title' => $lang->add_new_setting_group,
1702          'link' => "index.php?module=config-settings&amp;action=addgroup"
1703      );
1704  
1705      $sub_tabs['modify_setting'] = array(
1706          'title' => $lang->modify_existing_settings,
1707          'link' => "index.php?module=config-settings&amp;action=manage",
1708      );
1709  
1710      $page->output_nav_tabs($sub_tabs, 'change_settings');
1711  
1712      // Search form
1713      echo "<div style=\"text-align: right; margin-bottom: 3px;\">";
1714      $search = new Form("index.php", 'get', 'settings_search', 0, 'settings_search');
1715      echo $search->generate_hidden_field('module', 'config/settings');
1716      echo $search->generate_hidden_field('action', 'change');
1717      echo $search->generate_text_box('search', $lang->settings_search, array('id' => 'search', 'class' => 'search_default field150 field_small'));
1718      echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />";
1719      $search->end();
1720      echo "</div>\n";
1721  
1722      echo '<div id="search_results">&nbsp;</div><div id="group_list">';
1723      $table = new Table;
1724      $table->construct_header($lang->setting_groups);
1725  
1726      switch($db->type)
1727      {
1728          case "pgsql":
1729          $query = $db->query("
1730              SELECT g.*, COUNT(s.sid) AS settingcount
1731              FROM ".TABLE_PREFIX."settinggroups g
1732              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1733              WHERE g.isdefault = 1
1734              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1735              ORDER BY g.disporder
1736          ");
1737          break;
1738          default:
1739          $query = $db->query("
1740              SELECT g.*, COUNT(s.sid) AS settingcount
1741              FROM ".TABLE_PREFIX."settinggroups g
1742              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1743              WHERE g.isdefault = 1
1744              GROUP BY g.gid
1745              ORDER BY g.disporder
1746          ");
1747      }
1748      while($group = $db->fetch_array($query))
1749      {
1750          $group_lang_var = "setting_group_{$group['name']}";
1751          if(isset($lang->$group_lang_var))
1752          {
1753              $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1754          }
1755          else
1756          {
1757              $group_title = htmlspecialchars_uni($group['title']);
1758          }
1759  
1760          $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1761          if(isset($lang->$group_desc_lang_var))
1762          {
1763              $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1764          }
1765          else
1766          {
1767              $group_desc = htmlspecialchars_uni($group['description']);
1768          }
1769  
1770          $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>");
1771          $table->construct_row();
1772      }
1773  
1774      $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}");
1775  
1776      // Plugin Settings
1777      switch($db->type)
1778      {
1779          case "pgsql":
1780          $query = $db->query("
1781              SELECT g.*, COUNT(s.sid) AS settingcount
1782              FROM ".TABLE_PREFIX."settinggroups g
1783              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1784              WHERE g.isdefault <> 1
1785              GROUP BY ".$db->build_fields_string("settinggroups", "g.")."
1786              ORDER BY g.disporder
1787          ");
1788          break;
1789          default:
1790          $query = $db->query("
1791              SELECT g.*, COUNT(s.sid) AS settingcount
1792              FROM ".TABLE_PREFIX."settinggroups g
1793              LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid)
1794              WHERE g.isdefault <> 1
1795              GROUP BY g.gid
1796              ORDER BY g.disporder
1797          ");
1798      }
1799  
1800      if($db->num_rows($query))
1801      {
1802          $table = new Table;
1803          $table->construct_header($lang->setting_groups);
1804  
1805          while($group = $db->fetch_array($query))
1806          {
1807              $group_lang_var = "setting_group_{$group['name']}";
1808              if($lang->$group_lang_var)
1809              {
1810                  $group_title = htmlspecialchars_uni($lang->$group_lang_var);
1811              }
1812              else
1813              {
1814                  $group_title = htmlspecialchars_uni($group['title']);
1815              }
1816  
1817              $group_desc_lang_var = "setting_group_{$group['name']}_desc";
1818              if($lang->$group_desc_lang_var)
1819              {
1820                  $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var);
1821              }
1822              else
1823              {
1824                  $group_desc = htmlspecialchars_uni($group['description']);
1825              }
1826  
1827              $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>");
1828              $table->construct_row();
1829          }
1830  
1831          $table->output($lang->plugin_settings);
1832      }
1833  
1834      echo '</div>';
1835  
1836      echo '
1837  <script type="text/javascript" src="./jscripts/search.js?ver=1821"></script>
1838  <script type="text/javascript">
1839  //<!--
1840  $(function(){
1841      SettingSearch.init("'.$lang->settings_search.'","'.$lang->error_ajax_unknown.'");
1842  });
1843  //-->
1844  </script>';
1845  
1846      print_setting_peekers();
1847      $page->output_footer();
1848  }
1849  
1850  /**
1851   * Print all the peekers for all of the default settings
1852   */
1853  function print_setting_peekers()
1854  {
1855      global $plugins;
1856  
1857      $peekers = array(
1858          'new Peeker($(".setting_boardclosed"), $("#row_setting_boardclosed_reason"), 1, true)',
1859          'new Peeker($(".setting_gzipoutput"), $("#row_setting_gziplevel"), 1, true)',
1860          'new Peeker($(".setting_useerrorhandling"), $("#row_setting_errorlogmedium, #row_setting_errortypemedium, #row_setting_errorloglocation"), 1, true)',
1861          'new Peeker($("#setting_subforumsindex"), $("#row_setting_subforumsstatusicons"), /[^0+|]/, false)',
1862          'new Peeker($(".setting_showsimilarthreads"), $("#row_setting_similarityrating, #row_setting_similarlimit"), 1, true)',
1863          'new Peeker($(".setting_disableregs"), $("#row_setting_regtype, #row_setting_securityquestion, #row_setting_regtime, #row_setting_allowmultipleemails, #row_setting_hiddencaptchaimage, #row_setting_betweenregstime"), 0, true)',
1864          'new Peeker($(".setting_hiddencaptchaimage"), $("#row_setting_hiddencaptchaimagefield"), 1, true)',
1865          'new Peeker($("#setting_failedlogincount"), $("#row_setting_failedlogintime, #row_setting_failedlogintext"), /[^0+|]/, false)',
1866          'new Peeker($(".setting_postfloodcheck"), $("#row_setting_postfloodsecs"), 1, true)',
1867          'new Peeker($("#setting_postmergemins"), $("#row_setting_postmergefignore, #row_setting_postmergeuignore, #row_setting_postmergesep"), /[^0+|]/, false)',
1868          'new Peeker($(".setting_enablememberlist"), $("#row_setting_membersperpage, #row_setting_default_memberlist_sortby, #row_setting_default_memberlist_order, #row_setting_memberlistmaxavatarsize"), 1, true)',
1869          '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)',
1870          'new Peeker($(".setting_enablewarningsystem"), $("#row_setting_allowcustomwarnings, #row_setting_canviewownwarning, #row_setting_maxwarningpoints, #row_setting_allowanonwarningpms"), 1, true)',
1871          '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)',
1872          'new Peeker($(".setting_smilieinserter"), $("#row_setting_smilieinsertertot, #row_setting_smilieinsertercols"), 1, true)',
1873          '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)',
1874          'new Peeker($("#setting_mail_handler"), $("#row_setting_mail_parameters"), "mail", false)',
1875          'new Peeker($("#setting_captchaimage"), $("#row_setting_captchapublickey, #row_setting_captchaprivatekey"), /(4|5)/, false)',
1876          '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)',
1877          'new Peeker($(".setting_enablepruning"), $("#row_setting_enableprunebyposts, #row_setting_pruneunactived, #row_setting_prunethreads"), 1, true)',
1878          'new Peeker($(".setting_enableprunebyposts"), $("#row_setting_prunepostcount, #row_setting_dayspruneregistered, #row_setting_prunepostcountall"), 1, true)',
1879          'new Peeker($(".setting_pruneunactived"), $("#row_setting_dayspruneunactivated"), 1, true)',
1880          'new Peeker($(".setting_statsenabled"), $("#row_setting_statscachetime, #row_setting_statslimit, #row_setting_statstopreferrer"), 1, true)',
1881          'new Peeker($(".setting_purgespammergroups_forums_groups_check"), $("#row_setting_purgespammerpostlimit, #row_setting_purgespammerbandelete, #row_setting_purgespammerapikey"), /^(?!none)/, true)',
1882          'new Peeker($(".setting_purgespammerbandelete"),$("#row_setting_purgespammerbangroup, #row_setting_purgespammerbanreason"), "ban", true)',
1883          'new Peeker($("#setting_maxloginattempts"), $("#row_setting_loginattemptstimeout"), /[^0+|]/, false)',
1884          'new Peeker($(".setting_bbcodeinserter"), $("#row_setting_partialmode, #row_setting_smilieinserter"), 1, true)',
1885          '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)',
1886          'new Peeker($(".setting_portal_announcementsfid_forums_groups_check"), $("#row_setting_portal_numannouncements"), /^(?!none)/, true)',
1887          'new Peeker($(".setting_portal_showdiscussions"), $("#row_setting_portal_showdiscussionsnum, #row_setting_portal_excludediscussion"), 1, true)',
1888          'new Peeker($(".setting_enableattachments"), $("#row_setting_maxattachments, #row_setting_attachthumbnails"), 1, true)',
1889          'new Peeker($(".setting_attachthumbnails"), $("#row_setting_attachthumbh, #row_setting_attachthumbw"), "yes", true)',
1890          'new Peeker($(".setting_showbirthdays"), $("#row_setting_showbirthdayspostlimit"), 1, true)',
1891          'new Peeker($("#setting_betweenregstime"), $("#row_setting_maxregsbetweentime"), /[^0+|]/, false)',
1892          'new Peeker($(".setting_usecdn"), $("#row_setting_cdnurl, #row_setting_cdnpath"), 1, true)',
1893          'new Peeker($("#setting_errorlogmedium"), $("#row_setting_errortypemedium"), /^(log|email|both)/, false)',
1894          'new Peeker($("#setting_errorlogmedium"), $("#row_setting_errorloglocation"), /^(log|both)/, false)',
1895          'new Peeker($(".setting_sigmycode"), $("#row_setting_sigcountmycode, #row_setting_sigimgcode"), 1, true)',
1896          'new Peeker($(".setting_pmsallowmycode"), $("#row_setting_pmsallowimgcode, #row_setting_pmsallowvideocode"), 1, true)',
1897          'new Peeker($(".setting_enableshowteam"), $("#row_setting_showaddlgroups, #row_setting_showgroupleaders"), 1, true)',
1898          'new Peeker($(".setting_usereferrals"), $("#row_setting_referralsperpage"), 1, true)',
1899      );
1900  
1901      $peekers = $plugins->run_hooks("admin_settings_print_peekers", $peekers);
1902  
1903      $setting_peekers = implode("\n            ", $peekers);
1904  
1905      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
1906      <script type="text/javascript">
1907          $(function() {
1908              ' . $setting_peekers . '
1909          });
1910      </script>';
1911  }


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