Changeset 2889
- Timestamp:
- 09/18/2005 07:44:14 PM (19 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2886 r2889 1 1 <?php 2 2 3 3 4 // Creates a new post from the "Write Post" form using $_POST information. … … 5 6 global $user_ID; 6 7 7 if ( ! current_user_can('edit_posts'))8 die( __('You are not allowed to create posts or drafts on this blog.'));8 if (!current_user_can('edit_posts')) 9 die(__('You are not allowed to create posts or drafts on this blog.')); 9 10 10 11 // Rename. 11 $_POST['post_content'] 12 $_POST['post_excerpt'] 12 $_POST['post_content'] = $_POST['content']; 13 $_POST['post_excerpt'] = $_POST['excerpt']; 13 14 $_POST['post_parent'] = $_POST['parent_id']; 14 15 $_POST['to_ping'] = $_POST['trackback_url']; 15 16 16 if (! empty($_POST['post_author_override'])) {17 if (!empty ($_POST['post_author_override'])) { 17 18 $_POST['$post_author'] = (int) $_POST['post_author_override']; 18 } else if (! empty($_POST['post_author'])) { 19 $_POST['post_author'] = (int) $_POST['post_author']; 20 } else { 21 $_POST['post_author'] = (int) $_POST['user_ID']; 22 } 23 24 if ( ($_POST['post_author'] != $_POST['user_ID']) && ! current_user_can('edit_others_posts') ) 25 die( __('You cannot post as this user.') ); 26 19 } else 20 if (!empty ($_POST['post_author'])) { 21 $_POST['post_author'] = (int) $_POST['post_author']; 22 } else { 23 $_POST['post_author'] = (int) $_POST['user_ID']; 24 } 25 26 if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts')) 27 die(__('You cannot post as this user.')); 28 27 29 // What to do based on which button they pressed 28 if ('' != $_POST['saveasdraft']) $_POST['post_status'] = 'draft'; 29 if ('' != $_POST['saveasprivate']) $_POST['post_status'] = 'private'; 30 if ('' != $_POST['publish']) $_POST['post_status'] = 'publish'; 31 if ('' != $_POST['advanced']) $_POST['post_status'] = 'draft'; 32 if ('' != $_POST['savepage']) $_POST['post_status'] = 'static'; 33 34 if ( 'publish' == $_POST['post_status'] && ! current_user_can('publish_posts') ) 30 if ('' != $_POST['saveasdraft']) 35 31 $_POST['post_status'] = 'draft'; 36 37 if ( !empty($_POST['edit_date']) ) { 32 if ('' != $_POST['saveasprivate']) 33 $_POST['post_status'] = 'private'; 34 if ('' != $_POST['publish']) 35 $_POST['post_status'] = 'publish'; 36 if ('' != $_POST['advanced']) 37 $_POST['post_status'] = 'draft'; 38 if ('' != $_POST['savepage']) 39 $_POST['post_status'] = 'static'; 40 41 if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) 42 $_POST['post_status'] = 'draft'; 43 44 if (!empty ($_POST['edit_date'])) { 38 45 $aa = $_POST['aa']; 39 46 $mm = $_POST['mm']; … … 43 50 $ss = $_POST['ss']; 44 51 $jj = ($jj > 31) ? 31 : $jj; 45 $hh = ($hh > 23) ? $hh - 46 $mn = ($mn > 59) ? $mn - 47 $ss = ($ss > 59) ? $ss - 52 $hh = ($hh > 23) ? $hh -24 : $hh; 53 $mn = ($mn > 59) ? $mn -60 : $mn; 54 $ss = ($ss > 59) ? $ss -60 : $ss; 48 55 $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 49 56 $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); 50 } 57 } 51 58 52 59 // Create the post. … … 63 70 $post_ID = (int) $_POST['post_ID']; 64 71 65 if ( ! current_user_can('edit_post', $post_ID))66 die( __('You are not allowed to edit this post.'));72 if (!current_user_can('edit_post', $post_ID)) 73 die(__('You are not allowed to edit this post.')); 67 74 68 75 // Rename. 69 76 $_POST['ID'] = (int) $_POST['post_ID']; 70 $_POST['post_content'] 71 $_POST['post_excerpt'] 77 $_POST['post_content'] = $_POST['content']; 78 $_POST['post_excerpt'] = $_POST['excerpt']; 72 79 $_POST['post_parent'] = $_POST['parent_id']; 73 80 $_POST['to_ping'] = $_POST['trackback_url']; 74 81 75 if (! empty($_POST['post_author_override'])) {82 if (!empty ($_POST['post_author_override'])) { 76 83 $_POST['$post_author'] = (int) $_POST['post_author_override']; 77 } else if (! empty($_POST['post_author'])) { 78 $_POST['post_author'] = (int) $_POST['post_author']; 79 } else { 80 $_POST['post_author'] = (int) $_POST['user_ID']; 81 } 82 83 if ( ($_POST['post_author'] != $_POST['user_ID']) && ! current_user_can('edit_others_posts') ) 84 die( __('You cannot post as this user.') ); 84 } else 85 if (!empty ($_POST['post_author'])) { 86 $_POST['post_author'] = (int) $_POST['post_author']; 87 } else { 88 $_POST['post_author'] = (int) $_POST['user_ID']; 89 } 90 91 if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts')) 92 die(__('You cannot post as this user.')); 85 93 86 94 // What to do based on which button they pressed 87 if ('' != $_POST['saveasdraft']) $_POST['post_status'] = 'draft'; 88 if ('' != $_POST['saveasprivate']) $_POST['post_status'] = 'private'; 89 if ('' != $_POST['publish']) $_POST['post_status'] = 'publish'; 90 if ('' != $_POST['advanced']) $_POST['post_status'] = 'draft'; 91 if ('' != $_POST['savepage']) $_POST['post_status'] = 'static'; 92 93 if ( 'publish' == $_POST['post_status'] && ! current_user_can('publish_posts') ) 95 if ('' != $_POST['saveasdraft']) 94 96 $_POST['post_status'] = 'draft'; 95 96 if ( !isset($_POST['comment_status']) ) 97 if ('' != $_POST['saveasprivate']) 98 $_POST['post_status'] = 'private'; 99 if ('' != $_POST['publish']) 100 $_POST['post_status'] = 'publish'; 101 if ('' != $_POST['advanced']) 102 $_POST['post_status'] = 'draft'; 103 if ('' != $_POST['savepage']) 104 $_POST['post_status'] = 'static'; 105 106 if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) 107 $_POST['post_status'] = 'draft'; 108 109 if (!isset ($_POST['comment_status'])) 97 110 $_POST['comment_status'] = 'closed'; 98 111 99 if ( !isset($_POST['ping_status']))112 if (!isset ($_POST['ping_status'])) 100 113 $_POST['ping_status'] = 'closed'; 101 102 if ( !empty($_POST['edit_date'])) {114 115 if (!empty ($_POST['edit_date'])) { 103 116 $aa = $_POST['aa']; 104 117 $mm = $_POST['mm']; … … 108 121 $ss = $_POST['ss']; 109 122 $jj = ($jj > 31) ? 31 : $jj; 110 $hh = ($hh > 23) ? $hh - 111 $mn = ($mn > 59) ? $mn - 112 $ss = ($ss > 59) ? $ss - 123 $hh = ($hh > 23) ? $hh -24 : $hh; 124 $mn = ($mn > 59) ? $mn -60 : $mn; 125 $ss = ($ss > 59) ? $ss -60 : $ss; 113 126 $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 114 127 $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); 115 } 128 } 116 129 117 130 wp_update_post($_POST); 118 131 119 132 // Meta Stuff 120 if ($_POST['meta']) :121 foreach ($_POST['meta'] as $key => $value) :122 update_meta($key, $value['key'], $value['value']);123 133 if ($_POST['meta']) 134 : foreach ($_POST['meta'] as $key => $value) 135 : update_meta($key, $value['key'], $value['value']); 136 endforeach; 124 137 endif; 125 138 126 if ($_POST['deletemeta']) :127 foreach ($_POST['deletemeta'] as $key => $value) :128 delete_meta($key);129 139 if ($_POST['deletemeta']) 140 : foreach ($_POST['deletemeta'] as $key => $value) 141 : delete_meta($key); 142 endforeach; 130 143 endif; 131 144 132 145 add_meta($post_ID); 133 146 134 147 return $post_ID; 135 148 } … … 141 154 $comment_post_ID = (int) $_POST['comment_post_ID']; 142 155 143 if ( ! current_user_can('edit_post', $comment_post_ID))144 die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.'));156 if (!current_user_can('edit_post', $comment_post_ID)) 157 die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); 145 158 146 159 $_POST['comment_author'] = $_POST['newcomment_author']; 147 $_POST['comment_author_email'] 160 $_POST['comment_author_email'] = $_POST['newcomment_author_email']; 148 161 $_POST['comment_author_url'] = $_POST['newcomment_author_url']; 149 162 $_POST['comment_approved'] = $_POST['comment_status']; 150 163 $_POST['comment_content'] = $_POST['content']; 151 164 $_POST['comment_ID'] = (int) $_POST['comment_ID']; 152 153 if ( !empty($_POST['edit_date'])) {165 166 if (!empty ($_POST['edit_date'])) { 154 167 $aa = $_POST['aa']; 155 168 $mm = $_POST['mm']; … … 159 172 $ss = $_POST['ss']; 160 173 $jj = ($jj > 31) ? 31 : $jj; 161 $hh = ($hh > 23) ? $hh - 162 $mn = ($mn > 59) ? $mn - 163 $ss = ($ss > 59) ? $ss - 174 $hh = ($hh > 23) ? $hh -24 : $hh; 175 $mn = ($mn > 59) ? $mn -60 : $mn; 176 $ss = ($ss > 59) ? $ss -60 : $ss; 164 177 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 165 178 } … … 182 195 183 196 if ($post->post_status == 'static') 184 $post->page_template = get_post_meta($id, '_wp_page_template', true); 197 $post->page_template = get_post_meta($id, '_wp_page_template', true); 185 198 186 199 return $post; … … 234 247 235 248 // Are we updating or creating? 236 if ( !empty($cat_ID)) {249 if (!empty ($cat_ID)) { 237 250 $update = true; 238 251 } else { … … 244 257 $cat_name = wp_specialchars($cat_name); 245 258 246 if ( empty($category_nicename))259 if (empty ($category_nicename)) 247 260 $category_nicename = sanitize_title($cat_name, $cat_ID); 248 261 else 249 262 $category_nicename = sanitize_title($category_nicename, $cat_ID); 250 263 251 if ( empty($category_description))264 if (empty ($category_description)) 252 265 $category_description = ''; 253 266 254 if ( empty($category_parent))267 if (empty ($category_parent)) 255 268 $category_parent = 0; 256 269 257 if ( 270 if (!$update) 258 271 $query = "INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')"; 259 272 else … … 262 275 $result = $wpdb->query($query); 263 276 264 if ( $update) {277 if ($update) { 265 278 do_action('edit_category', $cat_ID); 266 279 } else { … … 276 289 277 290 $cat_ID = (int) $catarr['cat_ID']; 278 291 279 292 // First, get all of the original fields 280 $category = get_category($cat_ID, ARRAY_A); 293 $category = get_category($cat_ID, ARRAY_A); 281 294 282 295 // Escape data pulled from DB. … … 295 308 296 309 // Don't delete the default cat. 297 if ( 1 == $cat_ID)310 if (1 == $cat_ID) 298 311 return 0; 299 312 … … 321 334 } 322 335 323 324 336 function wp_create_categories($categories, $post_id = '') { 325 $cat_ids = array ();337 $cat_ids = array (); 326 338 foreach ($categories as $category) { 327 if ( $id = category_exists($category))339 if ($id = category_exists($category)) 328 340 $cat_ids[] = $id; 329 else if ( $id = wp_create_category($category) ) 330 $cat_ids[] = $id; 331 } 332 333 if ( $post_id ) 341 else 342 if ($id = wp_create_category($category)) 343 $cat_ids[] = $id; 344 } 345 346 if ($post_id) 334 347 wp_set_post_cats('', $post_id, $cat_ids); 335 348 336 349 return $cat_ids; 337 350 } … … 339 352 function category_exists($cat_name) { 340 353 global $wpdb; 341 if ( !$category_nicename = sanitize_title($cat_name))354 if (!$category_nicename = sanitize_title($cat_name)) 342 355 return 0; 343 356 344 357 return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 345 358 } … … 348 361 349 362 function add_user() { 350 return update_user();351 } 352 353 function update_user($user_id = 0) {354 355 if ( $user_id != 0) {363 return edit_user(); 364 } 365 366 function edit_user($user_id = 0) { 367 368 if ($user_id != 0) { 356 369 $update = true; 357 370 $user->ID = $user_id; … … 362 375 $user = ''; 363 376 } 364 365 if ( isset($_POST['user_login']))377 378 if (isset ($_POST['user_login'])) 366 379 $user->user_login = wp_specialchars(trim($_POST['user_login'])); 367 380 368 381 $pass1 = $pass2 = ''; 369 if ( isset($_POST['pass1']))382 if (isset ($_POST['pass1'])) 370 383 $pass1 = $_POST['pass1']; 371 if ( isset($_POST['pass2']))384 if (isset ($_POST['pass2'])) 372 385 $pass2 = $_POST['pass2']; 373 386 374 if ( isset($_POST['email']))387 if (isset ($_POST['email'])) 375 388 $user->user_email = wp_specialchars(trim($_POST['email'])); 376 if ( isset($_POST['url'])) {389 if (isset ($_POST['url'])) { 377 390 $user->user_url = wp_specialchars(trim($_POST['url'])); 378 $user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url;379 } 380 if ( isset($_POST['first_name']))391 $user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; 392 } 393 if (isset ($_POST['first_name'])) 381 394 $user->first_name = wp_specialchars(trim($_POST['first_name'])); 382 if ( isset($_POST['last_name']))395 if (isset ($_POST['last_name'])) 383 396 $user->last_name = wp_specialchars(trim($_POST['last_name'])); 384 if ( isset($_POST['nickname']))397 if (isset ($_POST['nickname'])) 385 398 $user->nickname = wp_specialchars(trim($_POST['nickname'])); 386 if ( isset($_POST['display_name']))399 if (isset ($_POST['display_name'])) 387 400 $user->display_name = wp_specialchars(trim($_POST['display_name'])); 388 if ( isset($_POST['description']))401 if (isset ($_POST['description'])) 389 402 $user->description = wp_specialchars(trim($_POST['description'])); 390 if ( isset($_POST['jabber']))403 if (isset ($_POST['jabber'])) 391 404 $user->jabber = wp_specialchars(trim($_POST['jabber'])); 392 if ( isset($_POST['aim']))405 if (isset ($_POST['aim'])) 393 406 $user->aim = wp_specialchars(trim($_POST['aim'])); 394 if ( isset($_POST['yim']))407 if (isset ($_POST['yim'])) 395 408 $user->yim = wp_specialchars(trim($_POST['yim'])); 396 409 397 $errors = array ();398 410 $errors = array (); 411 399 412 /* checking that username has been typed */ 400 413 if ($user->user_login == '') … … 402 415 403 416 /* checking the password has been typed twice */ 404 do_action('check_passwords', array ($user->user_login, &$pass1, &$pass2));405 406 if ( !$update) {407 if ( $pass1 == '' || $pass2 == '')417 do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2)); 418 419 if (!$update) { 420 if ($pass1 == '' || $pass2 == '') 408 421 $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.'); 409 422 } else { 410 if ( ( empty($pass1) && !empty($pass2) ) || ( empty($pass2) && !empty($pass1) ))423 if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1))) 411 424 $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); 412 425 } 413 426 414 427 /* checking the password has been typed twice the same */ 415 428 if ($pass1 != $pass2) 416 429 $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.'); 417 430 418 if ( !empty($pass1))431 if (!empty ($pass1)) 419 432 $user->user_pass = $pass1; 420 421 if ( !$update && username_exists( $user_login ))433 434 if (!$update && username_exists($user_login)) 422 435 $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 423 436 424 437 /* checking e-mail address */ 425 if (empty ($user->user_email)) {438 if (empty ($user->user_email)) { 426 439 $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address"); 427 } else if (!is_email($user->user_email)) { 428 $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); 429 } 430 431 if ( count($errors) != 0 ) 440 } else 441 if (!is_email($user->user_email)) { 442 $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); 443 } 444 445 if (count($errors) != 0) 432 446 return $errors; 433 434 if ( $update) {447 448 if ($update) { 435 449 $user_id = wp_update_user(get_object_vars($user)); 436 450 } else { … … 438 452 wp_new_user_notification($user_id); 439 453 } 440 454 441 455 return $errors; 442 456 } … … 446 460 447 461 $id = (int) $id; 448 449 if ($reassign == 'novalue') {462 463 if ($reassign == 'novalue') { 450 464 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); 451 465 452 466 if ($post_ids) { 453 467 $post_ids = implode(',', $post_ids); 454 468 455 469 // Delete comments, *backs 456 470 $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); … … 462 476 $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); 463 477 } 464 478 465 479 // Clean links 466 480 $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id"); 467 481 } else { 468 $reassign = (int) $reassign;482 $reassign = (int) $reassign; 469 483 $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}"); 470 484 $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}"); … … 479 493 } 480 494 495 function get_link($link_id, $output = OBJECT) { 496 global $wpdb; 497 498 $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'"); 499 500 if ( $output == OBJECT ) { 501 return $link; 502 } elseif ( $output == ARRAY_A ) { 503 return get_object_vars($link); 504 } elseif ( $output == ARRAY_N ) { 505 return array_values(get_object_vars($link)); 506 } else { 507 return $link; 508 } 509 } 510 511 function get_link_to_edit($link_id) { 512 $link = get_link($link_id); 513 514 $link->link_url = wp_specialchars($link->link_url, 1); 515 $link->link_name = wp_specialchars($link->link_name, 1); 516 $link->link_description = wp_specialchars($link->link_description); 517 $link->link_notes = wp_specialchars($link->link_notes); 518 $link->link_rss = wp_specialchars($link->link_rss); 519 520 return $link; 521 } 522 523 function add_link() { 524 return edit_link(); 525 } 526 527 function edit_link($link_id = '') { 528 if (!current_user_can('manage_links')) 529 die(__("Cheatin' uh ?")); 530 531 $_POST['link_url'] = wp_specialchars($_POST['link_url']); 532 //$link_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $link_url) ? $link_url : 'http://'.$link_url; 533 $_POST['link_name'] = wp_specialchars($_POST['link_name']); 534 $_POST['link_image'] = wp_specialchars($_POST['link_image']); 535 $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); 536 $auto_toggle = get_autotoggle($_POST['link_category']); 537 538 // if we are in an auto toggle category and this one is visible then we 539 // need to make the others invisible before we add this new one. 540 // FIXME Add category toggle func. 541 //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { 542 // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category"); 543 //} 544 545 if ( !empty($link_id) ) { 546 $_POST['link_id'] = $link_id; 547 return wp_update_link($_POST); 548 } else { 549 return wp_insert_link($_POST); 550 } 551 } 552 553 function wp_insert_link($linkdata) { 554 global $wpdb; 555 556 extract($linkdata); 557 558 $update = false; 559 if ( !empty($link_id) ) 560 $update = true; 561 562 if ( empty($link_rating) ) 563 $link_rating = 0; 564 565 if ( empty($link_target) ) 566 $link_target = ''; 567 568 if ( empty($link_visible) ) 569 $link_visible = 'Y'; 570 571 if ( $update ) { 572 $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url', 573 link_name='$link_name', link_image='$link_image', 574 link_target='$link_target', link_category='$link_category', 575 link_visible='$link_visible', link_description='$link_description', 576 link_rating='$link_rating', link_rel='$link_rel', 577 link_notes='$link_notes', link_rss = '$link_rss' 578 WHERE link_id='$link_id'"); 579 } else { 580 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')"); 581 $link_id = $wpdb->insert_id; 582 } 583 584 if ( $update ) 585 do_action('edit_link', $link_id); 586 else 587 do_action('add_link', $link_id); 588 589 return $link_id; 590 } 591 592 function wp_update_link($linkdata) { 593 global $wpdb; 594 595 $link_id = (int) $linkdata['link_id']; 596 597 $link = get_link($link_id, ARRAY_A); 598 599 // Escape data pulled from DB. 600 $link = add_magic_quotes($link); 601 602 // Merge old and new fields with new fields overwriting old ones. 603 $linkdata = array_merge($link, $linkdata); 604 605 return wp_insert_link($linkdata); 606 } 607 608 function wp_delete_link($link_id) { 609 global $wpdb; 610 611 return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); 612 } 613 481 614 function post_exists($title, $content = '', $post_date = '') { 482 615 global $wpdb; 483 484 if ( !empty($post_date))616 617 if (!empty ($post_date)) 485 618 $post_date = "AND post_date = '$post_date'"; 486 619 487 if ( ! empty($title))620 if (!empty ($title)) 488 621 return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date"); 489 else if ( ! empty($content) ) 490 return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); 622 else 623 if (!empty ($content)) 624 return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); 491 625 492 626 return 0; … … 497 631 498 632 return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments 499 WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");500 } 501 502 function url_shorten 633 WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'"); 634 } 635 636 function url_shorten($url) { 503 637 $short_url = str_replace('http://', '', stripslashes($url)); 504 638 $short_url = str_replace('www.', '', $short_url); … … 506 640 $short_url = substr($short_url, 0, -1); 507 641 if (strlen($short_url) > 35) 508 $short_url = 642 $short_url = substr($short_url, 0, 32).'...'; 509 643 return $short_url; 510 644 } 511 645 512 646 function selected($selected, $current) { 513 if ($selected == $current) echo ' selected="selected"'; 647 if ($selected == $current) 648 echo ' selected="selected"'; 514 649 } 515 650 516 651 function checked($checked, $current) { 517 if ($checked == $current) echo ' checked="checked"'; 518 } 519 520 function return_categories_list( $parent = 0 ) { 652 if ($checked == $current) 653 echo ' checked="checked"'; 654 } 655 656 function return_categories_list($parent = 0) { 521 657 global $wpdb; 522 658 return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC"); … … 524 660 525 661 function get_nested_categories($default = 0, $parent = 0) { 526 global $post_ID, $mode, $wpdb; 527 528 if ($post_ID) { 529 $checked_categories = $wpdb->get_col(" 530 SELECT category_id 531 FROM $wpdb->categories, $wpdb->post2cat 532 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' 533 "); 534 535 if(count($checked_categories) == 0) 536 { 537 // No selected categories, strange 538 $checked_categories[] = $default; 539 } 540 541 } else { 542 $checked_categories[] = $default; 543 } 544 545 $cats = return_categories_list($parent); 546 $result = array(); 547 548 if ( is_array( $cats ) ) { 549 foreach($cats as $cat) { 662 global $post_ID, $mode, $wpdb; 663 664 if ($post_ID) { 665 $checked_categories = $wpdb->get_col(" 666 SELECT category_id 667 FROM $wpdb->categories, $wpdb->post2cat 668 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' 669 "); 670 671 if (count($checked_categories) == 0) { 672 // No selected categories, strange 673 $checked_categories[] = $default; 674 } 675 676 } else { 677 $checked_categories[] = $default; 678 } 679 680 $cats = return_categories_list($parent); 681 $result = array (); 682 683 if (is_array($cats)) { 684 foreach ($cats as $cat) { 550 685 $result[$cat]['children'] = get_nested_categories($default, $cat); 551 686 $result[$cat]['cat_ID'] = $cat; … … 559 694 560 695 function write_nested_categories($categories) { 561 foreach($categories as $category) { 562 echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], 563 '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', 564 ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n"; 565 566 if(isset($category['children'])) { 567 echo "\n<span class='cat-nest'>\n"; 568 write_nested_categories($category['children']); 569 echo "</span>\n"; 570 } 571 } 696 foreach ($categories as $category) { 697 echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n"; 698 699 if (isset ($category['children'])) { 700 echo "\n<span class='cat-nest'>\n"; 701 write_nested_categories($category['children']); 702 echo "</span>\n"; 703 } 704 } 572 705 } 573 706 574 707 function dropdown_categories($default = 0) { 575 576 } 708 write_nested_categories(get_nested_categories($default)); 709 } 577 710 578 711 // Dandy new recursive multiple category stuff. … … 580 713 global $wpdb, $class; 581 714 582 if ( !$categories)715 if (!$categories) 583 716 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 584 717 … … 589 722 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); 590 723 $pad = str_repeat('— ', $level); 591 if ( current_user_can('manage_categories'))592 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1)) . "' );\" class='delete'>" . __('Delete') ."</a>";724 if (current_user_can('manage_categories')) 725 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td><td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>"; 593 726 else 594 727 $edit = ''; 595 728 596 729 $class = ('alternate' == $class) ? '' : 'alternate'; 597 730 echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td> 598 <td>$category->category_description</td>599 <td>$count</td>600 <td>$edit</td>601 </tr>";602 cat_rows($category->cat_ID, $level + 731 <td>$category->category_description</td> 732 <td>$count</td> 733 <td>$edit</td> 734 </tr>"; 735 cat_rows($category->cat_ID, $level +1, $categories); 603 736 } 604 737 } … … 608 741 } 609 742 610 function page_rows( $parent = 0, $level = 0, $pages = 0) {743 function page_rows($parent = 0, $level = 0, $pages = 0) { 611 744 global $wpdb, $class, $post; 612 745 if (!$pages) … … 614 747 615 748 if ($pages) { 616 foreach ($pages as $post) { start_wp(); 749 foreach ($pages as $post) { 750 start_wp(); 617 751 if ($post->post_parent == $parent) { 618 752 $post->post_title = wp_specialchars($post->post_title); … … 634 768 635 769 <?php 636 page_rows($id, $level + 1, $pages); 770 771 page_rows($id, $level +1, $pages); 637 772 } 638 773 } … … 648 783 } 649 784 if ($categories) { 650 foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { 651 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); 652 $pad = str_repeat('– ', $level); 653 $category->cat_name = wp_specialchars($category->cat_name); 654 echo "\n\t<option value='$category->cat_ID'"; 655 if ($currentparent == $category->cat_ID) 656 echo " selected='selected'"; 657 echo ">$pad$category->cat_name</option>"; 658 wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level + 1, $categories); 659 } } 785 foreach ($categories as $category) { 786 if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { 787 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); 788 $pad = str_repeat('– ', $level); 789 $category->cat_name = wp_specialchars($category->cat_name); 790 echo "\n\t<option value='$category->cat_ID'"; 791 if ($currentparent == $category->cat_ID) 792 echo " selected='selected'"; 793 echo ">$pad$category->cat_name</option>"; 794 wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level +1, $categories); 795 } 796 } 660 797 } else { 661 798 return false; … … 665 802 function wp_create_thumbnail($file, $max_side, $effect = '') { 666 803 667 // 1 = GIF, 2 = JPEG, 3 = PNG 668 669 if(file_exists($file)) { 670 $type = getimagesize($file); 671 672 // if the associated function doesn't exist - then it's not 673 // handle. duh. i hope. 674 675 if(!function_exists('imagegif') && $type[2] == 1) { 676 $error = __('Filetype not supported. Thumbnail not created.'); 677 }elseif(!function_exists('imagejpeg') && $type[2] == 2) { 678 $error = __('Filetype not supported. Thumbnail not created.'); 679 }elseif(!function_exists('imagepng') && $type[2] == 3) { 680 $error = __('Filetype not supported. Thumbnail not created.'); 681 } else { 682 683 // create the initial copy from the original file 684 if($type[2] == 1) { 685 $image = imagecreatefromgif($file); 686 } elseif($type[2] == 2) { 687 $image = imagecreatefromjpeg($file); 688 } elseif($type[2] == 3) { 689 $image = imagecreatefrompng($file); 690 } 691 804 // 1 = GIF, 2 = JPEG, 3 = PNG 805 806 if (file_exists($file)) { 807 $type = getimagesize($file); 808 809 // if the associated function doesn't exist - then it's not 810 // handle. duh. i hope. 811 812 if (!function_exists('imagegif') && $type[2] == 1) { 813 $error = __('Filetype not supported. Thumbnail not created.'); 814 } 815 elseif (!function_exists('imagejpeg') && $type[2] == 2) { 816 $error = __('Filetype not supported. Thumbnail not created.'); 817 } 818 elseif (!function_exists('imagepng') && $type[2] == 3) { 819 $error = __('Filetype not supported. Thumbnail not created.'); 820 } else { 821 822 // create the initial copy from the original file 823 if ($type[2] == 1) { 824 $image = imagecreatefromgif($file); 825 } 826 elseif ($type[2] == 2) { 827 $image = imagecreatefromjpeg($file); 828 } 829 elseif ($type[2] == 3) { 830 $image = imagecreatefrompng($file); 831 } 832 692 833 if (function_exists('imageantialias')) 693 imageantialias($image, TRUE); 694 695 $image_attr = getimagesize($file); 696 697 // figure out the longest side 698 699 if($image_attr[0] > $image_attr[1]) { 700 $image_width = $image_attr[0]; 701 $image_height = $image_attr[1]; 702 $image_new_width = $max_side; 703 704 $image_ratio = $image_width/$image_new_width; 705 $image_new_height = $image_height/$image_ratio; 706 //width is > height 707 } else { 708 $image_width = $image_attr[0]; 709 $image_height = $image_attr[1]; 710 $image_new_height = $max_side; 711 712 $image_ratio = $image_height/$image_new_height; 713 $image_new_width = $image_width/$image_ratio; 714 //height > width 715 } 716 717 $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height); 718 @imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]); 719 720 // move the thumbnail to it's final destination 721 722 $path = explode('/', $file); 723 $thumbpath = substr($file, 0, strrpos($file, '/')) . '/thumb-' . $path[count($path)-1]; 724 725 if($type[2] == 1) { 726 if(!imagegif($thumbnail, $thumbpath)) { 727 $error = __("Thumbnail path invalid"); 728 } 729 } elseif($type[2] == 2) { 730 if(!imagejpeg($thumbnail, $thumbpath)) { 731 $error = __("Thumbnail path invalid"); 732 } 733 } elseif($type[2] == 3) { 734 if(!imagepng($thumbnail, $thumbpath)) { 735 $error = __("Thumbnail path invalid"); 736 } 737 } 738 739 } 740 } 741 742 if(!empty($error)) 743 { 744 return $error; 745 } 746 else 747 { 748 return 1; 749 } 834 imageantialias($image, TRUE); 835 836 $image_attr = getimagesize($file); 837 838 // figure out the longest side 839 840 if ($image_attr[0] > $image_attr[1]) { 841 $image_width = $image_attr[0]; 842 $image_height = $image_attr[1]; 843 $image_new_width = $max_side; 844 845 $image_ratio = $image_width / $image_new_width; 846 $image_new_height = $image_height / $image_ratio; 847 //width is > height 848 } else { 849 $image_width = $image_attr[0]; 850 $image_height = $image_attr[1]; 851 $image_new_height = $max_side; 852 853 $image_ratio = $image_height / $image_new_height; 854 $image_new_width = $image_width / $image_ratio; 855 //height > width 856 } 857 858 $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height); 859 @ imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]); 860 861 // move the thumbnail to it's final destination 862 863 $path = explode('/', $file); 864 $thumbpath = substr($file, 0, strrpos($file, '/')).'/thumb-'.$path[count($path) - 1]; 865 866 if ($type[2] == 1) { 867 if (!imagegif($thumbnail, $thumbpath)) { 868 $error = __("Thumbnail path invalid"); 869 } 870 } 871 elseif ($type[2] == 2) { 872 if (!imagejpeg($thumbnail, $thumbpath)) { 873 $error = __("Thumbnail path invalid"); 874 } 875 } 876 elseif ($type[2] == 3) { 877 if (!imagepng($thumbnail, $thumbpath)) { 878 $error = __("Thumbnail path invalid"); 879 } 880 } 881 882 } 883 } 884 885 if (!empty ($error)) { 886 return $error; 887 } else { 888 return 1; 889 } 750 890 } 751 891 … … 755 895 756 896 return $wpdb->get_results(" 757 SELECT meta_key, meta_value, meta_id, post_id758 FROM $wpdb->postmeta759 WHERE post_id = '$postid'760 ORDER BY meta_key,meta_id",ARRAY_A);897 SELECT meta_key, meta_value, meta_id, post_id 898 FROM $wpdb->postmeta 899 WHERE post_id = '$postid' 900 ORDER BY meta_key,meta_id", ARRAY_A); 761 901 762 902 } 763 903 764 904 function list_meta($meta) { 765 global $post_ID; 905 global $post_ID; 766 906 // Exit if no meta 767 if (!$meta) return; 907 if (!$meta) 908 return; 768 909 $count = 0; 769 910 ?> … … 775 916 </tr> 776 917 <?php 777 918 919 778 920 foreach ($meta as $entry) { 779 ++$count; 780 if ( $count % 2 ) $style = 'alternate'; 781 else $style = ''; 782 if ( '_' == $entry['meta_key']{0} ) $style .= ' hidden'; 921 ++ $count; 922 if ($count % 2) 923 $style = 'alternate'; 924 else 925 $style = ''; 926 if ('_' == $entry['meta_key'] { 0 }) 927 $style .= ' hidden'; 783 928 echo " 784 <tr class='$style'>785 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>786 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>787 <td align='center' width='10%'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='" . __('Update')."' /></td>788 <td align='center' width='10%'><input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='" . __('Delete')."' /></td>789 </tr>790 ";929 <tr class='$style'> 930 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> 931 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> 932 <td align='center' width='10%'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /></td> 933 <td align='center' width='10%'><input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td> 934 </tr> 935 "; 791 936 } 792 937 echo " 793 </table>794 ";938 </table> 939 "; 795 940 } 796 941 … … 798 943 function get_meta_keys() { 799 944 global $wpdb; 800 945 801 946 $keys = $wpdb->get_col(" 802 SELECT meta_key803 FROM $wpdb->postmeta804 GROUP BY meta_key805 ORDER BY meta_key");806 947 SELECT meta_key 948 FROM $wpdb->postmeta 949 GROUP BY meta_key 950 ORDER BY meta_key"); 951 807 952 return $keys; 808 953 } … … 811 956 global $wpdb; 812 957 $keys = $wpdb->get_col(" 813 SELECT meta_key814 FROM $wpdb->postmeta815 GROUP BY meta_key816 ORDER BY meta_id DESC817 LIMIT 10");958 SELECT meta_key 959 FROM $wpdb->postmeta 960 GROUP BY meta_key 961 ORDER BY meta_id DESC 962 LIMIT 10"); 818 963 ?> 819 964 <h3><?php _e('Add a new custom field:') ?></h3> … … 829 974 <option value="#NONE#"><?php _e('- Select -'); ?></option> 830 975 <?php 831 foreach($keys as $key) { 976 977 foreach ($keys as $key) { 832 978 echo "\n\t<option value='$key'>$key</option>"; 833 979 } … … 843 989 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> 844 990 <?php 991 845 992 } 846 993 847 994 function add_meta($post_ID) { 848 995 global $wpdb; 849 850 $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ));851 $metakeyinput = $wpdb->escape( stripslashes( trim($_POST['metakeyinput']) ));852 $metavalue = $wpdb->escape( stripslashes( trim($_POST['metavalue']) ));853 854 if (!empty ($metavalue) && ((('#NONE#' != $metakeyselect) && !empty($metakeyselect)) || !empty($metakeyinput))) {996 997 $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); 998 $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); 999 $metavalue = $wpdb->escape(stripslashes(trim($_POST['metavalue']))); 1000 1001 if (!empty ($metavalue) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput))) { 855 1002 // We have a key/value pair. If both the select and the 856 1003 // input for the key have data, the input takes precedence: … … 858 1005 if ('#NONE#' != $metakeyselect) 859 1006 $metakey = $metakeyselect; 860 1007 861 1008 if ($metakeyinput) 862 1009 $metakey = $metakeyinput; // default 863 1010 864 1011 $result = $wpdb->query(" 865 INSERT INTO $wpdb->postmeta866 (post_id,meta_key,meta_value)867 VALUES ('$post_ID','$metakey','$metavalue')868 ");1012 INSERT INTO $wpdb->postmeta 1013 (post_id,meta_key,meta_value) 1014 VALUES ('$post_ID','$metakey','$metavalue') 1015 "); 869 1016 } 870 1017 } // add_meta … … 884 1031 function touch_time($edit = 1, $for_post = 1) { 885 1032 global $month, $post, $comment; 886 if ( $for_post && ('draft' == $post->post_status)) {1033 if ($for_post && ('draft' == $post->post_status)) { 887 1034 $checked = 'checked="checked" '; 888 1035 $edit = false; … … 891 1038 } 892 1039 893 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">' . __('Edit timestamp') .'</label></legend>';894 1040 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">'.__('Edit timestamp').'</label></legend>'; 1041 895 1042 $time_adj = time() + (get_settings('gmt_offset') * 3600); 896 1043 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; … … 903 1050 904 1051 echo "<select name=\"mm\">\n"; 905 for ($i =1; $i < 13; $i=$i+1) {1052 for ($i = 1; $i < 13; $i = $i +1) { 906 1053 echo "\t\t\t<option value=\"$i\""; 907 1054 if ($i == $mm) 908 echo " selected='selected'";1055 echo " selected='selected'"; 909 1056 if ($i < 10) { 910 1057 $ii = "0".$i; … … 913 1060 } 914 1061 echo ">".$month["$ii"]."</option>\n"; 915 } 916 1062 } 917 1063 ?> 918 1064 </select> … … 924 1070 <?php _e('Existing timestamp'); ?>: 925 1071 <?php 926 // We might need to readjust to display proper existing timestamp 927 if ( $for_post && ('draft' == $post->post_status) ) { 928 $jj = mysql2date('d', $post_date); 929 $mm = mysql2date('m', $post_date); 930 $aa = mysql2date('Y', $post_date); 931 $hh = mysql2date('H', $post_date); 932 $mn = mysql2date('i', $post_date); 933 $ss = mysql2date('s', $post_date); 934 } 935 echo "{$month[$mm]} $jj, $aa @ $hh:$mn"; ?> 1072 1073 // We might need to readjust to display proper existing timestamp 1074 if ($for_post && ('draft' == $post->post_status)) { 1075 $jj = mysql2date('d', $post_date); 1076 $mm = mysql2date('m', $post_date); 1077 $aa = mysql2date('Y', $post_date); 1078 $hh = mysql2date('H', $post_date); 1079 $mn = mysql2date('i', $post_date); 1080 $ss = mysql2date('s', $post_date); 1081 } 1082 echo "{$month[$mm]} $jj, $aa @ $hh:$mn"; 1083 ?> 936 1084 </fieldset> 937 1085 <?php 1086 938 1087 } 939 1088 940 1089 function check_admin_referer() { 941 $adminurl = strtolower( get_settings('siteurl') ) .'/wp-admin';942 $referer = strtolower( $_SERVER['HTTP_REFERER']);943 if ( !strstr($referer, $adminurl))1090 $adminurl = strtolower(get_settings('siteurl')).'/wp-admin'; 1091 $referer = strtolower($_SERVER['HTTP_REFERER']); 1092 if (!strstr($referer, $adminurl)) 944 1093 die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.')); 945 1094 do_action('check_admin_referer'); … … 963 1112 if ($markerdata) { 964 1113 $state = true; 965 foreach($markerdata as $markerline) { 966 if (strstr($markerline, "# BEGIN {$marker}")) $state = false; 967 if ($state) fwrite($f, "{$markerline}\n"); 1114 foreach ($markerdata as $markerline) { 1115 if (strstr($markerline, "# BEGIN {$marker}")) 1116 $state = false; 1117 if ($state) 1118 fwrite($f, "{$markerline}\n"); 968 1119 if (strstr($markerline, "# END {$marker}")) { 969 1120 fwrite($f, "# BEGIN {$marker}\n"); 970 if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$insertline}\n"); 1121 if (is_array($insertion)) 1122 foreach ($insertion as $insertline) 1123 fwrite($f, "{$insertline}\n"); 971 1124 fwrite($f, "# END {$marker}\n"); 972 1125 $state = true; … … 977 1130 if (!$foundit) { 978 1131 fwrite($f, "# BEGIN {$marker}\n"); 979 foreach($insertion as $insertline) fwrite($f, "{$insertline}\n"); 1132 foreach ($insertion as $insertline) 1133 fwrite($f, "{$insertline}\n"); 980 1134 fwrite($f, "# END {$marker}\n"); 981 1135 } … … 991 1145 // and END markers. 992 1146 function extract_from_markers($filename, $marker) { 993 $result = array ();1147 $result = array (); 994 1148 995 1149 if (!file_exists($filename)) { … … 997 1151 } 998 1152 999 if ($markerdata = explode("\n", implode('', file($filename))));1153 if ($markerdata = explode("\n", implode('', file($filename)))); 1000 1154 { 1001 1155 $state = false; 1002 foreach($markerdata as $markerline) { 1003 if(strstr($markerline, "# END {$marker}")) $state = false; 1004 if($state) $result[] = $markerline; 1005 if(strstr($markerline, "# BEGIN {$marker}")) $state = true; 1156 foreach ($markerdata as $markerline) { 1157 if (strstr($markerline, "# END {$marker}")) 1158 $state = false; 1159 if ($state) 1160 $result[] = $markerline; 1161 if (strstr($markerline, "# BEGIN {$marker}")) 1162 $state = true; 1006 1163 } 1007 1164 } … … 1014 1171 $home_path = get_home_path(); 1015 1172 1016 if (! 1173 if (!$wp_rewrite->using_mod_rewrite_permalinks()) 1017 1174 return; 1018 1175 1019 if ( ! ((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))1176 if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess'))) 1020 1177 return; 1021 1178 1022 if (! 1179 if (!$is_apache) 1023 1180 return; 1024 1181 … … 1027 1184 } 1028 1185 1029 function the_quicktags 1030 // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP1031 if ( !strstr($_SERVER['HTTP_USER_AGENT'], 'Safari') ) : 1032 echo '1033 <div id="quicktags">1034 <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>1035 <script type="text/javascript">edToolbar();</script>1036 ';1186 function the_quicktags() { 1187 // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP 1188 if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) 1189 : echo ' 1190 <div id="quicktags"> 1191 <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script> 1192 <script type="text/javascript">edToolbar();</script> 1193 '; 1037 1194 echo '</div>'; 1038 endif;1195 endif; 1039 1196 } 1040 1197 1041 1198 function validate_current_theme() { 1042 1199 $theme_loc = 'wp-content/themes'; 1043 $theme_root = ABSPATH .$theme_loc;1200 $theme_root = ABSPATH.$theme_loc; 1044 1201 1045 1202 $template = get_settings('template'); 1046 1203 $stylesheet = get_settings('stylesheet'); 1047 1204 1048 if (($template != 'default') && (! 1205 if (($template != 'default') && (!file_exists("$theme_root/$template/index.php"))) { 1049 1206 update_option('template', 'default'); 1050 1207 update_option('stylesheet', 'default'); … … 1053 1210 } 1054 1211 1055 if (($stylesheet != 'default') && (! 1212 if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) { 1056 1213 update_option('template', 'default'); 1057 1214 update_option('stylesheet', 'default'); … … 1074 1231 $theme = get_current_theme(); 1075 1232 $templates = $themes[$theme]['Template Files']; 1076 $page_templates = array ();1077 1078 if ( is_array( $templates )) {1233 $page_templates = array (); 1234 1235 if (is_array($templates)) { 1079 1236 foreach ($templates as $template) { 1080 $template_data = implode('', file(ABSPATH .$template));1237 $template_data = implode('', file(ABSPATH.$template)); 1081 1238 preg_match("|Template Name:(.*)|i", $template_data, $name); 1082 1239 preg_match("|Description:(.*)|i", $template_data, $description); … … 1085 1242 $description = $description[1]; 1086 1243 1087 if (! empty($name)) {1244 if (!empty ($name)) { 1088 1245 $page_templates[trim($name)] = basename($template); 1089 1246 } … … 1096 1253 function page_template_dropdown($default = '') { 1097 1254 $templates = get_page_templates(); 1098 foreach (array_keys($templates) as $template) : 1099 if ($default == $templates[$template]) $selected = " selected='selected'"; 1100 else $selected = ''; 1101 echo "\n\t<option value='" . $templates[$template] . "' $selected>$template</option>"; 1102 endforeach; 1255 foreach (array_keys($templates) as $template) 1256 : if ($default == $templates[$template]) 1257 $selected = " selected='selected'"; 1258 else 1259 $selected = ''; 1260 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>"; 1261 endforeach; 1103 1262 } 1104 1263 … … 1110 1269 foreach ($items as $item) { 1111 1270 // A page cannot be it's own parent. 1112 if (!empty ($post_ID)) {1271 if (!empty ($post_ID)) { 1113 1272 if ($item->ID == $post_ID) { 1114 1273 continue; … … 1122 1281 1123 1282 echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>"; 1124 parent_dropdown($default, $item->ID, $level + 1283 parent_dropdown($default, $item->ID, $level +1); 1125 1284 } 1126 1285 } else { … … 1139 1298 //echo "parent array: " . $menu_array[2]; 1140 1299 if ($menu_array[2] == $parent) { 1141 if ( !current_user_can($menu_array[1])) {1300 if (!current_user_can($menu_array[1])) { 1142 1301 return false; 1143 1302 } else { … … 1147 1306 } 1148 1307 1149 if (isset ($submenu[$parent])) {1308 if (isset ($submenu[$parent])) { 1150 1309 foreach ($submenu[$parent] as $submenu_array) { 1151 1310 if ($submenu_array[2] == $pagenow) { 1152 if ( !current_user_can($submenu_array[1])) {1311 if (!current_user_can($submenu_array[1])) { 1153 1312 return false; 1154 1313 } else { … … 1158 1317 } 1159 1318 } 1160 1319 1161 1320 return true; 1162 1321 } … … 1169 1328 global $plugin_page; 1170 1329 1171 if (isset ($title) && ! empty($title)) {1330 if (isset ($title) && !empty ($title)) { 1172 1331 return $title; 1173 1332 } 1174 1333 1175 1334 $parent = get_admin_page_parent(); 1176 if (empty ($parent)) {1335 if (empty ($parent)) { 1177 1336 foreach ($menu as $menu_array) { 1178 if (isset ($menu_array[3])) {1337 if (isset ($menu_array[3])) { 1179 1338 if ($menu_array[2] == $pagenow) { 1180 1339 $title = $menu_array[3]; 1181 1340 return $menu_array[3]; 1182 } else if (isset($plugin_page) && ($plugin_page == $menu_array[2])) { 1183 $title = $menu_array[3]; 1184 return $menu_array[3]; 1185 } 1341 } else 1342 if (isset ($plugin_page) && ($plugin_page == $menu_array[2])) { 1343 $title = $menu_array[3]; 1344 return $menu_array[3]; 1345 } 1186 1346 } 1187 1347 } … … 1189 1349 foreach (array_keys($submenu) as $parent) { 1190 1350 foreach ($submenu[$parent] as $submenu_array) { 1191 if (isset ($submenu_array[3])) {1351 if (isset ($submenu_array[3])) { 1192 1352 if ($submenu_array[2] == $pagenow) { 1193 1353 $title = $submenu_array[3]; 1194 1354 return $submenu_array[3]; 1195 } else if (isset($plugin_page) && ($plugin_page == $submenu_array[2])) { 1196 $title = $submenu_array[3]; 1197 return $submenu_array[3]; 1198 } 1355 } else 1356 if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) { 1357 $title = $submenu_array[3]; 1358 return $submenu_array[3]; 1359 } 1199 1360 } 1200 1361 } … … 1212 1373 global $plugin_page; 1213 1374 1214 if (isset ($parent_file) && ! empty($parent_file)) {1375 if (isset ($parent_file) && !empty ($parent_file)) { 1215 1376 return $parent_file; 1216 1377 } 1217 1378 1218 if ($pagenow == 'admin.php' && isset ($plugin_page)) {1379 if ($pagenow == 'admin.php' && isset ($plugin_page)) { 1219 1380 foreach ($menu as $parent_menu) { 1220 1381 if ($parent_menu[2] == $plugin_page) { … … 1224 1385 } 1225 1386 } 1226 1387 1227 1388 foreach (array_keys($submenu) as $parent) { 1228 1389 foreach ($submenu[$parent] as $submenu_array) { … … 1230 1391 $parent_file = $parent; 1231 1392 return $parent; 1232 } else if (isset($plugin_page) && ($plugin_page == $submenu_array[2])) { 1233 $parent_file = $parent; 1234 return $parent; 1235 } 1393 } else 1394 if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) { 1395 $parent_file = $parent; 1396 return $parent; 1397 } 1236 1398 } 1237 1399 } … … 1246 1408 $file = plugin_basename($file); 1247 1409 1248 $menu[] = array ($menu_title, $access_level, $file, $page_title);1410 $menu[] = array ($menu_title, $access_level, $file, $page_title); 1249 1411 1250 1412 $admin_page_hooks[$file] = sanitize_title($menu_title); 1251 1413 1252 1414 $hookname = get_plugin_page_hookname($file, ''); 1253 if ( !empty($function) && !empty($hookname))1415 if (!empty ($function) && !empty ($hookname)) 1254 1416 add_action($hookname, $function); 1255 1417 … … 1268 1430 // parent file someone is trying to link back to the parent manually. In 1269 1431 // this case, don't automatically add a link back to avoid duplication. 1270 if (! isset($submenu[$parent]) && $file != $parent) {1432 if (!isset ($submenu[$parent]) && $file != $parent) { 1271 1433 foreach ($menu as $parent_menu) { 1272 1434 if ($parent_menu[2] == $parent) { … … 1275 1437 } 1276 1438 } 1277 1278 $submenu[$parent][] = array ($menu_title, $access_level, $file, $page_title);1439 1440 $submenu[$parent][] = array ($menu_title, $access_level, $file, $page_title); 1279 1441 1280 1442 $hookname = get_plugin_page_hookname($file, $parent); 1281 if ( !empty($function) && !empty($hookname))1443 if (!empty ($function) && !empty ($hookname)) 1282 1444 add_action($hookname, $function); 1283 1445 … … 1294 1456 1295 1457 function add_theme_page($page_title, $menu_title, $access_level, $file, $function = '') { 1296 return add_submenu_page('themes.php', $page_title, $menu_title, $access_level, $file, $function); 1297 } 1298 1458 return add_submenu_page('themes.php', $page_title, $menu_title, $access_level, $file, $function); 1459 } 1299 1460 1300 1461 function validate_file($file, $allowed_files = '') { 1301 if ( 1462 if (false !== strpos($file, './')) 1302 1463 return 1; 1303 1304 if (':' == substr($file, 1,1))1464 1465 if (':' == substr($file, 1, 1)) 1305 1466 return 2; 1306 1467 1307 if ( !empty($allowed_files) && (! in_array($file, $allowed_files)))1468 if (!empty ($allowed_files) && (!in_array($file, $allowed_files))) 1308 1469 return 3; 1309 1470 … … 1316 1477 $code = validate_file($file, $allowed_files); 1317 1478 1318 if (! 1479 if (!$code) 1319 1480 return $file; 1320 1481 1321 1482 switch ($code) { 1322 case 1:1323 die(__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));1324 1325 case 2:1326 die(__('Sorry, can’t call files with their real path.'));1327 1328 case 3:1329 die(__('Sorry, that file cannot be edited.'));1483 case 1 : 1484 die(__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); 1485 1486 case 2 : 1487 die(__('Sorry, can’t call files with their real path.')); 1488 1489 case 3 : 1490 die(__('Sorry, that file cannot be edited.')); 1330 1491 } 1331 1492 } … … 1333 1494 function get_home_path() { 1334 1495 $home = get_settings('home'); 1335 if ( $home != '' && $home != get_settings('siteurl')) {1496 if ($home != '' && $home != get_settings('siteurl')) { 1336 1497 $home_path = parse_url($home); 1337 1498 $home_path = $home_path['path']; 1338 1499 $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]); 1339 $home_path = trailingslashit($root .$home_path);1500 $home_path = trailingslashit($root.$home_path); 1340 1501 } else { 1341 1502 $home_path = ABSPATH; … … 1346 1507 1347 1508 function get_real_file_to_edit($file) { 1348 if ('index.php' == $file || 1349 '.htaccess' == $file) { 1350 $real_file = get_home_path() . $file; 1351 } else { 1352 $real_file = ABSPATH . $file; 1509 if ('index.php' == $file || '.htaccess' == $file) { 1510 $real_file = get_home_path().$file; 1511 } else { 1512 $real_file = ABSPATH.$file; 1353 1513 } 1354 1514 … … 1356 1516 } 1357 1517 1358 $wp_file_descriptions = 1359 array( 1360 'index.php' => __('Main Index Template'), 1361 'style.css' => __('Stylesheet'), 1362 'comments.php' => __('Comments'), 1363 'comments-popup.php' => __('Popup Comments'), 1364 'footer.php' => __('Footer'), 1365 'header.php' => __('Header'), 1366 'sidebar.php' => __('Sidebar'), 1367 'archive.php' => __('Archives'), 1368 'category.php' => __('Category Template'), 1369 'page.php' => __('Page Template'), 1370 'search.php' => __('Search Results'), 1371 'single.php' => __('Single Post'), 1372 '404.php' => __('404 Template'), 1373 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), 1374 '.htaccess' => __('.htaccess (for rewrite rules)'), 1518 $wp_file_descriptions = array ('index.php' => __('Main Index Template'), 'style.css' => __('Stylesheet'), 'comments.php' => __('Comments'), 'comments-popup.php' => __('Popup Comments'), 'footer.php' => __('Footer'), 'header.php' => __('Header'), 'sidebar.php' => __('Sidebar'), 'archive.php' => __('Archives'), 'category.php' => __('Category Template'), 'page.php' => __('Page Template'), 'search.php' => __('Search Results'), 'single.php' => __('Single Post'), '404.php' => __('404 Template'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), '.htaccess' => __('.htaccess (for rewrite rules)'), 1375 1519 // Deprecated files 1376 'wp-layout.css' => __('Stylesheet'), 1377 'wp-comments.php' => __('Comments Template'), 1378 'wp-comments-popup.php' => __('Popup Comments Template') 1379 ); 1520 'wp-layout.css' => __('Stylesheet'), 'wp-comments.php' => __('Comments Template'), 'wp-comments-popup.php' => __('Popup Comments Template')); 1380 1521 1381 1522 function get_file_description($file) { 1382 1523 global $wp_file_descriptions; 1383 1524 1384 if ( isset($wp_file_descriptions[basename($file)] )) {1525 if (isset ($wp_file_descriptions[basename($file)])) { 1385 1526 return $wp_file_descriptions[basename($file)]; 1386 } elseif ( file_exists( ABSPATH . $file ) ) { 1387 $template_data = implode('', file(ABSPATH . $file)); 1388 if ( preg_match("|Template Name:(.*)|i", $template_data, $name) ) 1527 } 1528 elseif (file_exists(ABSPATH.$file)) { 1529 $template_data = implode('', file(ABSPATH.$file)); 1530 if (preg_match("|Template Name:(.*)|i", $template_data, $name)) 1389 1531 return $name[1]; 1390 1532 } 1391 1533 1392 return basename( $file);1534 return basename($file); 1393 1535 } 1394 1536 … … 1400 1542 $oldfiles = array_reverse($oldfiles); 1401 1543 $oldfiles = array_unique($oldfiles); 1402 if ( 5 < count($oldfiles))1544 if (5 < count($oldfiles)) 1403 1545 array_pop($oldfiles); 1404 1546 } else { … … 1415 1557 preg_match("|Author:(.*)|i", $plugin_data, $author_name); 1416 1558 preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri); 1417 if ( preg_match("|Version:(.*)|i", $plugin_data, $version))1559 if (preg_match("|Version:(.*)|i", $plugin_data, $version)) 1418 1560 $version = $version[1]; 1419 1561 else 1420 $version = '';1562 $version = ''; 1421 1563 1422 1564 $description = wptexturize($description[1]); … … 1426 1568 $plugin = $name; 1427 1569 if ('' != $plugin_uri[1] && '' != $name) { 1428 $plugin = '<a href="' . $plugin_uri[1] . '" title="' . __('Visit plugin homepage') . '">' . $plugin .'</a>';1570 $plugin = '<a href="'.$plugin_uri[1].'" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>'; 1429 1571 } 1430 1572 … … 1432 1574 $author = $author_name[1]; 1433 1575 } else { 1434 $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] .'</a>';1435 } 1436 1437 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);1576 $author = '<a href="'.$author_uri[1].'" title="'.__('Visit author homepage').'">'.$author_name[1].'</a>'; 1577 } 1578 1579 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]); 1438 1580 } 1439 1581 … … 1441 1583 global $wp_plugins; 1442 1584 1443 if (isset ($wp_plugins)) {1585 if (isset ($wp_plugins)) { 1444 1586 return $wp_plugins; 1445 1587 } 1446 1588 1447 $wp_plugins = array ();1589 $wp_plugins = array (); 1448 1590 $plugin_loc = 'wp-content/plugins'; 1449 $plugin_root = ABSPATH .$plugin_loc;1591 $plugin_root = ABSPATH.$plugin_loc; 1450 1592 1451 1593 // Files in wp-content/plugins directory 1452 1594 $plugins_dir = @ dir($plugin_root); 1453 1595 if ($plugins_dir) { 1454 while (($file = $plugins_dir->read()) !== false) {1455 if ( preg_match('|^\.+$|', $file))1596 while (($file = $plugins_dir->read()) !== false) { 1597 if (preg_match('|^\.+$|', $file)) 1456 1598 continue; 1457 if (is_dir($plugin_root . '/' .$file)) {1458 $plugins_subdir = @ dir($plugin_root . '/' .$file);1599 if (is_dir($plugin_root.'/'.$file)) { 1600 $plugins_subdir = @ dir($plugin_root.'/'.$file); 1459 1601 if ($plugins_subdir) { 1460 while (($subfile = $plugins_subdir->read()) !== false) {1461 if ( preg_match('|^\.+$|', $subfile))1602 while (($subfile = $plugins_subdir->read()) !== false) { 1603 if (preg_match('|^\.+$|', $subfile)) 1462 1604 continue; 1463 if ( preg_match('|\.php$|', $subfile))1605 if (preg_match('|\.php$|', $subfile)) 1464 1606 $plugin_files[] = "$file/$subfile"; 1465 1607 } 1466 1608 } 1467 1609 } else { 1468 if ( preg_match('|\.php$|', $file) )1610 if (preg_match('|\.php$|', $file)) 1469 1611 $plugin_files[] = $file; 1470 1612 } … … 1478 1620 sort($plugin_files); 1479 1621 1480 foreach ($plugin_files as $plugin_file) {1622 foreach ($plugin_files as $plugin_file) { 1481 1623 $plugin_data = get_plugin_data("$plugin_root/$plugin_file"); 1482 1483 if (empty ($plugin_data['Name'])) {1624 1625 if (empty ($plugin_data['Name'])) { 1484 1626 continue; 1485 1627 } … … 1496 1638 $parent = get_admin_page_parent(); 1497 1639 1498 if ( empty($parent_page) || 'admin.php' == $parent_page) {1499 if ( isset($admin_page_hooks[$plugin_page]))1640 if (empty ($parent_page) || 'admin.php' == $parent_page) { 1641 if (isset ($admin_page_hooks[$plugin_page])) 1500 1642 $page_type = 'toplevel'; 1501 else if ( isset($admin_page_hooks[$parent]) ) 1502 $page_type = $admin_page_hooks[$parent]; 1503 } else if ( isset($admin_page_hooks[$parent_page]) ) { 1504 $page_type = $admin_page_hooks[$parent_page]; 1505 } else { 1506 $page_type = 'admin'; 1507 } 1643 else 1644 if (isset ($admin_page_hooks[$parent])) 1645 $page_type = $admin_page_hooks[$parent]; 1646 } else 1647 if (isset ($admin_page_hooks[$parent_page])) { 1648 $page_type = $admin_page_hooks[$parent_page]; 1649 } else { 1650 $page_type = 'admin'; 1651 } 1508 1652 1509 1653 $plugin_name = preg_replace('!\.php!', '', $plugin_page); 1510 1654 1511 return $page_type . '_page_' .$plugin_name;1655 return $page_type.'_page_'.$plugin_name; 1512 1656 } 1513 1657 1514 1658 function get_plugin_page_hook($plugin_page, $parent_page) { 1515 1659 global $wp_filter; 1516 1660 1517 1661 $hook = get_plugin_page_hookname($plugin_page, $parent_page); 1518 if ( isset($wp_filter[$hook]))1662 if (isset ($wp_filter[$hook])) 1519 1663 return $hook; 1520 1664 else … … 1525 1669 $getit = __('WordPress recommends a better browser'); 1526 1670 echo ' 1527 <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="' . $getit .'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>1528 ';1529 } 1530 if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ))1671 <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p> 1672 '; 1673 } 1674 if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) 1531 1675 add_action('admin_footer', 'browse_happy'); 1532 1676 1533 function documentation_link( $for) {1677 function documentation_link($for) { 1534 1678 return; 1535 1679 } … … 1537 1681 function register_importer($id, $name, $description, $callback) { 1538 1682 global $wp_importers; 1539 1540 $wp_importers[$id] = array ($name, $description, $callback);1683 1684 $wp_importers[$id] = array ($name, $description, $callback); 1541 1685 } 1542 1686 … … 1562 1706 return $ct; 1563 1707 } 1564 1565 1708 ?> -
trunk/wp-admin/link-add.php
r2762 r2889 76 76 <tr> 77 77 <th width="33%" scope="row"><?php _e('URI:') ?></th> 78 <td width="67%"><input type="text" name="link url" value="<?php echo wp_specialchars($_GET['linkurl'], 1); ?>" style="width: 95%;" /></td>78 <td width="67%"><input type="text" name="link_url" value="<?php echo wp_specialchars($_GET['linkurl'], 1); ?>" style="width: 95%;" /></td> 79 79 </tr> 80 80 <tr> 81 81 <th scope="row"><?php _e('Link Name:') ?></th> 82 <td><input type="text" name=" name" value="<?php echo wp_specialchars( urldecode($_GET['name']), 1 ); ?>" style="width: 95%" /></td>82 <td><input type="text" name="link_name" value="<?php echo wp_specialchars( urldecode($_GET['name']), 1 ); ?>" style="width: 95%" /></td> 83 83 </tr> 84 84 <tr> 85 85 <th scope="row"><?php _e('Short description:') ?></th> 86 <td><input type="text" name=" description" value="" style="width: 95%" /></td>86 <td><input type="text" name="link_description" value="" style="width: 95%" /></td> 87 87 </tr> 88 88 <tr> 89 89 <th scope="row"><?php _e('Category:') ?></th> 90 <td><?php category_dropdown(' category'); ?></td>90 <td><?php category_dropdown('link_category'); ?></td> 91 91 </tr> 92 92 </table> … … 100 100 <tr> 101 101 <th width="33%" scope="row"><?php _e('rel:') ?></th> 102 <td width="67%"><input type="text" name=" rel" id="rel" size="50" value="<?php echo $link_rel; ?>" /></td>102 <td width="67%"><input type="text" name="link_rel" id="rel" size="50" value="<?php echo $link_rel; ?>" /></td> 103 103 </tr> 104 104 <tr> … … 213 213 <tr> 214 214 <th width="33%" scope="row"><?php _e('Image URI:') ?></th> 215 <td width="67%"><input type="text" name=" image" size="50" value="" style="width: 95%" /></td>215 <td width="67%"><input type="text" name="link_image" size="50" value="" style="width: 95%" /></td> 216 216 </tr> 217 217 <tr> 218 218 <th scope="row"><?php _e('RSS URI:') ?> </th> 219 <td><input name=" rss_uri" type="text" id="rss_uri" value="" size="50" style="width: 95%" /></td>219 <td><input name="link_rss" type="text" id="rss_uri" value="" size="50" style="width: 95%" /></td> 220 220 </tr> 221 221 <tr> 222 222 <th scope="row"><?php _e('Notes:') ?></th> 223 <td><textarea name=" notes" cols="50" rows="10" style="width: 95%"></textarea></td>223 <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"></textarea></td> 224 224 </tr> 225 225 <tr> 226 226 <th scope="row"><?php _e('Rating:') ?></th> 227 <td><select name=" rating" size="1">227 <td><select name="link_rating" size="1"> 228 228 <?php 229 229 for ($r = 0; $r < 10; $r++) { … … 237 237 <th scope="row"><?php _e('Target') ?></th> 238 238 <td><label> 239 <input type="radio" name=" target" value="_blank" />239 <input type="radio" name="link_target" value="_blank" /> 240 240 <code>_blank</code></label> 241 241 <br /> 242 <label><input type="radio" name=" target" value="_top" />242 <label><input type="radio" name="link_target" value="_top" /> 243 243 <code>_top</code></label> 244 244 <br /> 245 <label><input type="radio" name=" target" value="" checked="checked" />245 <label><input type="radio" name="link_target" value="" checked="checked" /> 246 246 <?php _e('none') ?></label> 247 247 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td> … … 250 250 <th scope="row"><?php _e('Visible:') ?></th> 251 251 <td><label> 252 <input type="radio" name=" visible" checked="checked" value="Y" />252 <input type="radio" name="link_visible" checked="checked" value="Y" /> 253 253 <?php _e('Yes') ?></label><br /> 254 <label><input type="radio" name=" visible" value="N" /> <input type="hidden" name="action" value="Add" />254 <label><input type="radio" name="link_visible" value="N" /> <input type="hidden" name="action" value="Add" /> 255 255 <?php _e('No') ?></label></td> 256 256 </tr> -
trunk/wp-admin/link-manager.php
r2832 r2889 160 160 check_admin_referer(); 161 161 162 $link_url = wp_specialchars($_POST['linkurl']); 163 $link_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $link_url) ? $link_url : 'http://' . $link_url; 164 $link_name = wp_specialchars($_POST['name']); 165 $link_image = wp_specialchars($_POST['image']); 166 $link_target = $_POST['target']; 167 $link_category = $_POST['category']; 168 $link_description = $_POST['description']; 169 $link_visible = $_POST['visible']; 170 $link_rating = $_POST['rating']; 171 $link_rel = $_POST['rel']; 172 $link_notes = $_POST['notes']; 173 $link_rss_uri = wp_specialchars($_POST['rss_uri']); 174 $auto_toggle = get_autotoggle($link_category); 162 add_link(); 163 164 header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true'); 165 break; 166 } // end Add 167 168 case 'editlink': 169 { 170 171 check_admin_referer(); 172 173 if (isset($links_show_cat_id) && ($links_show_cat_id != '')) 174 $cat_id = $links_show_cat_id; 175 176 if (!isset($cat_id) || ($cat_id == '')) { 177 if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) 178 $cat_id = 'All'; 179 } 180 $links_show_cat_id = $cat_id; 181 182 $link_id = (int) $_POST['link_id']; 183 edit_link($link_id); 184 185 setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 186 wp_redirect($this_file); 187 break; 188 } // end Save 189 190 case 'Delete': 191 { 192 check_admin_referer(); 175 193 176 194 if ( !current_user_can('manage_links') ) 177 195 die (__("Cheatin' uh ?")); 178 196 179 // if we are in an auto toggle category and this one is visible then we180 // need to make the others invisible before we add this new one.181 if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {182 $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");183 }184 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) " .185 " VALUES('" . $link_url . "','"186 . $link_name . "', '"187 . $link_image . "', '$link_target', $link_category, '"188 . $link_description . "', '$link_visible', $user_ID, $link_rating, '" . $link_rel . "', '" . $link_notes . "', '$link_rss_uri')");189 190 header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');191 break;192 } // end Add193 194 case 'editlink':195 {196 if (isset($submit)) {197 198 if (isset($links_show_cat_id) && ($links_show_cat_id != ''))199 $cat_id = $links_show_cat_id;200 201 if (!isset($cat_id) || ($cat_id == '')) {202 if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))203 $cat_id = 'All';204 }205 $links_show_cat_id = $cat_id;206 207 check_admin_referer();208 209 $link_id = (int) $_POST['link_id'];210 $link_url = wp_specialchars($_POST['linkurl']);211 $link_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $link_url) ? $link_url : 'http://' . $link_url;212 $link_name = wp_specialchars($_POST['name']);213 $link_image = wp_specialchars($_POST['image']);214 $link_target = wp_specialchars($_POST['target']);215 $link_category = $_POST['category'];216 $link_description = $_POST['description'];217 $link_visible = $_POST['visible'];218 $link_rating = $_POST['rating'];219 $link_rel = $_POST['rel'];220 $link_notes = $_POST['notes'];221 $link_rss_uri = $_POST['rss_uri'];222 $auto_toggle = get_autotoggle($link_category);223 224 if ( !current_user_can('manage_links') )225 die (__("Cheatin' uh ?"));226 227 // if we are in an auto toggle category and this one is visible then we228 // need to make the others invisible before we update this one.229 if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {230 $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");231 }232 233 $wpdb->query("UPDATE $wpdb->links SET link_url='" . $link_url . "',234 link_name='" . $link_name . "',\n link_image='" . $link_image . "',235 link_target='$link_target',\n link_category=$link_category,236 link_visible='$link_visible',\n link_description='" . $link_description . "',237 link_rating=$link_rating,238 link_rel='" . $link_rel . "',239 link_notes='" . $link_notes . "',240 link_rss = '$link_rss_uri'241 WHERE link_id=$link_id");242 } // end if save243 setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);244 wp_redirect($this_file);245 break;246 } // end Save247 248 case 'Delete':249 {250 check_admin_referer();251 252 197 $link_id = (int) $_GET['link_id']; 253 198 254 if ( !current_user_can('manage_links') ) 255 die (__("Cheatin' uh ?")); 256 257 $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = $link_id"); 258 199 wp_delete_link($link_id); 200 259 201 if (isset($links_show_cat_id) && ($links_show_cat_id != '')) 260 202 $cat_id = $links_show_cat_id; … … 277 219 278 220 $link_id = (int) $_GET['link_id']; 279 $row = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = $link_id"); 280 281 if ($row) { 282 $link_url = wp_specialchars($row->link_url, 1); 283 $link_name = wp_specialchars($row->link_name, 1); 284 $link_image = $row->link_image; 285 $link_target = $row->link_target; 286 $link_category = $row->link_category; 287 $link_description = wp_specialchars($row->link_description); 288 $link_visible = $row->link_visible; 289 $link_rating = $row->link_rating; 290 $link_rel = $row->link_rel; 291 $link_notes = wp_specialchars($row->link_notes); 292 $link_rss_uri = wp_specialchars($row->link_rss); 293 } else { 294 die( __('Link not found.') ); 295 } 296 221 222 if ( !$link = get_link_to_edit($link_id) ) 223 die( __('Link not found.') ); 297 224 ?> 298 225 … … 305 232 <tr> 306 233 <th width="33%" scope="row"><?php _e('URI:') ?></th> 307 <td width="67%"><input type="text" name="link url" value="<?php echo $link_url; ?>" style="width: 95%;" /></td>234 <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td> 308 235 </tr> 309 236 <tr> 310 237 <th scope="row"><?php _e('Link Name:') ?></th> 311 <td><input type="text" name=" name" value="<?php echo $link_name; ?>" style="width: 95%" /></td>238 <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td> 312 239 </tr> 313 240 <tr> 314 241 <th scope="row"><?php _e('Short description:') ?></th> 315 <td><input type="text" name=" description" value="<?php echo $link_description; ?>" style="width: 95%" /></td>242 <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td> 316 243 </tr> 317 244 <tr> 318 245 <th scope="row"><?php _e('Category:') ?></th> 319 <td><?php category_dropdown(' category', $link_category); ?></td>246 <td><?php category_dropdown('link_category', $link->link_category); ?></td> 320 247 </tr> 321 248 </table> … … 329 256 <tr> 330 257 <th width="33%" scope="row"><?php _e('rel:') ?></th> 331 <td width="67%"><input type="text" name=" rel" id="rel" size="50" value="<?php echo $link_rel; ?>" /></td>258 <td width="67%"><input type="text" name="link_rel" id="rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> 332 259 </tr> 333 260 <tr> … … 442 369 <tr> 443 370 <th width="33%" scope="row"><?php _e('Image URI:') ?></th> 444 <td width="67%"><input type="text" name=" image" size="50" value="<?php echo $link_image; ?>" style="width: 95%" /></td>371 <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> 445 372 </tr> 446 373 <tr> 447 374 <th scope="row"><?php _e('RSS URI:') ?> </th> 448 <td><input name=" rss_uri" type="text" id="rss_uri" value="<?php echo $link_rss_uri; ?>" size="50" style="width: 95%" /></td>375 <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> 449 376 </tr> 450 377 <tr> 451 378 <th scope="row"><?php _e('Notes:') ?></th> 452 <td><textarea name=" notes" cols="50" rows="10" style="width: 95%"><?php echo $link_notes; ?></textarea></td>379 <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> 453 380 </tr> 454 381 <tr> 455 382 <th scope="row"><?php _e('Rating:') ?></th> 456 <td><select name=" rating" size="1">383 <td><select name="link_rating" size="1"> 457 384 <?php 458 385 for ($r = 0; $r < 10; $r++) { 459 386 echo(' <option value="'.$r.'" '); 460 if ($link _rating == $r)387 if ($link->link_rating == $r) 461 388 echo 'selected="selected"'; 462 389 echo('>'.$r.'</option>'); … … 469 396 <th scope="row"><?php _e('Target') ?></th> 470 397 <td><label> 471 <input type="radio" name="target" value="_blank" <?php echo(($link _target == '_blank') ? 'checked="checked"' : ''); ?> />398 <input type="radio" name="target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 472 399 <code>_blank</code></label><br /> 473 400 <label> 474 <input type="radio" name="target" value="_top" <?php echo(($link _target == '_top') ? 'checked="checked"' : ''); ?> />401 <input type="radio" name="target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 475 402 <code>_top</code></label><br /> 476 403 <label> 477 <input type="radio" name=" target" value="" <?php echo(($link_target == '') ? 'checked="checked"' : ''); ?> />404 <input type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 478 405 <?php _e('none') ?></label><br /> 479 406 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td> … … 482 409 <th scope="row"><?php _e('Visible:') ?></th> 483 410 <td><label> 484 <input type="radio" name=" visible" <?php if ($link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />411 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" /> 485 412 <?php _e('Yes') ?></label><br /><label> 486 <input type="radio" name="visible" <?php if ($link _visible == 'N') echo "checked='checked'"; ?> value="N" />413 <input type="radio" name="visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" /> 487 414 <?php _e('No') ?></label></td> 488 415 </tr> -
trunk/wp-admin/profile-update.php
r2872 r2889 5 5 check_admin_referer(); 6 6 7 $errors = update_user($user_ID);7 $errors = edit_user($user_ID); 8 8 9 9 if (count($errors) != 0) { -
trunk/wp-admin/user-edit.php
r2872 r2889 38 38 $errors['head'] = __('You do not have permission to edit this user.'); 39 39 else 40 $errors = update_user($user_id);40 $errors = edit_user($user_id); 41 41 42 42 if(count($errors) == 0) {
Note: See TracChangeset
for help on using the changeset viewer.