Changeset 1568 for trunk/xmlrpc.php
- Timestamp:
- 08/27/2004 08:46:24 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc.php
r1565 r1568 14 14 $post_default_category = 1; // posts submitted via the xmlrpc interface go into that category 15 15 16 $xmlrpc_logging = 1;16 $xmlrpc_logging = 0; 17 17 18 18 function logIO($io,$msg) { … … 35 35 logIO("I", $HTTP_RAW_POST_DATA); 36 36 37 function printr ( $var, $do_not_echo = false ) 38 { 39 ob_start(); 40 print_r($var); 41 $code = htmlentities(ob_get_contents()); 42 ob_clean(); 43 if ( !$do_not_echo ) 44 { 45 echo "<pre>$code</pre>"; 46 } 47 return $code; 37 function printr($var, $do_not_echo = false) { 38 // from php.net/print_r user contributed notes 39 ob_start(); 40 print_r($var); 41 $code = htmlentities(ob_get_contents()); 42 ob_clean(); 43 if (!$do_not_echo) { 44 echo "<pre>$code</pre>"; 45 } 46 return $code; 48 47 } 49 48 … … 67 66 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', 68 67 'metaWeblog.getCategories' => 'this:mw_getCategories', 68 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', 69 69 70 70 'demo.sayHello' => 'this:sayHello', … … 170 170 $struct = array( 171 171 'userid' => $post_data['post_author'], 172 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s \Z', $post_data['post_date_gmt'])),172 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])), 173 173 'content' => $content, 174 174 'postid' => $post_data['ID'] … … 202 202 foreach ($posts_list as $entry) { 203 203 204 $post_date = mysql2date('Ymd\TH:i:s \Z', $entry['post_date_gmt']);204 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 205 205 $categories = implode(',', wp_get_post_cats(1, $entry['ID'])); 206 206 … … 478 478 479 479 $catnames = $content_struct['categories']; 480 // FIXME: commented until a fix to print_r is found: logio('O', 'Post cats: ' . print_r($catnames,true)); 481 //logio('O', 'Post cats: ' . printr($catnames,true)); 480 logio('O', 'Post cats: ' . printr($catnames,true)); 482 481 $post_category = array(); 483 482 … … 595 594 if ($postdata['post_date'] != '') { 596 595 597 $post_date = mysql2date('Ymd\TH:i:s \Z', $postdata['post_date_gmt']);596 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); 598 597 599 598 $categories = array(); … … 653 652 foreach ($posts_list as $entry) { 654 653 655 $post_date = mysql2date('Ymd\TH:i:s \Z', $entry['post_date_gmt']);654 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 656 655 $categories = array(); 657 656 $catids = wp_get_post_cats('', $entry['ID']); … … 724 723 } 725 724 725 726 /* metaweblog.newMediaObject uploads a file, following your settings */ 727 function mw_newMediaObject($args) { 728 // adapted from a patch by Johann Richard 729 // http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ 730 731 $blog_ID = $args[0]; 732 $user_login = $args[1]; 733 $user_pass = $args[2]; 734 $data = $args[3]; 735 736 $name = $data['name']; 737 $type = $data['type']; 738 $bits = $data['bits']; 739 740 $file_realpath = get_settings('fileupload_realpath'); 741 $file_url = get_settings('fileupload_url'); 742 743 if (!$this->login_pass_ok($user_login, $user_pass)) { 744 return $this->error; 745 } 746 747 $user_data = get_userdatabylogin($user_login); 748 749 if(!get_settings('use_fileupload')) { 750 // Uploads not allowed 751 logIO('O', '(MW) Uploads not allowed'); 752 $this->error = new IXR_Error(405, 'No uploads allowed for this site.'); 753 return $this->error; 754 } 755 756 if(get_settings('fileupload_minlevel') > $userlevel) { 757 // User has not enough privileges 758 logIO('O', '(MW) Not enough privilege: user level too low'); 759 $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.'); 760 return $this->error; 761 } 762 763 if(trim($file_realpath) == '' || trim($file_url) == '' ) { 764 // WordPress is not correctly configured 765 logIO('O', '(MW) Bad configuration. Real/URL path not defined'); 766 $this->error = new IXR_Error(500, 'Please configure WordPress with valid paths for file upload.'); 767 return $this->error; 768 } 769 770 $prefix = '/'; 771 772 if(!strlen(trim($name))) { 773 // Create the path 774 $localpath = $file_realpath.$prefix.$name; 775 $url = $file_url.$prefix.$name; 776 777 /* encode & write data (binary) */ 778 $ifp = fopen($localpath, 'wb'); 779 $success = fwrite($ifp, $bits); 780 fclose($ifp); 781 @chmod($localpath, 0666); 782 783 if( $success ) { 784 $resp = array($url); 785 return $resp; 786 } else { 787 logIO('O', '(MW) Could not write file '.$name.' to '.$localpath); 788 return new IXR_Error(500, 'Could not write file '.$name.' to '.$localpath); 789 } 790 } 791 } 792 726 793 } 727 794
Note: See TracChangeset
for help on using the changeset viewer.