[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 // Disallow direct access to this file for security reasons 13 if(!defined("IN_MYBB")) 14 { 15 die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); 16 } 17 18 $page->add_breadcrumb_item($lang->board_settings, "index.php?module=config-settings"); 19 20 $plugins->run_hooks("admin_config_settings_begin"); 21 22 /* 23 // Delete all duplicate settings and setting groups 24 if($mybb->input['action'] == "delete_duplicates") 25 { 26 $query = $db->query(" 27 DELETE s1 28 FROM ".TABLE_PREFIX."settings s1 29 INNER JOIN ".TABLE_PREFIX."settings s2 ON (s2.name=s1.name AND s2.sid!=s1.sid AND s2.sid < s1.sid) 30 "); 31 $query = $db->query(" 32 DELETE g1 33 FROM ".TABLE_PREFIX."settinggroups g1 34 INNER JOIN ".TABLE_PREFIX."settinggroups g2 ON (g2.title=g1.title AND g2.gid!=g1.gid AND g2.gid < g1.gid) 35 "); 36 rebuild_settings(); 37 38 $plugins->run_hooks("admin_config_settings_delete_duplicates_commit"); 39 40 // Log admin action 41 log_admin_action(); 42 43 flash_message($lang->success_duplicate_settings_deleted, 'success'); 44 admin_redirect("index.php?module=config-settings&action=manage"); 45 }*/ 46 // ^^ Code, Please go away. Forever. 47 48 // Creating a new setting group 49 if($mybb->input['action'] == "addgroup") 50 { 51 $plugins->run_hooks("admin_config_settings_addgroup"); 52 53 if($mybb->request_method == "post") 54 { 55 // Validate title 56 if(!trim($mybb->input['title'])) 57 { 58 $errors[] = $lang->error_missing_group_title; 59 } 60 61 // Validate identifier 62 if(!trim($mybb->input['name'])) 63 { 64 $errors[] = $lang->error_missing_group_name; 65 } 66 $query = $db->simple_select("settinggroups", "title", "name='".$db->escape_string($mybb->input['name'])."'"); 67 if($db->num_rows($query) > 0) 68 { 69 $dup_group_title = $db->fetch_field($query, 'title'); 70 $errors[] = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title); 71 } 72 73 if(!$errors) 74 { 75 $new_setting_group = array( 76 "name" => $db->escape_string($mybb->input['name']), 77 "title" => $db->escape_string($mybb->input['title']), 78 "description" => $db->escape_string($mybb->input['description']), 79 "disporder" => intval($mybb->input['disporder']), 80 "isdefault" => 0 81 ); 82 $gid = $db->insert_query("settinggroups", $new_setting_group); 83 84 $plugins->run_hooks("admin_config_settings_addgroup_commit"); 85 86 // Log admin action 87 log_admin_action($gid, $mybb->input['name']); 88 89 flash_message($lang->success_setting_group_added, 'success'); 90 admin_redirect("index.php?module=config-settings&action=manage"); 91 } 92 } 93 94 $page->add_breadcrumb_item($lang->add_new_setting_group); 95 $page->output_header($lang->board_settings." - ".$lang->add_new_setting_group); 96 97 $sub_tabs['change_settings'] = array( 98 'title' => $lang->change_settings, 99 'link' => "index.php?module=config-settings" 100 ); 101 102 $sub_tabs['add_setting'] = array( 103 'title' => $lang->add_new_setting, 104 'link' => "index.php?module=config-settings&action=add" 105 ); 106 107 $sub_tabs['add_setting_group'] = array( 108 'title' => $lang->add_new_setting_group, 109 'link' => "index.php?module=config-settings&action=addgroup", 110 'description' => $lang->add_new_setting_group_desc 111 ); 112 113 $sub_tabs['modify_setting'] = array( 114 'title' => $lang->modify_existing_settings, 115 'link' => "index.php?module=config-settings&action=manage" 116 ); 117 118 $page->output_nav_tabs($sub_tabs, 'add_setting_group'); 119 120 $form = new Form("index.php?module=config-settings&action=addgroup", "post", "add"); 121 122 if($errors) 123 { 124 $page->output_inline_error($errors); 125 } 126 127 $form_container = new FormContainer($lang->add_new_setting_group); 128 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); 129 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $mybb->input['description'], array('id' => 'description')), 'description'); 130 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), 'disporder'); 131 $form_container->output_row($lang->name." <em>*</em>", $lang->group_name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); 132 $form_container->end(); 133 134 $buttons[] = $form->generate_submit_button($lang->insert_new_setting_group); 135 $form->output_submit_wrapper($buttons); 136 $form->end(); 137 138 $page->output_footer(); 139 } 140 141 // Edit setting group 142 if($mybb->input['action'] == "editgroup") 143 { 144 $plugins->run_hooks("admin_config_settings_editgroup"); 145 146 $query = $db->simple_select("settinggroups", "*", "gid='".intval($mybb->input['gid'])."'"); 147 $group = $db->fetch_array($query); 148 149 // Does the setting not exist? 150 if(!$group['gid']) 151 { 152 flash_message($lang->error_invalid_gid2, 'error'); 153 admin_redirect("index.php?module=config-settings&action=manage"); 154 } 155 // Prevent editing of default 156 if($group['isdefault'] == 1) 157 { 158 flash_message($lang->error_cannot_edit_default, 'error'); 159 admin_redirect("index.php?module=config-settings&action=manage"); 160 } 161 162 // Do edit? 163 if($mybb->request_method == "post") 164 { 165 // Validate title 166 if(!trim($mybb->input['title'])) 167 { 168 $errors[] = $lang->error_missing_group_title; 169 } 170 171 // Validate identifier 172 if(!trim($mybb->input['name'])) 173 { 174 $errors[] = $lang->error_missing_group_name; 175 } 176 $query = $db->simple_select("settinggroups", "title", "name='".$db->escape_string($mybb->input['name'])."' AND gid != '{$group['gid']}'"); 177 if($db->num_rows($query) > 0) 178 { 179 $dup_group_title = $db->fetch_field($query, 'title'); 180 $errors[] = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title); 181 } 182 183 if(!$errors) 184 { 185 $update_setting_group = array( 186 "name" => $db->escape_string($mybb->input['name']), 187 "title" => $db->escape_string($mybb->input['title']), 188 "description" => $db->escape_string($mybb->input['description']), 189 "disporder" => intval($mybb->input['disporder']), 190 ); 191 192 $db->update_query("settinggroups", $update_setting_group, "gid='{$group['gid']}'"); 193 194 $plugins->run_hooks("admin_config_settings_editgroup_commit"); 195 196 // Log admin action 197 log_admin_action($group['gid'], $mybb->input['name']); 198 199 flash_message($lang->success_setting_group_updated, 'success'); 200 admin_redirect("index.php?module=config-settings&action=manage"); 201 } 202 } 203 204 $page->add_breadcrumb_item($lang->edit_setting_group); 205 $page->output_header($lang->board_settings." - ".$lang->edit_setting_group); 206 207 $sub_tabs['edit_setting_group'] = array( 208 'title' => $lang->edit_setting_group, 209 'link' => "index.php?module=config-settings&action=editgroup&gid={$group['gid']}", 210 'description' => $lang->edit_setting_group_desc 211 ); 212 213 $page->output_nav_tabs($sub_tabs, 'edit_setting_group'); 214 215 $form = new Form("index.php?module=config-settings&action=editgroup", "post", "editgroup"); 216 217 echo $form->generate_hidden_field("gid", $group['gid']); 218 219 if($errors) 220 { 221 $group_data = $mybb->input; 222 $page->output_inline_error($errors); 223 } 224 else 225 { 226 $group_data = $group; 227 } 228 229 $form_container = new FormContainer($lang->edit_setting_group); 230 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $group_data['title'], array('id' => 'title')), 'title'); 231 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $group_data['description'], array('id' => 'description')), 'description'); 232 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $group_data['disporder'], array('id' => 'disporder')), 'disporder'); 233 $form_container->output_row($lang->name." <em>*</em>", $lang->group_name_desc, $form->generate_text_box('name', $group_data['name'], array('id' => 'name')), 'name'); 234 $form_container->end(); 235 236 $buttons[] = $form->generate_submit_button($lang->update_setting_group); 237 $form->output_submit_wrapper($buttons); 238 $form->end(); 239 240 $page->output_footer(); 241 } 242 243 // Delete Setting Group 244 if($mybb->input['action'] == "deletegroup") 245 { 246 $plugins->run_hooks("admin_config_settings_deletegroup"); 247 248 $query = $db->simple_select("settinggroups", "*", "gid='".intval($mybb->input['gid'])."'"); 249 $group = $db->fetch_array($query); 250 251 // Does the setting group not exist? 252 if(!$group['gid']) 253 { 254 flash_message($lang->error_invalid_gid2, 'error'); 255 admin_redirect("index.php?module=config-settings&action=manage"); 256 } 257 // Prevent deletion of default 258 if($group['isdefault'] == 1) 259 { 260 flash_message($lang->error_cannot_edit_default, 'error'); 261 admin_redirect("index.php?module=config-settings&action=manage"); 262 } 263 264 // User clicked no 265 if($mybb->input['no']) 266 { 267 admin_redirect("index.php?module=config-settings&action=manage"); 268 } 269 270 if($mybb->request_method == "post") 271 { 272 // Delete the setting group and its settings 273 $db->delete_query("settinggroups", "gid='{$group['gid']}'"); 274 $db->delete_query("settings", "gid='{$group['gid']}'"); 275 276 rebuild_settings(); 277 278 $plugins->run_hooks("admin_config_settings_deletegroup_commit"); 279 280 // Log admin action 281 log_admin_action($group['gid'], $group['name']); 282 283 flash_message($lang->success_setting_group_deleted, 'success'); 284 admin_redirect("index.php?module=config-settings&action=manage"); 285 } 286 else 287 { 288 $page->output_confirm_action("index.php?module=config-settings&action=deletegroup&gid={$group['gid']}", $lang->confirm_setting_group_deletion); 289 } 290 } 291 292 // Creating a new setting 293 if($mybb->input['action'] == "add") 294 { 295 $plugins->run_hooks("admin_config_settings_add"); 296 297 if($mybb->request_method == "post") 298 { 299 if(!trim($mybb->input['title'])) 300 { 301 $errors[] = $lang->error_missing_title; 302 } 303 304 $query = $db->simple_select("settinggroups", "gid", "gid='".intval($mybb->input['gid'])."'"); 305 $gid = $db->fetch_field($query, 'gid'); 306 if(!$gid) 307 { 308 $errors[] = $lang->error_invalid_gid; 309 } 310 311 if(!trim($mybb->input['name'])) 312 { 313 $errors[] = $lang->error_missing_name; 314 } 315 $query = $db->simple_select("settings", "title", "name='".$db->escape_string($mybb->input['name'])."'"); 316 if($db->num_rows($query) > 0) 317 { 318 $dup_setting_title = $db->fetch_field($query, 'title'); 319 $errors[] = $lang->sprintf($lang->error_duplicate_name, $dup_setting_title); 320 } 321 322 // do some type filtering 323 $mybb->input['type'] = str_replace("\n", "", $mybb->input['type']); 324 if(strtolower(substr($mybb->input['type'], 0, 3)) == "php") 325 { 326 $mybb->input['type'] = ""; 327 } 328 329 if(!$mybb->input['type']) 330 { 331 $errors[] = $lang->error_invalid_type; 332 } 333 334 if(!$errors) 335 { 336 if($mybb->input['type'] == "custom") 337 { 338 $options_code = $mybb->input['extra']; 339 } 340 else if($mybb->input['extra']) 341 { 342 $options_code = "{$mybb->input['type']}\n{$mybb->input['extra']}"; 343 } 344 else 345 { 346 $options_code = $mybb->input['type']; 347 } 348 349 $new_setting = array( 350 "name" => $db->escape_string($mybb->input['name']), 351 "title" => $db->escape_string($mybb->input['title']), 352 "description" => $db->escape_string($mybb->input['description']), 353 "optionscode" => $db->escape_string($options_code), 354 "value" => $db->escape_string($mybb->input['value']), 355 "disporder" => intval($mybb->input['disporder']), 356 "gid" => intval($mybb->input['gid']) 357 ); 358 359 $sid = $db->insert_query("settings", $new_setting); 360 rebuild_settings(); 361 362 $plugins->run_hooks("admin_config_settings_add_commit"); 363 364 // Log admin action 365 log_admin_action($sid, $mybb->input['title']); 366 367 flash_message($lang->success_setting_added, 'success'); 368 admin_redirect("index.php?module=config-settings&action=manage"); 369 } 370 } 371 372 $page->add_breadcrumb_item($lang->add_new_setting); 373 $page->output_header($lang->board_settings." - ".$lang->add_new_setting); 374 375 $sub_tabs['change_settings'] = array( 376 'title' => $lang->change_settings, 377 'link' => "index.php?module=config-settings" 378 ); 379 380 $sub_tabs['add_setting'] = array( 381 'title' => $lang->add_new_setting, 382 'link' => "index.php?module=config-settings&action=add", 383 'description' => $lang->add_new_setting_desc 384 ); 385 386 $sub_tabs['add_setting_group'] = array( 387 'title' => $lang->add_new_setting_group, 388 'link' => "index.php?module=config-settings&action=addgroup" 389 ); 390 391 $sub_tabs['modify_setting'] = array( 392 'title' => $lang->modify_existing_settings, 393 'link' => "index.php?module=config-settings&action=manage" 394 ); 395 396 $page->output_nav_tabs($sub_tabs, 'add_setting'); 397 398 $form = new Form("index.php?module=config-settings&action=add", "post", "add"); 399 400 if($errors) 401 { 402 $page->output_inline_error($errors); 403 } 404 405 $form_container = new FormContainer($lang->add_new_setting); 406 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); 407 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $mybb->input['description'], array('id' => 'description')), 'description'); 408 409 $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder')); 410 while($group = $db->fetch_array($query)) 411 { 412 $options[$group['gid']] = $group['title']; 413 } 414 $form_container->output_row($lang->group." <em>*</em>", "", $form->generate_select_box("gid", $options, $mybb->input['gid'], array('id' => 'gid')), 'gid'); 415 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), 'disporder'); 416 417 $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); 418 419 $setting_types = array( 420 "text" => $lang->text, 421 "textarea" => $lang->textarea, 422 "yesno" => $lang->yesno, 423 "onoff" => $lang->onoff, 424 "select" => $lang->select, 425 "radio" => $lang->radio, 426 "checkbox" => $lang->checkbox, 427 "language" => $lang->language_selection_box, 428 "adminlanguage" => $lang->adminlanguage, 429 "cpstyle" => $lang->cpstyle, 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"></script> 443 <script type="text/javascript">Event.observe(window, "load", function() {var peeker = new Peeker($("type"), $("row_extra"), /select|radio|checkbox|php/, false);}); 444 // Add a star to the extra row since the "extra" is required if the box is shown 445 add_star("row_extra"); 446 </script>'; 447 448 $page->output_footer(); 449 } 450 451 // Editing a particular setting 452 if($mybb->input['action'] == "edit") 453 { 454 $plugins->run_hooks("admin_config_settings_edit"); 455 456 $query = $db->simple_select("settings", "*", "sid='".intval($mybb->input['sid'])."'"); 457 $setting = $db->fetch_array($query); 458 459 // Does the setting not exist? 460 if(!$setting['sid']) 461 { 462 flash_message($lang->error_invalid_sid, 'error'); 463 admin_redirect("index.php?module=config-settings"); 464 } 465 466 // Prevent editing of default 467 if($setting['isdefault'] == 1) 468 { 469 flash_message($lang->error_cannot_edit_default, 'error'); 470 admin_redirect("index.php?module=config-settings&action=manage"); 471 } 472 $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'] = str_replace("\n", "", $mybb->input['type']); 500 if(strtolower(substr($mybb->input['type'], 0, 3)) == "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['type'] == "custom") 513 { 514 $options_code = $mybb->input['extra']; 515 } 516 else if($mybb->input['extra']) 517 { 518 $options_code = "{$mybb->input['type']}\n{$mybb->input['extra']}"; 519 } 520 else 521 { 522 $options_code = $mybb->input['type']; 523 } 524 $updated_setting = array( 525 "name" => $db->escape_string($mybb->input['name']), 526 "title" => $db->escape_string($mybb->input['title']), 527 "description" => $db->escape_string($mybb->input['description']), 528 "optionscode" => $db->escape_string($options_code), 529 "value" => $db->escape_string($mybb->input['value']), 530 "disporder" => intval($mybb->input['disporder']), 531 "gid" => intval($mybb->input['gid']) 532 ); 533 $db->update_query("settings", $updated_setting, "sid='{$mybb->input['sid']}'"); 534 rebuild_settings(); 535 536 $plugins->run_hooks("admin_config_settings_edit_commit"); 537 538 // Log admin action 539 log_admin_action($setting['sid'], $mybb->input['title']); 540 541 flash_message($lang->success_setting_updated, 'success'); 542 admin_redirect("index.php?module=config-settings&action=manage"); 543 } 544 } 545 546 $page->add_breadcrumb_item($lang->edit_setting); 547 $page->output_header($lang->board_settings." - ".$lang->edit_setting); 548 549 $sub_tabs['change_settings'] = array( 550 'title' => $lang->change_settings, 551 'link' => "index.php?module=config-settings", 552 ); 553 554 $sub_tabs['add_setting'] = array( 555 'title' => $lang->add_new_setting, 556 'link' => "index.php?module=config-settings&action=add" 557 ); 558 559 $sub_tabs['add_setting_group'] = array( 560 'title' => $lang->add_new_setting_group, 561 'link' => "index.php?module=config-settings&action=addgroup" 562 ); 563 564 $sub_tabs['modify_setting'] = array( 565 'title' => $lang->modify_existing_settings, 566 'link' => "index.php?module=config-settings&action=manage", 567 'description' => $lang->modify_existing_settings_desc 568 ); 569 570 $page->output_nav_tabs($sub_tabs, 'modify_setting'); 571 572 $form = new Form("index.php?module=config-settings&action=edit", "post", "edit"); 573 574 echo $form->generate_hidden_field("sid", $setting['sid']); 575 576 if($errors) 577 { 578 $setting_data = $mybb->input; 579 $page->output_inline_error($errors); 580 } 581 else 582 { 583 $setting_data = $setting; 584 $type = explode("\n", $setting['optionscode'], 2); 585 $setting_data['type'] = trim($type[0]); 586 $setting_data['extra'] = trim($type[1]); 587 } 588 589 $form_container = new FormContainer($lang->modify_setting); 590 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $setting_data['title'], array('id' => 'title')), 'title'); 591 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $setting_data['description'], array('id' => 'description')), 'description'); 592 593 $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder')); 594 while($group = $db->fetch_array($query)) 595 { 596 $options[$group['gid']] = $group['title']; 597 } 598 $form_container->output_row($lang->group." <em>*</em>", "", $form->generate_select_box("gid", $options, $setting_data['gid'], array('id' => 'gid')), 'gid'); 599 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $setting_data['disporder'], array('id' => 'disporder')), 'disporder'); 600 $form_container->end(); 601 602 $form_container = new FormContainer($lang->setting_configuration, 1); 603 $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $setting_data['name'], array('id' => 'name')), 'name'); 604 605 $setting_types = array( 606 "text" => $lang->text, 607 "textarea" => $lang->textarea, 608 "yesno" => $lang->yesno, 609 "onoff" => $lang->onoff, 610 "select" => $lang->select, 611 "radio" => $lang->radio, 612 "checkbox" => $lang->checkbox, 613 "language" => $lang->language_selection_box, 614 "adminlanguage" => $lang->adminlanguage, 615 "cpstyle" => $lang->cpstyle, 616 //"php" => $lang->php // Internal Use Only 617 ); 618 619 $form_container->output_row($lang->type." <em>*</em>", "", $form->generate_select_box("type", $setting_types, $setting_data['type'], array('id' => 'type')), 'type'); 620 $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')); 621 $form_container->output_row($lang->value, '', $form->generate_text_area('value', $setting_data['value'], array('id' => 'value')), 'value'); 622 $form_container->end(); 623 624 $buttons[] = $form->generate_submit_button($lang->update_setting); 625 $form->output_submit_wrapper($buttons); 626 $form->end(); 627 628 echo '<script type="text/javascript" src="./jscripts/peeker.js"></script> 629 <script type="text/javascript">Event.observe(window, "load", function() {var peeker = new Peeker($("type"), $("row_extra"), /select|radio|checkbox|php/, false);}); 630 // Add a star to the extra row since the "extra" is required if the box is shown 631 add_star("row_extra"); 632 </script>'; 633 634 $page->output_footer(); 635 } 636 637 // Delete Setting 638 if($mybb->input['action'] == "delete") 639 { 640 $plugins->run_hooks("admin_config_settings_delete"); 641 642 $query = $db->simple_select("settings", "*", "sid='".intval($mybb->input['sid'])."'"); 643 $setting = $db->fetch_array($query); 644 645 // Does the setting not exist? 646 if(!$setting['sid']) 647 { 648 flash_message($lang->error_invalid_sid, 'error'); 649 admin_redirect("index.php?module=config-settings&action=manage"); 650 } 651 652 653 // Prevent editing of default 654 if($setting['isdefault'] == 1) 655 { 656 flash_message($lang->error_cannot_edit_default, 'error'); 657 admin_redirect("index.php?module=config-settings&action=manage"); 658 } 659 660 // User clicked no 661 if($mybb->input['no']) 662 { 663 admin_redirect("index.php?module=config-settings&action=manage"); 664 } 665 666 if($mybb->request_method == "post") 667 { 668 // Delete the setting 669 $db->delete_query("settings", "sid='{$setting['sid']}'"); 670 671 rebuild_settings(); 672 673 $plugins->run_hooks("admin_config_settings_delete_commit"); 674 675 // Log admin action 676 log_admin_action($setting['sid'], $setting['title']); 677 678 flash_message($lang->success_setting_deleted, 'success'); 679 admin_redirect("index.php?module=config-settings&action=manage"); 680 } 681 else 682 { 683 $page->output_confirm_action("index.php?module=config-settings&action=delete&sid={$setting['sid']}", $lang->confirm_setting_deletion); 684 } 685 } 686 687 // Modify Existing Settings 688 if($mybb->input['action'] == "manage") 689 { 690 $plugins->run_hooks("admin_config_settings_manage"); 691 692 // Update orders 693 if($mybb->request_method == "post") 694 { 695 if(is_array($mybb->input['group_disporder'])) 696 { 697 foreach($mybb->input['group_disporder'] as $gid => $new_order) 698 { 699 $gid = intval($gid); 700 $update_group = array('disporder' => intval($new_order)); 701 $db->update_query("settinggroups", $update_group, "gid={$gid}"); 702 } 703 } 704 705 if(is_array($mybb->input['setting_disporder'])) 706 { 707 foreach($mybb->input['setting_disporder'] as $sid => $new_order) 708 { 709 $sid = intval($sid); 710 $update_setting = array('disporder' => intval($new_order)); 711 $db->update_query("settings", $update_setting, "sid={$sid}"); 712 } 713 } 714 715 $plugins->run_hooks("admin_config_settings_manage_commit"); 716 717 // Log admin action 718 log_admin_action(); 719 720 flash_message($lang->success_display_orders_updated, 'success'); 721 admin_redirect("index.php?module=config-settings&action=manage"); 722 } 723 724 $page->add_breadcrumb_item($lang->modify_existing_settings); 725 $page->output_header($lang->board_settings." - ".$lang->modify_existing_settings); 726 727 $sub_tabs['change_settings'] = array( 728 'title' => $lang->change_settings, 729 'link' => "index.php?module=config-settings", 730 ); 731 732 $sub_tabs['add_setting'] = array( 733 'title' => $lang->add_new_setting, 734 'link' => "index.php?module=config-settings&action=add" 735 ); 736 737 $sub_tabs['add_setting_group'] = array( 738 'title' => $lang->add_new_setting_group, 739 'link' => "index.php?module=config-settings&action=addgroup" 740 ); 741 742 $sub_tabs['modify_setting'] = array( 743 'title' => $lang->modify_existing_settings, 744 'link' => "index.php?module=config-settings&action=manage", 745 'description' => $lang->modify_existing_settings_desc 746 ); 747 748 $page->output_nav_tabs($sub_tabs, 'modify_setting'); 749 750 // Cache settings 751 $settings_cache = array(); 752 $query = $db->simple_select("settings", "sid, name, title, disporder, gid, isdefault", "", array('order_by' => 'disporder', 'order_dir' => 'asc')); 753 while($setting = $db->fetch_array($query)) 754 { 755 $settings_cache[$setting['gid']][] = $setting; 756 } 757 758 $form = new Form("index.php?module=config-settings&action=manage", "post", "edit"); 759 760 $table = new Table; 761 762 $table->construct_header($lang->setting_group_setting); 763 $table->construct_header($lang->order, array('class' => 'align_center', 'style' => 'width: 5%')); 764 $table->construct_header($lang->controls, array('class' => 'align_center', 'style' => 'width: 200px')); 765 766 // Generate table 767 $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder', 'order_dir' => 'asc')); 768 while($group = $db->fetch_array($query)) 769 { 770 // Make setting group row 771 // Translated? 772 $group_lang_var = "setting_group_{$group['name']}"; 773 if($lang->$group_lang_var) 774 { 775 $group_title = htmlspecialchars_uni($lang->$group_lang_var); 776 } 777 else 778 { 779 $group_title = htmlspecialchars_uni($group['title']); 780 } 781 $table->construct_cell("<strong>{$group_title}</strong>", array('id' => "group{$group['gid']}")); 782 $table->construct_cell($form->generate_text_box("group_disporder[{$group['gid']}]", $group['disporder'], array('style' => 'width: 80%; font-weight: bold', 'class' => 'align_center'))); 783 // Only show options if not a default setting group 784 if($group['isdefault'] != 1) 785 { 786 $popup = new PopupMenu("group_{$group['gid']}", $lang->options); 787 $popup->add_item($lang->edit_setting_group, "index.php?module=config-settings&action=editgroup&gid={$group['gid']}"); 788 $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}')"); 789 $table->construct_cell($popup->fetch(), array('class' => 'align_center')); 790 } 791 else 792 { 793 $table->construct_cell(''); 794 } 795 $table->construct_row(array('class' => 'alt_row', 'no_alt_row' => 1)); 796 797 // Make rows for each setting in the group 798 if(is_array($settings_cache[$group['gid']])) 799 { 800 foreach($settings_cache[$group['gid']] as $setting) 801 { 802 $setting_lang_var = "setting_{$setting['name']}"; 803 if($lang->$setting_lang_var) 804 { 805 $setting_title = htmlspecialchars_uni($lang->$setting_lang_var); 806 } 807 else 808 { 809 $setting_title = htmlspecialchars_uni($setting['title']); 810 } 811 $table->construct_cell($setting_title, array('style' => 'padding-left: 40px;')); 812 $table->construct_cell($form->generate_text_box("setting_disporder[{$setting['sid']}]", $setting['disporder'], array('style' => 'width: 80%', 'class' => 'align_center'))); 813 // Only show options if not a default setting group or is a custom setting 814 if($group['isdefault'] != 1 || $setting['isdefault'] != 1) 815 { 816 $popup = new PopupMenu("setting_{$setting['sid']}", $lang->options); 817 $popup->add_item($lang->edit_setting, "index.php?module=config-settings&action=edit&sid={$setting['sid']}"); 818 $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}')"); 819 $table->construct_cell($popup->fetch(), array('class' => 'align_center')); 820 } 821 else 822 { 823 $table->construct_cell(''); 824 } 825 $table->construct_row(array('no_alt_row' => 1, 'class' => "group{$group['gid']}")); 826 } 827 } 828 } 829 830 $table->output($lang->modify_existing_settings); 831 832 $buttons[] = $form->generate_submit_button($lang->save_display_orders); 833 $form->output_submit_wrapper($buttons); 834 $form->end(); 835 836 /*echo '<script type="text/javascript" src="./jscripts/config_settings.js"></script><script type="text/javascript">Event.observe(window, "load", ManageSettings.init);</script>';*/ 837 838 $page->output_footer(); 839 } 840 841 // Change settings for a specified group. 842 if($mybb->input['action'] == "change") 843 { 844 $plugins->run_hooks("admin_config_settings_change"); 845 846 if($mybb->request_method == "post") 847 { 848 if(!is_writable(MYBB_ROOT.'inc/settings.php')) 849 { 850 flash_message($lang->error_chmod_settings_file, 'error'); 851 admin_redirect("index.php?module=config-settings"); 852 } 853 854 if(is_array($mybb->input['upsetting'])) 855 { 856 foreach($mybb->input['upsetting'] as $name => $value) 857 { 858 $value = $db->escape_string($value); 859 $db->update_query("settings", array('value' => $value), "name='".$db->escape_string($name)."'"); 860 } 861 } 862 863 // Check if we need to create our fulltext index after changing the search mode 864 if($mybb->settings['searchtype'] != $mybb->input['upsetting']['searchtype'] && $mybb->input['upsetting']['searchtype'] == "fulltext") 865 { 866 if(!$db->is_fulltext("posts") && $db->supports_fulltext_boolean("posts")) 867 { 868 $db->create_fulltext_index("posts", "message"); 869 } 870 if(!$db->is_fulltext("posts") && $db->supports_fulltext("threads")) 871 { 872 $db->create_fulltext_index("threads", "subject"); 873 } 874 } 875 876 // If the delayedthreadviews setting was changed, enable or disable the tasks for it. 877 if(isset($mybb->input['upsetting']['delayedthreadviews']) && $mybb->settings['delayedthreadviews'] != $mybb->input['upsetting']['delayedthreadviews']) 878 { 879 if($mybb->input['upsetting']['delayedthreadviews'] == 0) 880 { 881 $updated_task = array( 882 "enabled" => 0 883 ); 884 } 885 else 886 { 887 $updated_task = array( 888 "enabled" => 1 889 ); 890 } 891 $db->update_query("tasks", $updated_task, "file='threadviews'"); 892 } 893 894 // Have we changed our cookie prefix? If so, update our adminsid so we're not logged out 895 if($mybb->input['upsetting']['cookieprefix'] && $mybb->input['upsetting']['cookieprefix'] != $mybb->settings['cookieprefix']) 896 { 897 my_unsetcookie("adminsid"); 898 $mybb->settings['cookieprefix'] = $mybb->input['upsetting']['cookieprefix']; 899 my_setcookie("adminsid", $admin_session['sid']); 900 } 901 902 // Have we opted for a reCAPTCHA and not set a public/private key? 903 if($mybb->input['upsetting']['captchaimage'] == 2 && !$mybb->input['upsetting']['captchaprivatekey'] && !$mybb->input['upsetting']['captchapublickey']) 904 { 905 $db->update_query("settings", array("value" => 1), "name = 'captchaimage'"); 906 } 907 908 rebuild_settings(); 909 910 $plugins->run_hooks("admin_config_settings_change_commit"); 911 912 // Log admin action 913 log_admin_action(); 914 915 flash_message($lang->success_settings_updated, 'success'); 916 admin_redirect("index.php?module=config-settings"); 917 } 918 919 // What type of page 920 $cache_groups = $cache_settings = array(); 921 if(isset($mybb->input['search'])) 922 { 923 // Search 924 925 // Search for settings 926 $search = $db->escape_string_like($mybb->input['search']); 927 $query = $db->query(" 928 SELECT s.* 929 FROM ".TABLE_PREFIX."settings s 930 LEFT JOIN ".TABLE_PREFIX."settinggroups g ON(s.gid=g.gid) 931 WHERE s.name LIKE '%{$search}%' OR s.title LIKE '%{$search}%' OR s.description LIKE '%{$search}%' OR g.name LIKE '%{$search}%' OR g.title LIKE '%{$search}%' OR g.description LIKE '%{$search}%' 932 ORDER BY s.disporder 933 "); 934 while($setting = $db->fetch_array($query)) 935 { 936 $cache_settings[$setting['gid']][$setting['sid']] = $setting; 937 } 938 939 if(!$db->num_rows($query)) 940 { 941 if(isset($mybb->input['ajax_search'])) 942 { 943 echo("<error>{$lang->error_no_settings_found}</error>"); 944 exit; 945 } 946 else 947 { 948 flash_message($lang->error_no_settings_found, 'error'); 949 admin_redirect("index.php?module=config-settings"); 950 } 951 } 952 953 // Cache groups 954 $groups = array_keys($cache_settings); 955 $groups = implode(',', $groups); 956 $query = $db->simple_select("settinggroups", "*", "gid IN ({$groups})", array('order_by' => 'disporder')); 957 while($group = $db->fetch_array($query)) 958 { 959 $cache_groups[$group['gid']] = $group; 960 } 961 962 // Page header only if not AJAX 963 if(!isset($mybb->input['ajax_search'])) 964 { 965 $page->add_breadcrumb_item($lang->settings_search); 966 $page->output_header($lang->board_settings." - {$lang->settings_search}"); 967 } 968 969 $form = new Form("index.php?module=config-settings&action=change", "post", "change"); 970 971 echo $form->generate_hidden_field("gid", $group['gid']); 972 } 973 elseif($mybb->input['gid']) 974 { 975 // Group listing 976 // Cache groups 977 $query = $db->simple_select("settinggroups", "*", "gid = '".intval($mybb->input['gid'])."'"); 978 $groupinfo = $db->fetch_array($query); 979 $cache_groups[$groupinfo['gid']] = $groupinfo; 980 981 if(!$db->num_rows($query)) 982 { 983 $page->output_error($lang->error_invalid_gid2); 984 } 985 986 // Cache settings 987 $query = $db->simple_select("settings", "*", "gid='".intval($mybb->input['gid'])."'", array('order_by' => 'disporder')); 988 while($setting = $db->fetch_array($query)) 989 { 990 $cache_settings[$setting['gid']][$setting['sid']] = $setting; 991 } 992 993 if(!$db->num_rows($query)) 994 { 995 flash_message($lang->error_no_settings_found, 'error'); 996 admin_redirect("index.php?module=config-settings"); 997 } 998 999 $group_lang_var = "setting_group_{$groupinfo['name']}"; 1000 if(isset($lang->$group_lang_var)) 1001 { 1002 $groupinfo['title'] = $lang->$group_lang_var; 1003 } 1004 1005 // Page header 1006 $page->add_breadcrumb_item($groupinfo['title']); 1007 $page->output_header($lang->board_settings." - {$groupinfo['title']}"); 1008 1009 $form = new Form("index.php?module=config-settings&action=change", "post", "change"); 1010 1011 echo $form->generate_hidden_field("gid", $groupinfo['gid']); 1012 } 1013 else 1014 { 1015 // All settings list 1016 // Cache groups 1017 $query = $db->simple_select("settinggroups", "*", "", array('order_by' => 'disporder')); 1018 while($group = $db->fetch_array($query)) 1019 { 1020 $cache_groups[$group['gid']] = $group; 1021 } 1022 1023 if(!$db->num_rows($query)) 1024 { 1025 $page->output_error($lang->error_invalid_gid2); 1026 } 1027 1028 // Cache settings 1029 $query = $db->simple_select("settings", "*", "", array('order_by' => 'disporder')); 1030 while($setting = $db->fetch_array($query)) 1031 { 1032 $cache_settings[$setting['gid']][$setting['sid']] = $setting; 1033 } 1034 1035 // Page header 1036 $page->add_breadcrumb_item($lang->show_all_settings); 1037 $page->output_header($lang->board_settings." - {$lang->show_all_settings}"); 1038 1039 $form = new Form("index.php?module=config-settings&action=change", "post", "change"); 1040 } 1041 1042 // Build rest of page 1043 $buttons[] = $form->generate_submit_button($lang->save_settings); 1044 foreach($cache_groups as $groupinfo) 1045 { 1046 $group_lang_var = "setting_group_{$groupinfo['name']}"; 1047 if(isset($lang->$group_lang_var)) 1048 { 1049 $groupinfo['title'] = $lang->$group_lang_var; 1050 } 1051 1052 $form_container = new FormContainer($groupinfo['title']); 1053 1054 if(empty($cache_settings[$groupinfo['gid']])) 1055 { 1056 $form_container->output_cell($lang->error_no_settings_found); 1057 $form_container->construct_row(); 1058 1059 $form_container->end(); 1060 echo '<br />'; 1061 1062 continue; 1063 } 1064 1065 foreach($cache_settings[$groupinfo['gid']] as $setting) 1066 { 1067 $options = ""; 1068 $type = explode("\n", $setting['optionscode']); 1069 $type[0] = trim($type[0]); 1070 $element_name = "upsetting[{$setting['name']}]"; 1071 $element_id = "setting_{$setting['name']}"; 1072 if($type[0] == "text" || $type[0] == "") 1073 { 1074 $setting_code = $form->generate_text_box($element_name, $setting['value'], array('id' => $element_id)); 1075 } 1076 else if($type[0] == "textarea") 1077 { 1078 $setting_code = $form->generate_text_area($element_name, $setting['value'], array('id' => $element_id)); 1079 } 1080 else if($type[0] == "yesno") 1081 { 1082 $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)); 1083 } 1084 else if($type[0] == "onoff") 1085 { 1086 $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)); 1087 } 1088 else if($type[0] == "cpstyle") 1089 { 1090 $dir = @opendir(MYBB_ROOT.$config['admin_dir']."/styles"); 1091 while($folder = readdir($dir)) 1092 { 1093 if($file != "." && $file != ".." && @file_exists(MYBB_ROOT.$config['admin_dir']."/styles/$folder/main.css")) 1094 { 1095 $folders[$folder] = ucfirst($folder); 1096 } 1097 } 1098 closedir($dir); 1099 ksort($folders); 1100 $setting_code = $form->generate_select_box($element_name, $folders, $setting['value'], array('id' => $element_id)); 1101 } 1102 else if($type[0] == "language") 1103 { 1104 $languages = $lang->get_languages(); 1105 $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id)); 1106 } 1107 else if($type[0] == "adminlanguage") 1108 { 1109 $languages = $lang->get_languages(1); 1110 $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id)); 1111 } 1112 else if($type[0] == "passwordbox") 1113 { 1114 $setting_code = $form->generate_password_box($element_name, $setting['value'], array('id' => $element_id)); 1115 } 1116 else if($type[0] == "php") 1117 { 1118 $setting['optionscode'] = substr($setting['optionscode'], 3); 1119 eval("\$setting_code = \"".$setting['optionscode']."\";"); 1120 } 1121 else 1122 { 1123 for($i=0; $i < count($type); $i++) 1124 { 1125 $optionsexp = explode("=", $type[$i]); 1126 if(!isset($optionsexp[1])) 1127 { 1128 continue; 1129 } 1130 $title_lang = "setting_{$setting['name']}_{$optionsexp[0]}"; 1131 if(isset($lang->$title_lang)) 1132 { 1133 $optionsexp[1] = $lang->$title_lang; 1134 } 1135 1136 if($type[0] == "select") 1137 { 1138 $option_list[$optionsexp[0]] = htmlspecialchars_uni($optionsexp[1]); 1139 } 1140 else if($type[0] == "radio") 1141 { 1142 if($setting['value'] == $optionsexp[0]) 1143 { 1144 $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)); 1145 } 1146 else 1147 { 1148 $option_list[$i] = $form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id)); 1149 } 1150 } 1151 else if($type[0] == "checkbox") 1152 { 1153 if($setting['value'] == $optionsexp[0]) 1154 { 1155 $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)); 1156 } 1157 else 1158 { 1159 $option_list[$i] = $form->generate_check_box($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id)); 1160 } 1161 } 1162 } 1163 if($type[0] == "select") 1164 { 1165 $setting_code = $form->generate_select_box($element_name, $option_list, $setting['value'], array('id' => $element_id)); 1166 } 1167 else 1168 { 1169 $setting_code = implode("<br />", $option_list); 1170 } 1171 $option_list = array(); 1172 } 1173 // Do we have a custom language variable for this title or description? 1174 $title_lang = "setting_".$setting['name']; 1175 $desc_lang = $title_lang."_desc"; 1176 if(isset($lang->$title_lang)) 1177 { 1178 $setting['title'] = $lang->$title_lang; 1179 } 1180 if(isset($lang->$desc_lang)) 1181 { 1182 $setting['description'] = $lang->$desc_lang; 1183 } 1184 $form_container->output_row(htmlspecialchars_uni($setting['title']), $setting['description'], $setting_code, '', array(), array('id' => 'row_'.$element_id)); 1185 } 1186 $form_container->end(); 1187 1188 $form->output_submit_wrapper($buttons); 1189 echo '<br />'; 1190 } 1191 $form->end(); 1192 1193 print_setting_peekers(); 1194 1195 if(!isset($mybb->input['ajax_search'])) 1196 { 1197 $page->output_footer(); 1198 } 1199 } 1200 1201 if(!$mybb->input['action']) 1202 { 1203 $plugins->run_hooks("admin_config_settings_start"); 1204 1205 $page->output_header($lang->board_settings); 1206 if(isset($message)) 1207 { 1208 $page->output_inline_message($message); 1209 } 1210 1211 $sub_tabs['change_settings'] = array( 1212 'title' => $lang->change_settings, 1213 'link' => "index.php?module=config-settings", 1214 'description' => $lang->change_settings_desc 1215 ); 1216 1217 $sub_tabs['add_setting'] = array( 1218 'title' => $lang->add_new_setting, 1219 'link' => "index.php?module=config-settings&action=add" 1220 ); 1221 1222 $sub_tabs['add_setting_group'] = array( 1223 'title' => $lang->add_new_setting_group, 1224 'link' => "index.php?module=config-settings&action=addgroup" 1225 ); 1226 1227 $sub_tabs['modify_setting'] = array( 1228 'title' => $lang->modify_existing_settings, 1229 'link' => "index.php?module=config-settings&action=manage", 1230 ); 1231 1232 $page->output_nav_tabs($sub_tabs, 'change_settings'); 1233 1234 // Search form 1235 echo "<div style=\"text-align: right; margin-bottom: 3px;\">"; 1236 $search = new Form("index.php", 'get', 'settings_search', 0, 'settings_search'); 1237 echo $search->generate_hidden_field('module', 'config/settings'); 1238 echo $search->generate_hidden_field('action', 'change'); 1239 echo $search->generate_text_box('search', $lang->settings_search, array('id' => 'search', 'class' => 'search_default field150 field_small')); 1240 echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />"; 1241 $search->end(); 1242 echo "</div>\n"; 1243 1244 echo '<div id="search_results"> </div><div id="group_list">'; 1245 $table = new Table; 1246 $table->construct_header($lang->setting_groups); 1247 1248 switch($db->type) 1249 { 1250 case "pgsql": 1251 $query = $db->query(" 1252 SELECT g.*, COUNT(s.sid) AS settingcount 1253 FROM ".TABLE_PREFIX."settinggroups g 1254 LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid) 1255 GROUP BY ".$db->build_fields_string("settinggroups", "g.")." 1256 ORDER BY g.disporder 1257 "); 1258 break; 1259 default: 1260 $query = $db->query(" 1261 SELECT g.*, COUNT(s.sid) AS settingcount 1262 FROM ".TABLE_PREFIX."settinggroups g 1263 LEFT JOIN ".TABLE_PREFIX."settings s ON (s.gid=g.gid) 1264 GROUP BY g.gid 1265 ORDER BY g.disporder 1266 "); 1267 } 1268 while($group = $db->fetch_array($query)) 1269 { 1270 $group_lang_var = "setting_group_{$group['name']}"; 1271 if(isset($lang->$group_lang_var)) 1272 { 1273 $group_title = htmlspecialchars_uni($lang->$group_lang_var); 1274 } 1275 else 1276 { 1277 $group_title = htmlspecialchars_uni($group['title']); 1278 } 1279 1280 $group_desc_lang_var = "setting_group_{$group['name']}_desc"; 1281 if(isset($lang->$group_desc_lang_var)) 1282 { 1283 $group_desc = htmlspecialchars_uni($lang->$group_desc_lang_var); 1284 } 1285 else 1286 { 1287 $group_desc = htmlspecialchars_uni($group['description']); 1288 } 1289 1290 $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>"); 1291 $table->construct_row(); 1292 } 1293 $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}"); 1294 1295 echo '</div>'; 1296 1297 echo ' 1298 <script type="text/javascript"> 1299 //<!-- 1300 var SettingSearch = Class.create(); 1301 SettingSearch.prototype = { 1302 1303 spinner: null, 1304 form: null, 1305 result_div: null, 1306 hide_div: null, 1307 search_box: null, 1308 1309 initialize: function(form, search_box, result_div, hide_div) 1310 { 1311 Event.observe(form, "submit", this.onSubmit.bind(this)); 1312 this.form = form; 1313 this.result_div = result_div; 1314 this.hide_div = hide_div; 1315 result_div.style.display = "none"; 1316 this.search_box = search_box; 1317 Event.observe(search_box, "focus", function() { 1318 if($("search").value == "'.$lang->settings_search.'") 1319 { 1320 $("search").removeClassName("search_default"); 1321 $("search").value = ""; 1322 } 1323 }); 1324 Event.observe(search_box, "blur", function() { 1325 if($("search").value == "") 1326 { 1327 $("search").addClassName("search_default"); 1328 $("search").value = "'.$lang->settings_search.'"; 1329 $("search_results").style.display = "none"; 1330 $("group_list").style.display = ""; 1331 } 1332 }); 1333 }, 1334 1335 onSubmit: function(e) 1336 { 1337 Event.stop(e); 1338 if(this.search_box.value != "") 1339 { 1340 this.spinner = new ActivityIndicator("body", {image: "../images/spinner_big.gif"}); 1341 pars = "module=config-settings&action=change&ajax_search=1&search="+encodeURIComponent(this.search_box.value); 1342 new Ajax.Request("index.php", { 1343 method: "get", 1344 parameters: pars, 1345 onComplete: this.onComplete.bind(this) 1346 }); 1347 } 1348 }, 1349 1350 onComplete: function(request) 1351 { 1352 if(request.responseText.match(/<error>(.*)<\/error>/) || request.responseText == "") 1353 { 1354 message = request.responseText.match(/<error>(.*)<\/error>/); 1355 if(!message[1]) 1356 { 1357 message[1] = "'.$lang->error_ajax_unknown.'"; 1358 } 1359 alert(message[1]); 1360 } 1361 else if(request.responseText) 1362 { 1363 this.result_div.style.display = ""; 1364 this.hide_div.style.display = "none"; 1365 this.result_div.innerHTML = request.responseText; 1366 loadPeekers(); 1367 } 1368 this.spinner.destroy(); 1369 } 1370 } 1371 new SettingSearch($("settings_search"), $("search"), $("search_results"), $("group_list")); 1372 //--> 1373 </script>'; 1374 1375 print_setting_peekers(); 1376 $page->output_footer(); 1377 } 1378 1379 function print_setting_peekers() 1380 { 1381 echo '<script type="text/javascript" src="./jscripts/peeker.js"></script> 1382 <script type="text/javascript"> 1383 Event.observe(window, "load", function() { 1384 loadPeekers(); 1385 }); 1386 function loadPeekers() 1387 { 1388 new Peeker($$(".setting_boardclosed"), $("row_setting_boardclosed_reason"), /1/, true); 1389 new Peeker($$(".setting_gzipoutput"), $("row_setting_gziplevel"), /1/, true); 1390 new Peeker($$(".setting_useerrorhandling"), $("row_setting_errorlogmedium"), /1/, true); 1391 new Peeker($$(".setting_useerrorhandling"), $("row_setting_errortypemedium"), /1/, true); 1392 new Peeker($$(".setting_useerrorhandling"), $("row_setting_errorloglocation"), /1/, true); 1393 new Peeker($("setting_subforumsindex"), $("row_setting_subforumsstatusicons"), /[^0]/, false); 1394 new Peeker($$(".setting_showsimilarthreads"), $("row_setting_similarityrating"), /1/, true); 1395 new Peeker($$(".setting_showsimilarthreads"), $("row_setting_similarlimit"), /1/, true); 1396 new Peeker($$(".setting_disableregs"), $("row_setting_regtype"), /0/, true); 1397 new Peeker($$(".setting_hiddencaptchaimage"), $("row_setting_hiddencaptchaimagefield"), /1/, true); 1398 new Peeker($$(".setting_showsimilarthreads"), $("row_setting_similarlimit"), /1/, true); 1399 new Peeker($("setting_failedlogincount"), $("row_setting_failedlogintime"), /[^0]/, false); 1400 new Peeker($("setting_failedlogincount"), $("row_setting_failedlogintext"), /[^0]/, false); 1401 new Peeker($$(".setting_postfloodcheck"), $("row_setting_postfloodsecs"), /1/, true); 1402 new Peeker($("setting_postmergemins"), $("row_setting_postmergefignore"), /[^0]/, false); 1403 new Peeker($("setting_postmergemins"), $("row_setting_postmergeuignore"), /[^0]/, false); 1404 new Peeker($("setting_postmergemins"), $("row_setting_postmergesep"), /[^0]/, false); 1405 new Peeker($$(".setting_enablememberlist"), $("row_setting_membersperpage"), /1/, true); 1406 new Peeker($$(".setting_enablememberlist"), $("row_setting_default_memberlist_sortby"), /1/, true); 1407 new Peeker($$(".setting_enablememberlist"), $("row_setting_default_memberlist_order"), /1/, true); 1408 new Peeker($$(".setting_enablereputation"), $("row_setting_repsperpage"), /1/, true); 1409 new Peeker($$(".setting_enablewarningsystem"), $("row_setting_allowcustomwarnings"), /1/, true); 1410 new Peeker($$(".setting_enablewarningsystem"), $("row_setting_canviewownwarning"), /1/, true); 1411 new Peeker($$(".setting_enablewarningsystem"), $("row_setting_maxwarningpoints"), /1/, true); 1412 new Peeker($$(".setting_enablepms"), $("row_setting_pmsallowhtml"), /1/, true); 1413 new Peeker($$(".setting_enablepms"), $("row_setting_pmsallowmycode"), /1/, true); 1414 new Peeker($$(".setting_enablepms"), $("row_setting_pmsallowsmilies"), /1/, true); 1415 new Peeker($$(".setting_enablepms"), $("row_setting_pmsallowimgcode"), /1/, true); 1416 new Peeker($$(".setting_enablepms"), $("row_setting_pmsallowvideocode"), /1/, true); 1417 new Peeker($$(".setting_smilieinserter"), $("row_setting_smilieinsertertot"), /1/, true); 1418 new Peeker($$(".setting_smilieinserter"), $("row_setting_smilieinsertercols"), /1/, true); 1419 new Peeker($("setting_mail_handler"), $("row_setting_smtp_host"), /smtp/, false); 1420 new Peeker($("setting_mail_handler"), $("row_setting_smtp_port"), /smtp/, false); 1421 new Peeker($("setting_mail_handler"), $("row_setting_smtp_user"), /smtp/, false); 1422 new Peeker($("setting_mail_handler"), $("row_setting_smtp_pass"), /smtp/, false); 1423 new Peeker($("setting_mail_handler"), $("row_setting_secure_smtp"), /smtp/, false); 1424 new Peeker($("setting_mail_handler"), $("row_setting_mail_parameters"), /mail/, false); 1425 new Peeker($("setting_captchaimage"), $("row_setting_captchapublickey"), 2, false); 1426 new Peeker($("setting_captchaimage"), $("row_setting_captchaprivatekey"), 2, false); 1427 } 1428 </script>'; 1429 } 1430 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |