Vergleich admin/modules/config/mycode.php - 1.8.4 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 20Zeile 20

if($mybb->input['action'] == "toggle_status")
{


if($mybb->input['action'] == "toggle_status")
{

	if(!verify_post_check($mybb->input['my_post_key']))

	if(!verify_post_check($mybb->get_input('my_post_key')))

	{
flash_message($lang->invalid_post_verify_key2, 'error');
admin_redirect("index.php?module=config-mycode");

	{
flash_message($lang->invalid_post_verify_key2, 'error');
admin_redirect("index.php?module=config-mycode");

Zeile 29Zeile 29
	$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);


	$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);


	if(!$mycode['cid'])

	if(!$mycode)

	{
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");

Zeile 53Zeile 53

$plugins->run_hooks("admin_config_mycode_toggle_status_commit");



$plugins->run_hooks("admin_config_mycode_toggle_status_commit");


	$db->update_query("mycode", $mycode_update, "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");

	$db->update_query("mycode", $mycode_update, "cid='{$mycode['cid']}'");


$cache->update_mycode();



$cache->update_mycode();


Zeile 85Zeile 85

if($mybb->input['action'] == "add")
{


if($mybb->input['action'] == "add")
{

	$plugins->run_hooks("admin_config_mycode_add");

	$sandbox = array();





 
	$plugins->run_hooks("admin_config_mycode_add");


	if($mybb->request_method == "post")
{
if(!trim($mybb->input['title']))

	if($mybb->request_method == "post")
{
if(!trim($mybb->input['title']))

		{

		{

			$errors[] = $lang->error_missing_title;
}


			$errors[] = $lang->error_missing_title;
}


		if(!trim($mybb->input['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_missing_regex;

			$errors[] = $lang->error_regex_already_available;

		}

if(!trim($mybb->input['replacement']))

		}

if(!trim($mybb->input['replacement']))

Zeile 104Zeile 113
			$errors[] = $lang->error_missing_replacement;
}


			$errors[] = $lang->error_missing_replacement;
}


		if($mybb->input['test'])

		if($mybb->get_input('test'))

		{
$errors[] = $lang->changes_not_saved;
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);

		{
$errors[] = $lang->changes_not_saved;
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);

Zeile 115Zeile 124
			$new_mycode = array(
'title' => $db->escape_string($mybb->input['title']),
'description' => $db->escape_string($mybb->input['description']),

			$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']),

				'replacement' => $db->escape_string($mybb->input['replacement']),

				'active' => $db->escape_string($mybb->input['active']),

				'active' => $mybb->get_input('active', MyBB::INPUT_INT),

				'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
);


				'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
);


Zeile 128Zeile 137
			$cache->update_mycode();

// Log admin action

			$cache->update_mycode();

// Log admin action

			log_admin_action($cid, htmlspecialchars_uni($mybb->input['title']));

			log_admin_action($cid, $mybb->input['title']);


flash_message($lang->success_added_mycode, 'success');
admin_redirect('index.php?module=config-mycode');


flash_message($lang->success_added_mycode, 'success');
admin_redirect('index.php?module=config-mycode');

Zeile 168Zeile 177

$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> &lt;strong&gt;$1&lt;/strong&gt;', $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->output_row($lang->title." <em>*</em>", '', $form->generate_text_box('title', $mybb->get_input('title'), array('id' => 'title')), 'title');
$form_container->output_row($lang->short_description, '', $form->generate_text_box('description', $mybb->get_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->get_input('regex'), array('id' => 'regex')), 'regex');
$form_container->output_row($lang->replacement." <em>*</em>", $lang->replacement_desc.'<br /><strong>'.$lang->example.'</strong> &lt;strong&gt;$1&lt;/strong&gt;', $form->generate_text_area('replacement', $mybb->get_input('replacement'), array('id' => 'replacement')), 'replacement');
$form_container->output_row($lang->enabled." <em>*</em>", '', $form->generate_yes_no_radio('active', $mybb->get_input('active')));
$form_container->output_row($lang->parse_order, $lang->parse_order_desc, $form->generate_numeric_field('parseorder', $mybb->get_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

	$form_container->end();

$buttons[] = $form->generate_submit_button($lang->save_mycode);
$form->output_submit_wrapper($buttons);

// Sandbox

 
	$sandbox_actual = isset($sandbox['actual']) ? $sandbox['actual'] : null;


	echo "<br />\n";
$form_container = new FormContainer($lang->sandbox);
$form_container->output_row($lang->sandbox_desc);

	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->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->get_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', isset($sandbox['html']) ? $sandbox['html'] : null, 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>';
echo '<script type="text/javascript">

	$form_container->end();
echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
echo '<script type="text/javascript">

Zeile 205Zeile 216
{
$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);

{
$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);


if(!$mycode['cid'])


if(!$mycode)

	{
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");
}

 

$sandbox = array();


$plugins->run_hooks("admin_config_mycode_edit");



$plugins->run_hooks("admin_config_mycode_edit");


Zeile 224Zeile 237
		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, $mycode))
{
$errors[] = $lang->error_regex_already_available;

		}

if(!trim($mybb->input['replacement']))

		}

if(!trim($mybb->input['replacement']))

Zeile 231Zeile 251
			$errors[] = $lang->error_missing_replacement;
}


			$errors[] = $lang->error_missing_replacement;
}


		if($mybb->input['test'])

		if($mybb->get_input('test'))

		{
$errors[] = $lang->changes_not_saved;
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);

		{
$errors[] = $lang->changes_not_saved;
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);

Zeile 242Zeile 262
			$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']),

				'replacement' => $db->escape_string($mybb->input['replacement']),

				'active' => $db->escape_string($mybb->input['active']),

				'active' => $mybb->get_input('active', MyBB::INPUT_INT),

				'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
);

$plugins->run_hooks("admin_config_mycode_edit_commit");


				'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
);

