Zeile 97 | Zeile 97 |
---|
if(!trim($mybb->input['regex'])) { $errors[] = $lang->error_missing_regex;
|
if(!trim($mybb->input['regex'])) { $errors[] = $lang->error_missing_regex;
|
| }
$regex = str_replace("\x0", "", $mybb->input['regex']);
if(check_existing_regex($regex)) { $errors[] = $lang->error_regex_already_available;
|
}
if(!trim($mybb->input['replacement'])) { $errors[] = $lang->error_missing_replacement;
|
}
if(!trim($mybb->input['replacement'])) { $errors[] = $lang->error_missing_replacement;
|
}
| }
|
if($mybb->input['test']) { $errors[] = $lang->changes_not_saved; $sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);
|
if($mybb->input['test']) { $errors[] = $lang->changes_not_saved; $sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);
|
}
| }
|
if(!$errors) { $new_mycode = array( 'title' => $db->escape_string($mybb->input['title']), 'description' => $db->escape_string($mybb->input['description']),
|
if(!$errors) { $new_mycode = array( 'title' => $db->escape_string($mybb->input['title']), 'description' => $db->escape_string($mybb->input['description']),
|
'regex' => $db->escape_string(str_replace("\x0", "", $mybb->input['regex'])),
| 'regex' => $db->escape_string($regex),
|
'replacement' => $db->escape_string($mybb->input['replacement']), 'active' => $mybb->get_input('active', MyBB::INPUT_INT), 'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT) );
$cid = $db->insert_query("mycode", $new_mycode);
|
'replacement' => $db->escape_string($mybb->input['replacement']), 'active' => $mybb->get_input('active', MyBB::INPUT_INT), 'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT) );
$cid = $db->insert_query("mycode", $new_mycode);
|
|
|
$plugins->run_hooks("admin_config_mycode_add_commit");
|
$plugins->run_hooks("admin_config_mycode_add_commit");
|
|
|
$cache->update_mycode();
|
$cache->update_mycode();
|
|
|
// Log admin action log_admin_action($cid, htmlspecialchars_uni($mybb->input['title']));
|
// Log admin action log_admin_action($cid, htmlspecialchars_uni($mybb->input['title']));
|
|
|
flash_message($lang->success_added_mycode, 'success');
|
flash_message($lang->success_added_mycode, 'success');
|
admin_redirect('index.php?module=config-mycode'); } }
$sub_tabs['mycode'] = array( 'title' => $lang->mycode, 'link' => "index.php?module=config-mycode", 'description' => $lang->mycode_desc );
$sub_tabs['add_new_mycode'] = array( 'title' => $lang->add_new_mycode,
| admin_redirect('index.php?module=config-mycode'); } }
$sub_tabs['mycode'] = array( 'title' => $lang->mycode, 'link' => "index.php?module=config-mycode", 'description' => $lang->mycode_desc );
$sub_tabs['add_new_mycode'] = array( 'title' => $lang->add_new_mycode,
|
'link' => "index.php?module=config-mycode&action=add", 'description' => $lang->add_new_mycode_desc );
| 'link' => "index.php?module=config-mycode&action=add", 'description' => $lang->add_new_mycode_desc );
|
Zeile 158 | Zeile 165 |
---|
$page->output_nav_tabs($sub_tabs, 'add_new_mycode');
if($errors)
|
$page->output_nav_tabs($sub_tabs, 'add_new_mycode');
if($errors)
|
{
| {
|
$page->output_inline_error($errors); } else
| $page->output_inline_error($errors); } else
|
Zeile 168 | Zeile 175 |
---|
$form = new Form("index.php?module=config-mycode&action=add", "post", "add"); $form_container = new FormContainer($lang->add_mycode);
|
$form = new Form("index.php?module=config-mycode&action=add", "post", "add"); $form_container = new FormContainer($lang->add_mycode);
|
$form_container->output_row($lang->title." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->short_description, '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description'); $form_container->output_row($lang->regular_expression." <em>*</em>", $lang->regular_expression_desc.'<br /><strong>'.$lang->example.'</strong> \[b\](.*?)\[/b\]', $form->generate_text_area('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex'); $form_container->output_row($lang->replacement." <em>*</em>", $lang->replacement_desc.'<br /><strong>'.$lang->example.'</strong> <strong>$1</strong>', $form->generate_text_area('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement'); $form_container->output_row($lang->enabled." <em>*</em>", '', $form->generate_yes_no_radio('active', $mybb->input['active'])); $form_container->output_row($lang->parse_order, $lang->parse_order_desc, $form->generate_numeric_field('parseorder', $mybb->input['parseorder'], array('id' => 'parseorder', 'min' => 0)), 'parseorder'); $form_container->end();
$buttons[] = $form->generate_submit_button($lang->save_mycode); $form->output_submit_wrapper($buttons);
// Sandbox echo "<br />\n"; $form_container = new FormContainer($lang->sandbox); $form_container->output_row($lang->sandbox_desc); $form_container->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->input['test_value'], array('id' => 'test_value'))."<br />".$form->generate_submit_button($lang->test, array('id' => 'test', 'name' => 'test')), 'test_value'); $form_container->output_row($lang->result_html, $lang->result_html_desc, $form->generate_text_area('result_html', $sandbox['html'], array('id' => 'result_html', 'disabled' => 1)), 'result_html');
| $form_container->output_row($lang->title." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->short_description, '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description'); $form_container->output_row($lang->regular_expression." <em>*</em>", $lang->regular_expression_desc.'<br /><strong>'.$lang->example.'</strong> \[b\](.*?)\[/b\]', $form->generate_text_area('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex'); $form_container->output_row($lang->replacement." <em>*</em>", $lang->replacement_desc.'<br /><strong>'.$lang->example.'</strong> <strong>$1</strong>', $form->generate_text_area('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement'); $form_container->output_row($lang->enabled." <em>*</em>", '', $form->generate_yes_no_radio('active', $mybb->input['active'])); $form_container->output_row($lang->parse_order, $lang->parse_order_desc, $form->generate_numeric_field('parseorder', $mybb->input['parseorder'], array('id' => 'parseorder', 'min' => 0)), 'parseorder'); $form_container->end();
$buttons[] = $form->generate_submit_button($lang->save_mycode); $form->output_submit_wrapper($buttons);
// Sandbox echo "<br />\n"; $form_container = new FormContainer($lang->sandbox); $form_container->output_row($lang->sandbox_desc); $form_container->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->input['test_value'], array('id' => 'test_value'))."<br />".$form->generate_submit_button($lang->test, array('id' => 'test', 'name' => 'test')), 'test_value'); $form_container->output_row($lang->result_html, $lang->result_html_desc, $form->generate_text_area('result_html', $sandbox['html'], array('id' => 'result_html', 'disabled' => 1)), 'result_html');
|
$form_container->output_row($lang->result_actual, $lang->result_actual_desc, "<div id=\"result_actual\">{$sandbox['actual']}</div>"); $form_container->end(); echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
| $form_container->output_row($lang->result_actual, $lang->result_actual_desc, "<div id=\"result_actual\">{$sandbox['actual']}</div>"); $form_container->end(); echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
|
Zeile 195 | Zeile 202 |
---|
}); //]]> </script>';
|
}); //]]> </script>';
|
|
|
$form->end();
$page->output_footer();
| $form->end();
$page->output_footer();
|
Zeile 211 | Zeile 218 |
---|
flash_message($lang->error_invalid_mycode, 'error'); admin_redirect("index.php?module=config-mycode"); }
|
flash_message($lang->error_invalid_mycode, 'error'); admin_redirect("index.php?module=config-mycode"); }
|
|
|
$plugins->run_hooks("admin_config_mycode_edit");
if($mybb->request_method == "post") { if(!trim($mybb->input['title']))
|
$plugins->run_hooks("admin_config_mycode_edit");
if($mybb->request_method == "post") { if(!trim($mybb->input['title']))
|
{
| {
|
$errors[] = $lang->error_missing_title; }
if(!trim($mybb->input['regex']))
|
$errors[] = $lang->error_missing_title; }
if(!trim($mybb->input['regex']))
|
{
| {
|
$errors[] = $lang->error_missing_regex;
|
$errors[] = $lang->error_missing_regex;
|
| }
$regex = str_replace("\x0", "", $mybb->input['regex']);
if(check_existing_regex($regex)) { $errors[] = $lang->error_regex_already_available;
|
}
if(!trim($mybb->input['replacement']))
|
}
if(!trim($mybb->input['replacement']))
|
{
| {
|
$errors[] = $lang->error_missing_replacement; }
| $errors[] = $lang->error_missing_replacement; }
|
Zeile 242 | Zeile 256 |
---|
$updated_mycode = array( 'title' => $db->escape_string($mybb->input['title']), 'description' => $db->escape_string($mybb->input['description']),
|
$updated_mycode = array( 'title' => $db->escape_string($mybb->input['title']), 'description' => $db->escape_string($mybb->input['description']),
|
'regex' => $db->escape_string(str_replace("\x0", "", $mybb->input['regex'])),
| 'regex' => $db->escape_string($regex),
|
'replacement' => $db->escape_string($mybb->input['replacement']), 'active' => $mybb->get_input('active', MyBB::INPUT_INT), 'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
| 'replacement' => $db->escape_string($mybb->input['replacement']), 'active' => $mybb->get_input('active', MyBB::INPUT_INT), 'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
|
Zeile 313 | Zeile 327 |
---|
$form_container->end(); echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>'; echo '<script type="text/javascript">
|
$form_container->end(); echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>'; echo '<script type="text/javascript">
|
|
|
$(function(){ //<![CDATA[ new MyCodeSandbox("./index.php?module=config-mycode&action=xmlhttp_test_mycode", $("#test"), $("#regex"), $("#replacement"), $("#test_value"), $("#result_html"), $("#result_actual"));
| $(function(){ //<![CDATA[ new MyCodeSandbox("./index.php?module=config-mycode&action=xmlhttp_test_mycode", $("#test"), $("#regex"), $("#replacement"), $("#test_value"), $("#result_html"), $("#result_actual"));
|
Zeile 334 | Zeile 348 |
---|
if(!$mycode['cid']) { flash_message($lang->error_invalid_mycode, 'error');
|
if(!$mycode['cid']) { flash_message($lang->error_invalid_mycode, 'error');
|
admin_redirect("index.php?module=config-mycode");
| admin_redirect("index.php?module=config-mycode");
|
}
$plugins->run_hooks("admin_config_mycode_delete");
| }
$plugins->run_hooks("admin_config_mycode_delete");
|
Zeile 350 | Zeile 364 |
---|
$db->delete_query("mycode", "cid='{$mycode['cid']}'");
$plugins->run_hooks("admin_config_mycode_delete_commit");
|
$db->delete_query("mycode", "cid='{$mycode['cid']}'");
$plugins->run_hooks("admin_config_mycode_delete_commit");
|
|
|
$cache->update_mycode();
// Log admin action log_admin_action($mycode['cid'], htmlspecialchars_uni($mycode['title']));
|
$cache->update_mycode();
// Log admin action log_admin_action($mycode['cid'], htmlspecialchars_uni($mycode['title']));
|
|
|
flash_message($lang->success_deleted_mycode, 'success'); admin_redirect("index.php?module=config-mycode"); }
| flash_message($lang->success_deleted_mycode, 'success'); admin_redirect("index.php?module=config-mycode"); }
|
Zeile 441 | Zeile 455 |
---|
$array['actual'] = @preg_replace("#".str_replace("\x0", "", $regex)."#si", $replacement, $test); $array['html'] = htmlspecialchars_uni($array['actual']); return $array;
|
$array['actual'] = @preg_replace("#".str_replace("\x0", "", $regex)."#si", $replacement, $test); $array['html'] = htmlspecialchars_uni($array['actual']); return $array;
|
| }
/** * Checks if a regex is already available * * @param string $regex * * @return bool True if already available, false otherwise */ function check_existing_regex($regex='') { global $cache;
$mycodes = $cache->read('mycode'); foreach($mycodes as $mycode) { if($mycode['regex'] == $regex) { return true; } }
return false;
|
}
| }
|