本文整理汇总了PHP中blc_got_unsynched_items函数的典型用法代码示例。如果您正苦于以下问题:PHP blc_got_unsynched_items函数的具体用法?PHP blc_got_unsynched_items怎么用?PHP blc_got_unsynched_items使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了blc_got_unsynched_items函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: microtime
$blclog->info('Upgrading the database...');
$upgrade_start = microtime(true);
require_once BLC_DIRECTORY . '/includes/admin/db-upgrade.php';
blcDatabaseUpgrader::upgrade_database();
$blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $upgrade_start));
//Remove invalid DB entries
$blclog->info('Cleaning up the database...');
$cleanup_start = microtime(true);
blc_cleanup_database();
$blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $cleanup_start));
//Notify modules that the plugin has been activated. This will cause container
//modules to create and update synch. records for all new/modified posts and other items.
$blclog->info('Notifying modules...');
$notification_start = microtime(true);
$moduleManager->plugin_activated();
blc_got_unsynched_items();
$blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $notification_start));
//Turn off load limiting if it's not available on this server.
$blclog->info('Updating server load limit settings...');
$load = blcUtility::get_server_load();
if (empty($load)) {
$blc_config_manager->options['enable_load_limit'] = false;
$blclog->info('Disable load limit. Cannot retrieve current load average.');
} elseif ($blc_config_manager->options['enable_load_limit'] && !isset($blc_config_manager->options['server_load_limit'])) {
$fifteen_minutes = floatval(end($load));
$default_load_limit = round(max(min($fifteen_minutes * 2, $fifteen_minutes + 2), 4));
$blc_config_manager->options['server_load_limit'] = $default_load_limit;
$blclog->info(sprintf('Set server load limit to %.2f. Current load average is %.2f', $default_load_limit, $fifteen_minutes));
}
//And optimize my DB tables, too (for good measure)
$blclog->info('Optimizing the database...');
示例2: blc_resynch
/**
* (Re)create synchronization records for all containers and mark them all as unparsed.
*
* @param bool $forced If true, the plugin will recreate all synch. records from scratch.
* @return void
*/
function blc_resynch($forced = false)
{
global $wpdb, $blclog;
/* @var wpdb $wpdb */
if ($forced) {
$blclog->info('... Forced resynchronization initiated');
//Drop all synchronization records
$wpdb->query("TRUNCATE {$wpdb->prefix}blc_synch");
} else {
$blclog->info('... Resynchronization initiated');
}
//Remove invalid DB entries
blc_cleanup_database();
//(Re)create and update synch. records for all container types.
$blclog->info('... (Re)creating container records');
blcContainerHelper::resynch($forced);
$blclog->info('... Setting resync. flags');
blc_got_unsynched_items();
//All done.
$blclog->info('Database resynchronization complete.');
}
示例3: options_page
//.........这里部分代码省略.........
$this->conf->options['server_load_limit'] = 0;
}
$this->conf->options['enable_load_limit'] = $this->conf->options['server_load_limit'] > 0;
}
//When to run the checker
$this->conf->options['run_in_dashboard'] = !empty($_POST['run_in_dashboard']);
$this->conf->options['run_via_cron'] = !empty($_POST['run_via_cron']);
//Email notifications on/off
$email_notifications = !empty($_POST['send_email_notifications']);
$send_authors_email_notifications = !empty($_POST['send_authors_email_notifications']);
if ($email_notifications && !$this->conf->options['send_email_notifications'] || $send_authors_email_notifications && !$this->conf->options['send_authors_email_notifications']) {
/*
The plugin should only send notifications about links that have become broken
since the time when email notifications were turned on. If we don't do this,
the first email notification will be sent nigh-immediately and list *all* broken
links that the plugin currently knows about.
*/
$this->conf->options['last_notification_sent'] = time();
}
$this->conf->options['send_email_notifications'] = $email_notifications;
$this->conf->options['send_authors_email_notifications'] = $send_authors_email_notifications;
//Make settings that affect our Cron events take effect immediately
$this->setup_cron_events();
$this->conf->save_options();
/*
If the list of custom fields was modified then we MUST resynchronize or
custom fields linked with existing posts may not be detected. This is somewhat
inefficient.
*/
if (count($diff1) > 0 || count($diff2) > 0) {
$manager = blcContainerHelper::get_manager('custom_field');
if (!is_null($manager)) {
$manager->resynch();
blc_got_unsynched_items();
}
}
//Redirect back to the settings page
$base_url = remove_query_arg(array('_wpnonce', 'noheader', 'updated', 'error', 'action', 'message'));
wp_redirect(add_query_arg(array('settings-updated' => true), $base_url));
}
//Show a confirmation message when settings are saved.
if (!empty($_GET['settings-updated'])) {
echo '<div id="message" class="updated fade"><p><strong>', __('Settings saved.', 'broken-link-checker'), '</strong></p></div>';
}
//Show a thank-you message when a donation is made.
if (!empty($_GET['donated'])) {
echo '<div id="message" class="updated fade"><p><strong>', __('Thank you for your donation!', 'broken-link-checker'), '</strong></p></div>';
$this->conf->set('user_has_donated', true);
$this->conf->save_options();
}
//Show one when recheck is started, too.
if (!empty($_GET['recheck-initiated'])) {
echo '<div id="message" class="updated fade"><p><strong>', __('Complete site recheck started.', 'broken-link-checker'), '</strong></p></div>';
}
//Cull invalid and missing modules
$moduleManager->validate_active_modules();
$debug = $this->get_debug_info();
$details_text = __('Details', 'broken-link-checker');
add_filter('blc-module-settings-custom_field', array(&$this, 'make_custom_field_input'), 10, 2);
//Translate and markup-ify module headers for display
$modules = $moduleManager->get_modules_by_category('', true, true);
//Output the custom broken link/removed link styles for example links
printf('<style type="text/css">%s %s</style>', $this->conf->options['broken_link_css'], $this->conf->options['removed_link_css']);
$section_names = array('general' => __('General', 'broken-link-checker'), 'where' => __('Look For Links In', 'broken-link-checker'), 'which' => __('Which Links To Check', 'broken-link-checker'), 'how' => __('Protocols & APIs', 'broken-link-checker'), 'advanced' => __('Advanced', 'broken-link-checker'));
?>
示例4: mark_as_unsynched_where
/**
* Mark as unparsed all containers that match one of the the specified formats or
* container types and that were last parsed after a specific timestamp.
*
* Used by newly activated parsers to force the containers they're interested in
* to resynchronize and thus let the parser process them.
*
* @param array $formats Associative array of timestamps, indexed by format IDs.
* @param array $container_types Associative array of timestamps, indexed by container types.
* @return bool
*/
static function mark_as_unsynched_where($formats, $container_types)
{
global $wpdb;
/* @var wpdb $wpdb */
global $blclog;
//Find containers that match any of the specified formats and add them to
//the list of container types that need to be marked as unsynched.
$module_manager = blcModuleManager::getInstance();
$containers = $module_manager->get_active_by_category('container');
foreach ($containers as $module_id => $module_data) {
if ($container_manager = $module_manager->get_module($module_id)) {
$fields = $container_manager->get_parseable_fields();
$container_type = $container_manager->container_type;
foreach ($formats as $format => $timestamp) {
if (in_array($format, $fields)) {
//Choose the earliest timestamp
if (isset($container_types[$container_type])) {
$container_types[$container_type] = min($timestamp, $container_types[$container_type]);
} else {
$container_types[$container_type] = $timestamp;
}
}
}
}
}
if (empty($container_types)) {
return true;
}
//Build the query to update all synch. records that match one of the specified
//container types and have been parsed after the specified time.
$q = "UPDATE {$wpdb->prefix}blc_synch SET synched = 0 WHERE ";
$pieces = array();
foreach ($container_types as $container_type => $timestamp) {
$pieces[] = $wpdb->prepare('(container_type = %s AND last_synch >= %s)', $container_type, date('Y-m-d H:i:s', $timestamp));
}
$q .= implode(' OR ', $pieces);
$blclog->log('...... Executing query: ' . $q);
$start_time = microtime(true);
$rez = $wpdb->query($q) !== false;
$blclog->log(sprintf('...... %d rows affected, %.3f seconds', $wpdb->rows_affected, microtime(true) - $start_time));
blc_got_unsynched_items();
return $rez;
}
示例5: mark_as_unsynched
/**
* blcContainer::mark_as_unsynched()
* Mark the container as not synchronized (not parsed, or modified since the last parse).
* The plugin will attempt to (re)parse the container at the earliest opportunity.
*
* @return bool
*/
function mark_as_unsynched()
{
global $wpdb;
$q = "INSERT INTO {$wpdb->prefix}blc_synch( container_id, container_type, synched, last_synch)\r\n\t\t\t VALUES( %d, %s, %d, '0000-00-00 00:00:00' )\r\n\t\t\t ON DUPLICATE KEY UPDATE synched = VALUES(synched)";
$rez = $wpdb->query($wpdb->prepare($q, $this->container_id, $this->container_type, 0));
blc_got_unsynched_items();
return $rez !== false;
}
示例6: blc_resynch
/**
* (Re)create synchronization records for all containers and mark them all as unparsed.
*
* @param bool $forced If true, the plugin will recreate all synch. records from scratch.
* @return void
*/
function blc_resynch($forced = false)
{
global $wpdb, $blclog;
if ($forced) {
$blclog->info('... Forced resynchronization initiated');
//Drop all synchronization records
$wpdb->query("TRUNCATE {$wpdb->prefix}blc_synch");
} else {
$blclog->info('... Resynchronization initiated');
}
//(Re)create and update synch. records for all container types.
$blclog->info('... (Re)creating container records');
blc_resynch_containers($forced);
//Delete invalid instances
$blclog->info('... Deleting invalid link instances');
blc_cleanup_instances();
//Delete orphaned links
$blclog->info('... Deleting orphaned links');
blc_cleanup_links();
$blclog->info('... Setting resync. flags');
blc_got_unsynched_items();
//All done.
$blclog->info('Database resynchronization complete.');
}
示例7: options_page
function options_page()
{
global $blc_container_registry;
//Sanity check : make sure the DB is all set up
if ($this->db_version != $this->conf->options['current_db_version']) {
printf(__("Error: The plugin's database tables are not up to date! (Current version : %d, expected : %d)", 'broken-link-checker'), $this->conf->options['current_db_version'], $this->db_version);
return;
}
if (isset($_GET['recheck']) && $_GET['recheck'] == 'true') {
$this->initiate_recheck();
}
if (isset($_POST['submit'])) {
check_admin_referer('link-checker-options');
//The execution time limit must be above zero
$new_execution_time = intval($_POST['max_execution_time']);
if ($new_execution_time > 0) {
$this->conf->options['max_execution_time'] = $new_execution_time;
}
//The check threshold also must be > 0
$new_check_threshold = intval($_POST['check_threshold']);
if ($new_check_threshold > 0) {
$this->conf->options['check_threshold'] = $new_check_threshold;
}
$this->conf->options['mark_broken_links'] = !empty($_POST['mark_broken_links']);
$new_broken_link_css = trim($_POST['broken_link_css']);
$this->conf->options['broken_link_css'] = $new_broken_link_css;
$this->conf->options['mark_removed_links'] = !empty($_POST['mark_removed_links']);
$new_removed_link_css = trim($_POST['removed_link_css']);
$this->conf->options['removed_link_css'] = $new_removed_link_css;
$this->conf->options['nofollow_broken_links'] = !empty($_POST['nofollow_broken_links']);
$this->conf->options['exclusion_list'] = array_filter(preg_split('/[\\s\\r\\n]+/', $_POST['exclusion_list'], -1, PREG_SPLIT_NO_EMPTY));
//Parse the custom field list
$new_custom_fields = array_filter(preg_split('/[\\s\\r\\n]+/', $_POST['blc_custom_fields'], -1, PREG_SPLIT_NO_EMPTY));
//Calculate the difference between the old custom field list and the new one (used later)
$diff1 = array_diff($new_custom_fields, $this->conf->options['custom_fields']);
$diff2 = array_diff($this->conf->options['custom_fields'], $new_custom_fields);
$this->conf->options['custom_fields'] = $new_custom_fields;
//Temporary file directory
$this->conf->options['custom_tmp_dir'] = trim(stripslashes(strval($_POST['custom_tmp_dir'])));
//HTTP timeout
$new_timeout = intval($_POST['timeout']);
if ($new_timeout > 0) {
$this->conf->options['timeout'] = $new_timeout;
}
//Server load limit
if (isset($_POST['server_load_limit'])) {
$this->conf->options['server_load_limit'] = floatval($_POST['server_load_limit']);
if ($this->conf->options['server_load_limit'] < 0) {
$this->conf->options['server_load_limit'] = 0;
}
$this->conf->options['enable_load_limit'] = $this->conf->options['server_load_limit'] > 0;
}
//When to run the checker
$this->conf->options['run_in_dashboard'] = !empty($_POST['run_in_dashboard']);
$this->conf->options['run_via_cron'] = !empty($_POST['run_via_cron']);
//Email notifications on/off
$email_notifications = !empty($_POST['send_email_notifications']);
if ($email_notifications && !$this->conf->options['send_email_notifications']) {
/*
The plugin should only send notifications about links that have become broken
since the time when email notifications were turned on. If we don't do this,
the first email notification will be sent nigh-immediately and list *all* broken
links that the plugin currently knows about.
*/
$this->options['last_notification_sent'] = time();
}
$this->conf->options['send_email_notifications'] = $email_notifications;
//Make settings that affect our Cron events take effect immediately
$this->setup_cron_events();
$this->conf->save_options();
/*
If the list of custom fields was modified then we MUST resynchronize or
custom fields linked with existing posts may not be detected. This is somewhat
inefficient.
*/
if (count($diff1) > 0 || count($diff2) > 0) {
$manager = $blc_container_registry->get_manager('custom_field');
if (!is_null($manager)) {
$manager->resynch();
blc_got_unsynched_items();
}
}
//Redirect back to the settings page
$base_url = remove_query_arg(array('_wpnonce', 'noheader', 'updated', 'error', 'action', 'message'));
wp_redirect(add_query_arg(array('settings-updated' => true), $base_url));
}
//Show a confirmation message when settings are saved.
if (!empty($_GET['settings-updated'])) {
echo '<div id="message" class="updated fade"><p><strong>', __('Settings saved.', 'broken-link-checker'), '</strong></p></div>';
}
$debug = $this->get_debug_info();
$this->print_uservoice_widget();
?>
<div class="wrap"><h2><?php
_e('Broken Link Checker Options', 'broken-link-checker');
?>
</h2>
<form name="link_checker_options" method="post" action="<?php
//.........这里部分代码省略.........