Changeset 4495 for trunk/xmlrpc.php
- Timestamp:
- 11/19/2006 07:56:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/xmlrpc.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc.php
r4412 r4495 67 67 function wp_xmlrpc_server() { 68 68 $this->methods = array( 69 // Blogger API70 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',71 'blogger.getUserInfo' => 'this:blogger_getUserInfo',72 'blogger.getPost' => 'this:blogger_getPost',73 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',74 'blogger.getTemplate' => 'this:blogger_getTemplate',75 'blogger.setTemplate' => 'this:blogger_setTemplate',76 'blogger.newPost' => 'this:blogger_newPost',77 'blogger.editPost' => 'this:blogger_editPost',78 'blogger.deletePost' => 'this:blogger_deletePost',79 80 // MetaWeblog API (with MT extensions to structs)81 'metaWeblog.newPost' => 'this:mw_newPost',82 'metaWeblog.editPost' => 'this:mw_editPost',83 'metaWeblog.getPost' => 'this:mw_getPost',84 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',85 'metaWeblog.getCategories' => 'this:mw_getCategories',86 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',87 88 // MetaWeblog API aliases for Blogger API89 // see http://www.xmlrpc.com/stories/storyReader$246090 'metaWeblog.deletePost' => 'this:blogger_deletePost',91 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',92 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',93 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',94 95 // MovableType API96 'mt.getCategoryList' => 'this:mt_getCategoryList',97 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',98 'mt.getPostCategories' => 'this:mt_getPostCategories',99 'mt.setPostCategories' => 'this:mt_setPostCategories',100 'mt.supportedMethods' => 'this:mt_supportedMethods',101 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',102 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',103 'mt.publishPost' => 'this:mt_publishPost',104 105 // PingBack106 'pingback.ping' => 'this:pingback_ping',107 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',108 109 'demo.sayHello' => 'this:sayHello',110 'demo.addTwoNumbers' => 'this:addTwoNumbers'69 // Blogger API 70 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', 71 'blogger.getUserInfo' => 'this:blogger_getUserInfo', 72 'blogger.getPost' => 'this:blogger_getPost', 73 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', 74 'blogger.getTemplate' => 'this:blogger_getTemplate', 75 'blogger.setTemplate' => 'this:blogger_setTemplate', 76 'blogger.newPost' => 'this:blogger_newPost', 77 'blogger.editPost' => 'this:blogger_editPost', 78 'blogger.deletePost' => 'this:blogger_deletePost', 79 80 // MetaWeblog API (with MT extensions to structs) 81 'metaWeblog.newPost' => 'this:mw_newPost', 82 'metaWeblog.editPost' => 'this:mw_editPost', 83 'metaWeblog.getPost' => 'this:mw_getPost', 84 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', 85 'metaWeblog.getCategories' => 'this:mw_getCategories', 86 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', 87 88 // MetaWeblog API aliases for Blogger API 89 // see http://www.xmlrpc.com/stories/storyReader$2460 90 'metaWeblog.deletePost' => 'this:blogger_deletePost', 91 'metaWeblog.getTemplate' => 'this:blogger_getTemplate', 92 'metaWeblog.setTemplate' => 'this:blogger_setTemplate', 93 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', 94 95 // MovableType API 96 'mt.getCategoryList' => 'this:mt_getCategoryList', 97 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', 98 'mt.getPostCategories' => 'this:mt_getPostCategories', 99 'mt.setPostCategories' => 'this:mt_setPostCategories', 100 'mt.supportedMethods' => 'this:mt_supportedMethods', 101 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', 102 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', 103 'mt.publishPost' => 'this:mt_publishPost', 104 105 // PingBack 106 'pingback.ping' => 'this:pingback_ping', 107 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', 108 109 'demo.sayHello' => 'this:sayHello', 110 'demo.addTwoNumbers' => 'this:addTwoNumbers' 111 111 ); 112 112 $this->methods = apply_filters('xmlrpc_methods', $this->methods); … … 125 125 126 126 function login_pass_ok($user_login, $user_pass) { 127 if (!user_pass_ok($user_login, $user_pass)) {128 $this->error = new IXR_Error(403, 'Bad login/pass combination.');129 return false;130 }131 return true;127 if (!user_pass_ok($user_login, $user_pass)) { 128 $this->error = new IXR_Error(403, 'Bad login/pass combination.'); 129 return false; 130 } 131 return true; 132 132 } 133 133 … … 182 182 $this->escape($args); 183 183 184 $user_login = $args[1];185 $user_pass = $args[2];186 187 if (!$this->login_pass_ok($user_login, $user_pass)) {188 return $this->error;189 }190 191 $user_data = get_userdatabylogin($user_login);192 193 $struct = array(194 'nickname' => $user_data->nickname,195 'userid' => $user_data->ID,196 'url' => $user_data->user_url,197 'email' => $user_data->user_email,198 'lastname' => $user_data->last_name,199 'firstname' => $user_data->first_name200 );201 202 return $struct;184 $user_login = $args[1]; 185 $user_pass = $args[2]; 186 187 if (!$this->login_pass_ok($user_login, $user_pass)) { 188 return $this->error; 189 } 190 191 $user_data = get_userdatabylogin($user_login); 192 193 $struct = array( 194 'nickname' => $user_data->nickname, 195 'userid' => $user_data->ID, 196 'url' => $user_data->user_url, 197 'email' => $user_data->user_email, 198 'lastname' => $user_data->last_name, 199 'firstname' => $user_data->first_name 200 ); 201 202 return $struct; 203 203 } 204 204 … … 209 209 $this->escape($args); 210 210 211 $post_ID = $args[1];212 $user_login = $args[2];213 $user_pass = $args[3];214 215 if (!$this->login_pass_ok($user_login, $user_pass)) {216 return $this->error;217 }218 219 $user_data = get_userdatabylogin($user_login);220 $post_data = wp_get_single_post($post_ID, ARRAY_A);221 222 $categories = implode(',', wp_get_post_categories($post_ID));223 224 $content = '<title>'.stripslashes($post_data['post_title']).'</title>';225 $content .= '<category>'.$categories.'</category>';226 $content .= stripslashes($post_data['post_content']);227 228 $struct = array(229 'userid' => $post_data['post_author'],230 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),231 'content' => $content,232 'postid' => $post_data['ID']233 );234 235 return $struct;211 $post_ID = $args[1]; 212 $user_login = $args[2]; 213 $user_pass = $args[3]; 214 215 if (!$this->login_pass_ok($user_login, $user_pass)) { 216 return $this->error; 217 } 218 219 $user_data = get_userdatabylogin($user_login); 220 $post_data = wp_get_single_post($post_ID, ARRAY_A); 221 222 $categories = implode(',', wp_get_post_categories($post_ID)); 223 224 $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; 225 $content .= '<category>'.$categories.'</category>'; 226 $content .= stripslashes($post_data['post_content']); 227 228 $struct = array( 229 'userid' => $post_data['post_author'], 230 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])), 231 'content' => $content, 232 'postid' => $post_data['ID'] 233 ); 234 235 return $struct; 236 236 } 237 237 … … 240 240 function blogger_getRecentPosts($args) { 241 241 242 global $wpdb;243 244 $this->escape($args); 245 246 $blog_ID = $args[1]; /* though we don't use it yet */247 $user_login = $args[2];248 $user_pass = $args[3];249 $num_posts = $args[4];250 251 if (!$this->login_pass_ok($user_login, $user_pass)) {252 return $this->error;253 }254 255 $posts_list = wp_get_recent_posts($num_posts);256 257 if (!$posts_list) {258 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');259 return $this->error;260 }261 262 foreach ($posts_list as $entry) {263 264 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);265 $categories = implode(',', wp_get_post_categories($entry['ID']));266 267 $content = '<title>'.stripslashes($entry['post_title']).'</title>';268 $content .= '<category>'.$categories.'</category>';269 $content .= stripslashes($entry['post_content']);270 271 $struct[] = array(272 'userid' => $entry['post_author'],273 'dateCreated' => new IXR_Date($post_date),274 'content' => $content,275 'postid' => $entry['ID'],276 );277 278 }279 280 $recent_posts = array();281 for ($j=0; $j<count($struct); $j++) {282 array_push($recent_posts, $struct[$j]);283 }284 285 return $recent_posts;242 global $wpdb; 243 244 $this->escape($args); 245 246 $blog_ID = $args[1]; /* though we don't use it yet */ 247 $user_login = $args[2]; 248 $user_pass = $args[3]; 249 $num_posts = $args[4]; 250 251 if (!$this->login_pass_ok($user_login, $user_pass)) { 252 return $this->error; 253 } 254 255 $posts_list = wp_get_recent_posts($num_posts); 256 257 if (!$posts_list) { 258 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); 259 return $this->error; 260 } 261 262 foreach ($posts_list as $entry) { 263 264 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 265 $categories = implode(',', wp_get_post_categories($entry['ID'])); 266 267 $content = '<title>'.stripslashes($entry['post_title']).'</title>'; 268 $content .= '<category>'.$categories.'</category>'; 269 $content .= stripslashes($entry['post_content']); 270 271 $struct[] = array( 272 'userid' => $entry['post_author'], 273 'dateCreated' => new IXR_Date($post_date), 274 'content' => $content, 275 'postid' => $entry['ID'], 276 ); 277 278 } 279 280 $recent_posts = array(); 281 for ($j=0; $j<count($struct); $j++) { 282 array_push($recent_posts, $struct[$j]); 283 } 284 285 return $recent_posts; 286 286 } 287 287 … … 713 713 $this->escape($args); 714 714 715 $blog_ID = $args[0];716 $user_login = $args[1];717 $user_pass = $args[2];718 $num_posts = $args[3];719 720 if (!$this->login_pass_ok($user_login, $user_pass)) {721 return $this->error;722 }723 724 $posts_list = wp_get_recent_posts($num_posts);725 726 if (!$posts_list) {727 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');728 return $this->error;729 }730 731 foreach ($posts_list as $entry) {732 733 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);734 $categories = array();735 $catids = wp_get_post_categories($entry['ID']);736 foreach($catids as $catid) {737 $categories[] = get_cat_name($catid);738 }739 740 $post = get_extended($entry['post_content']);741 $link = post_permalink($entry['ID']);742 743 $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;744 $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;745 746 $struct[] = array(747 'dateCreated' => new IXR_Date($post_date),748 'userid' => $entry['post_author'],749 'postid' => $entry['ID'],750 'description' => $post['main'],751 'title' => $entry['post_title'],752 'link' => $link,753 'permaLink' => $link,715 $blog_ID = $args[0]; 716 $user_login = $args[1]; 717 $user_pass = $args[2]; 718 $num_posts = $args[3]; 719 720 if (!$this->login_pass_ok($user_login, $user_pass)) { 721 return $this->error; 722 } 723 724 $posts_list = wp_get_recent_posts($num_posts); 725 726 if (!$posts_list) { 727 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); 728 return $this->error; 729 } 730 731 foreach ($posts_list as $entry) { 732 733 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 734 $categories = array(); 735 $catids = wp_get_post_categories($entry['ID']); 736 foreach($catids as $catid) { 737 $categories[] = get_cat_name($catid); 738 } 739 740 $post = get_extended($entry['post_content']); 741 $link = post_permalink($entry['ID']); 742 743 $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; 744 $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; 745 746 $struct[] = array( 747 'dateCreated' => new IXR_Date($post_date), 748 'userid' => $entry['post_author'], 749 'postid' => $entry['ID'], 750 'description' => $post['main'], 751 'title' => $entry['post_title'], 752 'link' => $link, 753 'permaLink' => $link, 754 754 // commented out because no other tool seems to use this 755 755 // 'content' => $entry['post_content'], 756 'categories' => $categories,757 'mt_excerpt' => $entry['post_excerpt'],758 'mt_text_more' => $post['extended'],759 'mt_allow_comments' => $allow_comments,760 'mt_allow_pings' => $allow_pings761 );762 763 }764 765 $recent_posts = array();766 for ($j=0; $j<count($struct); $j++) {767 array_push($recent_posts, $struct[$j]);768 }769 770 return $recent_posts;756 'categories' => $categories, 757 'mt_excerpt' => $entry['post_excerpt'], 758 'mt_text_more' => $post['extended'], 759 'mt_allow_comments' => $allow_comments, 760 'mt_allow_pings' => $allow_pings 761 ); 762 763 } 764 765 $recent_posts = array(); 766 for ($j=0; $j<count($struct); $j++) { 767 array_push($recent_posts, $struct[$j]); 768 } 769 770 return $recent_posts; 771 771 } 772 772 … … 775 775 function mw_getCategories($args) { 776 776 777 global $wpdb;778 779 $this->escape($args); 780 781 $blog_ID = $args[0];782 $user_login = $args[1];783 $user_pass = $args[2];784 785 if (!$this->login_pass_ok($user_login, $user_pass)) {786 return $this->error;787 }788 789 $categories_struct = array();790 791 // FIXME: can we avoid using direct SQL there?792 if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {793 foreach ($cats as $cat) {794 $struct['categoryId'] = $cat['cat_ID'];795 $struct['description'] = $cat['cat_name'];796 $struct['categoryName'] = $cat['cat_name'];797 $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']));798 $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));799 800 $categories_struct[] = $struct;801 }802 }803 804 return $categories_struct;777 global $wpdb; 778 779 $this->escape($args); 780 781 $blog_ID = $args[0]; 782 $user_login = $args[1]; 783 $user_pass = $args[2]; 784 785 if (!$this->login_pass_ok($user_login, $user_pass)) { 786 return $this->error; 787 } 788 789 $categories_struct = array(); 790 791 // FIXME: can we avoid using direct SQL there? 792 if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) { 793 foreach ($cats as $cat) { 794 $struct['categoryId'] = $cat['cat_ID']; 795 $struct['description'] = $cat['cat_name']; 796 $struct['categoryName'] = $cat['cat_name']; 797 $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID'])); 798 $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name'])); 799 800 $categories_struct[] = $struct; 801 } 802 } 803 804 return $categories_struct; 805 805 } 806 806 … … 853 853 $this->escape($args); 854 854 855 $blog_ID = $args[0];856 $user_login = $args[1];857 $user_pass = $args[2];858 $num_posts = $args[3];859 860 if (!$this->login_pass_ok($user_login, $user_pass)) {861 return $this->error;862 }863 864 $posts_list = wp_get_recent_posts($num_posts);865 866 if (!$posts_list) {867 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');868 return $this->error;869 }870 871 foreach ($posts_list as $entry) {872 873 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);874 875 $struct[] = array(876 'dateCreated' => new IXR_Date($post_date),877 'userid' => $entry['post_author'],878 'postid' => $entry['ID'],879 'title' => $entry['post_title'],880 );881 882 }883 884 $recent_posts = array();885 for ($j=0; $j<count($struct); $j++) {886 array_push($recent_posts, $struct[$j]);887 }888 889 return $recent_posts;855 $blog_ID = $args[0]; 856 $user_login = $args[1]; 857 $user_pass = $args[2]; 858 $num_posts = $args[3]; 859 860 if (!$this->login_pass_ok($user_login, $user_pass)) { 861 return $this->error; 862 } 863 864 $posts_list = wp_get_recent_posts($num_posts); 865 866 if (!$posts_list) { 867 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); 868 return $this->error; 869 } 870 871 foreach ($posts_list as $entry) { 872 873 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 874 875 $struct[] = array( 876 'dateCreated' => new IXR_Date($post_date), 877 'userid' => $entry['post_author'], 878 'postid' => $entry['ID'], 879 'title' => $entry['post_title'], 880 ); 881 882 } 883 884 $recent_posts = array(); 885 for ($j=0; $j<count($struct); $j++) { 886 array_push($recent_posts, $struct[$j]); 887 } 888 889 return $recent_posts; 890 890 } 891 891 … … 894 894 function mt_getCategoryList($args) { 895 895 896 global $wpdb;897 898 $this->escape($args); 899 900 $blog_ID = $args[0];901 $user_login = $args[1];902 $user_pass = $args[2];903 904 if (!$this->login_pass_ok($user_login, $user_pass)) {905 return $this->error;906 }907 908 $categories_struct = array();909 910 // FIXME: can we avoid using direct SQL there?911 if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {912 foreach ($cats as $cat) {913 $struct['categoryId'] = $cat['cat_ID'];914 $struct['categoryName'] = $cat['cat_name'];915 916 $categories_struct[] = $struct;917 }918 }919 920 return $categories_struct;896 global $wpdb; 897 898 $this->escape($args); 899 900 $blog_ID = $args[0]; 901 $user_login = $args[1]; 902 $user_pass = $args[2]; 903 904 if (!$this->login_pass_ok($user_login, $user_pass)) { 905 return $this->error; 906 } 907 908 $categories_struct = array(); 909 910 // FIXME: can we avoid using direct SQL there? 911 if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) { 912 foreach ($cats as $cat) { 913 $struct['categoryId'] = $cat['cat_ID']; 914 $struct['categoryName'] = $cat['cat_name']; 915 916 $categories_struct[] = $struct; 917 } 918 } 919 920 return $categories_struct; 921 921 } 922 922 … … 927 927 $this->escape($args); 928 928 929 $post_ID = $args[0];930 $user_login = $args[1];931 $user_pass = $args[2];932 933 if (!$this->login_pass_ok($user_login, $user_pass)) {934 return $this->error;935 }936 937 $categories = array();938 $catids = wp_get_post_categories(intval($post_ID));939 // first listed category will be the primary category940 $isPrimary = true;941 foreach($catids as $catid) {942 $categories[] = array(943 'categoryName' => get_cat_name($catid),944 'categoryId' => $catid,945 'isPrimary' => $isPrimary946 );947 $isPrimary = false;948 }949 950 return $categories;929 $post_ID = $args[0]; 930 $user_login = $args[1]; 931 $user_pass = $args[2]; 932 933 if (!$this->login_pass_ok($user_login, $user_pass)) { 934 return $this->error; 935 } 936 937 $categories = array(); 938 $catids = wp_get_post_categories(intval($post_ID)); 939 // first listed category will be the primary category 940 $isPrimary = true; 941 foreach($catids as $catid) { 942 $categories[] = array( 943 'categoryName' => get_cat_name($catid), 944 'categoryId' => $catid, 945 'isPrimary' => $isPrimary 946 ); 947 $isPrimary = false; 948 } 949 950 return $categories; 951 951 } 952 952 … … 957 957 $this->escape($args); 958 958 959 $post_ID = $args[0];960 $user_login = $args[1];961 $user_pass = $args[2];962 $categories = $args[3];963 964 if (!$this->login_pass_ok($user_login, $user_pass)) {965 return $this->error;966 }967 968 set_current_user(0, $user_login);969 if ( !current_user_can('edit_post', $post_ID) )970 return new IXR_Error(401, 'Sorry, you can not edit this post.');971 972 foreach($categories as $cat) {973 $catids[] = $cat['categoryId'];974 }975 976 wp_set_post_categories($post_ID, $catids);977 978 return true;959 $post_ID = $args[0]; 960 $user_login = $args[1]; 961 $user_pass = $args[2]; 962 $categories = $args[3]; 963 964 if (!$this->login_pass_ok($user_login, $user_pass)) { 965 return $this->error; 966 } 967 968 set_current_user(0, $user_login); 969 if ( !current_user_can('edit_post', $post_ID) ) 970 return new IXR_Error(401, 'Sorry, you can not edit this post.'); 971 972 foreach($categories as $cat) { 973 $catids[] = $cat['categoryId']; 974 } 975 976 wp_set_post_categories($post_ID, $catids); 977 978 return true; 979 979 } 980 980 … … 983 983 function mt_supportedMethods($args) { 984 984 985 $supported_methods = array();986 foreach($this->methods as $key=>$value) {987 $supported_methods[] = $key;988 }989 990 return $supported_methods;985 $supported_methods = array(); 986 foreach($this->methods as $key=>$value) { 987 $supported_methods[] = $key; 988 } 989 990 return $supported_methods; 991 991 } 992 992 993 993 994 994 /* mt.supportedTextFilters ...returns an empty array because we don't 995 support per-post text filters yet */995 support per-post text filters yet */ 996 996 function mt_supportedTextFilters($args) { 997 return array();997 return array(); 998 998 } 999 999 … … 1002 1002 function mt_getTrackbackPings($args) { 1003 1003 1004 global $wpdb;1005 1006 $post_ID = intval($args);1007 1008 $actual_post = wp_get_single_post($post_ID, ARRAY_A);1009 1010 if (!$actual_post) {1011 return new IXR_Error(404, 'Sorry, no such post.');1012 }1013 1014 $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");1015 1016 if (!$comments) {1017 return array();1018 }1019 1020 $trackback_pings = array();1021 foreach($comments as $comment) {1022 if ( 'trackback' == $comment->comment_type ) {1023 $content = $comment->comment_content;1024 $title = substr($content, 8, (strpos($content, '</strong>') - 8));1025 $trackback_pings[] = array(1026 'pingTitle' => $title,1027 'pingURL' => $comment->comment_author_url,1028 'pingIP' => $comment->comment_author_IP1029 );1030 } 1031 }1032 1033 return $trackback_pings;1004 global $wpdb; 1005 1006 $post_ID = intval($args); 1007 1008 $actual_post = wp_get_single_post($post_ID, ARRAY_A); 1009 1010 if (!$actual_post) { 1011 return new IXR_Error(404, 'Sorry, no such post.'); 1012 } 1013 1014 $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID"); 1015 1016 if (!$comments) { 1017 return array(); 1018 } 1019 1020 $trackback_pings = array(); 1021 foreach($comments as $comment) { 1022 if ( 'trackback' == $comment->comment_type ) { 1023 $content = $comment->comment_content; 1024 $title = substr($content, 8, (strpos($content, '</strong>') - 8)); 1025 $trackback_pings[] = array( 1026 'pingTitle' => $title, 1027 'pingURL' => $comment->comment_author_url, 1028 'pingIP' => $comment->comment_author_IP 1029 ); 1030 } 1031 } 1032 1033 return $trackback_pings; 1034 1034 } 1035 1035 … … 1040 1040 $this->escape($args); 1041 1041 1042 $post_ID = $args[0];1043 $user_login = $args[1];1044 $user_pass = $args[2];1045 1046 if (!$this->login_pass_ok($user_login, $user_pass)) {1047 return $this->error;1048 }1049 1050 set_current_user(0, $user_login);1051 if ( !current_user_can('edit_post', $post_ID) )1052 return new IXR_Error(401, 'Sorry, you can not edit this post.');1053 1054 $postdata = wp_get_single_post($post_ID,ARRAY_A);1055 1056 $postdata['post_status'] = 'publish';1057 1058 // retain old cats1059 $cats = wp_get_post_categories($post_ID);1060 $postdata['post_category'] = $cats;1042 $post_ID = $args[0]; 1043 $user_login = $args[1]; 1044 $user_pass = $args[2]; 1045 1046 if (!$this->login_pass_ok($user_login, $user_pass)) { 1047 return $this->error; 1048 } 1049 1050 set_current_user(0, $user_login); 1051 if ( !current_user_can('edit_post', $post_ID) ) 1052 return new IXR_Error(401, 'Sorry, you can not edit this post.'); 1053 1054 $postdata = wp_get_single_post($post_ID,ARRAY_A); 1055 1056 $postdata['post_status'] = 'publish'; 1057 1058 // retain old cats 1059 $cats = wp_get_post_categories($post_ID); 1060 $postdata['post_category'] = $cats; 1061 1061 $this->escape($postdata); 1062 1062 1063 $result = wp_update_post($postdata);1064 1065 return $result;1063 $result = wp_update_post($postdata); 1064 1065 return $result; 1066 1066 } 1067 1067 … … 1074 1074 /* pingback.ping gets a pingback and registers it */ 1075 1075 function pingback_ping($args) { 1076 global $wpdb, $wp_version; 1076 global $wpdb, $wp_version; 1077 1077 1078 1078 $this->escape($args); … … 1091 1091 $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); 1092 1092 if( !$pos1 ) 1093 return new IXR_Error(0, 'Is there no link to us?');1093 return new IXR_Error(0, 'Is there no link to us?'); 1094 1094 1095 1095 // let's find which post is linked to … … 1224 1224 1225 1225 /* pingback.extensions.getPingbacks returns an array of URLs 1226 that pingbacked the given URL1227 specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */1226 that pingbacked the given URL 1227 specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */ 1228 1228 function pingback_extensions_getPingbacks($args) { 1229 1229
Note: See TracChangeset
for help on using the changeset viewer.