mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
Trackback on edit done.
git-svn-id: http://svn.automattic.com/wordpress/trunk@636 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
61df3dab96
commit
d3d08d60ef
@ -26,8 +26,16 @@ switch($action) {
|
|||||||
$form_pingback = '';
|
$form_pingback = '';
|
||||||
}
|
}
|
||||||
if ($use_trackback) {
|
if ($use_trackback) {
|
||||||
$form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a>:</label> (Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with commas.)<br />
|
$form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a>:</label> (Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with spaces.)<br />
|
||||||
<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" /></p>';
|
<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" /></p>';
|
||||||
|
if ('' != $pinged) {
|
||||||
|
$form_trackback .= '<p>Already pinged:</p><ul>';
|
||||||
|
$already_pinged = explode("\n", trim($pinged));
|
||||||
|
foreach ($already_pinged as $pinged_url) {
|
||||||
|
$form_trackback .= "\n\t<li>$pinged_url</li>";
|
||||||
|
}
|
||||||
|
$form_trackback .= '</ul>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$form_trackback = '';
|
$form_trackback = '';
|
||||||
}
|
}
|
||||||
@ -42,7 +50,21 @@ switch($action) {
|
|||||||
$colspan = 2;
|
$colspan = 2;
|
||||||
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
|
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
|
||||||
$form_prevstatus = '<input type="hidden" name="prev_status" value="'.$post_status.'" />';
|
$form_prevstatus = '<input type="hidden" name="prev_status" value="'.$post_status.'" />';
|
||||||
$form_trackback = '';
|
if ($use_trackback) {
|
||||||
|
$form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a></label>
|
||||||
|
(Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with spaces.)<br />
|
||||||
|
<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $to_ping) .'" /></p>';
|
||||||
|
if ('' != $pinged) {
|
||||||
|
$form_trackback .= '<p>Already pinged:</p><ul>';
|
||||||
|
$already_pinged = explode("\n", trim($pinged));
|
||||||
|
foreach ($already_pinged as $pinged_url) {
|
||||||
|
$form_trackback .= "\n\t<li>$pinged_url</li>";
|
||||||
|
}
|
||||||
|
$form_trackback .= '</ul>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$form_trackback = '';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "editcomment":
|
case "editcomment":
|
||||||
$submitbutton_text = 'Edit this!';
|
$submitbutton_text = 'Edit this!';
|
||||||
|
@ -62,6 +62,9 @@ switch($action) {
|
|||||||
$ping_status = $HTTP_POST_VARS['ping_status'];
|
$ping_status = $HTTP_POST_VARS['ping_status'];
|
||||||
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
||||||
$post_name = sanitize_title($post_title);
|
$post_name = sanitize_title($post_title);
|
||||||
|
$trackback = $HTTP_POST_VARS['trackback_url'];
|
||||||
|
// Format trackbacks
|
||||||
|
$trackback = preg_replace('|\s+|', '\n', $trackback);
|
||||||
|
|
||||||
if ($user_level == 0)
|
if ($user_level == 0)
|
||||||
die ('Cheatin’ uh?');
|
die ('Cheatin’ uh?');
|
||||||
@ -86,15 +89,15 @@ switch($action) {
|
|||||||
|
|
||||||
if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
|
if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
|
||||||
$postquery ="INSERT INTO $tableposts
|
$postquery ="INSERT INTO $tableposts
|
||||||
(ID, post_author, post_date, post_content, post_title, post_lat, post_lon, post_excerpt, post_status, comment_status, ping_status, post_password, post_name)
|
(ID, post_author, post_date, post_content, post_title, post_lat, post_lon, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping)
|
||||||
VALUES
|
VALUES
|
||||||
('0', '$user_ID', '$now', '$content', '$post_title', $post_latf, $post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')
|
('0', '$user_ID', '$now', '$content', '$post_title', $post_latf, $post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback')
|
||||||
";
|
";
|
||||||
} else {
|
} else {
|
||||||
$postquery ="INSERT INTO $tableposts
|
$postquery ="INSERT INTO $tableposts
|
||||||
(ID, post_author, post_date, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name)
|
(ID, post_author, post_date, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping)
|
||||||
VALUES
|
VALUES
|
||||||
('0', '$user_ID', '$now', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')
|
('0', '$user_ID', '$now', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback')
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
$postquery =
|
$postquery =
|
||||||
@ -140,7 +143,8 @@ switch($action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('' != $HTTP_POST_VARS['save']) $location = "post.php?action=edit&post=$post_ID";
|
if ('' != $HTTP_POST_VARS['save']) $location = "post.php?action=edit&post=$post_ID";
|
||||||
header("Location: $location");
|
|
||||||
|
header("Location: $location");
|
||||||
|
|
||||||
if ($post_status == 'publish') {
|
if ($post_status == 'publish') {
|
||||||
if((get_settings('use_geo_positions')) && ($post_latf != null) && ($post_lonf != null)) {
|
if((get_settings('use_geo_positions')) && ($post_latf != null) && ($post_lonf != null)) {
|
||||||
@ -153,19 +157,26 @@ switch($action) {
|
|||||||
pingback($content, $post_ID);
|
pingback($content, $post_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($HTTP_POST_VARS['trackback_url'])) {
|
// Time for trackbacks
|
||||||
|
$to_ping = $wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID");
|
||||||
|
$pinged = $wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID");
|
||||||
|
$pinged = explode("\n", $pinged);
|
||||||
|
if ('' != $to_ping) {
|
||||||
if (strlen($excerpt) > 0) {
|
if (strlen($excerpt) > 0) {
|
||||||
$the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ;
|
$the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ;
|
||||||
} else {
|
} else {
|
||||||
$the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
$the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
||||||
}
|
}
|
||||||
$excerpt = stripslashes($the_excerpt);
|
$excerpt = stripslashes($the_excerpt);
|
||||||
$trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
|
$to_pings = explode("\n", $to_ping);
|
||||||
foreach($trackback_urls as $tb_url) {
|
foreach ($to_pings as $tb_ping) {
|
||||||
$tb_url = trim($tb_url);
|
$tb_ping = trim($tb_ping);
|
||||||
trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
|
if (!in_array($tb_ping, $pinged)) {
|
||||||
}
|
trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // end if publish
|
} // end if publish
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -195,6 +206,8 @@ switch($action) {
|
|||||||
$comment_status = $postdata['comment_status'];
|
$comment_status = $postdata['comment_status'];
|
||||||
$ping_status = $postdata['ping_status'];
|
$ping_status = $postdata['ping_status'];
|
||||||
$post_password = $postdata['post_password'];
|
$post_password = $postdata['post_password'];
|
||||||
|
$to_ping = $postdata['to_ping'];
|
||||||
|
$pinged = $postdata['pinged'];
|
||||||
|
|
||||||
include('edit-form.php');
|
include('edit-form.php');
|
||||||
} else {
|
} else {
|
||||||
@ -245,6 +258,9 @@ switch($action) {
|
|||||||
$ping_status = $HTTP_POST_VARS['ping_status'];
|
$ping_status = $HTTP_POST_VARS['ping_status'];
|
||||||
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
||||||
$post_name = sanitize_title($post_title);
|
$post_name = sanitize_title($post_title);
|
||||||
|
$trackback = $HTTP_POST_VARS['trackback_url'];
|
||||||
|
// Format trackbacks
|
||||||
|
$trackback = preg_replace('|\s+|', '\n', $trackback);
|
||||||
|
|
||||||
if (($user_level > 4) && (!empty($HTTP_POST_VARS['edit_date']))) {
|
if (($user_level > 4) && (!empty($HTTP_POST_VARS['edit_date']))) {
|
||||||
$aa = $HTTP_POST_VARS['aa'];
|
$aa = $HTTP_POST_VARS['aa'];
|
||||||
@ -273,7 +289,8 @@ switch($action) {
|
|||||||
comment_status = '$comment_status',
|
comment_status = '$comment_status',
|
||||||
ping_status = '$ping_status',
|
ping_status = '$ping_status',
|
||||||
post_password = '$post_password',
|
post_password = '$post_password',
|
||||||
post_name = '$post_name'
|
post_name = '$post_name',
|
||||||
|
to_ping = '$trackback'
|
||||||
WHERE ID = $post_ID ");
|
WHERE ID = $post_ID ");
|
||||||
|
|
||||||
|
|
||||||
@ -301,21 +318,29 @@ switch($action) {
|
|||||||
if ((($prev_status == 'draft') || ($prev_status == 'private')) && ($post_status == 'publish')) {
|
if ((($prev_status == 'draft') || ($prev_status == 'private')) && ($post_status == 'publish')) {
|
||||||
pingWeblogs($blog_ID);
|
pingWeblogs($blog_ID);
|
||||||
pingBlogs($blog_ID);
|
pingBlogs($blog_ID);
|
||||||
|
} // end if moving from draft/private to published
|
||||||
if ($post_pingback) {
|
if ($post_status == 'publish') {
|
||||||
pingback($content, $post_ID);
|
// Trackback time.
|
||||||
}
|
$to_ping = trim($wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID"));
|
||||||
|
$pinged = trim($wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID"));
|
||||||
if (!empty($HTTP_POST_VARS['trackback_url'])) {
|
$pinged = explode("\n", $pinged);
|
||||||
$excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
if ('' != $to_ping) {
|
||||||
$excerpt = stripslashes($excerpt);
|
if (strlen($excerpt) > 0) {
|
||||||
$trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
|
$the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ;
|
||||||
foreach($trackback_urls as $tb_url) {
|
} else {
|
||||||
$tb_url = trim($tb_url);
|
$the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
||||||
trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
|
}
|
||||||
}
|
$excerpt = stripslashes($the_excerpt);
|
||||||
}
|
$to_pings = explode("\n", $to_ping);
|
||||||
|
foreach ($to_pings as $tb_ping) {
|
||||||
|
$tb_ping = trim($tb_ping);
|
||||||
|
if (!in_array($tb_ping, $pinged)) {
|
||||||
|
trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} // end if publish
|
} // end if publish
|
||||||
|
|
||||||
|
|
||||||
$location = "Location: post.php";
|
$location = "Location: post.php";
|
||||||
header ($location);
|
header ($location);
|
||||||
@ -357,7 +382,6 @@ switch($action) {
|
|||||||
sleep($sleep_after_edit);
|
sleep($sleep_after_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pingWeblogs($blog_ID);
|
|
||||||
$sendback = $HTTP_SERVER_VARS['HTTP_REFERER'];
|
$sendback = $HTTP_SERVER_VARS['HTTP_REFERER'];
|
||||||
if (strstr($sendback, 'post.php')) $sendback = $siteurl .'/wp-admin/post.php';
|
if (strstr($sendback, 'post.php')) $sendback = $siteurl .'/wp-admin/post.php';
|
||||||
header ('Location: ' . $sendback);
|
header ('Location: ' . $sendback);
|
||||||
|
@ -59,7 +59,12 @@ $wpdb->hide_errors();
|
|||||||
$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)");
|
$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)");
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors();
|
||||||
|
|
||||||
|
// Create ping status fields
|
||||||
|
|
||||||
|
$query = "ALTER TABLE $tableposts ADD `to_ping` TEXT NOT NULL";
|
||||||
|
maybe_add_column($tableposts, 'to_ping', $query);
|
||||||
|
$query = "ALTER TABLE $tableposts ADD `pinged` TEXT NOT NULL";
|
||||||
|
maybe_add_column($tableposts, 'pinged', $query);
|
||||||
|
|
||||||
// Create category_nicename field
|
// Create category_nicename field
|
||||||
$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL";
|
$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL";
|
||||||
|
@ -588,7 +588,9 @@ function get_postdata($postid) {
|
|||||||
'post_status' => $post->post_status,
|
'post_status' => $post->post_status,
|
||||||
'comment_status' => $post->comment_status,
|
'comment_status' => $post->comment_status,
|
||||||
'ping_status' => $post->ping_status,
|
'ping_status' => $post->ping_status,
|
||||||
'post_password' => $post->post_password
|
'post_password' => $post->post_password,
|
||||||
|
'to_ping' => $post->to_ping,
|
||||||
|
'pinged' => $post->pinged
|
||||||
);
|
);
|
||||||
return $postdata;
|
return $postdata;
|
||||||
}
|
}
|
||||||
@ -887,50 +889,38 @@ function pingBlogs($blog_ID="1") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// trackback - send
|
// Send a Trackback
|
||||||
function trackback($trackback_url, $title, $excerpt, $ID) {
|
function trackback($trackback_url, $title, $excerpt, $ID) {
|
||||||
global $siteurl, $blogfilename, $blogname;
|
global $blogname, $wpdb, $tableposts;
|
||||||
global $querystring_start, $querystring_equal;
|
$title = urlencode(stripslashes($title));
|
||||||
$title = urlencode($title);
|
|
||||||
$excerpt = urlencode(stripslashes($excerpt));
|
$excerpt = urlencode(stripslashes($excerpt));
|
||||||
$blog_name = urlencode($blogname);
|
$blog_name = urlencode(stripslashes($blogname));
|
||||||
$url = urlencode($siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$ID);
|
$tb_url = $trackback_url;
|
||||||
|
$url = urlencode(get_permalink($ID));
|
||||||
$query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
|
$query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
|
||||||
if (strstr($trackback_url, '?')) {
|
$trackback_url = parse_url($trackback_url);
|
||||||
$trackback_url .= "&".$query_string;;
|
$http_request = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
|
||||||
$fp = @fopen($trackback_url, 'r');
|
$http_request .= 'Host: '.$trackback_url['host']."\r\n";
|
||||||
$result = @fread($fp, 4096);
|
$http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
|
||||||
@fclose($fp);
|
$http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
|
||||||
/* debug code
|
$http_request .= "\r\n";
|
||||||
$debug_file = 'trackback.log';
|
$http_request .= $query_string;
|
||||||
$fp = fopen($debug_file, 'a');
|
$fs = @fsockopen($trackback_url['host'], 80);
|
||||||
fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
|
@fputs($fs, $http_request);
|
||||||
fwrite($fp, $result);
|
/*
|
||||||
fwrite($fp, "\n\n");
|
$debug_file = 'trackback.log';
|
||||||
fclose($fp);
|
$fp = fopen($debug_file, 'a');
|
||||||
*/
|
fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
|
||||||
} else {
|
while(!@feof($fs)) {
|
||||||
$trackback_url = parse_url($trackback_url);
|
fwrite($fp, @fgets($fs, 4096));
|
||||||
$http_request = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
|
|
||||||
$http_request .= 'Host: '.$trackback_url['host']."\r\n";
|
|
||||||
$http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
|
|
||||||
$http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
|
|
||||||
$http_request .= "\r\n";
|
|
||||||
$http_request .= $query_string;
|
|
||||||
$fs = @fsockopen($trackback_url['host'], 80);
|
|
||||||
@fputs($fs, $http_request);
|
|
||||||
/* debug code
|
|
||||||
$debug_file = 'trackback.log';
|
|
||||||
$fp = fopen($debug_file, 'a');
|
|
||||||
fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
|
|
||||||
while(!@feof($fs)) {
|
|
||||||
fwrite($fp, @fgets($fs, 4096));
|
|
||||||
}
|
|
||||||
fwrite($fp, "\n\n");
|
|
||||||
fclose($fp);
|
|
||||||
*/
|
|
||||||
@fclose($fs);
|
|
||||||
}
|
}
|
||||||
|
fwrite($fp, "\n\n");
|
||||||
|
fclose($fp);
|
||||||
|
*/
|
||||||
|
@fclose($fs);
|
||||||
|
|
||||||
|
$wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = $ID");
|
||||||
|
$wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = $ID");
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u
|
|||||||
$comment = '<trackback />';
|
$comment = '<trackback />';
|
||||||
$comment .= "<strong>$title</strong>\n$excerpt";
|
$comment .= "<strong>$title</strong>\n$excerpt";
|
||||||
|
|
||||||
$author = addslashes($blog_name);
|
$author = addslashes(stripslashes(stripslashes($blog_name)));
|
||||||
$email = '';
|
$email = '';
|
||||||
$original_comment = $comment;
|
$original_comment = $comment;
|
||||||
$comment_post_ID = $tb_id;
|
$comment_post_ID = $tb_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user