Future post pinging and cron fixups from masquerade. fixes #2469

git-svn-id: http://svn.automattic.com/wordpress/trunk@3663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-03-30 07:36:54 +00:00
parent 31cb659651
commit 73ef659763
5 changed files with 28 additions and 55 deletions

View File

@ -9,11 +9,5 @@
<?php do_action('admin_footer', ''); ?> <?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
<?php
if ( (substr(php_sapi_name(), 0, 3) == 'cgi') && spawn_pinger() ) {
echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
}
?>
</body> </body>
</html> </html>

View File

@ -1,27 +0,0 @@
<?php
require_once('../wp-config.php');
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
}
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
do_enclose($enclosure->post_content, $enclosure->ID);
}
// Do Trackbacks
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
if ( is_array($trackbacks) ) {
foreach ( $trackbacks as $trackback ) {
do_trackbacks($trackback->ID);
}
}
generic_ping();
?>

View File

@ -92,4 +92,5 @@ add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
add_action('do_feed_rss', 'do_feed_rss', 10, 1); add_action('do_feed_rss', 'do_feed_rss', 10, 1);
add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
add_action('do_feed_atom', 'do_feed_atom', 10, 1); add_action('do_feed_atom', 'do_feed_atom', 10, 1);
add_action('do_pings', 'do_all_pings', 10, 1);
?> ?>

View File

@ -199,7 +199,7 @@ function wp_insert_post($postarr = array()) {
(post_id,meta_key,meta_value) (post_id,meta_key,meta_value)
VALUES ('$post_ID','_encloseme','1') VALUES ('$post_ID','_encloseme','1')
"); ");
spawn_pinger(); wp_schedule_single_event(time(), 'do_pings');
} }
} else if ($post_type == 'page') { } else if ($post_type == 'page') {
wp_cache_delete('all_page_ids', 'pages'); wp_cache_delete('all_page_ids', 'pages');
@ -1002,4 +1002,30 @@ function wp_upload_bits($name, $type, $bits) {
return array('file' => $new_file, 'url' => $url, 'error' => false); return array('file' => $new_file, 'url' => $url, 'error' => false);
} }
function do_all_pings() {
global $wpdb;
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
}
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
do_enclose($enclosure->post_content, $enclosure->ID);
}
// Do Trackbacks
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
if ( is_array($trackbacks) ) {
foreach ( $trackbacks as $trackback ) {
do_trackbacks($trackback->ID);
}
}
//Do Update Services/Generic Pings
generic_ping();
}
?> ?>

View File

@ -1119,27 +1119,6 @@ function debug_fclose($fp) {
} }
} }
function spawn_pinger() {
global $wpdb;
$doping = false;
if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") )
$doping = true;
if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") )
$doping = true;
if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
return $doping;
if ( $doping ) {
$ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php';
$parts = parse_url($ping_url);
$argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01);
if ( $argyle )
fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n");
}
}
function do_enclose( $content, $post_ID ) { function do_enclose( $content, $post_ID ) {
global $wp_version, $wpdb; global $wp_version, $wpdb;
include_once (ABSPATH . WPINC . '/class-IXR.php'); include_once (ABSPATH . WPINC . '/class-IXR.php');