Changeset 599114
- Timestamp:
- 09/14/2012 09:59:45 PM (14 years ago)
- Location:
- kickpress/trunk
- Files:
-
- 6 edited
-
kickpress-api.php (modified) (20 diffs)
-
kickpress-bookmarks.php (modified) (4 diffs)
-
kickpress-functions.php (modified) (1 diff)
-
kickpress-oauth.php (modified) (11 diffs)
-
kickpress-redirects.php (modified) (6 diffs)
-
kickpress.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kickpress/trunk/kickpress-api.php
r595539 r599114 38 38 'callback' => '', 39 39 'label' => 'OAuth 1.0a', 40 'capability' => '' 41 ), 42 'register' => array( 43 'slug' => 'register', 44 'method' => 'register', 45 'callback' => '', 46 'label' => 'Register User', 40 47 'capability' => '' 41 48 ), … … 61 68 'capability' => 'read' 62 69 ), 63 'export-comments' => array(70 'export-comments' => array( 64 71 'slug' => 'export-comments', 65 72 'method' => 'export_comments', 66 73 'callback' => '', 67 74 'label' => 'Export Comments', 75 'capability' => 'read' 76 ), 77 'import-comments' => array( 78 'slug' => 'import-comments', 79 'method' => 'import_comments', 80 'callback' => '', 81 'label' => 'Import Comments', 68 82 'capability' => 'read' 69 83 ), … … 208 222 209 223 $default_params = array( 210 'post_type' => null,211 'action' => null224 'post_type' => null, 225 'action' => null 212 226 ); 213 227 … … 229 243 // Initialize custom post type options 230 244 $this->init_post_type_options(); 245 } 246 247 public function __get( $key ) { 248 return @$this->params[$key]; 249 } 250 251 public function __isset( $key ) { 252 return isset( $this->params[$key] ); 231 253 } 232 254 … … 886 908 $post = array_shift( get_posts( array( 887 909 'post_type' => $this->params['post_type'], 888 'name' => $this->params['post_name']910 'name' => $this->params['post_name'] 889 911 ) ) ); 890 912 … … 894 916 if ( is_null( $action ) ) $action = $this->params['action']; 895 917 896 if ( $current_action = $this->get_current_action( $action) ) {918 if ( $current_action = $this->get_current_action( $action ) ) { 897 919 extract( $current_action ); 898 920 … … 900 922 901 923 if ( $post_type = get_post_type_object( $this->params['post_type'] ) ) { 902 if ( isset( $post_type->cap->$capability) )924 if ( isset( $post_type->cap->$capability ) ) 903 925 $capability = $post_type->cap->$capability; 904 926 } 905 927 906 928 $this->params['callback'] = $callback; 907 929 908 930 // Validate that the user has permission to perform this action 909 931 if ( ! empty( $capability ) && ! current_user_can( $capability ) ) { … … 969 991 970 992 switch ( $format ) { 971 case 'xml':972 $doc = new DOMDocument();973 $doc->formatOutput = true;974 $doc->appendChild( $root = $doc->createElement( 'result' ) );975 976 $root->appendChild( $doc->createElement( 'status', $this->action_results['status'] ) );977 $root->appendChild( $messages = $doc->createElement( 'messages' ) );978 $root->appendChild( $data = $doc->createElement( 'data' ) );979 980 foreach ( $this->action_results['messages'] as $type => $message ) {981 $messages->appendChild( $doc->createElement( $type, $message ) );982 }983 984 // TODO write data XML985 986 return $doc->saveXML();987 case 'json':988 default:989 $output = json_encode( $this->action_results );990 991 if ( isset( $_REQUEST['callback'] ) )992 $output .= $_REQUEST['callback'] . '(' . $output . ');';993 994 return $output;993 case 'xml': 994 $doc = new DOMDocument(); 995 $doc->formatOutput = true; 996 $doc->appendChild( $root = $doc->createElement( 'result' ) ); 997 998 $root->appendChild( $doc->createElement( 'status', $this->action_results['status'] ) ); 999 $root->appendChild( $messages = $doc->createElement( 'messages' ) ); 1000 $root->appendChild( $data = $doc->createElement( 'data' ) ); 1001 1002 foreach ( $this->action_results['messages'] as $type => $message ) { 1003 $messages->appendChild( $doc->createElement( $type, $message ) ); 1004 } 1005 1006 // TODO write data XML 1007 1008 return $doc->saveXML(); 1009 case 'json': 1010 default: 1011 $output = json_encode( $this->action_results ); 1012 1013 if ( isset( $_REQUEST['callback'] ) ) 1014 $output .= $_REQUEST['callback'] . '(' . $output . ');'; 1015 1016 return $output; 995 1017 } 996 1018 } … … 1380 1402 1381 1403 switch ( $proxy ) { 1382 case 'facebook':1383 $this->login_facebook();1384 break;1385 case 'twitter':1386 $this->login_twitter();1387 break;1388 default:1389 $this->action_results['status'] = 'failure';1390 $this->action_results['messages'][] = 'Unknown login proxy.';1391 $this->action_results['data'][] = $proxy;1392 break;1393 } 1394 } 1395 1396 p ublicfunction login_facebook() {1404 case 'facebook': 1405 $this->login_facebook(); 1406 break; 1407 case 'twitter': 1408 $this->login_twitter(); 1409 break; 1410 default: 1411 $this->action_results['status'] = 'failure'; 1412 $this->action_results['messages'][] = 'Unknown login proxy.'; 1413 $this->action_results['data'][] = $proxy; 1414 break; 1415 } 1416 } 1417 1418 private function login_facebook() { 1397 1419 global $kickpress_plugin_options; 1398 1420 … … 1520 1542 } 1521 1543 1522 p ublicfunction login_twitter() {1544 private function login_twitter() { 1523 1545 $log_file = dirname( __FILE__ ) . '/kickpress-twitter.log'; 1524 1546 … … 1722 1744 1723 1745 switch ( strtolower( $this->params['action_key'] ) ) { 1724 case 'request-token': 1725 kickpress_oauth_provider::request_token( $args ); 1726 break; 1727 case 'access-token': 1728 kickpress_oauth_provider::access_token( $args ); 1729 break; 1730 case 'authorize': 1746 case 'request-token': 1747 kickpress_oauth_provider::request_token( $args ); 1748 break; 1749 case 'access-token': 1750 kickpress_oauth_provider::access_token( $args ); 1751 break; 1752 case 'authorize': 1753 kickpress_oauth_provider::authorize( $args ); 1754 break; 1755 case 'register': 1756 global $wpdb; 1757 1758 if ( kickpress_is_remote_app() ) { 1759 add_filter( 'wpmu_signup_user_notification', '__return_false' ); 1760 1761 $user_login = $_REQUEST['login']; 1762 $user_email = $_REQUEST['email']; 1763 1764 if ( empty( $user_email ) ) 1765 die( 'Email address may not be empty' ); 1766 1767 if ( empty( $user_login ) ) $user_login = $user_email; 1768 1769 $user_data = wpmu_validate_user_signup( $user_login, $user_email ); 1770 // unset( $user_data['errors']->errors['user_email_used'] ); 1771 1772 if ( is_wp_error( $user_data ) ) 1773 die( json_encode( $user_data['errors'] ) ); 1774 1775 // change password 1776 $user_password = $_REQUEST['password']; 1777 1778 if ( empty( $user_password ) ) 1779 die( 'Password may not be empty' ); 1780 1781 $user_login = apply_filters( 'pre_user_login', 1782 sanitize_user( stripslashes( $user_login ), true ) ); 1783 1784 wpmu_signup_user( $user_login, $user_email, array( 1785 'add_to_blog' => $wpdb->blogid, 1786 'new_role' => 'subscriber' 1787 ) ); 1788 1789 $key = $wpdb->get_var( $wpdb->prepare( 1790 "SELECT activation_key " . 1791 "FROM {$wpdb->signups} " . 1792 "WHERE user_login = %s " . 1793 "AND user_email = %s", 1794 $user_login, 1795 $user_email 1796 ) ); 1797 1798 // action hook handles first/last name? 1799 $user_data = wpmu_activate_signup( $key ); 1800 1801 if ( is_wp_error( $user_data ) ) 1802 die( $user_data->get_error_message() ); 1803 1804 wp_set_current_user( $user_data['user_id'] ); 1805 1731 1806 kickpress_oauth_provider::authorize( $args ); 1732 break; 1807 } 1808 1809 break; 1733 1810 } 1734 1811 … … 2445 2522 2446 2523 public function export_comments() { 2447 $format = isset( $this->params['action_key'] ) 2448 ? $this->params['action_key'] : 'json'; 2449 2450 if ( empty( $this->params['id'] ) ) exit; 2451 2452 $comments = get_comments( array( 2453 'post_id' => $this->params['id'] 2454 ) ); 2455 2456 $trees = array(); 2457 $nodes = array(); 2458 2459 foreach ( $comments as &$comment ) { 2460 $nodes[$comment->comment_ID] =& $comment; 2461 $nodes[$comment->comment_ID]->comments = array(); 2462 } 2463 2464 ksort( $nodes ); 2465 2466 foreach ( $nodes as &$node ) { 2467 if ( 0 == $node->comment_parent ) $trees[$node->comment_ID] =& $node; 2468 else $nodes[$node->comment_parent]->comments[$node->comment_ID] =& $node; 2524 $action = $this->params['action']; 2525 $action_key = $this->params['action_key']; 2526 $format = isset( $this->params['format'] ) 2527 ? $this->params['format'] : 'json'; 2528 2529 $post_id = $this->params['id']; 2530 $post_type = $this->params['post_type']; 2531 2532 if ( in_array( $action_key, array( 'bookmarks', 'notes' ) ) ) { 2533 $comments = call_user_func( 'kickpress_get_' . $action_key ); 2534 } else { 2535 if ( empty( $post_id ) ) exit; 2536 2537 $comments = get_comments( array( 2538 'post_id' => $post_id 2539 ) ); 2540 2541 $trees = array(); 2542 $nodes = array(); 2543 2544 foreach ( $comments as &$comment ) { 2545 $nodes[$comment->comment_ID] =& $comment; 2546 $nodes[$comment->comment_ID]->comments = array(); 2547 } 2548 2549 unset( $comments, $comment); 2550 2551 ksort( $nodes ); 2552 2553 foreach ( $nodes as &$node ) { 2554 if ( 0 == $node->comment_parent ) $trees[$node->comment_ID] =& $node; 2555 else $nodes[$node->comment_parent]->comments[$node->comment_ID] =& $node; 2556 } 2557 2558 $comments = $trees; 2469 2559 } 2470 2560 … … 2474 2564 2475 2565 if ( method_exists( $this, $method ) ) 2476 call_user_func( array( $this, $method ), $ trees );2566 call_user_func( array( $this, $method ), $comments ); 2477 2567 2478 2568 exit; … … 2486 2576 2487 2577 private function export_comments_json( $comments ) { 2578 $json_array = array(); 2579 2488 2580 foreach ( $comments as $comment ) { 2489 2581 $json_array[] = $this->export_comment_node_json( $comment ); … … 2505 2597 $json_object = (object) array( 2506 2598 'id' => $comment->comment_ID, 2599 'post_id' => $comment->comment_post_ID, 2507 2600 'date' => date( DATE_RSS, strtotime( $comment->comment_date ) ), 2508 2601 'author' => (object) array( … … 2510 2603 'email' => $comment->comment_author_email, 2511 2604 'url' => $comment->comment_author_url 2512 ), 2513 'content' => $comment->comment_content 2605 ) 2514 2606 ); 2607 2608 if ( isset( $comment->comment_title ) ) 2609 $json_object->title = $comment->comment_title; 2610 2611 $json_object->content = $comment->comment_content; 2612 2613 if ( isset( $comment->comment_modified ) ) 2614 $json_object->modified = date( DATE_RSS, strtotime( $comment->comment_modified ) ); 2515 2615 2516 2616 if ( ! empty( $comment->comments ) ) { … … 2530 2630 $doc->formatOutput = true; 2531 2631 2532 $root = $doc->appendChild( $doc->createElement( 'post' ) ); 2533 $root->setAttribute( 'id', $this->params['id'] ); 2534 2535 $list = $root->appendChild( $doc->createElement( 'comments' ) ); 2632 $root = $doc->appendChild( $doc->createElement( 'comments' ) ); 2536 2633 2537 2634 foreach ( $comments as $comment ) { 2538 2635 $node = $this->export_comment_node_xml( $comment ); 2539 $ list->appendChild( $doc->importNode( $node, true ) );2636 $root->appendChild( $doc->importNode( $node, true ) ); 2540 2637 } 2541 2638 … … 2552 2649 $root = $doc->appendChild( $doc->createElement( 'comment' ) ); 2553 2650 $root->setAttribute( 'id', $comment->comment_ID ); 2651 $root->setAttribute( 'post_id', $comment->comment_post_ID ); 2554 2652 2555 2653 /* if ( 0 < $comment->comment_parent ) 2556 2654 $root->setAttribute( 'parent-id', $comment->comment_parent ); */ 2557 2655 2558 $root->appendChild( $doc->createElement( 'date', date( DATE_RSS, strtotime( $comment->comment_date ) ) ) ); 2656 $root->appendChild( $doc->createElement( 'date', 2657 date( DATE_RSS, strtotime( $comment->comment_date ) ) ) ); 2658 2659 if ( isset( $comment->comment_modified ) ) 2660 $root->appendChild( $doc->createElement( 'modified', 2661 date( DATE_RSS, strtotime( $comment->comment_modified ) ) ) ); 2559 2662 2560 2663 $author = $root->appendChild( $doc->createElement( 'author' ) ); … … 2563 2666 $author->appendChild( $doc->createElement( 'url', $comment->comment_author_url ) ); 2564 2667 2668 if ( isset( $comment->comment_title ) ) { 2669 $title = $root->appendChild( $doc->createElement( 'title' ) ); 2670 $title->appendChild( $doc->createCDATASection( $comment->comment_title ) ); 2671 } 2672 2565 2673 $content = $root->appendChild( $doc->createElement( 'content' ) ); 2566 2674 $content->appendChild( $doc->createCDATASection( $comment->comment_content ) ); … … 2578 2686 } 2579 2687 2688 public function import_comments() { 2689 $action = $this->params['action']; 2690 $action_key = $this->params['action_key']; 2691 $format = isset( $this->params['format'] ) 2692 ? $this->params['format'] : 'json'; 2693 2694 $post_id = $this->params['id']; 2695 $post_type = $this->params['post_type']; 2696 2697 if ( 'xml' == $format ) { 2698 $comments = $this->import_comments_xml( $_REQUEST['data'] ); 2699 } else { 2700 $comments = $this->import_comments_json( $_REQUEST['data'] ); 2701 } 2702 2703 if ( is_array( $comments ) ) { 2704 if ( 'bookmarks' == $action_key ) { 2705 foreach ( $comments as $comment ) { 2706 kickpress_insert_bookmark( $comment->post_id ); 2707 } 2708 } elseif ( 'notes' == $action_key ) { 2709 foreach ( $comments as $comment ) { 2710 if ( isset( $comment->id ) && 0 < $comment->id ) { 2711 $mod_date = get_comment_meta( $comment->id, '_modified', true ); 2712 2713 $old_comment = get_comment( $comment->id ); 2714 $old_comment->comment_modified = empty( $mod_date ) 2715 ? $old_comment->comment_date : $mod_date; 2716 2717 $save_time = strtotime( $old_comment->comment_modified ); 2718 $edit_time = strtotime( $comment->modified ); 2719 2720 if ( $save_time < $edit_time ) { 2721 $modified = date( 'Y-m-d H:i:s', $edit_time ); 2722 2723 kickpress_update_private_comment( $comment->id, array( 2724 'comment_title' => $comment->title, 2725 'comment_content' => $comment->content, 2726 'comment_modified' => $modified 2727 ) ); 2728 } 2729 } else { 2730 kickpress_insert_note( $comment->post_id, 2731 $comment->title, $comment->content ); 2732 } 2733 } 2734 } 2735 } 2736 } 2737 2738 private function import_comments_json( $json ) { 2739 return json_decode( stripslashes( $json ) ); 2740 } 2741 2742 private function import_comments_xml( $xml ) { 2743 $sxe = simplexml_load_string( stripslashes( $xml ) ); 2744 2745 $comments = array(); 2746 2747 foreach ( $sxe->comment as $node ) { 2748 $comments[] = (object) array( 2749 'id' => (string) $node['id'], 2750 'post_id' => (string) $node['post_id'], 2751 'date' => (string) $node->date, 2752 'modified' => (string) $node->modified, 2753 'author' => (object) array( 2754 'name' => (string) $node->author->name, 2755 'email' => (string) $node->author->email, 2756 'url' => (string) $node->author->url 2757 ), 2758 'title' => trim( (string) $node->title ), 2759 'content' => trim( (string) $node->content ) 2760 ); 2761 } 2762 2763 return $comments; 2764 } 2580 2765 /* Theme/Template Elements */ 2581 2766 -
kickpress/trunk/kickpress-bookmarks.php
r559958 r599114 41 41 42 42 foreach ( $comments as $comment ) { 43 $comment_title = get_comment_meta( $comment->comment_ID, '_title', true ); 44 if ( ! empty( $comment_title ) ) $comment->comment_title = $comment_title; 43 $title = get_comment_meta( $comment->comment_ID, '_title', true ); 44 if ( ! empty( $title ) ) $comment->comment_title = $title; 45 46 $modified = get_comment_meta( $comment->comment_ID, '_modified', true ); 47 $modified_gmt = get_comment_meta( $comment->comment_ID, '_modified_gmt', true ); 48 49 if ( ! empty( $modified ) && ! empty( $modified_gmt ) ) { 50 $comment->comment_modified = $modified; 51 $comment->comment_modified_gmt = $modified_gmt; 52 } else { 53 $comment->comment_modified = $comment->comment_date; 54 $comment->comment_modified_gmt = $comment->comment_date_gmt; 55 } 45 56 } 46 57 … … 102 113 function kickpress_insert_private_comment( $post_id, $data = array() ) { 103 114 if ( is_user_logged_in() && $post = get_post( $post_id ) ) { 104 extract( $data );115 extract( $data, EXTR_SKIP ); 105 116 106 117 $comment_post_ID = $post->ID; … … 144 155 ); 145 156 146 if ( isset( $comment_ID ) && $comment_ID > 0 ) { 147 $comment_data['comment_ID'] = $comment_ID; 148 wp_update_comment( $comment_data ); 149 } else { 150 $comment_ID = wp_insert_comment( $comment_data ); 151 $comment_data['comment_ID'] = $comment_ID; 152 } 157 $comment_ID = wp_insert_comment( $comment_data ); 153 158 154 159 if ( isset( $comment_title ) ) 155 160 update_comment_meta( $comment_ID, '_title', $comment_title ); 161 } 162 } 163 164 function kickpress_update_private_comment( $comment_id, $data = array() ) { 165 if ( is_user_logged_in() && $comment = get_comment( $comment_id ) ) { 166 if ( get_current_user_id() == $comment->user_id ) { 167 extract( $data, EXTR_SKIP ); 168 169 $comment_ID = $comment_id; 170 171 $comment_data = compact( 172 'comment_ID', 173 'comment_content' 174 ); 175 176 wp_update_comment( $comment_data ); 177 178 if ( isset( $comment_title ) ) 179 update_comment_meta( $comment_ID, '_title', $comment_title ); 180 181 if ( ! isset( $comment_modified ) ) 182 $comment_modified = current_time( 'mysql' ); 183 184 $comment_modified_gmt = get_gmt_from_date( $comment_modified ); 185 186 update_comment_meta( $comment_ID, '_modified', $comment_modified ); 187 update_comment_meta( $comment_ID, '_modified_gmt', $comment_modified_gmt ); 188 } 156 189 } 157 190 } … … 200 233 201 234 function kickpress_update_note( $comment_id, $title, $content ) { 202 203 if ( is_user_logged_in() && $note = get_comment( $comment_id ) ) { 204 kickpress_insert_private_comment( $note->comment_post_ID, array( 205 'comment_ID' => $comment_id, 235 if ( is_user_logged_in() && $comment = get_comment( $comment_id ) ) { 236 kickpress_update_private_comment( $comment_id, array( 237 'comment_title' => $title, 206 238 'comment_content' => $content, 207 239 'comment_type' => 'note' -
kickpress/trunk/kickpress-functions.php
r595539 r599114 432 432 433 433 if ( $log = @fopen( $file, 'a' ) ) { 434 fwrite( $log, date( 'c' ) . "\t" . $data . PHP_EOL ); 434 $line = sprintf( 435 "%s\t%s\t%s", 436 date( 'c' ), 437 KICKPRESS_DEBUG_TOKEN, 438 $data 439 ); 440 441 fwrite( $log, $line . PHP_EOL ); 435 442 fflush( $log ); 436 443 fclose( $log ); -
kickpress/trunk/kickpress-oauth.php
r595581 r599114 119 119 120 120 foreach ( $vars as $key => $value ) { 121 if ( ! is_string( $value ) ) continue; 122 121 123 $item = $quotes . rawurlencode( $value ) . $quotes; 122 124 … … 199 201 $query = self::normalize_params( $query ); 200 202 201 $key = self::normalize_params( array(203 /* $key = self::normalize_params( array( 202 204 $this->_consumer_secret, 203 205 $this->_token_secret … … 205 207 'sorted' => false, 206 208 'keyed' => false 207 ) ); 209 ) ); */ 210 211 $key = sprintf( "%s&%s", $this->consumer_secret, $this->token_secret ); 208 212 209 213 $msg = self::normalize_params( array( … … 415 419 if ( is_null( $args ) ) $args = self::get_args(); 416 420 421 if ( kickpress_is_remote_app() && ! is_user_logged_in() ) { 422 $user = wp_authenticate( $_REQUEST['login'], $_REQUEST['password'] ); 423 424 if ( is_a( $user, 'WP_User' ) ) 425 wp_set_current_user( $user->ID ); 426 else 427 die( 'Invalid username/password' ); 428 } 429 417 430 if ( $user_id = get_current_user_id() ) { 418 431 $token = $args['query']['oauth_token']; … … 426 439 427 440 $authorize = strtolower( $query['authorize'] ); 428 unset( $query['authorize']);441 unset( $query['authorize'] ); 429 442 430 443 // Check for prior authorization … … 443 456 } 444 457 445 $url = $oauth->oauth_callback . '?' . http_build_query( $query ); 458 if ( kickpress_is_remote_app() ) { 459 unset( $query['login'], $query['password'] ); 460 die( self::normalize_params( $query ) ); 461 } 462 463 $url = $oauth->oauth_callback . '?' 464 . http_build_query( $query ); 446 465 447 466 header( 'Location: ' . $url ); … … 479 498 self::$_action = 'authenticate'; 480 499 481 if ( isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { 500 $auth = @trim( $_SERVER['HTTP_AUTHORIZATION'] ); 501 502 if ( stripos( $auth, 'OAuth' ) === 0 ) { 482 503 $consumer = self::validate_consumer( $args ); 483 504 484 if ( ! is_wp_error( $consumer ) ) 485 wp_set_current_user( $consumer->user_id ); 505 if ( ! is_wp_error( $consumer ) ) { 506 define( 'REMOTE_APP_TOKEN', $consumer->consumer_key ); 507 508 if ( 0 < $consumer->user_id ) 509 wp_set_current_user( $consumer->user_id ); 510 } 486 511 } 487 512 } … … 534 559 } 535 560 } elseif ( 'authenticate' == self::$_action ) { 536 $meta = kickpress_user_meta_query( 0, 537 'kickpress\_oauth\_access\_token\_%', 538 array( 'oauth_token' => $token ) ); 539 540 if ( $meta = array_shift( $meta ) ) { 541 $token = $meta->oauth_token; 542 $token_secret = $meta->oauth_secret; 561 if ( ! empty( $token ) ) { 562 $meta = kickpress_user_meta_query( 0, 563 'kickpress\_oauth\_access\_token\_%', 564 array( 'oauth_token' => $token ) ); 543 565 544 $consumer->set_user_id( $meta->user_id ); 545 $consumer->set_blog_id( $meta->blog_id ); 566 if ( $meta = @array_shift( $meta ) ) { 567 $token = $meta->oauth_token; 568 $token_secret = $meta->oauth_secret; 569 570 $consumer->set_user_id( $meta->user_id ); 571 $consumer->set_blog_id( $meta->blog_id ); 572 } 546 573 } 547 574 } … … 551 578 $consumer->set_token( $token, $token_secret ); 552 579 } else { 553 return new WP_Error( 'oauth_error',554 'Failed to validate oauth token' ); 580 /* return new WP_Error( 'oauth_error', 581 'Failed to validate oauth token' ); */ 555 582 } 556 583 } … … 621 648 if ( empty( $uri ) ) return false; 622 649 650 $uri = str_replace( array( '%5B', '%5D' ), array( '[', ']' ), $uri ); 651 623 652 if ( $oauth = $this->parse_signature( $signature ) ) { 624 653 $oauth_signature = $oauth['oauth_signature']; … … 632 661 ) ); 633 662 663 // var_dump( $oauth_signature, $proof_signature ); 664 634 665 return $oauth_signature == $proof_signature; 635 666 } -
kickpress/trunk/kickpress-redirects.php
r595581 r599114 159 159 160 160 if ( count($query_parts) ) { 161 // Check whether or not the first parameter is notin the filter array,161 // Check whether or not the first parameter is in the filter array, 162 162 // if it is not, we will evaluate if it is a valid post_name to 163 163 // determine if it needs to be loaded as a post 164 164 $first_index = 0; 165 165 $first_param = $query_parts[0]; 166 167 // Determine if the return format is passed as part of an action: toggle-term[category].json/featured/ 168 if ( strpos( $first_param, '.' ) !== false ) { 169 list( $first_param, $format ) = explode( '.', $first_param ); 166 167 // Determine if the return format is passed as part of an action 168 // eg: toggle-term[category].json/featured/ 169 if ( ( $pos = strrpos( $first_param, '.' ) ) !== false ) { 170 $format = substr( $first_param, $pos + 1 ); 171 $first_param = substr( $first_param, 0, $pos ); 170 172 } elseif ( isset( $_REQUEST['format'] ) ) { 171 173 if ( ( $pos = strpos( $_REQUEST['format'], '/' ) ) !== false ) … … 176 178 $format = null; 177 179 } 178 179 if ( $param_is_array = strpos( $first_param, '[' ) ) { 180 $first_param_key = substr( $first_param, $param_is_array + 1, -1 ); 181 $first_param = substr( $first_param, 0, $param_is_array ); 180 181 if ( ( $pos = strpos( $first_param, '[' ) ) !== false ) { 182 $first_param_key = substr( $first_param, $pos + 1, -1 ); 183 $first_param = substr( $first_param, 0, $pos ); 184 } else { 185 $first_param_key = null; 182 186 } 183 187 … … 192 196 $query_string['action'] = $action; 193 197 194 if ( ! empty( $format ) )198 if ( ! empty( $format ) ) 195 199 $query_string['format'] = $format; 196 200 … … 198 202 $kickpress_api->params['format'] = $format; 199 203 200 if ( isset( $first_param_key ) )204 if ( ! empty( $first_param_key ) ) 201 205 $kickpress_api->params['action_key'] = $first_param_key; 202 206 … … 213 217 $kickpress_api->params['view'] = $view; 214 218 $kickpress_api->params['view_alias'] = $first_param; 219 $kickpress_api->params['format'] = $format; 215 220 } 216 221 … … 220 225 221 226 foreach ( $query_parts as $query_part_index => $query_part_value ) { 222 if ( $query_part_index < $first_index ) 223 continue; 227 if ( $query_part_index < $first_index ) continue; 224 228 225 229 // Overwrite the defaults if needed with the query string 226 230 $eval_decoded = urldecode( $query_part_value ); 227 231 228 /* if ( preg_match_all( '/\[(.+)\]/Ui', $eval_decoded, $keys ) && preg_match( '/^[^\[]+/i', $eval_decoded, $names ) ) {229 $new_query_value = array();230 $ptr_query_value =& $new_query_value;231 232 foreach ( $keys[1] as $key ) {233 $ptr_query_value[$key] = null;234 $ptr_query_value =& $ptr_query_value[$key];235 }236 237 echo '<pre>' . print_r( $new_query_value, true ) . '</pre>';238 } */239 240 232 // evaluate if an array existes in the query string like: term[category] 241 if ( $is_array = strpos( $eval_decoded, '[' ))242 $eval_query_part = substr( $eval_decoded, 0, $ is_array);233 if ( ( $pos = strpos( $eval_decoded, '[' ) ) !== false ) 234 $eval_query_part = substr( $eval_decoded, 0, $pos ); 243 235 else 244 236 $eval_query_part = $eval_decoded; 245 237 246 238 // Rebuild the query string with key=value&key=value pairs 247 if ( in_array( $eval_query_part, $filter_array ) && isset( $query_parts[$query_part_index + 1] ) ) { 239 if ( in_array( $eval_query_part, $filter_array ) && 240 isset( $query_parts[$query_part_index + 1] ) ) { 248 241 if ( 'search' == $query_part_value ) { 249 242 $_GET['s'] = $query_parts[$query_part_index + 1]; -
kickpress/trunk/kickpress.php
r589549 r599114 25 25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 26 */ 27 28 define( 'KICKPRESS_DEBUG_TOKEN', 29 md5( uniqid( rand(), true ) ) ); 30 31 if ( isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) 32 remove_action('init', 'wp_cron'); 27 33 28 34 // Global plugin settings … … 98 104 require_once(WP_PLUGIN_DIR.'/kickpress/kickpress-application.php'); 99 105 require_once(WP_PLUGIN_DIR.'/kickpress/kickpress-oauth.php'); 100 require_once(WP_PLUGIN_DIR.'/kickpress/kickpress-curation.php');106 // require_once(WP_PLUGIN_DIR.'/kickpress/kickpress-curation.php'); 101 107 102 108 /** Register the kickpress shortcodes */
Note: See TracChangeset
for help on using the changeset viewer.