$plugins->run_hooks("admin_config_mycode_edit_commit");


			$db->update_query("mycode", $updated_mycode, "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");

			$db->update_query("mycode", $updated_mycode, "cid='{$mycode['cid']}'");


$cache->update_mycode();

// Log admin action


$cache->update_mycode();

// Log admin action

			log_admin_action($mycode['cid'], htmlspecialchars_uni($mybb->input['title']));

			log_admin_action($mycode['cid'], $mybb->input['title']);


flash_message($lang->success_updated_mycode, 'success');
admin_redirect('index.php?module=config-mycode');


flash_message($lang->success_updated_mycode, 'success');
admin_redirect('index.php?module=config-mycode');

Zeile 304Zeile 324
	$form->output_submit_wrapper($buttons);

// Sandbox

	$form->output_submit_wrapper($buttons);

// Sandbox

 
	$sandbox_actual = isset($sandbox['actual']) ? $sandbox['actual'] : null;


	echo "<br />\n";
$form_container = new FormContainer($lang->sandbox);
$form_container->output_row($lang->sandbox_desc);

	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->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->get_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', isset($sandbox['html']) ? $sandbox['html'] : null, 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>';
echo '<script type="text/javascript">

	$form_container->end();
echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
echo '<script type="text/javascript">

Zeile 331Zeile 353
	$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);


	$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
$mycode = $db->fetch_array($query);


	if(!$mycode['cid'])

	if(!$mycode)

	{
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");

Zeile 340Zeile 362
	$plugins->run_hooks("admin_config_mycode_delete");

// User clicked no

	$plugins->run_hooks("admin_config_mycode_delete");

// User clicked no

	if($mybb->input['no'])

	if($mybb->get_input('no'))

	{
admin_redirect("index.php?module=config-mycode");
}

	{
admin_redirect("index.php?module=config-mycode");
}

Zeile 354Zeile 376
		$cache->update_mycode();

// Log admin action

		$cache->update_mycode();

// Log admin action

		log_admin_action($mycode['cid'], htmlspecialchars_uni($mycode['title']));

		log_admin_action($mycode['cid'], $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 383Zeile 405
	);

$page->output_nav_tabs($sub_tabs, 'mycode');

	);

