本文整理汇总了PHP中fetch_next_run函数的典型用法代码示例。如果您正苦于以下问题:PHP fetch_next_run函数的具体用法?PHP fetch_next_run怎么用?PHP fetch_next_run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch_next_run函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_task
/**
* Execute a scheduled task.
*
* @param int $tid The task ID. If none specified, the next task due to be ran is executed
* @return boolean True if successful, false on failure
*/
function run_task($tid = 0)
{
global $db, $mybb, $cache, $plugins, $task, $lang;
// Run a specific task
if ($tid > 0) {
$query = $db->simple_select("tasks", "*", "tid='{$tid}'");
$task = $db->fetch_array($query);
} else {
$query = $db->simple_select("tasks", "*", "enabled=1 AND nextrun<='" . TIME_NOW . "'", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1));
$task = $db->fetch_array($query);
}
// No task? Return
if (!$task['tid']) {
$cache->update_tasks();
return false;
}
// Is this task still running and locked less than 5 minutes ago? Well don't run it now - clearly it isn't broken!
if ($task['locked'] != 0 && $task['locked'] > TIME_NOW - 300) {
$cache->update_tasks();
return false;
} else {
$db->update_query("tasks", array("locked" => TIME_NOW), "tid='{$task['tid']}'");
}
// The task file does not exist
if (!file_exists(MYBB_ROOT . "inc/tasks/{$task['file']}.php")) {
if ($task['logging'] == 1) {
add_task_log($task, $lang->missing_task);
}
// If task file does not exist, disable task and inform the administrator
$updated_task = array("enabled" => 0, "locked" => 0);
$db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");
$subject = $lang->sprintf($lang->email_broken_task_subject, $mybb->settings['bbname']);
$message = $lang->sprintf($lang->email_broken_task, $mybb->settings['bbname'], $mybb->settings['bburl'], $task['title']);
my_mail($mybb->settings['adminemail'], $subject, $message, $mybb->settings['adminemail']);
$cache->update_tasks();
return false;
} else {
// Update the nextrun time now, so if the task causes a fatal error, it doesn't get stuck first in the queue
$nextrun = fetch_next_run($task);
$db->update_query("tasks", array("nextrun" => $nextrun), "tid='{$task['tid']}'");
include_once MYBB_ROOT . "inc/tasks/{$task['file']}.php";
$function = "task_{$task['file']}";
if (function_exists($function)) {
$function($task);
}
}
$updated_task = array("lastrun" => TIME_NOW, "locked" => 0);
$db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");
$cache->update_tasks();
return true;
}
示例2: purgesoftdeleted_activate
function purgesoftdeleted_activate()
{
global $db, $cache;
// Create task - Purge soft deleted
// Have we already added this task?
$query = $db->simple_select('tasks', 'tid', "file='purgesoftdeleted'", array('limit' => '1'));
if ($db->num_rows($query) == 0) {
// Load tasks function needed to run a task and add nextrun time
require_once MYBB_ROOT . "/inc/functions_task.php";
// If not then add
$new_task = array("title" => "Purge soft deleted posts and threads", "description" => "Checks for soft deleted posts and threads and purges them automatically.", "file" => "purgesoftdeleted", "minute" => '2', "hour" => '0', "day" => '*', "month" => '*', "weekday" => '*', "enabled" => '1', "logging" => '1');
$new_task['nextrun'] = fetch_next_run($new_task);
$tid = $db->insert_query("tasks", $new_task);
// Update the task and run it right now
$cache->update_tasks();
run_task($tid);
}
}
示例3: create_admin_user
/**
* How do we want to name the admin user?
*/
function create_admin_user()
{
global $output, $mybb, $errors, $db, $lang;
$mybb->input['action'] = "adminuser";
// If no errors then check for errors from last step
if (!is_array($errors)) {
if (empty($mybb->input['bburl'])) {
$errors[] = $lang->config_step_error_url;
}
if (empty($mybb->input['bbname'])) {
$errors[] = $lang->config_step_error_name;
}
if (is_array($errors)) {
configure();
}
}
$output->print_header($lang->create_admin, 'admin');
echo <<<EOF
\t\t<script type="text/javascript">\t
\t\tfunction comparePass()
\t\t{
\t\t\tvar parenttr = \$('#adminpass2').closest('tr');
\t\t\tvar passval = \$('#adminpass2').val();
\t\t\tif(passval && passval != \$('#adminpass').val())
\t\t\t{
\t\t\t\tif(!parenttr.next('.pass_peeker').length)
\t\t\t\t{
\t\t\t\t\tparenttr.removeClass('last').after('<tr class="pass_peeker"><td colspan="2">{$lang->admin_step_nomatch}</td></tr>');
\t\t\t\t}
\t\t\t} else {
\t\t\t\tparenttr.addClass('last').next('.pass_peeker').remove();
\t\t\t}
\t\t}
\t\t</script>
\t\t
EOF;
if (is_array($errors)) {
$error_list = error_list($errors);
echo $lang->sprintf($lang->admin_step_error_config, $error_list);
$adminuser = $mybb->get_input('adminuser');
$adminemail = $mybb->get_input('adminemail');
} else {
require MYBB_ROOT . 'inc/config.php';
$db = db_connection($config);
echo $lang->admin_step_setupsettings;
$adminuser = $adminemail = '';
$settings = file_get_contents(INSTALL_ROOT . 'resources/settings.xml');
$parser = new XMLParser($settings);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
$groupcount = $settingcount = 0;
// Insert all the settings
foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
$groupdata = array('name' => $db->escape_string($settinggroup['attributes']['name']), 'title' => $db->escape_string($settinggroup['attributes']['title']), 'description' => $db->escape_string($settinggroup['attributes']['description']), 'disporder' => (int) $settinggroup['attributes']['disporder'], 'isdefault' => $settinggroup['attributes']['isdefault']);
$gid = $db->insert_query('settinggroups', $groupdata);
++$groupcount;
foreach ($settinggroup['setting'] as $setting) {
$settingdata = array('name' => $db->escape_string($setting['attributes']['name']), 'title' => $db->escape_string($setting['title'][0]['value']), 'description' => $db->escape_string($setting['description'][0]['value']), 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 'disporder' => (int) $setting['disporder'][0]['value'], 'gid' => $gid, 'isdefault' => 1);
$db->insert_query('settings', $settingdata);
$settingcount++;
}
}
if (my_substr($mybb->get_input('bburl'), -1, 1) == '/') {
$mybb->input['bburl'] = my_substr($mybb->get_input('bburl'), 0, -1);
}
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('bbname'))), "name='bbname'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('bburl'))), "name='bburl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('websitename'))), "name='homename'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('websiteurl'))), "name='homeurl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('cookiedomain'))), "name='cookiedomain'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('cookiepath'))), "name='cookiepath'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('contactemail'))), "name='adminemail'");
$db->update_query("settings", array('value' => 'contact.php'), "name='contactlink'");
write_settings();
echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount);
// Save the acp pin
$pin = addslashes($mybb->get_input('pin'));
$file = @fopen(MYBB_ROOT . "inc/config.php", "a");
@fwrite($file, "/**\n * Admin CP Secret PIN\n * If you wish to request a PIN\n * when someone tries to login\n * on your Admin CP, enter it below.\n */\n\n\$config['secret_pin'] = '{$pin}';");
@fclose($file);
include_once MYBB_ROOT . "inc/functions_task.php";
$tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
$parser = new XMLParser($tasks);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
$taskcount = 0;
// Insert scheduled tasks
foreach ($tree['tasks'][0]['task'] as $task) {
$new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
$taskcount++;
}
// For the version check task, set a random date and hour (so all MyBB installs don't query mybb.com all at the same time)
$update_array = array('hour' => rand(0, 23), 'weekday' => rand(0, 6));
$db->update_query("tasks", $update_array, "file = 'versioncheck'");
echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount);
//.........这里部分代码省略.........
示例4: admin_redirect
admin_redirect("index.php?module=tools/tasks");
}
if ($mybb->request_method == "post") {
$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");
// 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");
} else {
$page->output_confirm_action("index.php?module=tools/tasks&action=enable&tid={$task['tid']}", $lang->confirm_task_enable);
}
} else {
$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");
// 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");
}
} else {
$db->update_query("tasks", array("enabled" => 0), "tid='{$task['tid']}'");
$cache->update_tasks();
$plugins->run_hooks("admin_tools_tasks_disable_commit");
// Log admin action
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);
flash_message($lang->success_task_disabled, 'success');
示例5: create_admin_user
function create_admin_user()
{
global $output, $mybb, $errors, $db, $lang;
$mybb->input['action'] = "adminuser";
// If no errors then check for errors from last step
if (!is_array($errors)) {
if (empty($mybb->input['bburl'])) {
$errors[] = $lang->config_step_error_url;
}
if (empty($mybb->input['bbname'])) {
$errors[] = $lang->config_step_error_name;
}
if (is_array($errors)) {
configure();
}
}
$output->print_header($lang->create_admin, 'admin');
if (is_array($errors)) {
$error_list = error_list($errors);
echo $lang->sprintf($lang->admin_step_error_config, $error_list);
$adminuser = $mybb->input['adminuser'];
$adminemail = $mybb->input['adminemail'];
} else {
require MYBB_ROOT . 'inc/config.php';
$db = db_connection($config);
echo $lang->admin_step_setupsettings;
$settings = file_get_contents(INSTALL_ROOT . 'resources/settings.xml');
$parser = new XMLParser($settings);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert all the settings
foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
$groupdata = array('name' => $db->escape_string($settinggroup['attributes']['name']), 'title' => $db->escape_string($settinggroup['attributes']['title']), 'description' => $db->escape_string($settinggroup['attributes']['description']), 'disporder' => intval($settinggroup['attributes']['disporder']), 'isdefault' => $settinggroup['attributes']['isdefault']);
$gid = $db->insert_query('settinggroups', $groupdata);
++$groupcount;
foreach ($settinggroup['setting'] as $setting) {
$settingdata = array('name' => $db->escape_string($setting['attributes']['name']), 'title' => $db->escape_string($setting['title'][0]['value']), 'description' => $db->escape_string($setting['description'][0]['value']), 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 'disporder' => intval($setting['disporder'][0]['value']), 'gid' => $gid, 'isdefault' => 1);
$db->insert_query('settings', $settingdata);
$settingcount++;
}
}
if (my_substr($mybb->input['bburl'], -1, 1) == '/') {
$mybb->input['bburl'] = my_substr($mybb->input['bburl'], 0, -1);
}
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['bbname'])), "name='bbname'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['bburl'])), "name='bburl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['websitename'])), "name='homename'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['websiteurl'])), "name='homeurl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiedomain'])), "name='cookiedomain'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiepath'])), "name='cookiepath'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['contactemail'])), "name='adminemail'");
$db->update_query("settings", array('value' => 'mailto:' . $db->escape_string($mybb->input['contactemail'])), "name='contactlink'");
write_settings();
echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount);
include_once MYBB_ROOT . "inc/functions_task.php";
$tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
$parser = new XMLParser($tasks);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert scheduled tasks
foreach ($tree['tasks'][0]['task'] as $task) {
$new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
$taskcount++;
}
echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount);
$views = file_get_contents(INSTALL_ROOT . 'resources/adminviews.xml');
$parser = new XMLParser($views);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert admin views
foreach ($tree['adminviews'][0]['view'] as $view) {
$fields = array();
foreach ($view['fields'][0]['field'] as $field) {
$fields[] = $field['attributes']['name'];
}
$conditions = array();
if (is_array($view['conditions'][0]['condition'])) {
foreach ($view['conditions'][0]['condition'] as $condition) {
if (!$condition['value']) {
continue;
}
if ($condition['attributes']['is_serialized'] == 1) {
$condition['value'] = unserialize($condition['value']);
}
$conditions[$condition['attributes']['name']] = $condition['value'];
}
}
$custom_profile_fields = array();
if (is_array($view['custom_profile_fields'][0]['field'])) {
foreach ($view['custom_profile_fields'][0]['field'] as $field) {
$custom_profile_fields[] = $field['attributes']['name'];
}
}
$new_view = array("uid" => 0, "type" => $db->escape_string($view['attributes']['type']), "visibility" => intval($view['attributes']['visibility']), "title" => $db->escape_string($view['title'][0]['value']), "fields" => $db->escape_string(serialize($fields)), "conditions" => $db->escape_string(serialize($conditions)), "custom_profile_fields" => $db->escape_string(serialize($custom_profile_fields)), "sortby" => $db->escape_string($view['sortby'][0]['value']), "sortorder" => $db->escape_string($view['sortorder'][0]['value']), "perpage" => intval($view['perpage'][0]['value']), "view_type" => $db->escape_string($view['view_type'][0]['value']));
$db->insert_query("adminviews", $new_view);
$view_count++;
}
echo $lang->sprintf($lang->admin_step_insertedviews, $view_count);
//.........这里部分代码省略.........
示例6: upgrade12_dbchanges2
//.........这里部分代码省略.........
$collation = $db->build_create_table_collation();
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "massemails (\n\t\tmid int unsigned NOT NULL auto_increment,\n\t\tuid int unsigned NOT NULL default '0',\n\t\tsubject varchar(200) NOT NULL default '',\n\t\tmessage text NOT NULL,\n\t\thtmlmessage text NOT NULL,\n\t\ttype tinyint(1) NOT NULL default '0',\n\t\tformat tinyint(1) NOT NULL default '0',\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\tsenddate bigint(30) NOT NULL default '0',\n\t\tstatus tinyint(1) NOT NULL default '0',\n\t\tsentcount int unsigned NOT NULL default '0',\n\t\ttotalcount int unsigned NOT NULL default '0',\n\t\tconditions text NOT NULL,\n\t\tperpage smallint(4) NOT NULL default '50',\n\t\tPRIMARY KEY(mid)\n\t) ENGINE=MyISAM{$collation};");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "maillogs (\n\t\tmid int unsigned NOT NULL auto_increment,\n\t\tsubject varchar(200) not null default '',\n\t\tmessage TEXT NOT NULL,\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\tfromuid int unsigned NOT NULL default '0',\n\t\tfromemail varchar(200) not null default '',\n\t\ttouid bigint(30) NOT NULL default '0',\n\t\ttoemail varchar(200) NOT NULL default '',\n\t\ttid int unsigned NOT NULL default '0',\n\t\tipaddress varchar(20) NOT NULL default '',\n\t\tPRIMARY KEY(mid)\n\t) ENGINE=MyISAM{$collation};");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "mailerrors(\n\t\teid int unsigned NOT NULL auto_increment,\n\t\tsubject varchar(200) NOT NULL default '',\n\t\tmessage TEXT NOT NULL,\n\t\ttoaddress varchar(150) NOT NULL default '',\n\t\tfromaddress varchar(150) NOT NULL default '',\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\terror text NOT NULL,\n\t\tsmtperror varchar(200) NOT NULL default '',\n\t\tsmtpcode int(5) NOT NULL default '0',\n\t\tPRIMARY KEY(eid)\n \t) ENGINE=MyISAM{$collation};");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "promotions (\n\t\tpid int unsigned NOT NULL auto_increment,\n\t\ttitle varchar(120) NOT NULL default '',\n\t\tdescription text NOT NULL,\n\t\tenabled tinyint(1) NOT NULL default '1',\n\t\tlogging tinyint(1) NOT NULL default '0',\n\t\tposts int NOT NULL default '0',\n\t\tposttype char(2) NOT NULL default '',\n\t\tregistered int NOT NULL default '0',\n\t\tregisteredtype varchar(20) NOT NULL default '',\n\t\treputations int NOT NULL default '0',\n\t\treputationtype char(2) NOT NULL default '',\n\t\trequirements varchar(200) NOT NULL default '',\n\t\toriginalusergroup varchar(120) NOT NULL default '0',\n\t\tnewusergroup smallint unsigned NOT NULL default '0',\n\t\tusergrouptype varchar(120) NOT NULL default '0',\n\t\tPRIMARY KEY (pid)\n\t) ENGINE=MyISAM{$collation};");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "promotionlogs(\n\t\tplid int unsigned NOT NULL auto_increment,\n\t\tpid int unsigned NOT NULL default '0',\n\t\tuid int unsigned NOT NULL default '0',\n\t\toldusergroup varchar(200) NOT NULL default '0',\n\t\tnewusergroup smallint unsigned NOT NULL default '0',\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\ttype varchar(9) NOT NULL default 'primary',\n\t\tPRIMARY KEY(plid)\n \t) ENGINE=MyISAM{$collation};");
if ($db->field_exists('maxemails', "usergroups")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "usergroups DROP maxemails;");
}
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "usergroups ADD maxemails int(3) NOT NULL default '5' AFTER cansendemail");
if ($db->field_exists('parseorder', "mycode")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "mycode DROP parseorder;");
}
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "mycode ADD parseorder smallint unsigned NOT NULL default '0' AFTER active");
if ($db->field_exists('mod_edit_posts', "forums")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "forums DROP mod_edit_posts;");
}
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "forums ADD mod_edit_posts int(1) NOT NULL default '0' AFTER modthreads");
if ($db->field_exists('pmpopup', "users") && !$db->field_exists('pmnotice', "users")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "users CHANGE pmpopup pmnotice int(1) NOT NULL default '0'");
}
$db->drop_table("tasks");
$db->drop_table("tasklog");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\ttid int unsigned NOT NULL auto_increment,\n\t\ttitle varchar(120) NOT NULL default '',\n\t\tdescription text NOT NULL,\n\t\tfile varchar(30) NOT NULL default '',\n\t\tminute varchar(200) NOT NULL default '',\n\t\thour varchar(200) NOT NULL default '',\n\t\tday varchar(100) NOT NULL default '',\n\t\tmonth varchar(30) NOT NULL default '',\n\t\tweekday varchar(15) NOT NULL default '',\n\t\tnextrun bigint(30) NOT NULL default '0',\n\t\tlastrun bigint(30) NOT NULL default '0',\n\t\tenabled int(1) NOT NULL default '1',\n\t\tlogging int(1) NOT NULL default '0',\n\t\tlocked bigint(30) NOT NULL default '0',\n\t\tPRIMARY KEY(tid)\n\t) ENGINE=MyISAM{$collation};");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasklog (\n\t\tlid int unsigned NOT NULL auto_increment,\n\t\ttid int unsigned NOT NULL default '0',\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\tdata text NOT NULL,\n\t\tPRIMARY KEY(lid)\n\t) ENGINE=MyISAM{$collation};");
include_once MYBB_ROOT . "inc/functions_task.php";
$tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
$parser = new XMLParser($tasks);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert scheduled tasks
foreach ($tree['tasks'][0]['task'] as $task) {
$new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
$taskcount++;
}
if ($db->table_exists("favorites") && !$db->table_exists("threadsubscriptions")) {
$db->write_query("RENAME TABLE " . TABLE_PREFIX . "favorites TO " . TABLE_PREFIX . "threadsubscriptions");
}
if ($db->field_exists('fid', "threadsubscriptions")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions CHANGE fid sid int unsigned NOT NULL auto_increment");
}
if ($db->field_exists('type', "threadsubscriptions")) {
$db->update_query("threadsubscriptions", array('type' => 0), "type='f'");
$db->update_query("threadsubscriptions", array('type' => 1), "type='s'");
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions CHANGE type notification int(1) NOT NULL default '0'");
}
if ($db->field_exists('dateline', "threadsubscriptions")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions DROP dateline;");
}
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions ADD dateline bigint(30) NOT NULL default '0'");
if ($db->field_exists('subscriptionkey', "threadsubscriptions")) {
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions DROP subscriptionkey;");
}
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "threadsubscriptions ADD subscriptionkey varchar(32) NOT NULL default ''");
if ($db->field_exists('emailnotify', "users")) {
$db->update_query("users", array('emailnotify' => 0), "emailnotify='no' OR emailnotify='0'");
$db->update_query("users", array('emailnotify' => 2), "emailnotify='yes' OR emailnotify='1'");
$db->update_query("users", array('emailnotify' => 0), "emailnotify != 1 AND emailnotify != 2");
$db->write_query("ALTER TABLE " . TABLE_PREFIX . "users CHANGE emailnotify subscriptionmethod int(1) NOT NULL default '0'");
}
$db->drop_table("warninglevels");
$db->drop_table("warningtypes");
$db->drop_table("warnings");
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "warninglevels (\n\t\tlid int unsigned NOT NULL auto_increment,\n\t\tpercentage int(3) NOT NULL default '0',\n\t\taction text NOT NULL,\n\t\tPRIMARY KEY(lid)\n\t) ENGINE=MyISAM{$collation};");
示例7: sync_tasks
function sync_tasks($redo = 0)
{
global $db;
$taskcount = 0;
$tasks = array();
if ($redo == 2) {
$db->drop_table("tasks");
switch ($db->type) {
case "pgsql":
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid serial,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription text NOT NULL default '',\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint NOT NULL default '0',\n\t\t\t\t\tlastrun bigint NOT NULL default '0',\n\t\t\t\t\tenabled int NOT NULL default '1',\n\t\t\t\t\tlogging int NOT NULL default '0',\n\t\t\t\t\tlocked bigint NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY(tid)\n\t\t\t\t);");
break;
case "sqlite":
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid INTEGER PRIMARY KEY,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription TEXT NOT NULL,\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tlastrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tenabled int(1) NOT NULL default '1',\n\t\t\t\t\tlogging int(1) NOT NULL default '0',\n\t\t\t\t\tlocked bigint(30) NOT NULL default '0'\n\t\t\t\t);");
break;
case "mysql":
default:
$db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid int unsigned NOT NULL auto_increment,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription text NOT NULL,\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tlastrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tenabled int(1) NOT NULL default '1',\n\t\t\t\t\tlogging int(1) NOT NULL default '0',\n\t\t\t\t\tlocked bigint(30) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY (tid)\n\t\t\t\t) ENGINE=MyISAM;");
}
} else {
$query = $db->simple_select("tasks", "file,tid");
while ($task = $db->fetch_array($query)) {
$tasks[$task['file']] = $task['tid'];
}
}
require_once MYBB_ROOT . "inc/functions_task.php";
$task_file = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
$parser = new XMLParser($task_file);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Resync tasks
foreach ($tree['tasks'][0]['task'] as $task) {
if (!$tasks[$task['file'][0]['value']] || $redo == 2) {
$new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
$taskcount++;
} else {
$update_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']));
$db->update_query("tasks", $update_task, "file='" . $db->escape_string($task['file'][0]['value']) . "'");
}
}
return $taskcount;
}
示例8: captchapack_task_add
/**
* Add a task.
*
* Code stolen from MyBB itself.
*/
function captchapack_task_add($task)
{
require_once MYBB_ROOT . 'inc/functions_task.php';
global $db, $cache;
// Merge default values
$task_def = array('title' => '', 'description' => '', 'file' => '', 'minute' => '*', 'hour' => '*', 'day' => '*', 'month' => '*', 'weekday' => '*', 'enabled' => 0, 'logging' => 1);
$task = array_merge($task_def, $task);
if (!$task['file'] || !$task['title']) {
return false;
}
// If there's a task with the same title or filename, drop it
captchapack_task_drop($task['file'], $task['title']);
// Escape all the things in the task
$task = array('title' => $db->escape_string($task['title']), 'description' => $db->escape_string($task['description']), 'file' => $db->escape_string($task['file']), 'minute' => $db->escape_string($task['minute']), 'hour' => $db->escape_string($task['hour']), 'day' => $db->escape_string($task['day']), 'month' => $db->escape_string($task['month']), 'weekday' => $db->escape_string($task['weekday']), 'enabled' => (int) $task['enabled'], 'logging' => (int) $task['logging']);
// Fill nextrun
$task['nextrun'] = fetch_next_run($task);
// Insert, and update cache
$db->insert_query("tasks", $task);
$cache->update_tasks();
return true;
}
示例9: mysupport_insert_task
function mysupport_insert_task()
{
global $db, $lang;
$lang->load("mysupport");
include_once MYBB_ROOT . "inc/functions_task.php";
$new_task = array("title" => $lang->mysupport, "description" => $lang->mysupport_task_description, "file" => "mysupport", "minute" => 0, "hour" => 0, "day" => "*", "month" => "*", "weekday" => "*", "enabled" => 1, "logging" => 1);
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
}
示例10: myalerts_activate
function myalerts_activate()
{
global $db, $lang, $PL, $plugins, $cache;
if (!isset($lang->myalerts)) {
$lang->load('myalerts');
}
if (!file_exists(PLUGINLIBRARY)) {
flash_message($lang->myalerts_pluginlibrary_missing, 'error');
admin_redirect('index.php?module=config-plugins');
}
$PL or (require_once PLUGINLIBRARY);
if ($PL->version < 9) {
flash_message('This plugin requires PluginLibrary 9 or newer', 'error');
admin_redirect('index.php?module=config-plugins');
}
$plugin_info = myalerts_info();
$euantorPlugins = $cache->read('euantor_plugins');
if (!empty($euantorPlugins) && isset($euantorPlugins['myalerts'])) {
$oldVersion = $euantorPlugins['myalerts'];
if ($oldVersion['version'] == '1.05') {
myalerts_upgrade_105_200();
}
}
$euantorPlugins['myalerts'] = array('title' => 'MyAlerts', 'version' => $plugin_info['version']);
$cache->update('euantor_plugins', $euantorPlugins);
$PL->settings('myalerts', $lang->setting_group_myalerts, $lang->setting_group_myalerts_desc, array('perpage' => array('title' => $lang->setting_myalerts_perpage, 'description' => $lang->setting_myalerts_perpage_desc, 'value' => '10', 'optionscode' => 'text'), 'dropdown_limit' => array('title' => $lang->setting_myalerts_dropdown_limit, 'description' => $lang->setting_myalerts_dropdown_limit_desc, 'value' => '5', 'optionscode' => 'text'), 'autorefresh' => array('title' => $lang->setting_myalerts_autorefresh, 'description' => $lang->setting_myalerts_autorefresh_desc, 'value' => '0', 'optionscode' => 'text'), 'avatar_size' => array('title' => $lang->setting_myalerts_avatar_size, 'description' => $lang->setting_myalerts_avatar_size_desc, 'optionscode' => 'text', 'value' => '64|64')));
$dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
$templates = array();
foreach ($dir as $file) {
if (!$file->isDot() && !$file->isDir() && pathinfo($file->getPathname(), PATHINFO_EXTENSION) === 'html') {
$templateName = $file->getPathname();
$templateName = basename($templateName, '.html');
$templates[$templateName] = file_get_contents($file->getPathname());
}
}
$PL->templates('myalerts', 'MyAlerts', $templates);
$stylesheet = file_get_contents(MYALERTS_PLUGIN_PATH . '/stylesheets/alerts.css');
$PL->stylesheet('alerts.css', $stylesheet);
// Attach usercp.css to alerts.php
$query = $db->simple_select('themestylesheets', 'sid,attachedto,tid', "name = 'usercp.css'");
while ($userCpStylesheet = $db->fetch_array($query)) {
$sid = (int) $userCpStylesheet['sid'];
$db->update_query('themestylesheets', array('attachedto' => $db->escape_string($userCpStylesheet['attachedto'] . '|alerts.php')), "sid = {$sid}");
update_theme_stylesheet_list((int) $userCpStylesheet['tid']);
}
require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';
find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}');
find_replace_templatesets('header_welcomeblock_member', "#" . preg_quote('{$modcplink}') . "#i", '{$myalerts_headericon}{$modcplink}');
find_replace_templatesets('footer', '/$/', '{$myalerts_modal}');
$taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1'));
if ($db->num_rows($taskExists) == 0) {
require_once MYBB_ROOT . '/inc/functions_task.php';
$myTask = array('title' => $lang->myalerts_task_title, 'file' => 'myalerts', 'description' => $lang->myalerts_task_description, 'minute' => 0, 'hour' => 1, 'day' => '*', 'weekday' => 1, 'month' => '*', 'nextrun' => TIME_NOW + 3600, 'lastrun' => 0, 'enabled' => 1, 'logging' => 1, 'locked' => 0);
$task_id = $db->insert_query('tasks', $myTask);
$theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = ' . (int) $task_id, 1));
$nextrun = fetch_next_run($theTask);
$db->update_query('tasks', 'nextrun = ' . $nextrun, 'tid = ' . (int) $task_id);
$plugins->run_hooks('admin_tools_tasks_add_commit');
$cache->update_tasks();
} else {
require_once MYBB_ROOT . '/inc/functions_task.php';
$theTask = $db->fetch_array($db->simple_select('tasks', '*', 'file = \'myalerts\'', 1));
$db->update_query('tasks', array('enabled' => 1, 'nextrun' => fetch_next_run($theTask)), 'file = \'myalerts\'');
$cache->update_tasks();
}
$plugins->run_hooks('myalerts_activate');
}