Changeset 1794
- Timestamp:
- 10/14/2004 07:26:41 AM (20 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/post.php
r1793 r1794 14 14 15 15 if (!get_magic_quotes_gpc()) { 16 $_GET = add_magic_quotes($_GET);17 $_POST = add_magic_quotes($_POST);18 $_COOKIE = add_magic_quotes($_COOKIE);16 $_GET = add_magic_quotes($_GET); 17 $_POST = add_magic_quotes($_POST); 18 $_COOKIE = add_magic_quotes($_COOKIE); 19 19 } 20 20 … … 38 38 switch($action) { 39 39 case 'post': 40 $standalone = 1; 41 require_once('admin-header.php'); 42 43 $post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1") + 1; 44 45 $post_pingback = intval($_POST['post_pingback']); 46 $content = apply_filters('content_save_pre', $_POST['content']); 47 $content = format_to_post($content); 48 $excerpt = apply_filters('excerpt_save_pre',$_POST['excerpt']); 49 $excerpt = format_to_post($excerpt); 50 $post_title = $_POST['post_title']; 51 $post_categories = $_POST['post_category']; 52 $post_status = $_POST['post_status']; 53 $post_name = $_POST['post_name']; 54 $post_parent = 0; 55 if (isset($_POST['parent_id'])) { 56 $post_parent = $_POST['parent_id']; 57 } 58 59 if (empty($post_status)) $post_status = 'draft'; 60 // Double-check 61 if ( 'publish' == $post_status && 1 == $user_level && 2 != get_option('new_users_can_blog') ) 62 $post_status = 'draft'; 63 $comment_status = $_POST['comment_status']; 64 if (empty($comment_status)) $comment_status = get_settings('default_comment_status'); 65 $ping_status = $_POST['ping_status']; 66 if (empty($ping_status)) $ping_status = get_settings('default_ping_status'); 67 $post_password = $_POST['post_password']; 68 69 if (empty($post_name)) { 70 if (! empty($post_title)) { 71 $post_name = sanitize_title($post_title, $post_ID); 72 } 73 } else { 74 $post_name = sanitize_title($post_name, $post_ID); 75 } 76 77 $trackback = $_POST['trackback_url']; 78 // Format trackbacks 79 $trackback = preg_replace('|\s+|', '\n', $trackback); 40 $standalone = 1; 41 require_once('admin-header.php'); 42 43 $post_ID = $wpdb->get_var("SELECT MAX(ID) FROM $wpdb->posts") + 1; 44 45 $post_pingback = intval($_POST['post_pingback']); 46 $content = apply_filters('content_save_pre', $_POST['content']); 47 $content = format_to_post($content); 48 $excerpt = apply_filters('excerpt_save_pre',$_POST['excerpt']); 49 $excerpt = format_to_post($excerpt); 50 $post_title = $_POST['post_title']; 51 $post_categories = $_POST['post_category']; 52 $post_status = $_POST['post_status']; 53 $post_name = $_POST['post_name']; 54 $post_parent = 0; 55 56 if ( isset($_POST['parent_id']) ) 57 $post_parent = $_POST['parent_id']; 58 59 if ( empty($post_status) ) 60 $post_status = 'draft'; 61 // Double-check 62 if ( 'publish' == $post_status && 1 == $user_level && 2 != get_option('new_users_can_blog') ) 63 $post_status = 'draft'; 64 $comment_status = $_POST['comment_status']; 65 if ( empty($comment_status) ) 66 $comment_status = get_option('default_comment_status'); 67 $ping_status = $_POST['ping_status']; 68 if ( empty($ping_status) ) 69 $ping_status = get_option('default_ping_status'); 70 $post_password = $_POST['post_password']; 71 72 if ( empty($post_name) ) { 73 if ( !empty($post_title) ) 74 $post_name = sanitize_title($post_title, $post_ID); 75 } else { 76 $post_name = sanitize_title($post_name, $post_ID); 77 } 78 79 $trackback = $_POST['trackback_url']; 80 $trackback = preg_replace('|\s+|', "\n", $trackback); 80 81 81 82 if ($user_level == 0) … … 93 94 $mn = ($mn > 59) ? $mn - 60 : $mn; 94 95 $ss = ($ss > 59) ? $ss - 60 : $ss; 95 $now = "$aa-$mm-$jj $hh:$mn:$ss";96 $now_gmt = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss");97 } else { 98 $now = current_time('mysql');99 $now_gmt = current_time('mysql', 1);96 $now = "$aa-$mm-$jj $hh:$mn:$ss"; 97 $now_gmt = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); 98 } else { 99 $now = current_time('mysql'); 100 $now_gmt = current_time('mysql', 1); 100 101 } 101 102 … … 110 111 (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent) 111 112 VALUES 112 (' 0', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt', '$post_parent')113 ('$post_ID', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt', '$post_parent') 113 114 "; 114 115 … … 128 129 } 129 130 } else { 130 $location = 'post.php'; 131 } 131 $location = 'post.php?posted=true'; 132 } 133 132 134 if ( '' != $_POST['advanced'] || isset($_POST['save']) ) 133 135 $location = "post.php?action=edit&post=$post_ID"; … … 138 140 header("Location: $location"); // Send user on their way while we keep working 139 141 140 141 142 // Insert categories 142 143 // Check to make sure there is a category, if not just set it to some default 143 if (!$post_categories) $post_categories[] = 1;144 if (!$post_categories) $post_categories[] = get_option('default_category'); 144 145 foreach ($post_categories as $post_category) { 145 146 // Double check it's not there already 146 147 $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); 147 148 148 if (!$exists && $result) {149 if (!$exists) { 149 150 $wpdb->query(" 150 151 INSERT INTO $wpdb->post2cat … … 159 160 160 161 $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); 161 162 if (isset($sleep_after_edit) && $sleep_after_edit > 0) { 163 sleep($sleep_after_edit); 164 } 165 166 if ($post_status == 'publish') { 167 168 if ($post_pingback) { 162 163 do_action('save_post', $post_ID); 164 165 if ('publish' == $post_status) { 166 if ($post_pingback) 169 167 pingback($content, $post_ID); 170 } 171 168 do_trackbacks($post_ID); 172 169 do_action('publish_post', $post_ID); 173 174 // Time for trackbacks 175 $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_ID"); 176 $pinged = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_ID"); 177 $pinged = explode("\n", $pinged); 178 if ('' != $to_ping) { 179 if (strlen($excerpt) > 0) { 180 $the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ; 181 } else { 182 $the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content); 183 } 184 $excerpt = stripslashes($the_excerpt); 185 $to_pings = explode("\n", $to_ping); 186 foreach ($to_pings as $tb_ping) { 187 $tb_ping = trim($tb_ping); 188 if (!in_array($tb_ping, $pinged)) { 189 trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID); 190 } 191 } 192 } 193 194 } // end if publish 170 } 195 171 196 172 if ($post_status == 'static') { 197 173 generate_page_rewrite_rules(); 198 199 174 add_post_meta($post_ID, '_wp_page_template', $_POST['page_template'], true); 200 175 } … … 350 325 $location = 'post.php'; 351 326 } 352 header ('Location: ' . $location); // Send user on their way while we keep working327 //header ('Location: ' . $location); // Send user on their way while we keep working 353 328 354 329 $now = current_time('mysql'); … … 402 377 if (!in_array($new_cat, $old_categories)) 403 378 $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_ID, $new_cat)"); 404 }405 406 if (isset($sleep_after_edit) && $sleep_after_edit > 0) {407 sleep($sleep_after_edit);408 379 } 409 380 … … 447 418 } 448 419 449 // are we going from draft/private to published? 450 if ($prev_status != 'publish' && $post_status == 'publish') { 451 if ($post_pingback) { 452 pingback($content, $post_ID); 453 } 454 } // end if moving from draft/private to published 420 if ($prev_status != 'publish' && $post_status == 'publish') 421 do_action('private_to_published', $post_ID); 422 455 423 if ($post_status == 'publish') { 456 424 do_action('publish_post', $post_ID); 457 458 // Trackback time. 459 $to_ping = trim($wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_ID")); 460 $pinged = trim($wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_ID")); 461 $pinged = explode("\n", $pinged); 462 if ('' != $to_ping) { 463 if (strlen($excerpt) > 0) { 464 $the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt) ; 465 } else { 466 $the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content); 467 } 468 $excerpt = stripslashes($the_excerpt); 469 $to_pings = explode("\n", $to_ping); 470 foreach ($to_pings as $tb_ping) { 471 $tb_ping = trim($tb_ping); 472 if (!in_array($tb_ping, $pinged)) { 473 trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID); 474 } 475 } 476 } 477 } // end if publish 425 do_trackbacks($post_ID); 426 if ( get_option('default_pingback_flag') ) 427 pingback($content, $post_ID); 428 } 478 429 479 430 if ($post_status == 'static') { … … 500 451 501 452 $post_id = intval($_GET['post']); 502 $postdata = get_postdata($post_id) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'post.php'));503 $authordata = get_userdata($postdata ['Author_ID']);453 $postdata = $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_id'") or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'post.php')); 454 $authordata = get_userdata($postdata->post_author); 504 455 505 456 if ($user_level < $authordata->user_level) … … 515 466 516 467 $meta = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $post_id"); 517 518 if (isset($sleep_after_edit) && $sleep_after_edit > 0) {519 sleep($sleep_after_edit);520 }521 468 522 469 $sendback = $_SERVER['HTTP_REFERER']; -
trunk/wp-includes/functions-post.php
r1778 r1794 361 361 $comment_author = strip_tags($comment_author); 362 362 $comment_author = htmlspecialchars($comment_author); 363 $comment_author = $wpdb->escape($comment_author);364 363 365 364 $comment_author_email = preg_replace('/[^a-z+_.@-]/i', '', $comment_author_email); … … 367 366 $comment_author_url = strip_tags($comment_author_url); 368 367 $comment_author_url = htmlspecialchars($comment_author_url); 369 $comment_author_url = $wpdb->escape($comment_author_url);370 368 371 369 $comment_content = apply_filters('comment_content_presave', $comment_content); 372 $comment_content = $wpdb->escape($comment_content);373 370 374 371 $user_ip = addslashes($_SERVER['REMOTE_ADDR']); … … 407 404 } 408 405 406 function do_trackbacks($post_id) { 407 global $wpdb; 408 409 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id"); 410 $to_ping = get_to_ping($post_id); 411 $pinged = get_pung($post_id); 412 $content = strip_tags($post->post_content); 413 $excerpt = strip_tags($post->post_excerpt); 414 $post_title = strip_tags($post->post_title); 415 416 if ( $excerpt ) 417 $excerpt = substr($excerpt, 0, 252) . '...'; 418 else 419 $excerpt = substr($content, 0, 252) . '...'; 420 421 if ($to_ping) : foreach ($to_ping as $tb_ping) : 422 $tb_ping = trim($tb_ping); 423 if ( !in_array($tb_ping, $pinged) ) 424 trackback($tb_ping, $post_title, $excerpt, $post_id); 425 endforeach; endif; 426 } 427 428 function get_pung($post_id) { // Get URIs already pung for a post 429 global $wpdb; 430 $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id"); 431 $pung = trim($pung); 432 $pung = preg_split('/\s/', $pung); 433 return $pung; 434 } 435 436 function get_to_ping($post_id) { // Get any URIs in the todo list 437 global $wpdb; 438 $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id"); 439 $to_ping = trim($to_ping); 440 $to_ping = preg_split('/\s/', $to_ping); 441 return $to_ping; 442 } 443 444 function add_ping($post_id, $uri) { // Add a URI to those already pung 445 global $wpdb; 446 $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id"); 447 $pung = trim($pung); 448 $pung = preg_split('/\s/', $pung); 449 $pung[] = $uri; 450 $new = implode("\n", $pung); 451 return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id"); 452 } 453 409 454 ?> -
trunk/wp-includes/functions.php
r1792 r1794 735 735 736 736 function pingback($content, $post_ID) { 737 738 global $wp_version; 737 global $wp_version, $wpdb; 739 738 include_once (ABSPATH . WPINC . '/class-IXR.php'); 740 739 741 740 // original code by Mort (http://mort.mine.nu:8080) 742 $log = debug_fopen( './pingback.log', 'a');741 $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); 743 742 $post_links = array(); 744 743 debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); 744 745 $pung = get_pung($post_ID); 745 746 746 747 // Variables … … 748 749 $gunk = '/#~:.?+=&%@!\-'; 749 750 $punc = '.:?\-'; 750 $any = $ltrs .$gunk.$punc;751 $any = $ltrs . $gunk . $punc; 751 752 752 753 // Step 1 … … 769 770 // We don't wanna ping first and second types, even if they have a valid <link/> 770 771 771 foreach($post_links_temp[0] as $link_test){ 772 $test = parse_url($link_test); 773 if (isset($test['query'])) { 774 $post_links[] = $link_test; 775 } elseif(($test['path'] != '/') && ($test['path'] != '')) { 776 $post_links[] = $link_test; 777 } 778 } 772 foreach($post_links_temp[0] as $link_test) : 773 if ( !in_array($link_test, $pung) ) : // If we haven't pung it already 774 $test = parse_url($link_test); 775 if (isset($test['query'])) 776 $post_links[] = $link_test; 777 elseif(($test['path'] != '/') && ($test['path'] != '')) 778 $post_links[] = $link_test; 779 endif; 780 endforeach; 779 781 780 782 foreach ($post_links as $pagelinkedto){ 781 782 783 debug_fwrite($log, "Processing -- $pagelinkedto\n"); 783 784 $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 784 785 785 if($pingback_server_url) { 786 786 if ($pingback_server_url) { 787 787 // Now, the RPC call 788 $method = 'pingback.ping'; 789 debug_fwrite($log, 'Page Linked To: '.$pagelinkedto."\n"); 788 debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); 790 789 debug_fwrite($log, 'Page Linked From: '); 791 790 $pagelinkedfrom = get_permalink($post_ID); … … 795 794 $client = new IXR_Client($pingback_server_url); 796 795 $client->timeout = 3; 797 $client->useragent .= ' -- WordPress/' .$wp_version;796 $client->useragent .= ' -- WordPress/' . $wp_version; 798 797 799 798 // when set to true, this outputs debug messages by itself 800 799 $client->debug = false; 801 800 $client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto)); 802 803 if ( !$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto))) {801 802 if ( !$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto) ) ) 804 803 debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); 805 } 806 } 807 } 808 809 debug_fwrite($log, "\nEND: ".time()."\n****************************\n\r"); 804 else 805 add_ping( $post_ID, $pagelinkedto ); 806 } 807 } 808 809 debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); 810 810 debug_fclose($log); 811 811 } … … 1608 1608 1609 1609 // Get post-meta info 1610 if ( $meta_list = $wpdb->get_results(" 1611 SELECT post_id,meta_key,meta_value 1612 FROM $wpdb->postmeta 1613 WHERE post_id IN($post_id_list) 1614 ORDER BY post_id,meta_key 1615 ", ARRAY_A) ) { 1610 if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) { 1616 1611 1617 1612 // Change from flat structure to hierarchical: -
trunk/wp-settings.php
r1773 r1794 50 50 require (ABSPATH . WPINC . '/functions.php'); 51 51 require (ABSPATH . WPINC . '/functions-formatting.php'); 52 require (ABSPATH . WPINC . '/functions-post.php'); 52 53 require (ABSPATH . WPINC . '/classes.php'); 53 54 require (ABSPATH . WPINC . '/template-functions.php'); -
trunk/wp-trackback.php
r1734 r1794 1 1 <?php 2 3 function add_magic_quotes($array) { 4 foreach ($array as $k => $v) { 5 if (is_array($v)) { 6 $array[$k] = add_magic_quotes($v); 7 } else { 8 $array[$k] = addslashes($v); 9 } 10 } 11 return $array; 12 } 13 14 if (!get_magic_quotes_gpc()) { 15 $_GET = add_magic_quotes($_GET); 16 $_POST = add_magic_quotes($_POST); 17 $_COOKIE = add_magic_quotes($_COOKIE); 18 } 2 19 3 20 if ( !$doing_trackback) { … … 5 22 require('wp-blog-header.php'); 6 23 } 7 8 include_once (ABSPATH . WPINC . '/functions-post.php');9 24 10 25 function trackback_response($error = 0, $error_message = '') { -
trunk/xmlrpc.php
r1777 r1794 6 6 include('./wp-config.php'); 7 7 include_once(ABSPATH . WPINC . '/class-IXR.php'); 8 include_once(ABSPATH . WPINC . '/functions-post.php');9 8 10 9 // Turn off all warnings and errors.
Note: See TracChangeset
for help on using the changeset viewer.