$page->output_nav_tabs($sub_tabs, 'mycode');

 

$query = $db->simple_select("mycode", "COUNT(cid) AS mycode");
$total_rows = $db->fetch_field($query, "mycode");

$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->title);
$table->construct_header($lang->controls, array('class' => 'align_center', 'width' => 150));



$table = new Table;
$table->construct_header($lang->title);
$table->construct_header($lang->controls, array('class' => 'align_center', 'width' => 150));


	$query = $db->simple_select("mycode", "*", "", array('order_by' => 'parseorder'));

	$query = $db->simple_select("mycode", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'parseorder'));

	while($mycode = $db->fetch_array($query))
{
if($mycode['active'] == 1)

	while($mycode = $db->fetch_array($query))
{
if($mycode['active'] == 1)

		{

		{

			$phrase = $lang->deactivate_mycode;
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
}

			$phrase = $lang->deactivate_mycode;
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
}

Zeile 403Zeile 445
		}

if($mycode['description'])

		}

if($mycode['description'])

		{

		{

			$mycode['description'] = "<small>".htmlspecialchars_uni($mycode['description'])."</small>";

			$mycode['description'] = "<small>".htmlspecialchars_uni($mycode['description'])."</small>";

		}

$table->construct_cell("<div>{$icon}<strong><a href=\"index.php?module=config-mycode&amp;action=edit&amp;cid={$mycode['cid']}\">".htmlspecialchars_uni($mycode['title'])."</a></strong><br />{$mycode['description']}</div>");


		}

$table->construct_cell("<div>{$icon}<strong><a href=\"index.php?module=config-mycode&amp;action=edit&amp;cid={$mycode['cid']}\">".htmlspecialchars_uni($mycode['title'])."</a></strong><br />{$mycode['description']}</div>");


		$popup = new PopupMenu("mycode_{$mycode['cid']}", $lang->options);
$popup->add_item($lang->edit_mycode, "index.php?module=config-mycode&amp;action=edit&amp;cid={$mycode['cid']}");
$popup->add_item($phrase, "index.php?module=config-mycode&amp;action=toggle_status&amp;cid={$mycode['cid']}&amp;my_post_key={$mybb->post_code}");

		$popup = new PopupMenu("mycode_{$mycode['cid']}", $lang->options);
$popup->add_item($lang->edit_mycode, "index.php?module=config-mycode&amp;action=edit&amp;cid={$mycode['cid']}");
$popup->add_item($phrase, "index.php?module=config-mycode&amp;action=toggle_status&amp;cid={$mycode['cid']}&amp;my_post_key={$mybb->post_code}");

Zeile 418Zeile 460
	}

if($table->num_rows() == 0)

	}

if($table->num_rows() == 0)

	{

	{

		$table->construct_cell($lang->no_mycode, array('colspan' => 2));
$table->construct_row();

		$table->construct_cell($lang->no_mycode, array('colspan' => 2));
$table->construct_row();

	}

$table->output($lang->custom_mycode);



	}

$table->output($lang->custom_mycode);

echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-mycode&amp;page={page}");


$page->output_footer();
}



$page->output_footer();
}


 
/**
* @param string $regex
* @param string $replacement
* @param string $test
*
* @return array
*/

function test_regex($regex, $replacement, $test)
{
$array = array();
$array['actual'] = @preg_replace("#".str_replace("\x0", "", $regex)."#si", $replacement, $test);
$array['html'] = htmlspecialchars_uni($array['actual']);
return $array;

function test_regex($regex, $replacement, $test)
{
$array = 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 The regex to check
* @param array $current The currently edited MyCode
*
* @return bool True if already available, false otherwise
*/
function check_existing_regex($regex='', $current=array())
{
global $cache;

if(!empty($current) && $current['regex'] == $regex)
{
return false;
}

$mycodes = $cache->read('mycode');

foreach($mycodes as $mycode)
{
if($mycode['regex'] == $regex)
{
return true;
}
}

return false;

}

}