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 = '';
|
||||
}
|
||||
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>';
|
||||
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 = '';
|
||||
}
|
||||
|
@ -42,7 +50,21 @@ switch($action) {
|
|||
$colspan = 2;
|
||||
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
|
||||
$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;
|
||||
case "editcomment":
|
||||
$submitbutton_text = 'Edit this!';
|
||||
|
|
|
@ -62,6 +62,9 @@ switch($action) {
|
|||
$ping_status = $HTTP_POST_VARS['ping_status'];
|
||||
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
||||
$post_name = sanitize_title($post_title);
|
||||
$trackback = $HTTP_POST_VARS['trackback_url'];
|
||||
// Format trackbacks
|
||||
$trackback = preg_replace('|\s+|', '\n', $trackback);
|
||||
|
||||
if ($user_level == 0)
|
||||
die ('Cheatin’ uh?');
|
||||
|
@ -86,15 +89,15 @@ switch($action) {
|
|||
|
||||
if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
|
||||
$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
|
||||
('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 {
|
||||
$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
|
||||
('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 =
|
||||
|
@ -140,7 +143,8 @@ switch($action) {
|
|||
}
|
||||
|
||||
if ('' != $HTTP_POST_VARS['save']) $location = "post.php?action=edit&post=$post_ID";
|
||||
header("Location: $location");
|
||||
|
||||
header("Location: $location");
|
||||
|
||||
if ($post_status == 'publish') {
|
||||
if((get_settings('use_geo_positions')) && ($post_latf != null) && ($post_lonf != null)) {
|
||||
|
@ -153,19 +157,26 @@ switch($action) {
|
|||
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) {
|
||||
$the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ;
|
||||
} else {
|
||||
$the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
||||
}
|
||||
$excerpt = stripslashes($the_excerpt);
|
||||
$trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
|
||||
foreach($trackback_urls as $tb_url) {
|
||||
$tb_url = trim($tb_url);
|
||||
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
|
||||
|
||||
exit();
|
||||
|
@ -195,6 +206,8 @@ switch($action) {
|
|||
$comment_status = $postdata['comment_status'];
|
||||
$ping_status = $postdata['ping_status'];
|
||||
$post_password = $postdata['post_password'];
|
||||
$to_ping = $postdata['to_ping'];
|
||||
$pinged = $postdata['pinged'];
|
||||
|
||||
include('edit-form.php');
|
||||
} else {
|
||||
|
@ -245,6 +258,9 @@ switch($action) {
|
|||
$ping_status = $HTTP_POST_VARS['ping_status'];
|
||||
$post_password = addslashes($HTTP_POST_VARS['post_password']);
|
||||
$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']))) {
|
||||
$aa = $HTTP_POST_VARS['aa'];
|
||||
|
@ -273,7 +289,8 @@ switch($action) {
|
|||
comment_status = '$comment_status',
|
||||
ping_status = '$ping_status',
|
||||
post_password = '$post_password',
|
||||
post_name = '$post_name'
|
||||
post_name = '$post_name',
|
||||
to_ping = '$trackback'
|
||||
WHERE ID = $post_ID ");
|
||||
|
||||
|
||||
|
@ -301,21 +318,29 @@ switch($action) {
|
|||
if ((($prev_status == 'draft') || ($prev_status == 'private')) && ($post_status == 'publish')) {
|
||||
pingWeblogs($blog_ID);
|
||||
pingBlogs($blog_ID);
|
||||
|
||||
if ($post_pingback) {
|
||||
pingback($content, $post_ID);
|
||||
}
|
||||
|
||||
if (!empty($HTTP_POST_VARS['trackback_url'])) {
|
||||
$excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
||||
$excerpt = stripslashes($excerpt);
|
||||
$trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
|
||||
foreach($trackback_urls as $tb_url) {
|
||||
$tb_url = trim($tb_url);
|
||||
trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
|
||||
}
|
||||
}
|
||||
} // end if moving from draft/private to published
|
||||
if ($post_status == 'publish') {
|
||||
// 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"));
|
||||
$pinged = explode("\n", $pinged);
|
||||
if ('' != $to_ping) {
|
||||
if (strlen($excerpt) > 0) {
|
||||
$the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ;
|
||||
} else {
|
||||
$the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
|
||||
}
|
||||
$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
|
||||
|
||||
|
||||
$location = "Location: post.php";
|
||||
header ($location);
|
||||
|
@ -357,7 +382,6 @@ switch($action) {
|
|||
sleep($sleep_after_edit);
|
||||
}
|
||||
|
||||
// pingWeblogs($blog_ID);
|
||||
$sendback = $HTTP_SERVER_VARS['HTTP_REFERER'];
|
||||
if (strstr($sendback, 'post.php')) $sendback = $siteurl .'/wp-admin/post.php';
|
||||
header ('Location: ' . $sendback);
|
||||
|
|
|
@ -59,7 +59,12 @@ $wpdb->hide_errors();
|
|||
$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)");
|
||||
$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
|
||||
$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL";
|
||||
|
|
|
@ -588,7 +588,9 @@ function get_postdata($postid) {
|
|||
'post_status' => $post->post_status,
|
||||
'comment_status' => $post->comment_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;
|
||||
}
|
||||
|
@ -887,50 +889,38 @@ function pingBlogs($blog_ID="1") {
|
|||
}
|
||||
|
||||
|
||||
// trackback - send
|
||||
// Send a Trackback
|
||||
function trackback($trackback_url, $title, $excerpt, $ID) {
|
||||
global $siteurl, $blogfilename, $blogname;
|
||||
global $querystring_start, $querystring_equal;
|
||||
$title = urlencode($title);
|
||||
global $blogname, $wpdb, $tableposts;
|
||||
$title = urlencode(stripslashes($title));
|
||||
$excerpt = urlencode(stripslashes($excerpt));
|
||||
$blog_name = urlencode($blogname);
|
||||
$url = urlencode($siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$ID);
|
||||
$blog_name = urlencode(stripslashes($blogname));
|
||||
$tb_url = $trackback_url;
|
||||
$url = urlencode(get_permalink($ID));
|
||||
$query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
|
||||
if (strstr($trackback_url, '?')) {
|
||||
$trackback_url .= "&".$query_string;;
|
||||
$fp = @fopen($trackback_url, 'r');
|
||||
$result = @fread($fp, 4096);
|
||||
@fclose($fp);
|
||||
/* debug code
|
||||
$debug_file = 'trackback.log';
|
||||
$fp = fopen($debug_file, 'a');
|
||||
fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
|
||||
fwrite($fp, $result);
|
||||
fwrite($fp, "\n\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
} else {
|
||||
$trackback_url = parse_url($trackback_url);
|
||||
$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);
|
||||
$trackback_url = parse_url($trackback_url);
|
||||
$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_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);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u
|
|||
$comment = '<trackback />';
|
||||
$comment .= "<strong>$title</strong>\n$excerpt";
|
||||
|
||||
$author = addslashes($blog_name);
|
||||
$author = addslashes(stripslashes(stripslashes($blog_name)));
|
||||
$email = '';
|
||||
$original_comment = $comment;
|
||||
$comment_post_ID = $tb_id;
|
||||
|
|
Loading…
Reference in New Issue