forked from mybb/mybb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.php
73 lines (64 loc) · 1.65 KB
/
task.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
ignore_user_abort(true);
@set_time_limit(0);
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
define("IN_TASK", 1);
define('THIS_SCRIPT', 'task.php');
require_once dirname(__FILE__)."/inc/init.php";
// Load language
$lang->set_language($mybb->settings['bblanguage']);
$lang->load("global");
$lang->load("messages");
if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))
{
@mb_internal_encoding($lang->settings['charset']);
}
require_once MYBB_ROOT."inc/functions_task.php";
// Are tasks set to run via cron instead & are we accessing this file via the CLI?
// php task.php [tid]
if(PHP_SAPI == "cli")
{
// Passing a specific task ID
if($_SERVER['argc'] == 2)
{
$query = $db->simple_select("tasks", "tid", "tid='".(int)$_SERVER['argv'][1]."'");
$tid = $db->fetch_field($query, "tid");
}
if($tid)
{
run_task($tid);
}
else
{
run_task();
}
}
// Otherwise false GIF image, only supports running next available task
else
{
// Send our fake gif image (clear 1x1 transparent image)
header("Content-type: image/gif");
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo base64_decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
// If the use shutdown functionality is turned off, run any shutdown related items now.
if($mybb->use_shutdown == true)
{
add_shutdown("run_task");
}
else
{
run_task();
}
}