Zeile 18 | Zeile 18 |
---|
$plugins->run_hooks("admin_config_badwords_begin");
|
$plugins->run_hooks("admin_config_badwords_begin");
|
if($mybb->input['action'] == "add" && $mybb->request_method == "post")
| if($mybb->input['action'] == "add")
|
{ $plugins->run_hooks("admin_config_badwords_add");
|
{ $plugins->run_hooks("admin_config_badwords_add");
|
if(!trim($mybb->input['badword'])) { $errors[] = $lang->error_missing_bad_word; }
if(strlen(trim($mybb->input['badword'])) > 100) { $errors[] = $lang->bad_word_max; }
if(strlen($mybb->input['replacement']) > 100) { $errors[] = $lang->replacement_word_max; }
if(!$errors) { $query = $db->simple_select("badwords", "bid", "badword = '".$db->escape_string($mybb->input['badword'])."'");
if($db->num_rows($query)) { $errors[] = $lang->error_bad_word_filtered; } }
$badword = trim($mybb->input['badword']);
if($mybb->get_input('regex', MyBB::INPUT_INT)) { // Check validity of defined regular expression if((@preg_match('#'.$badword.'#is', null) === false)) { $errors[] = $lang->error_invalid_regex; } } else { if(!is_object($parser)) { require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser; } $badword = $parser->generate_regex($badword); }
// Don't allow certain badword replacements to be added if it would cause an infinite recursive loop. if(@preg_match('#'.$badword.'#is', $mybb->input['replacement'])) { $errors[] = $lang->error_replacement_word_invalid; }
if(!$errors) { $new_badword = array( "badword" => $db->escape_string($mybb->input['badword']), "regex" => $mybb->get_input('regex', MyBB::INPUT_INT), "replacement" => $db->escape_string($mybb->input['replacement']) );
$bid = $db->insert_query("badwords", $new_badword);
$plugins->run_hooks("admin_config_badwords_add_commit");
// Log admin action log_admin_action($bid, $mybb->input['badword']);
$cache->update_badwords(); flash_message($lang->success_added_bad_word, 'success'); admin_redirect("index.php?module=config-badwords"); } else { $mybb->input['action'] = '';
| if($mybb->request_method == "post") { if(!trim($mybb->input['badword'])) { $errors[] = $lang->error_missing_bad_word; }
if(strlen(trim($mybb->input['badword'])) > 100) { $errors[] = $lang->bad_word_max; }
if(strlen($mybb->input['replacement']) > 100) { $errors[] = $lang->replacement_word_max; }
if(!$errors) { $query = $db->simple_select("badwords", "bid", "badword = '".$db->escape_string($mybb->input['badword'])."'");
if($db->num_rows($query)) { $errors[] = $lang->error_bad_word_filtered; } }
$badword = trim($mybb->input['badword']);
if($mybb->get_input('regex', MyBB::INPUT_INT)) { // Check validity of defined regular expression if((@preg_match('#'.$badword.'#is', '') === false)) { $errors[] = $lang->error_invalid_regex; } } else { if(!isset($parser) || !is_object($parser)) { require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser; }
$badword = $parser->generate_regex($badword); }
// Don't allow certain badword replacements to be added if it would cause an infinite recursive loop. if(@preg_match('#'.$badword.'#is', $mybb->input['replacement'])) { $errors[] = $lang->error_replacement_word_invalid; }
if(!$errors) { $new_badword = array( "badword" => $db->escape_string($mybb->input['badword']), "regex" => $mybb->get_input('regex', MyBB::INPUT_INT), "replacement" => $db->escape_string($mybb->input['replacement']) );
$bid = $db->insert_query("badwords", $new_badword);
$plugins->run_hooks("admin_config_badwords_add_commit");
// Log admin action log_admin_action($bid, $mybb->input['badword']);
$cache->update_badwords(); flash_message($lang->success_added_bad_word, 'success'); admin_redirect("index.php?module=config-badwords"); } }
$page->add_breadcrumb_item($lang->add_bad_word); $page->output_header($lang->bad_words." - ".$lang->add_bad_word);
$sub_tabs['badwords'] = array( 'title' => $lang->bad_word_filters, 'description' => $lang->bad_word_filters_desc, 'link' => "index.php?module=config-badwords" );
$sub_tabs['add_badword'] = array( 'title' => $lang->add_bad_word, 'description' => $lang->add_bad_word_desc, 'link' => "index.php?module=config-badwords&action=add" );
$page->output_nav_tabs($sub_tabs, "add_badword");
$form = new Form("index.php?module=config-badwords&action=add", "post", "add");
if($errors) { $page->output_inline_error($errors);
|
}
|
}
|
| $form_container = new FormContainer($lang->add_bad_word); $form_container->output_row($lang->bad_word." <em>*</em>", $lang->bad_word_desc, $form->generate_text_box('badword', $mybb->get_input('badword'), array('id' => 'badword')), 'badword'); $form_container->output_row($lang->replacement, $lang->replacement_desc, $form->generate_text_box('replacement', $mybb->get_input('replacement'), array('id' => 'replacement')), 'replacement'); $form_container->output_row($lang->regex, $lang->regex_desc, $form->generate_yes_no_radio('regex', $mybb->get_input('regex', MyBB::INPUT_INT), array('id' => 'regex')), 'regex'); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->save_bad_word); $form->output_submit_wrapper($buttons); $form->end();
$page->output_footer();
|
}
if($mybb->input['action'] == "delete") { $query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'"); $badword = $db->fetch_array($query);
|
}
if($mybb->input['action'] == "delete") { $query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'"); $badword = $db->fetch_array($query);
|
|
|
// Does the bad word not exist?
|
// Does the bad word not exist?
|
if(!$badword['bid'])
| if(!$badword)
|
{ flash_message($lang->error_invalid_bid, 'error'); admin_redirect("index.php?module=config-badwords"); }
// User clicked no
|
{ flash_message($lang->error_invalid_bid, 'error'); admin_redirect("index.php?module=config-badwords"); }
// User clicked no
|
if($mybb->input['no']) { admin_redirect("index.php?module=config-badwords"); }
| if($mybb->get_input('no')) { admin_redirect("index.php?module=config-badwords"); }
|
$plugins->run_hooks("admin_config_badwords_delete");
| $plugins->run_hooks("admin_config_badwords_delete");
|
Zeile 123 | Zeile 157 |
---|
{ // Delete the bad word $db->delete_query("badwords", "bid='{$badword['bid']}'");
|
{ // Delete the bad word $db->delete_query("badwords", "bid='{$badword['bid']}'");
|
|
|
$plugins->run_hooks("admin_config_badwords_delete_commit");
// Log admin action log_admin_action($badword['bid'], $badword['badword']);
$cache->update_badwords();
|
$plugins->run_hooks("admin_config_badwords_delete_commit");
// Log admin action log_admin_action($badword['bid'], $badword['badword']);
$cache->update_badwords();
|
|
|
flash_message($lang->success_deleted_bad_word, 'success'); admin_redirect("index.php?module=config-badwords"); }
| flash_message($lang->success_deleted_bad_word, 'success'); admin_redirect("index.php?module=config-badwords"); }
|
Zeile 143 | Zeile 177 |
---|
if($mybb->input['action'] == "edit") { $query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'");
|
if($mybb->input['action'] == "edit") { $query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'");
|
$badword = $db->fetch_array($query);
| $badword = $db->fetch_array($query);
|
// Does the bad word not exist?
|
// Does the bad word not exist?
|
if(!$badword['bid'])
| if(!$badword)
|
{ flash_message($lang->error_invalid_bid, 'error'); admin_redirect("index.php?module=config-badwords"); }
|
{ flash_message($lang->error_invalid_bid, 'error'); admin_redirect("index.php?module=config-badwords"); }
|
|
|
$plugins->run_hooks("admin_config_badwords_edit");
if($mybb->request_method == "post") { if(!trim($mybb->input['badword']))
|
$plugins->run_hooks("admin_config_badwords_edit");
if($mybb->request_method == "post") { if(!trim($mybb->input['badword']))
|
{
| {
|
$errors[] = $lang->error_missing_bad_word;
|
$errors[] = $lang->error_missing_bad_word;
|
}
| }
|
if(strlen(trim($mybb->input['badword'])) > 100) { $errors[] = $lang->bad_word_max;
| if(strlen(trim($mybb->input['badword'])) > 100) { $errors[] = $lang->bad_word_max;
|
Zeile 168 | Zeile 202 |
---|
if(strlen($mybb->input['replacement']) > 100) {
|
if(strlen($mybb->input['replacement']) > 100) {
|
$errors[] = $lang->replacement_word_max;
| $errors[] = $lang->replacement_word_max; }
if(!$errors) { $query = $db->simple_select("badwords", "bid", "badword = '".$db->escape_string($mybb->input['badword'])."' AND bid != '".$badword['bid']."'");
if($db->num_rows($query)) { $errors[] = $lang->error_bad_word_filtered; } }
$badword_check = trim($mybb->input['badword']);
if($mybb->get_input('regex', MyBB::INPUT_INT)) { // Check validity of defined regular expression if((@preg_match('#'.$badword_check.'#is', '') === false)) { $errors[] = $lang->error_invalid_regex; } } else { if(!isset($parser) || !is_object($parser)) { require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser; }
$badword_check = $parser->generate_regex($badword_check); }
// Don't allow certain badword replacements to be added if it would cause an infinite recursive loop. if(@preg_match('#'.$badword_check.'#is', $mybb->input['replacement'])) { $errors[] = $lang->error_replacement_word_invalid;
|
}
if(!$errors)
| }
if(!$errors)
|
Zeile 199 | Zeile 270 |
---|
$sub_tabs['editbadword'] = array( 'title' => $lang->edit_bad_word, 'description' => $lang->edit_bad_word_desc,
|
$sub_tabs['editbadword'] = array( 'title' => $lang->edit_bad_word, 'description' => $lang->edit_bad_word_desc,
|
'link' => "index.php?module=config-badwords" );
$page->output_nav_tabs($sub_tabs, "editbadword");
| 'link' => "index.php?module=config-badwords" );
$page->output_nav_tabs($sub_tabs, "editbadword");
|
$form = new Form("index.php?module=config-badwords&action=edit&bid={$badword['bid']}", "post");
if($errors)
| $form = new Form("index.php?module=config-badwords&action=edit&bid={$badword['bid']}", "post");
if($errors)
|
Zeile 236 | Zeile 307 |
---|
'title' => $lang->bad_word_filters, 'description' => $lang->bad_word_filters_desc, 'link' => "index.php?module=config-badwords"
|
'title' => $lang->bad_word_filters, 'description' => $lang->bad_word_filters_desc, 'link' => "index.php?module=config-badwords"
|
| );
$sub_tabs['add_badword'] = array( 'title' => $lang->add_bad_word, 'description' => $lang->add_bad_word_desc, 'link' => "index.php?module=config-badwords&action=add"
|
);
$plugins->run_hooks("admin_config_badwords_start");
$page->output_nav_tabs($sub_tabs, "badwords");
|
);
$plugins->run_hooks("admin_config_badwords_start");
$page->output_nav_tabs($sub_tabs, "badwords");
|
if($errors) { $page->output_inline_error($errors); }
| $query = $db->simple_select("badwords", "COUNT(bid) AS badwords"); $total_rows = $db->fetch_field($query, "badwords");
$pagenum = $mybb->get_input('page', MyBB::INPUT_INT); if($pagenum) { $start = ($pagenum - 1) * 20; $pages = ceil($total_rows / 20); if($pagenum > $pages) { $start = 0; $pagenum = 1; } } else { $start = 0; $pagenum = 1; }
|
$table = new Table; $table->construct_header($lang->bad_word); $table->construct_header($lang->replacement, array("width" => "50%")); $table->construct_header($lang->regex, array("class" => "align_center", "width" => "20%")); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150, "colspan" => 2));
|
$table = new Table; $table->construct_header($lang->bad_word); $table->construct_header($lang->replacement, array("width" => "50%")); $table->construct_header($lang->regex, array("class" => "align_center", "width" => "20%")); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150, "colspan" => 2));
|
$query = $db->simple_select("badwords", "*", "", array("order_by" => "badword", "order_dir" => "asc"));
| $query = $db->simple_select("badwords", "*", "", array('limit_start' => $start, 'limit' => 20, "order_by" => "badword", "order_dir" => "asc"));
|
while($badword = $db->fetch_array($query)) { $badword['badword'] = htmlspecialchars_uni($badword['badword']);
| while($badword = $db->fetch_array($query)) { $badword['badword'] = htmlspecialchars_uni($badword['badword']);
|
Zeile 261 | Zeile 353 |
---|
if(!$badword['replacement']) { $badword['replacement'] = '*****';
|
if(!$badword['replacement']) { $badword['replacement'] = '*****';
|
}
| }
|
$regex = $lang->no; if($badword['regex']) {
| $regex = $lang->no; if($badword['regex']) {
|
Zeile 274 | Zeile 366 |
---|
$table->construct_cell($regex, array("class" => "align_center")); $table->construct_cell("<a href=\"index.php?module=config-badwords&action=edit&bid={$badword['bid']}\">{$lang->edit}</a>", array("class" => "align_center")); $table->construct_cell("<a href=\"index.php?module=config-badwords&action=delete&bid={$badword['bid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_bad_word_deletion}');\">{$lang->delete}</a>", array("class" => "align_center"));
|
$table->construct_cell($regex, array("class" => "align_center")); $table->construct_cell("<a href=\"index.php?module=config-badwords&action=edit&bid={$badword['bid']}\">{$lang->edit}</a>", array("class" => "align_center")); $table->construct_cell("<a href=\"index.php?module=config-badwords&action=delete&bid={$badword['bid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_bad_word_deletion}');\">{$lang->delete}</a>", array("class" => "align_center"));
|
$table->construct_row(); }
| $table->construct_row(); }
|
if($table->num_rows() == 0) {
| if($table->num_rows() == 0) {
|
Zeile 285 | Zeile 377 |
---|
$table->output($lang->bad_word_filters);
|
$table->output($lang->bad_word_filters);
|
$form = new Form("index.php?module=config-badwords&action=add", "post", "add");
$form_container = new FormContainer($lang->add_bad_word); $form_container->output_row($lang->bad_word." <em>*</em>", $lang->bad_word_desc, $form->generate_text_box('badword', $mybb->input['badword'], array('id' => 'badword')), 'badword'); $form_container->output_row($lang->replacement, $lang->replacement_desc, $form->generate_text_box('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement'); $form_container->output_row($lang->regex, $lang->regex_desc, $form->generate_yes_no_radio('regex', !$mybb->get_input('regex'), array('id' => 'regex')), 'regex'); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->save_bad_word); $form->output_submit_wrapper($buttons); $form->end();
| echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-badwords&page={page}");
|
$page->output_footer(); }
| $page->output_footer(); }
|