Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 1312 lines (975 sloc) 38.444 kb
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
1 <?php
2
3 # fix for mozBlog and other cases where '<?xml' isn't on the very first line
4 $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
5
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
6 include('../wp-config.php');
7 include_once(ABSPATH . WPINC . '/class-IXR.php');
8 include_once(ABSPATH . WPINC . '/functions-post.php');
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
9
10 // Turn off all warnings and errors.
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
11 // error_reporting(0);
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
12
13 $post_default_title = ""; // posts submitted via the xmlrpc interface get that title
14 $post_default_category = 1; // posts submitted via the xmlrpc interface go into that category
15
80b3445c » michelvaldrighi
2004-09-14 fixed comment_status screwup, removed debug stuff, screwed up big tim…
16 $xmlrpc_logging = 0;
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
17
18 function logIO($io,$msg) {
19 global $xmlrpc_logging;
20 if ($xmlrpc_logging) {
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
21 $fp = fopen("../xmlrpc.log","a+");
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
22 $date = gmdate("Y-m-d H:i:s ");
23 $iot = ($io == "I") ? " Input: " : " Output: ";
24 fwrite($fp, "\n\n".$date.$iot.$msg);
25 fclose($fp);
26 }
27 return true;
28 }
29
30 function starify($string) {
31 $i = strlen($string);
32 return str_repeat('*', $i);
33 }
34
35 logIO("I", $HTTP_RAW_POST_DATA);
36
96114636 » michelvaldrighi
2004-09-01 added Emmanuel Frecon's fix to create directories in mw.newMediaObjec…
37
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
38 function printr($var, $do_not_echo = false) {
39 // from php.net/print_r user contributed notes
40 ob_start();
41 print_r($var);
42 $code = htmlentities(ob_get_contents());
43 ob_clean();
44 if (!$do_not_echo) {
45 echo "<pre>$code</pre>";
17d6d76c » michelvaldrighi
2004-08-27 added mw.newMediaObject (not tested yet), fixed local/gmt dates confu…
46 }
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
47 return $code;
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
48 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
49
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
50 function mkdir_p($target) {
51 // from php.net/mkdir user contributed notes
52 if (file_exists($target)) {
53 if (!is_dir($target)) {
54 return false;
55 } else {
56 return true;
57 }
96114636 » michelvaldrighi
2004-09-01 added Emmanuel Frecon's fix to create directories in mw.newMediaObjec…
58 }
59
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
60 // Attempting to create the directory may clutter up our display.
61 if (@mkdir($target)) {
62 return true;
96114636 » michelvaldrighi
2004-09-01 added Emmanuel Frecon's fix to create directories in mw.newMediaObjec…
63 }
64
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
65 // If the above failed, attempt to create the parent node, then try again.
66 if (mkdir_p(dirname($target))) {
67 return mkdir_p($target);
96114636 » michelvaldrighi
2004-09-01 added Emmanuel Frecon's fix to create directories in mw.newMediaObjec…
68 }
69
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
70 return false;
96114636 » michelvaldrighi
2004-09-01 added Emmanuel Frecon's fix to create directories in mw.newMediaObjec…
71 }
72
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
73
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
74 class wp_xmlrpc_server extends IXR_Server {
75
76 function wp_xmlrpc_server() {
77 $this->methods = array(
78 // Blogger API
79 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
80 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
81 'blogger.getPost' => 'this:blogger_getPost',
82 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
83 'blogger.getTemplate' => 'this:blogger_getTemplate',
84 'blogger.setTemplate' => 'this:blogger_setTemplate',
85 'blogger.newPost' => 'this:blogger_newPost',
86 'blogger.editPost' => 'this:blogger_editPost',
87 'blogger.deletePost' => 'this:blogger_deletePost',
88
89 // MetaWeblog API (with MT extensions to structs)
90 'metaWeblog.newPost' => 'this:mw_newPost',
91 'metaWeblog.editPost' => 'this:mw_editPost',
92 'metaWeblog.getPost' => 'this:mw_getPost',
93 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
94 'metaWeblog.getCategories' => 'this:mw_getCategories',
95 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
96
97 // MetaWeblog API aliases for Blogger API
98 // see http://www.xmlrpc.com/stories/storyReader$2460
99 'metaWeblog.deletePost' => 'this:blogger_deletePost',
100 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
101 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
102 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
103
104 // MovableType API
105 'mt.getCategoryList' => 'this:mt_getCategoryList',
106 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
107 'mt.getPostCategories' => 'this:mt_getPostCategories',
108 'mt.setPostCategories' => 'this:mt_setPostCategories',
109 'mt.supportedMethods' => 'this:mt_supportedMethods',
110 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
111 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
112 'mt.publishPost' => 'this:mt_publishPost',
113
114 // PingBack
115 'pingback.ping' => 'this:pingback_ping',
116 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
117
118 'demo.sayHello' => 'this:sayHello',
119 'demo.addTwoNumbers' => 'this:addTwoNumbers'
120 );
121 $this->IXR_Server($this->methods);
122 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
123
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
124 function sayHello($args) {
125 return 'Hello!';
126 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
127
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
128 function addTwoNumbers($args) {
129 $number1 = $args[0];
130 $number2 = $args[1];
131 return $number1 + $number2;
132 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
133
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
134 function login_pass_ok($user_login, $user_pass) {
135 if (!user_pass_ok($user_login, $user_pass)) {
136 $this->error = new IXR_Error(403, 'Bad login/pass combination.');
137 return false;
138 }
139 return true;
140 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
141
142
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
143
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
144
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
145 /* Blogger API functions
146 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
147 */
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
148
149
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
150 /* blogger.getUsersBlogs will make more sense once we support multiple blogs */
151 function blogger_getUsersBlogs($args) {
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
152
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
153 $user_login = $args[1];
154 $user_pass = $args[2];
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
155
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
156 if (!$this->login_pass_ok($user_login, $user_pass)) {
157 return $this->error;
158 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
159
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
160 $user_data = get_userdatabylogin($user_login);
161 $is_admin = $user_data->user_level > 3;
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
162
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
163 $struct = array(
164 'isAdmin' => $is_admin,
165 'url' => get_settings('home') .'/'.get_settings('blogfilename'),
166 'blogid' => '1',
167 'blogName' => get_settings('blogname')
168 );
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
169
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
170 return array($struct);
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
171 }
172
173
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
174 /* blogger.getUsersInfo gives your client some info about you, so you don't have to */
175 function blogger_getUserInfo($args) {
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
176
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
177 $user_login = $args[1];
178 $user_pass = $args[2];
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
179
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
180 if (!$this->login_pass_ok($user_login, $user_pass)) {
181 return $this->error;
182 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
183
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
184 $user_data = get_userdatabylogin($user_login);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
185
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
186 $struct = array(
187 'nickname' => $user_data->user_nickname,
188 'userid' => $user_data->ID,
189 'url' => $user_data->user_url,
190 'email' => $user_data->user_email,
191 'lastname' => $user_data->user_lastname,
192 'firstname' => $user_data->user_firstname
193 );
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
194
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
195 return $struct;
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
196 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
197
198
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
199 /* blogger.getPost ...gets a post */
200 function blogger_getPost($args) {
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
201
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
202 $post_ID = $args[1];
203 $user_login = $args[2];
204 $user_pass = $args[3];
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
205
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
206 if (!$this->login_pass_ok($user_login, $user_pass)) {
207 return $this->error;
208 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
209
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
210 $user_data = get_userdatabylogin($user_login);
211 $post_data = wp_get_single_post($post_ID, ARRAY_A);
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
212
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
213 $categories = implode(',', wp_get_post_cats(1, $post_ID));
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
214
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
215 $content = '<title>'.stripslashes($post_data['post_title']).'</title>';
216 $content .= '<category>'.$categories.'</category>';
217 $content .= stripslashes($post_data['post_content']);
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
218
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
219 $struct = array(
220 'userid' => $post_data['post_author'],
221 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),
222 'content' => $content,
223 'postid' => $post_data['ID']
224 );
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
225
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
226 return $struct;
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
227 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
228
229
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
230 /* blogger.getRecentPosts ...gets recent posts */
231 function blogger_getRecentPosts($args) {
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
232
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
233 global $wpdb;
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
234
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
235 $blog_ID = $args[1]; /* though we don't use it yet */
236 $user_login = $args[2];
237 $user_pass = $args[3];
238 $num_posts = $args[4];
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
239
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
240 if (!$this->login_pass_ok($user_login, $user_pass)) {
241 return $this->error;
242 }
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
243
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
244 $posts_list = wp_get_recent_posts($num_posts);
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
245
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
246 if (!$posts_list) {
247 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
248 return $this->error;
249 }
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
250
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
251 foreach ($posts_list as $entry) {
252
253 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
254 $categories = implode(',', wp_get_post_cats(1, $entry['ID']));
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
255
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
256 $content = '<title>'.stripslashes($entry['post_itle']).'</title>';
257 $content .= '<category>'.$categories.'</category>';
258 $content .= stripslashes($entry['post_content']);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
259
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
260 $struct[] = array(
261 'userid' => $entry['post_author'],
262 'dateCreated' => new IXR_Date($post_date),
263 'content' => $content,
264 'postid' => $entry['ID'],
265 );
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
266
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
267 }
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
268
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
269 $recent_posts = array();
270 for ($j=0; $j<count($struct); $j++) {
271 array_push($recent_posts, $struct[$j]);
272 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
273
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
274 return $recent_posts;
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
275 }
276
277
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
278 /* blogger.getTemplate returns your blog_filename */
279 function blogger_getTemplate($args) {
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
280
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
281 $blog_ID = $args[1];
282 $user_login = $args[2];
283 $user_pass = $args[3];
284 $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
285
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
286 if (!$this->login_pass_ok($user_login, $user_pass)) {
287 return $this->error;
288 }
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
289
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
290 $user_data = get_userdatabylogin($user_login);
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
291
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
292 if ($user_data->user_level < 3) {
293 return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.');
294 }
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
295
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
296 /* warning: here we make the assumption that the weblog's URI is on the same server */
297 $filename = get_settings('home').'/'.get_settings('blogfilename');
298 $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
299
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
300 $f = fopen($filename, 'r');
301 $content = fread($f, filesize($filename));
302 fclose($f);
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
303
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
304 /* so it is actually editable with a windows/mac client */
305 // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
306
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
307 return $content;
308 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
309
310
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
311 /* blogger.setTemplate updates the content of blog_filename */
312 function blogger_setTemplate($args) {
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
313
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
314 $blog_ID = $args[1];
315 $user_login = $args[2];
316 $user_pass = $args[3];
317 $content = $args[4];
318 $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
7feb841e » michelvaldrighi
2004-05-23 added blogger.getTemplate and blogger.setTemplate
319
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
320 if (!$this->login_pass_ok($user_login, $user_pass)) {
321 return $this->error;
322 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
323
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
324 $user_data = get_userdatabylogin($user_login);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
325
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
326 if ($user_data->user_level < 3) {
327 return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.');
328 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
329
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
330 /* warning: here we make the assumption that the weblog's URI is on the same server */
331 $filename = get_settings('home').'/'.get_settings('blogfilename');
332 $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
333
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
334 if ($f = fopen($filename, 'w+')) {
335 fwrite($f, $content);
336 fclose($f);
337 } else {
338 return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.');
339 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
340
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
341 return true;
342 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
343
344
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
345 /* blogger.newPost ...creates a new post */
346 function blogger_newPost($args) {
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
347
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
348 global $wpdb;
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
349
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
350 $blog_ID = $args[1]; /* though we don't use it yet */
351 $user_login = $args[2];
352 $user_pass = $args[3];
353 $content = $args[4];
354 $publish = $args[5];
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
355
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
356 if (!$this->login_pass_ok($user_login, $user_pass)) {
357 return $this->error;
358 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
359
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
360 $user_data = get_userdatabylogin($user_login);
361 if (!user_can_create_post($user_data->ID, $blog_ID)) {
362 return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
363 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
364
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
365 $post_status = ($publish) ? 'publish' : 'draft';
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
366
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
367 $post_author = $user_data->ID;
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
368
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
369 $post_title = xmlrpc_getposttitle($content);
370 $post_category = xmlrpc_getpostcategory($content);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
371
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
372 $content = xmlrpc_removepostdata($content);
373 $post_content = format_to_post($content);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
374
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
375 $post_date = current_time('mysql');
376 $post_date_gmt = current_time('mysql', 1);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
377
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
378 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
379
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
380 $post_ID = wp_insert_post($post_data);
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
381
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
382 if (!$post_ID) {
383 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
384 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
385
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
386 logIO('O', "Posted ! ID: $post_ID");
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
387
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
388 return $post_ID;
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
389 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
390
391
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
392 /* blogger.editPost ...edits a post */
393 function blogger_editPost($args) {
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
394
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
395 global $wpdb;
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
396
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
397 $post_ID = $args[1];
398 $user_login = $args[2];
399 $user_pass = $args[3];
400 $new_content = $args[4];
401 $publish = $args[5];
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
402
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
403 if (!$this->login_pass_ok($user_login, $user_pass)) {
404 return $this->error;
405 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
406
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
407 $actual_post = wp_get_single_post($post_ID,ARRAY_A);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
408
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
409 if (!$actual_post) {
410 return new IXR_Error(404, 'Sorry, no such post.');
411 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
412
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
413 $post_author_data = get_userdata($actual_post['post_author']);
414 $user_data = get_userdatabylogin($user_login);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
415
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
416 if (!user_can_edit_post($user_data->ID, $post_ID)) {
417 return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
418 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
419
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
420 extract($actual_post);
421 $content = $newcontent;
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
422
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
423 $post_title = xmlrpc_getposttitle($content);
424 $post_category = xmlrpc_getpostcategory($content);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
425
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
426 $content = xmlrpc_removepostdata($content);
427 $post_content = format_to_post($content);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
428
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
429 $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
430
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
431 $result = wp_update_post($postdata);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
432
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
433 if (!$result) {
434 return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.');
435 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
436
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
437 return true;
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
438 }
439
440
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
441 /* blogger.deletePost ...deletes a post */
442 function blogger_deletePost($args) {
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
443
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
444 global $wpdb;
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
445
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
446 $post_ID = $args[1];
447 $user_login = $args[2];
448 $user_pass = $args[3];
449 $publish = $args[4];
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
450
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
451 if (!$this->login_pass_ok($user_login, $user_pass)) {
452 return $this->error;
453 }
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
454
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
455 $actual_post = wp_get_single_post($post_ID,ARRAY_A);
a41790f7 » michelvaldrighi
2004-08-25 added blogger.editPost and blogger.deletePost, time to move on to met…
456
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
457 if (!$actual_post) {
458 return new IXR_Error(404, 'Sorry, no such post.');
459 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
460
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
461 $user_data = get_userdatabylogin($user_login);
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
462
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
463 if (!user_can_delete_post($user_data->ID, $post_ID)) {
464 return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
465 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
466
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
467 $result = wp_delete_post($post_ID);
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
468
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
469 if (!$result) {
470 return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.');
471 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
472
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
473 return true;
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
474 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
475
476
477
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
478 /* MetaWeblog API functions
479 * specs on wherever Dave Winer wants them to be
480 */
80b3445c » michelvaldrighi
2004-09-14 fixed comment_status screwup, removed debug stuff, screwed up big tim…
481
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
482 /* metaweblog.newPost creates a post */
483 function mw_newPost($args) {
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
484
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
485 global $wpdb;
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
486
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
487 $blog_ID = $args[0]; // we will support this in the near future
488 $user_login = $args[1];
489 $user_pass = $args[2];
490 $content_struct = $args[3];
491 $publish = $args[4];
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
492
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
493 if (!$this->login_pass_ok($user_login, $user_pass)) {
494 return $this->error;
495 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
496
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
497 $user_data = get_userdatabylogin($user_login);
498 if (!user_can_create_post($user_data->ID, $blog_ID)) {
499 return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
500 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
501
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
502 $post_author = $user_data->ID;
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
503
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
504 $post_title = $content_struct['title'];
505 $post_content = format_to_post($content_struct['description']);
506 $post_status = $publish ? 'publish' : 'draft';
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
507
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
508 $post_excerpt = $content_struct['mt_excerpt'];
509 $post_more = $content_struct['mt_text_more'];
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
510
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
511 $comment_status = (empty($content_struct['mt_allow_comments'])) ?
512 get_settings('default_comment_status')
513 : $content_struct['mt_allow_comments'];
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
514
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
515 $ping_status = (empty($content_struct['mt_allow_pings'])) ?
516 get_settings('default_ping_status')
517 : $content_struct['mt_allow_pings'];
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
518
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
519 if ($post_more) {
520 $post_content = $post_content . "\n<!--more-->\n" . $post_more;
521 }
522
523 // Do some timestamp voodoo
524 $dateCreatedd = $content_struct['dateCreated'];
525 $dateCreated = $dateCreatedd->getIso();
526 if (!empty($dateCreated)) {
527 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
528 $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
529 } else {
530 $post_date = current_time('mysql');
531 $post_date_gmt = current_time('mysql', 1);
532 }
533
534 $catnames = $content_struct['categories'];
535 logio('O', 'Post cats: ' . printr($catnames,true));
536 $post_category = array();
537
538 if ($catnames) {
539 foreach ($catnames as $cat) {
540 $post_category[] = get_cat_ID($cat);
541 }
542 } else {
543 $post_category[] = 1;
544 }
545
546 // We've got all the data -- post it:
547 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status');
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
548
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
549 $post_ID = wp_insert_post($postdata);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
550
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
551 if (!$post_ID) {
552 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
553 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
554
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
555 logIO('O', "Posted ! ID: $post_ID");
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
556
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
557 // FIXME: do we pingback always? pingback($content, $post_ID);
558 trackback_url_list($content_struct['mt_tb_ping_urls'],$post_ID);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
559
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
560 return strval($post_ID);
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
561 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
562
563
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
564 /* metaweblog.editPost ...edits a post */
565 function mw_editPost($args) {
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
566
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
567 global $wpdb;
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
568
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
569 $post_ID = $args[0];
570 $user_login = $args[1];
571 $user_pass = $args[2];
572 $content_struct = $args[3];
573 $publish = $args[4];
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
574
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
575 if (!$this->login_pass_ok($user_login, $user_pass)) {
576 return $this->error;
577 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
578
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
579 $user_data = get_userdatabylogin($user_login);
580 if (!user_can_edit_post($user_data->ID, $post_ID)) {
581 return new IXR_Error(401, 'Sorry, you can not edit this post.');
582 }
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
583
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
584 $postdata = wp_get_single_post($post_ID, ARRAY_A);
585 extract($postdata);
13004042 » michelvaldrighi
2004-08-25 added metaweblog methods: newPost, editPost, getPost -- UNTESTED (yet)
586
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
587 $post_title = $content_struct['title'];
588 $post_content = format_to_post($content_struct['description']);
589 $catnames = $content_struct['categories'];
590
591 if ($catnames) {
592 foreach ($catnames as $cat) {
593 $post_category[] = get_cat_ID($cat);
594 }
595 }
596
597 $post_excerpt = $content_struct['mt_excerpt'];
598 $post_more = $content_struct['mt_text_more'];
599 $post_status = $publish ? 'publish' : 'draft';
600
601 if ($post_more) {
602 $post_content = $post_content . "\n<!--more-->\n" . $post_more;
603 }
604
605 $comment_status = (empty($content_struct['mt_allow_comments'])) ?
606 get_settings('default_comment_status')
607 : $content_struct['mt_allow_comments'];
608
609 $ping_status = (empty($content_struct['mt_allow_pings'])) ?
610 get_settings('default_ping_status')
611 : $content_struct['mt_allow_pings'];
612
613 // Do some timestamp voodoo
614 $dateCreated = $content_struct['dateCreated'];
615 $dateCreated = $dateCreated->getIso();
616 if (!empty($dateCreated)) {
617 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
618 $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
619 } else {
620 $post_date = $postdata['post_date'];
621 $post_date_gmt = $postdata['post_date_gmt'];
622 }
623
624 // We've got all the data -- post it:
625 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt');
626
627 $post_ID = wp_update_post($newpost);
628 if (!$post_ID) {
629 return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.');
630 }
631
632 logIO('O',"(MW) Edited ! ID: $post_ID");
633
634 // FIXME: do we pingback always? pingback($content, $post_ID);
635 trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID);
636
637 return true;
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
638 }
639
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
640
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
641 /* metaweblog.getPost ...returns a post */
642 function mw_getPost($args) {
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
643
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
644 global $wpdb;
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
645
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
646 $post_ID = $args[0];
647 $user_login = $args[1];
648 $user_pass = $args[2];
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
649
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
650 if (!$this->login_pass_ok($user_login, $user_pass)) {
651 return $this->error;
652 }
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
653
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
654 $postdata = wp_get_single_post($post_ID, ARRAY_A);
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
655
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
656 if ($postdata['post_date'] != '') {
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
657
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
658 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
659
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
660 $categories = array();
661 $catids = wp_get_post_cats('', $post_ID);
662 foreach($catids as $catid) {
663 $categories[] = get_cat_name($catid);
664 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
665
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
666 $post = get_extended($postdata['post_content']);
667 $link = post_permalink($postdata['ID']);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
668
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
669 $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0;
670 $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0;
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
671
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
672 $resp = array(
673 'dateCreated' => new IXR_Date($post_date),
674 'userid' => $postdata['post_author'],
675 'postid' => $postdata['ID'],
676 'description' => $post['main'],
677 'title' => $postdata['post_title'],
678 'link' => $link,
679 'permaLink' => $link,
680 // commented out because no other tool seems to use this
681 // 'content' => $entry['post_content'],
682 'categories' => $categories,
683 'mt_excerpt' => $postdata['post_excerpt'],
684 'mt_text_more' => $post['extended'],
685 'mt_allow_comments' => $allow_comments,
686 'mt_allow_pings' => $allow_pings
687 );
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
688
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
689 return $resp;
690 } else {
691 return new IXR_Error(404, 'Sorry, no such post.');
692 }
693 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
694
695
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
696 /* metaweblog.getRecentPosts ...returns recent posts */
697 function mw_getRecentPosts($args) {
698
699 $blog_ID = $args[0];
700 $user_login = $args[1];
701 $user_pass = $args[2];
702 $num_posts = $args[3];
703
704 if (!$this->login_pass_ok($user_login, $user_pass)) {
705 return $this->error;
706 }
707
708 $posts_list = wp_get_recent_posts($num_posts);
709
710 if (!$posts_list) {
711 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
712 return $this->error;
713 }
714
715 foreach ($posts_list as $entry) {
716
717 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
718 $categories = array();
719 $catids = wp_get_post_cats('', $entry['ID']);
720 foreach($catids as $catid) {
721 $categories[] = get_cat_name($catid);
722 }
723
724 $post = get_extended($entry['post_content']);
725 $link = post_permalink($entry['ID']);
726
727 $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
728 $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
729
730 $struct[] = array(
731 'dateCreated' => new IXR_Date($post_date),
732 'userid' => $entry['post_author'],
733 'postid' => $entry['ID'],
734 'description' => $post['main'],
735 'title' => $entry['post_title'],
736 'link' => $link,
737 'permaLink' => $link,
738 // commented out because no other tool seems to use this
739 // 'content' => $entry['post_content'],
740 'categories' => $categories,
741 'mt_excerpt' => $entry['post_excerpt'],
742 'mt_text_more' => $post['extended'],
743 'mt_allow_comments' => $allow_comments,
744 'mt_allow_pings' => $allow_pings
745 );
746
747 }
748
749 $recent_posts = array();
750 for ($j=0; $j<count($struct); $j++) {
751 array_push($recent_posts, $struct[$j]);
752 }
753
754 return $recent_posts;
755 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
756
757
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
758 /* metaweblog.getCategories ...returns the list of categories on a given weblog */
759 function mw_getCategories($args) {
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
760
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
761 global $wpdb;
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
762
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
763 $blog_ID = $args[0];
764 $user_login = $args[1];
765 $user_pass = $args[2];
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
766
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
767 if (!$this->login_pass_ok($user_login, $user_pass)) {
768 return $this->error;
769 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
770
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
771 $categories_struct = array();
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
772
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
773 // FIXME: can we avoid using direct SQL there?
774 if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
775 foreach ($cats as $cat) {
776 $struct['categoryId'] = $cat['cat_ID'];
777 $struct['description'] = $cat['cat_name'];
778 $struct['categoryName'] = $cat['cat_name'];
779 $struct['htmlUrl'] = htmlspecialchars(get_category_link(false, $cat['cat_ID'], $cat['cat_name']));
780 $struct['rssUrl'] = htmlspecialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
781
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
782 $categories_struct[] = $struct;
783 }
784 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
785
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
786 return $categories_struct;
b763f6ca » michelvaldrighi
2004-08-26 added mw.getRecentPosts, mw.getCategories, refactored the living shit…
787 }
788
17d6d76c » michelvaldrighi
2004-08-27 added mw.newMediaObject (not tested yet), fixed local/gmt dates confu…
789
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
790 /* metaweblog.newMediaObject uploads a file, following your settings */
791 function mw_newMediaObject($args) {
792 // adapted from a patch by Johann Richard
793 // http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
794
795 $blog_ID = $args[0];
796 $user_login = $args[1];
797 $user_pass = $args[2];
798 $data = $args[3];
799
800 $name = $data['name'];
801 $type = $data['type'];
802 $bits = $data['bits'];
803
804 $file_realpath = get_settings('fileupload_realpath');
805 $file_url = get_settings('fileupload_url');
806
807 logIO('O', '(MW) Received '.strlen($bits).' bytes');
808
809 if (!$this->login_pass_ok($user_login, $user_pass)) {
810 return $this->error;
811 }
812
813 $user_data = get_userdatabylogin($user_login);
814
815 if(!get_settings('use_fileupload')) {
816 // Uploads not allowed
817 logIO('O', '(MW) Uploads not allowed');
818 $this->error = new IXR_Error(405, 'No uploads allowed for this site.');
819 return $this->error;
820 }
821
822 if(get_settings('fileupload_minlevel') > $user_data->user_level) {
823 // User has not enough privileges
824 logIO('O', '(MW) Not enough privilege: user level too low');
825 $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
826 return $this->error;
827 }
828
829 if(trim($file_realpath) == '' || trim($file_url) == '' ) {
830 // WordPress is not correctly configured
831 logIO('O', '(MW) Bad configuration. Real/URL path not defined');
832 $this->error = new IXR_Error(500, 'Please configure WordPress with valid paths for file upload.');
833 return $this->error;
834 }
835
836 $prefix = '/';
837
838 if(!empty($name)) {
839 // Create the path
840 $localpath = $file_realpath.$prefix.$name;
841 $url = $file_url.$prefix.$name;
842
843 if (mkdir_p(dirname($localpath))) {
844
845 /* encode & write data (binary) */
846 $ifp = fopen($localpath, 'wb');
847 $success = fwrite($ifp, $bits);
848 fclose($ifp);
849 @chmod($localpath, 0666);
850
851 if($success) {
852 $resp = array('url' => $url);
853 return $resp;
854 } else {
855 logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
856 return new IXR_Error(500, 'Could not write file '.$name);
857 }
858
859 } else {
860 return new IXR_Error(500, 'Could not create directories for '.$name);
861 }
862 }
17d6d76c » michelvaldrighi
2004-08-27 added mw.newMediaObject (not tested yet), fixed local/gmt dates confu…
863 }
864
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
865
866
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
867 /* MovableType API functions
868 * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
869 */
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
870
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
871 /* mt.getRecentPostTitles ...returns recent posts' titles */
872 function mt_getRecentPostTitles($args) {
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
873
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
874 $blog_ID = $args[0];
875 $user_login = $args[1];
876 $user_pass = $args[2];
877 $num_posts = $args[3];
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
878
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
879 if (!$this->login_pass_ok($user_login, $user_pass)) {
880 return $this->error;
881 }
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
882
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
883 $posts_list = wp_get_recent_posts($num_posts);
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
884
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
885 if (!$posts_list) {
886 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
887 return $this->error;
888 }
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
889
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
890 foreach ($posts_list as $entry) {
891
892 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
893
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
894 $struct[] = array(
895 'dateCreated' => new IXR_Date($post_date),
896 'userid' => $entry['post_author'],
897 'postid' => $entry['ID'],
898 'title' => $entry['post_title'],
899 );
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
900
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
901 }
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
902
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
903 $recent_posts = array();
904 for ($j=0; $j<count($struct); $j++) {
905 array_push($recent_posts, $struct[$j]);
906 }
907
908 return $recent_posts;
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
909 }
910
911
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
912 /* mt.getCategoryList ...returns the list of categories on a given weblog */
913 function mt_getCategoryList($args) {
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
914
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
915 global $wpdb;
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
916
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
917 $blog_ID = $args[0];
918 $user_login = $args[1];
919 $user_pass = $args[2];
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
920
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
921 if (!$this->login_pass_ok($user_login, $user_pass)) {
922 return $this->error;
923 }
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
924
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
925 $categories_struct = array();
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
926
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
927 // FIXME: can we avoid using direct SQL there?
928 if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
929 foreach ($cats as $cat) {
930 $struct['categoryId'] = $cat['cat_ID'];
931 $struct['categoryName'] = $cat['cat_name'];
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
932
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
933 $categories_struct[] = $struct;
934 }
935 }
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
936
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
937 return $categories_struct;
89e04090 » michelvaldrighi
2004-09-14 various fixes, and started MT API support
938 }
939
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
940
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
941 /* mt.getPostCategories ...returns a post's categories */
942 function mt_getPostCategories($args) {
943
944 $post_ID = $args[0];
945 $user_login = $args[1];
946 $user_pass = $args[2];
947
948 if (!$this->login_pass_ok($user_login, $user_pass)) {
949 return $this->error;
950 }
951
952 $categories = array();
953 $catids = wp_get_post_cats('', intval($post_ID));
954 // first listed category will be the primary category
955 $isPrimary = true;
956 foreach($catids as $catid) {
957 $categories[] = array(
958 'categoryName' => get_cat_name($catid),
959 'categoryId' => $catid,
960 'isPrimary' => $isPrimary
961 );
962 $isPrimary = false;
963 }
964
965 return $categories;
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
966 }
967
968
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
969 /* mt.setPostCategories ...sets a post's categories */
970 function mt_setPostCategories($args) {
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
971
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
972 $post_ID = $args[0];
973 $user_login = $args[1];
974 $user_pass = $args[2];
975 $categories = $args[3];
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
976
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
977 if (!$this->login_pass_ok($user_login, $user_pass)) {
978 return $this->error;
979 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
980
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
981 $user_data = get_userdatabylogin($user_login);
982 if (!user_can_edit_post($user_data->ID, $post_ID)) {
983 return new IXR_Error(401, 'Sorry, you can not edit this post.');
984 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
985
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
986 foreach($categories as $cat) {
987 $catids[] = $cat['categoryId'];
988 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
989
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
990 wp_set_post_cats('', $post_ID, $catids);
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
991
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
992 return true;
993 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
994
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
995
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
996 /* mt.supportedMethods ...returns an array of methods supported by this server */
997 function mt_supportedMethods($args) {
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
998
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
999 $supported_methods = array();
1000 foreach($this->methods as $key=>$value) {
1001 $supported_methods[] = $key;
1002 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1003
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1004 return $supported_methods;
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1005 }
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1006
1007
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1008 /* mt.supportedTextFilters ...returns an empty array because we don't
1009 support per-post text filters yet */
1010 function mt_supportedTextFilters($args) {
1011 return array();
1012 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1013
1014
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1015 /* mt.getTrackbackPings ...returns trackbacks sent to a given post */
1016 function mt_getTrackbackPings($args) {
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1017
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1018 global $wpdb;
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1019
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1020 $post_ID = intval($args);
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1021
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1022 $actual_post = wp_get_single_post($post_ID, ARRAY_A);
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1023
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1024 if (!$actual_post) {
1025 return new IXR_Error(404, 'Sorry, no such post.');
1026 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1027
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1028 $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1029
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1030 if (!$comments) {
1031 return array();
1032 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1033
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1034 $trackback_pings = array();
1035 foreach($comments as $comment) {
1036 if ((strpos($comment->comment_content, '<trackback />') === 0)
1037 || ('trackback' == $comment->comment_type)) {
1038 // FIXME: would be nicer to have a comment_title field?
1039 // FIXME: assumption: here we make the assumption that trackback
1040 // titles are stored as <strong>title</strong>
1041 $content = str_replace('<trackback />', '', $comment->comment_content);
1042 $title = substr($content, 8, (strpos($content, '</strong>') - 8));
1043 $trackback_pings[] = array(
1044 'pingTitle' => $title,
1045 'pingURL' => $comment->comment_author_url,
1046 'pingIP' => $comment->comment_author_IP
1047 );
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1048 }
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1049 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1050
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1051 return $trackback_pings;
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1052 }
1053
1054
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1055 /* mt.publishPost ...sets a post's publish status to 'publish' */
1056 function mt_publishPost($args) {
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1057
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1058 $post_ID = $args[0];
1059 $user_login = $args[1];
1060 $user_pass = $args[2];
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1061
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1062 if (!$this->login_pass_ok($user_login, $user_pass)) {
1063 return $this->error;
1064 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1065
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1066 $user_data = get_userdatabylogin($user_login);
1067 if (!user_can_edit_post($user_data->ID, $post_ID)) {
1068 return new IXR_Error(401, 'Sorry, you can not edit this post.');
1069 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1070
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1071 $postdata = wp_get_single_post($post_ID,ARRAY_A);
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1072
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1073 $postdata['post_status'] = 'publish';
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1074
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1075 // retain old cats
1076 $cats = wp_get_post_cats('',$post_ID);
1077 $postdata['post_category'] = $cats;
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1078
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1079 $result = wp_update_post($postdata);
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1080
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1081 return $result;
1082 }
83d97232 » michelvaldrighi
2004-09-16 now with complete MT API support -- TEST TEST TEST THIS (here it work…
1083
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1084
1085
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1086 /* PingBack functions
1087 * specs on www.hixie.ch/specs/pingback/pingback
1088 */
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1089
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1090 /* pingback.ping gets a pingback and registers it */
1091 function pingback_ping($args) {
1092 // original code by Mort (http://mort.mine.nu:8080 -- site seems dead)
1093 // refactored to return error codes and avoid deep ifififif headaches
1094 global $wpdb, $wp_version;
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1095
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1096 $pagelinkedfrom = $args[0];
1097 $pagelinkedto = $args[1];
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1098
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1099 $title = '';
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1100
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1101 $pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
1102 $pagelinkedto = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedto);
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1103
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1104 $error_code = -1;
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1105
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1106 // Check if the page linked to is in our site
1107 $pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', get_settings('home'))));
1108 if(!$pos1) {
1109 return new IXR_Error(0, '');
1110 }
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1111
1112
1113 // let's find which post is linked to
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1114 // FIXME: does url_to_postid() cover all these cases already?
1115 // if so, then let's use it and drop the old code.
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1116 $urltest = parse_url($pagelinkedto);
1117 if ($post_ID = url_to_postid($pagelinkedto)) {
1118 $way = 'url_to_postid()';
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1119 } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1120 // the path defines the post_ID (archives/p/XXXX)
1121 $blah = explode('/', $match[0]);
1122 $post_ID = $blah[1];
1123 $way = 'from the path';
1124 } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
1125 // the querystring defines the post_ID (?p=XXXX)
1126 $blah = explode('=', $match[0]);
1127 $post_ID = $blah[1];
1128 $way = 'from the querystring';
1129 } elseif (isset($urltest['fragment'])) {
1130 // an #anchor is there, it's either...
1131 if (intval($urltest['fragment'])) {
1132 // ...an integer #XXXX (simpliest case)
1133 $post_ID = $urltest['fragment'];
1134 $way = 'from the fragment (numeric)';
1135 } elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
1136 // ...a post id in the form 'post-###'
1137 $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
1138 $way = 'from the fragment (post-###)';
1139 } elseif (is_string($urltest['fragment'])) {
1140 // ...or a string #title, a little more complicated
1141 $title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
1142 $sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'";
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1143 if (! ($post_ID = $wpdb->get_var($sql)) ) {
1144 // returning unknown error '0' is better than die()ing
1145 return new IXR_Error(0, '');
1146 }
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1147 $way = 'from the fragment (title)';
1148 }
1149 } else {
1150 // TODO: Attempt to extract a post ID from the given URL
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1151 return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1152 }
1153
1154
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1155 logIO("O","(PB) URI='$pagelinkedto' ID='$post_ID' Found='$way'");
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1156
7c7e0fb3 » michelvaldrighi
2004-09-17 moved wp-admin/xmlrpc.php to the root dir
1157 $sql = 'SELECT post_author FROM '.$wpdb->posts.' WHERE ID = '.$post_ID;
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1158 $result = $wpdb->get_results($sql);
1159
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1160 if (!$wpdb->num_rows) {
1161 // Post_ID not found
1162 return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
1163 }
1164
1165
1166 // Let's check that the remote site didn't already pingback this entry
1167 $sql = 'SELECT * FROM '.$wpdb->comments.'
1168 WHERE comment_post_ID = '.$post_ID.'
1169 AND comment_author_url = \''.$pagelinkedfrom.'\'
1170 AND comment_type = \'pingback\'';
1171 $result = $wpdb->get_results($sql);
1172 //return($sql);
1173
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1174 if ($wpdb->num_rows) {
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1175 // We already have a Pingback from this URL
1176 return new IXR_Error(48, 'The pingback has already been registered.');
1177 }
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1178
1179
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1180 // very stupid, but gives time to the 'from' server to publish !
1181 sleep(1);
093993d9 » michelvaldrighi
2004-09-16 added pingback (now with accurate fault codes and more easily readabl…
1182
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1183 // Let's check the remote site
1184 $fp = @fopen($pagelinkedfrom, 'r');
1185 if (!$fp) {
1186 // The source URI does not exist
1187 return new IXR_Error(16, 'The source URI does not exist.');
1188 }
fcb0c547 » michelvaldrighi
2004-09-16 added pingback.extensions.getPingbacks
1189
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1190 $puntero = 4096;
1191 while($remote_read = fread($fp, $puntero)) {
1192 $linea .= $remote_read;
1193 }
fcb0c547 » michelvaldrighi
2004-09-16 added pingback.extensions.getPingbacks
1194
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1195 // Work around bug in strip_tags():
1196 $linea = str_replace('<!DOCTYPE','<DOCTYPE',$linea);
1197 $linea = strip_tags($linea, '<title><a>');
1198 $linea = strip_all_but_one_link($linea, $pagelinkedto);
1199 // I don't think we need this? -- emc3
1200 //$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea);
1201 if (empty($matchtitle)) {
1202 preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
1203 }
1204 $pos2 = strpos($linea, $pagelinkedto);
1205 $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
1206 if (is_integer($pos2) || is_integer($pos3)) {
1207 // The page really links to us :)
1208 $pos4 = (is_integer($pos2)) ? $pos2 : $pos3;
1209 $start = $pos4-100;
1210 $context = substr($linea, $start, 250);
1211 $context = str_replace("\n", ' ', $context);
1212 $context = str_replace('&amp;', '&', $context);
1213 }
1214
1215 fclose($fp);
1216
1217 if (empty($context)) {
1218 // URL pattern not found
1219 return new IXR_Error(17, 'The source URI does not contain a link to the target URI, and so cannot be used as a source.');
1220 }
1221
1222
1223 // Check if pings are on, inelegant exit
1224 $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $post_ID");
1225 if ('closed' == $pingstatus) {
1226 return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
1227 }
1228
1229
1230 $pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedfrom);
1231 $title = (!strlen($matchtitle[1])) ? $pagelinkedfrom : $matchtitle[1];
1232 $original_context = strip_tags($context);
1233 $context = '[...] ';
1234 $context = htmlspecialchars($original_context);
1235 $context .= ' [...]';
1236 $original_pagelinkedfrom = $pagelinkedfrom;
1237 $pagelinkedfrom = addslashes($pagelinkedfrom);
1238 $original_title = $title;
1239 $title = addslashes(strip_tags(trim($title)));
1240 $user_ip = $_SERVER['REMOTE_ADDR'];
1241 $user_agent = addslashes($_SERVER['HTTP_USER_AGENT']);
1242 $now = current_time('mysql');
1243 $now_gmt = current_time('mysql', 1);
1244
1245 // Check if the entry allows pings
1246 if( !check_comment($title, '', $pagelinkedfrom, $context, $user_ip, $user_agent) ) {
1247 return new IXR_Error(49, 'Pingbacks not allowed on this entry.');
1248 }
1249
1250
1251 $consulta = $wpdb->query("INSERT INTO $wpdb->comments
1252 (comment_post_ID, comment_author, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type)
1253 VALUES
1254 ($post_ID, '$title', '$pagelinkedfrom', '$user_ip', '$now', '$now_gmt', '$context', '1', '$user_agent', 'pingback')
1255 ");
1256
1257 $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
1258
1259 if (get_settings('comments_notify')) {
1260 wp_notify_postauthor($comment_ID, 'pingback');
1261 }
1262
1263 do_action('pingback_post', $comment_ID);
1264
1265 return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
1266 }
1267
1268
1269 /* pingback.extensions.getPingbacks returns an array of URLs
1270 that pingbacked the given URL
1271 specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
1272 function pingback_extensions_getPingbacks($args) {
1273
1274 global $wpdb;
1275
1276 $url = $args;
1277
1278 $post_ID = url_to_postid($url);
1279 if (!$post_ID) {
1280 // We aren't sure that the resource is available and/or pingback enabled
1281 return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
1282 }
1283
1284 $actual_post = wp_get_single_post($post_ID, ARRAY_A);
1285
1286 if (!$actual_post) {
1287 // No such post = resource not found
1288 return new IXR_Error(32, 'The specified target URI does not exist.');
1289 }
1290
1291 $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
1292
1293 if (!$comments) {
1294 return array();
1295 }
1296
1297 $pingbacks = array();
1298 foreach($comments as $comment) {
1299 if ((strpos($comment->comment_content, '<pingback />') === 0)
1300 || ('pingback' == $comment->comment_type)) {
1301 $pingbacks[] = $comment->comment_author_url;
fcb0c547 » michelvaldrighi
2004-09-16 added pingback.extensions.getPingbacks
1302 }
1303 }
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1304
1305 return $pingbacks;
fcb0c547 » michelvaldrighi
2004-09-16 added pingback.extensions.getPingbacks
1306 }
1387744b » michelvaldrighi
2004-05-23 added blogger.newPost
1307 }
e61a7ce5 » michelvaldrighi
2004-05-23 work in progress: replacement for xmlrpc.php, using IXR
1308
a7322e87 » michelvaldrighi
2004-09-17 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
1309
1310 $wp_xmlrpc_server = new wp_xmlrpc_server();
1311
1312 ?>
Something went wrong with that request. Please try again.