Vergleich admin/modules/tools/tasks.php - 1.8.0 - 1.8.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 23Zeile 23
/**
* Validates a string or array of values
*

/**
* Validates a string or array of values
*

 * @param mixed Comma-separated list or array of values
* @param int Minimum value
* @param int Maximum value
* @param string Set "string" to return in a comma-separated list, or "array" to return in an array
* @return mixed String or array of valid values OR false if string/array is invalid

 * @param string|array $value Comma-separated list or array of values
* @param int $min Minimum value
* @param int $max Maximum value
* @param string $return_type Set "string" to return in a comma-separated list, or "array" to return in an array
* @return string|array String or array of valid values OR false if string/array is invalid

 */
function check_time_values($value, $min, $max, $return_type)
{

 */
function check_time_values($value, $min, $max, $return_type)
{

Zeile 79Zeile 79
			$errors[] = $lang->error_missing_description;
}


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


		if(!file_exists(MYBB_ROOT."inc/tasks/".$mybb->input['file'].".php"))




		$file = $mybb->get_input('file');
$file = basename($file, '.php');

if(!file_exists(MYBB_ROOT."inc/tasks/".$file.".php"))

		{
$errors[] = $lang->error_invalid_task_file;
}

		{
$errors[] = $lang->error_invalid_task_file;
}

Zeile 92Zeile 95

$mybb->input['hour'] = check_time_values($mybb->input['hour'], 0, 59, 'string');
if($mybb->input['hour'] === false)


$mybb->input['hour'] = check_time_values($mybb->input['hour'], 0, 59, 'string');
if($mybb->input['hour'] === false)

		{

		{

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


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


Zeile 106Zeile 109
			$mybb->input['weekday'] = array('*');
}
else

			$mybb->input['weekday'] = array('*');
}
else

		{

		{

			$mybb->input['weekday'] = check_time_values($mybb->input['weekday'], 0, 6, 'array');
if($mybb->input['weekday'] === false)
{
$errors[] = $lang->error_invalid_weekday;
}
$mybb->input['day'] = '*';

			$mybb->input['weekday'] = check_time_values($mybb->input['weekday'], 0, 6, 'array');
if($mybb->input['weekday'] === false)
{
$errors[] = $lang->error_invalid_weekday;
}
$mybb->input['day'] = '*';

		}


		}


		$mybb->input['month'] = check_time_values($mybb->input['month'], 1, 12, 'array');
if($mybb->input['month'] === false)
{
$errors[] = $lang->error_invalid_month;
}

		$mybb->input['month'] = check_time_values($mybb->input['month'], 1, 12, 'array');
if($mybb->input['month'] === false)
{
$errors[] = $lang->error_invalid_month;
}





		if(!$errors)
{
$new_task = array(
"title" => $db->escape_string($mybb->input['title']),
"description" => $db->escape_string($mybb->input['description']),

		if(!$errors)
{
$new_task = array(
"title" => $db->escape_string($mybb->input['title']),
"description" => $db->escape_string($mybb->input['description']),

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

				"file" => $db->escape_string($file),

				"minute" => $db->escape_string($mybb->input['minute']),
"hour" => $db->escape_string($mybb->input['hour']),
"day" => $db->escape_string($mybb->input['day']),
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),

				"minute" => $db->escape_string($mybb->input['minute']),
"hour" => $db->escape_string($mybb->input['hour']),
"day" => $db->escape_string($mybb->input['day']),
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),

				"enabled" => (int)$mybb->input['enabled'],
"logging" => (int)$mybb->input['logging']

				"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)

			);

$new_task['nextrun'] = fetch_next_run($new_task);
$tid = $db->insert_query("tasks", $new_task);

			);

$new_task['nextrun'] = fetch_next_run($new_task);
$tid = $db->insert_query("tasks", $new_task);

			$cache->update_tasks();

$plugins->run_hooks("admin_tools_tasks_add_commit");

// Log admin action



$plugins->run_hooks("admin_tools_tasks_add_commit");

$cache->update_tasks();

// Log admin action

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

flash_message($lang->success_task_created, 'success');

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

flash_message($lang->success_task_created, 'success');

Zeile 156Zeile 160
	$sub_tabs['scheduled_tasks'] = array(
'title' => $lang->scheduled_tasks,
'link' => "index.php?module=tools-tasks"

	$sub_tabs['scheduled_tasks'] = array(
'title' => $lang->scheduled_tasks,
'link' => "index.php?module=tools-tasks"

	);


	);


	$sub_tabs['add_task'] = array(
'title' => $lang->add_new_task,
'link' => "index.php?module=tools-tasks&action=add",

	$sub_tabs['add_task'] = array(
'title' => $lang->add_new_task,
'link' => "index.php?module=tools-tasks&action=add",

Zeile 172Zeile 176
	$page->output_nav_tabs($sub_tabs, 'add_task');
$form = new Form("index.php?module=tools-tasks&action=add", "post", "add");
if($errors)

	$page->output_nav_tabs($sub_tabs, 'add_task');
$form = new Form("index.php?module=tools-tasks&action=add", "post", "add");
if($errors)

	{

	{

		$page->output_inline_error($errors);
}
else

		$page->output_inline_error($errors);
}
else

Zeile 201Zeile 205
	$form_container->output_row($lang->time_minutes, $lang->time_minutes_desc, $form->generate_text_box('minute', $mybb->input['minute'], array('id' => 'minute')), 'minute');
$form_container->output_row($lang->time_hours, $lang->time_hours_desc, $form->generate_text_box('hour', $mybb->input['hour'], array('id' => 'hour')), 'hour');
$form_container->output_row($lang->time_days_of_month, $lang->time_days_of_month_desc, $form->generate_text_box('day', $mybb->input['day'], array('id' => 'day')), 'day');

	$form_container->output_row($lang->time_minutes, $lang->time_minutes_desc, $form->generate_text_box('minute', $mybb->input['minute'], array('id' => 'minute')), 'minute');
$form_container->output_row($lang->time_hours, $lang->time_hours_desc, $form->generate_text_box('hour', $mybb->input['hour'], array('id' => 'hour')), 'hour');
$form_container->output_row($lang->time_days_of_month, $lang->time_days_of_month_desc, $form->generate_text_box('day', $mybb->input['day'], array('id' => 'day')), 'day');





	$options = array(
"*" => $lang->every_weekday,
"0" => $lang->sunday,

	$options = array(
"*" => $lang->every_weekday,
"0" => $lang->sunday,

Zeile 246Zeile 250

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


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

	$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', 1)."'");

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

	$task = $db->fetch_array($query);

// Does the task not exist?

	$task = $db->fetch_array($query);

// Does the task not exist?

Zeile 261Zeile 265
	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['description']))
{
$errors[] = $lang->error_missing_description;

		if(!trim($mybb->input['description']))
{
$errors[] = $lang->error_missing_description;

		}

if(!file_exists(MYBB_ROOT."inc/tasks/".$mybb->input['file'].".php"))




		}

$file = $mybb->get_input('file');
$file = basename($file, '.php');

if(!file_exists(MYBB_ROOT."inc/tasks/".$file.".php"))

		{
$errors[] = $lang->error_invalid_task_file;
}

$mybb->input['minute'] = check_time_values($mybb->input['minute'], 0, 59, 'string');
if($mybb->input['minute'] === false)

		{
$errors[] = $lang->error_invalid_task_file;
}

$mybb->input['minute'] = check_time_values($mybb->input['minute'], 0, 59, 'string');
if($mybb->input['minute'] === false)

		{

		{

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


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


Zeile 285Zeile 292
		if($mybb->input['hour'] === false)
{
$errors[] = $lang->error_invalid_hour;

		if($mybb->input['hour'] === false)
{
$errors[] = $lang->error_invalid_hour;

		}

		}


if($mybb->input['day'] != "*" && $mybb->input['day'] != '')
{


if($mybb->input['day'] != "*" && $mybb->input['day'] != '')
{

Zeile 320Zeile 327
			{
$mybb->input['enabled'] = 0;
$enable_confirmation = true;

			{
$mybb->input['enabled'] = 0;
$enable_confirmation = true;

			}


			}


			$updated_task = array(
"title" => $db->escape_string($mybb->input['title']),
"description" => $db->escape_string($mybb->input['description']),

			$updated_task = array(
"title" => $db->escape_string($mybb->input['title']),
"description" => $db->escape_string($mybb->input['description']),

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

				"file" => $db->escape_string($file),

				"minute" => $db->escape_string($mybb->input['minute']),
"hour" => $db->escape_string($mybb->input['hour']),
"day" => $db->escape_string($mybb->input['day']),
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),

				"minute" => $db->escape_string($mybb->input['minute']),
"hour" => $db->escape_string($mybb->input['hour']),
"day" => $db->escape_string($mybb->input['day']),
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),

				"enabled" => (int)$mybb->input['enabled'],
"logging" => (int)$mybb->input['logging']

				"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)

			);

			);





			$updated_task['nextrun'] = fetch_next_run($updated_task);

			$updated_task['nextrun'] = fetch_next_run($updated_task);

 

$plugins->run_hooks("admin_tools_tasks_edit_commit");


			$db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");

			$db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");

			$cache->update_tasks();

 




			$plugins->run_hooks("admin_tools_tasks_edit_commit");

			$cache->update_tasks();


// Log admin action
log_admin_action($task['tid'], $mybb->input['title']);


// Log admin action
log_admin_action($task['tid'], $mybb->input['title']);

Zeile 442Zeile 451
	$form->end();

$page->output_footer();

	$form->end();

$page->output_footer();

}


}


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

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

{
$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', 1)."'");
$task = $db->fetch_array($query);

// Does the task not exist?
if(!$task['tid'])
{
flash_message($lang->error_invalid_task, 'error');

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

// Does the task not exist?
if(!$task['tid'])
{
flash_message($lang->error_invalid_task, 'error');

		admin_redirect("index.php?module=tools-tasks");
}

// User clicked no

		admin_redirect("index.php?module=tools-tasks");
}

// User clicked no

	if($mybb->input['no'])
{
admin_redirect("index.php?module=tools-tasks");

	if($mybb->input['no'])
{
admin_redirect("index.php?module=tools-tasks");

	}

$plugins->run_hooks("admin_tools_tasks_delete");

	}

$plugins->run_hooks("admin_tools_tasks_delete");

Zeile 471Zeile 480
		$db->delete_query("tasklog", "tid='{$task['tid']}'");

// Fetch next task run

		$db->delete_query("tasklog", "tid='{$task['tid']}'");

// Fetch next task run

		$cache->update_tasks();

$plugins->run_hooks("admin_tools_tasks_delete_commit");




$plugins->run_hooks("admin_tools_tasks_delete_commit");

$cache->update_tasks();


		// Log admin action
log_admin_action($task['tid'], $task['title']);


		// Log admin action
log_admin_action($task['tid'], $task['title']);


Zeile 495Zeile 505
		admin_redirect("index.php?module=tools-tasks");
}


		admin_redirect("index.php?module=tools-tasks");
}


	$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', 1)."'");

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

	$task = $db->fetch_array($query);

// Does the task not exist?

	$task = $db->fetch_array($query);

// Does the task not exist?

Zeile 503Zeile 513
	{
flash_message($lang->error_invalid_task, 'error');
admin_redirect("index.php?module=tools-tasks");

	{
flash_message($lang->error_invalid_task, 'error');
admin_redirect("index.php?module=tools-tasks");

	}


	}


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

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

	{

	{

		$plugins->run_hooks("admin_tools_tasks_enable");
}
else
{
$plugins->run_hooks("admin_tools_tasks_disable");

		$plugins->run_hooks("admin_tools_tasks_enable");
}
else
{
$plugins->run_hooks("admin_tools_tasks_disable");

	}

	}


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


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

Zeile 528Zeile 538
			{
$nextrun = fetch_next_run($task);
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");

			{
$nextrun = fetch_next_run($task);
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");

 

$plugins->run_hooks("admin_tools_tasks_enable_commit");


				$cache->update_tasks();

				$cache->update_tasks();


$plugins->run_hooks("admin_tools_tasks_enable_commit");

 

// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);


// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);





				flash_message($lang->success_task_enabled, 'success');
admin_redirect("index.php?module=tools-tasks");
}

				flash_message($lang->success_task_enabled, 'success');
admin_redirect("index.php?module=tools-tasks");
}

Zeile 547Zeile 558
		{
$nextrun = fetch_next_run($task);
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");

		{
$nextrun = fetch_next_run($task);
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");

			$cache->update_tasks();

$plugins->run_hooks("admin_tools_tasks_enable_commit");



$plugins->run_hooks("admin_tools_tasks_enable_commit");

$cache->update_tasks();


// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);


// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);

Zeile 561Zeile 573
	else
{
$db->update_query("tasks", array("enabled" => 0), "tid='{$task['tid']}'");

	else
{
$db->update_query("tasks", array("enabled" => 0), "tid='{$task['tid']}'");

		$cache->update_tasks();





		$plugins->run_hooks("admin_tools_tasks_disable_commit");

		$plugins->run_hooks("admin_tools_tasks_disable_commit");

 

$cache->update_tasks();


// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);


// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);

Zeile 586Zeile 599

$plugins->run_hooks("admin_tools_tasks_run");



$plugins->run_hooks("admin_tools_tasks_run");


	$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', 1)."'");

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

	$task = $db->fetch_array($query);

// Does the task not exist?

	$task = $db->fetch_array($query);

// Does the task not exist?

Zeile 645Zeile 658

if($mybb->input['page'] > 0)
{


if($mybb->input['page'] > 0)
{

		$current_page = $mybb->get_input('page', 1);

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

		$start = ($current_page-1)*$per_page;
$pages = $log_count / $per_page;
$pages = ceil($pages);

		$start = ($current_page-1)*$per_page;
$pages = $log_count / $per_page;
$pages = ceil($pages);

Zeile 723Zeile 736
	{
$task['title'] = htmlspecialchars_uni($task['title']);
$task['description'] = htmlspecialchars_uni($task['description']);

	{
$task['title'] = htmlspecialchars_uni($task['title']);
$task['description'] = htmlspecialchars_uni($task['description']);

		$next_run = date($mybb->settings['dateformat'], $task['nextrun']).", ".date($mybb->settings['timeformat'], $task['nextrun']);

		$next_run = my_date('normal', $task['nextrun'], "", 2);

		if($task['enabled'] == 1)
{
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";

		if($task['enabled'] == 1)
{
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";