Changeset 1794 for trunk/wp-admin/post.php
- Timestamp:
- 10/14/2004 07:26:41 AM (20 years ago)
- File:
-
- 1 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'];
Note: See TracChangeset
for help on using the changeset viewer.