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