web/wp-trackback.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    34 }
    34 }
    35 
    35 
    36 // trackback is done by a POST
    36 // trackback is done by a POST
    37 $request_array = 'HTTP_POST_VARS';
    37 $request_array = 'HTTP_POST_VARS';
    38 
    38 
    39 if ( !$_GET['tb_id'] ) {
    39 if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
    40 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
    40 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
    41 	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
    41 	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
    42 }
    42 }
    43 
    43 
    44 $tb_url  = $_POST['url'];
    44 $tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
    45 $charset = $_POST['charset'];
    45 $charset = isset($_POST['charset']) ? $_POST['charset'] : '';
    46 
    46 
    47 // These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
    47 // These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
    48 $title     = stripslashes($_POST['title']);
    48 $title     = isset($_POST['title'])     ? stripslashes($_POST['title'])      : '';
    49 $excerpt   = stripslashes($_POST['excerpt']);
    49 $excerpt   = isset($_POST['excerpt'])   ? stripslashes($_POST['excerpt'])    : '';
    50 $blog_name = stripslashes($_POST['blog_name']);
    50 $blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name'])  : '';
    51 
    51 
    52 if ($charset)
    52 if ($charset)
    53 	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
    53 	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
    54 else
    54 else
    55 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
    55 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
    70 $blog_name = $wpdb->escape($blog_name);
    70 $blog_name = $wpdb->escape($blog_name);
    71 
    71 
    72 if ( is_single() || is_page() )
    72 if ( is_single() || is_page() )
    73 	$tb_id = $posts[0]->ID;
    73 	$tb_id = $posts[0]->ID;
    74 
    74 
    75 if ( !intval( $tb_id ) )
    75 if ( !isset($tb_id) || !intval( $tb_id ) )
    76 	trackback_response(1, 'I really need an ID for this to work.');
    76 	trackback_response(1, 'I really need an ID for this to work.');
    77 
    77 
    78 if (empty($title) && empty($tb_url) && empty($blog_name)) {
    78 if (empty($title) && empty($tb_url) && empty($blog_name)) {
    79 	// If it doesn't look like a trackback at all...
    79 	// If it doesn't look like a trackback at all...
    80 	wp_redirect(get_permalink($tb_id));
    80 	wp_redirect(get_permalink($tb_id));