Changeset 572 for trunk/wp-admin/wp-post.php
- Timestamp:
- 12/05/2003 09:41:27 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/wp-post.php
r560 r572 49 49 $excerpt = format_to_post($excerpt); 50 50 $post_title = addslashes($HTTP_POST_VARS['post_title']); 51 $post_categor y = intval($HTTP_POST_VARS['post_category']);51 $post_categories = $HTTP_POST_VARS['post_category']; 52 52 if(get_settings('use_geo_positions')) { 53 53 $latstr = $HTTP_POST_VARS['post_latf']; … … 87 87 if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) { 88 88 $postquery ="INSERT INTO $tableposts 89 (ID, post_author, post_date, post_content, post_title, post_ category, post_lat, post_lon, post_excerpt, post_status, comment_status, ping_status, post_password, post_name)89 (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) 90 90 VALUES 91 ('0', '$user_ID','$now','$content','$post_title','$post_category',$post_latf,$post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')91 ('0', '$user_ID', '$now', '$content', '$post_title', $post_latf, $post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name') 92 92 "; 93 93 } else { 94 94 $postquery ="INSERT INTO $tableposts 95 (ID, post_author, post_date, post_content, post_title, post_ category, post_excerpt, post_status, comment_status, ping_status, post_password, post_name)95 (ID, post_author, post_date, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name) 96 96 VALUES 97 ('0', '$user_ID','$now','$content','$post_title','$post_category','$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')97 ('0', '$user_ID', '$now', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name') 98 98 "; 99 99 } … … 103 103 $post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1"); 104 104 105 // Insert categories 106 foreach ($post_categories as $post_category) { 107 // Double check it's not there already 108 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category"); 109 110 if (!$exists && $result) { 111 $wpdb->query(" 112 INSERT INTO $tablepost2cat 113 (post_id, category_id) 114 VALUES 115 ($post_ID, $post_category) 116 "); 117 } 118 } 119 105 120 if (isset($sleep_after_edit) && $sleep_after_edit > 0) { 106 121 sleep($sleep_after_edit); … … 204 219 } 205 220 $post_ID = $HTTP_POST_VARS['post_ID']; 206 $post_categor y = intval($HTTP_POST_VARS['post_category']);221 $post_categories = $HTTP_POST_VARS['post_category']; 207 222 $post_autobr = intval($HTTP_POST_VARS['post_autobr']); 208 223 $content = balanceTags($HTTP_POST_VARS['content']); … … 249 264 post_content = '$content', 250 265 post_excerpt = '$excerpt', 251 post_title = '$post_title' ,252 post_category = '$post_category'".$datemodif.",253 ".$latlonaddition."266 post_title = '$post_title'" 267 .$datemodif."," 268 .$latlonaddition." 254 269 post_status = '$post_status', 255 270 comment_status = '$comment_status', … … 259 274 WHERE ID = $post_ID "); 260 275 276 277 // Now it's category time! 278 // First the old categories 279 $old_categories = $wpdb->get_col("SELECT category_id FROM $tablepost2cat WHERE post_id = $post_ID"); 280 281 // Delete any? 282 foreach ($old_categories as $old_cat) { 283 if (!in_array($old_cat, $post_categories)) // If a category was there before but isn't now 284 $wpdb->query("DELETE FROM $tablepost2cat WHERE category_id = $old_cat AND post_id = $post_ID LIMIT 1"); 285 } 286 287 // Add any? 288 foreach ($post_categories as $new_cat) { 289 if (!in_array($new_cat, $old_categories)) 290 $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_ID, $new_cat)"); 291 } 292 261 293 if (isset($sleep_after_edit) && $sleep_after_edit > 0) { 262 294 sleep($sleep_after_edit); … … 295 327 die ('Cheatin’ uh?'); 296 328 297 $post = $HTTP_GET_VARS['post'];329 $post_id = $HTTP_GET_VARS['post']; 298 330 $postdata = get_postdata($post) or die('Oops, no post with this ID. <a href="wp-post.php">Go back</a>!'); 299 331 $authordata = get_userdata($postdata['Author_ID']); … … 303 335 304 336 // send geoURL ping to "erase" from their DB 305 $query = "SELECT post_lat from $tableposts WHERE ID=$post ";337 $query = "SELECT post_lat from $tableposts WHERE ID=$post_id"; 306 338 $rows = $wpdb->query($query); 307 339 $myrow = $rows[0]; … … 311 343 } 312 344 313 $result = $wpdb->query("DELETE FROM $tableposts WHERE ID=$post ");345 $result = $wpdb->query("DELETE FROM $tableposts WHERE ID=$post_id"); 314 346 if (!$result) 315 347 die('Error in deleting... contact the <a href="mailto:$admin_email">webmaster</a>.'); 316 348 317 $result = $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID=$post"); 349 $result = $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID=$post_id"); 350 351 $categories = $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id = $post_id"); 318 352 319 353 if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
Note: See TracChangeset
for help on using the changeset viewer.