[wp-cvs] wordpress/wp-admin xmlrpc.php,1.12,1.13

Michel Valdrighi michelvaldrighi at users.sourceforge.net
Wed Sep 1 16:13:37 UTC 2004


Update of /cvsroot/cafelog/wordpress/wp-admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13678/wp-admin

Modified Files:
	xmlrpc.php 
Log Message:
added Emmanuel Frecon's fix to create directories in mw.newMediaObject, removed some useless (and/or potentially dangerous) debug strings

Index: xmlrpc.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/xmlrpc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** xmlrpc.php	27 Aug 2004 13:31:22 -0000	1.12
--- xmlrpc.php	1 Sep 2004 16:13:35 -0000	1.13
***************
*** 35,38 ****
--- 35,39 ----
  logIO("I", $HTTP_RAW_POST_DATA);
  
+ 
  function printr($var, $do_not_echo = false) {
  	// from php.net/print_r user contributed notes 
***************
*** 47,50 ****
--- 48,75 ----
  }
  
+ function mkdir_p($target) {
+ 	// from php.net/mkdir user contributed notes 
+ 	if (file_exists($target)) {
+ 	  if (!is_dir($target)) {
+ 	    return false;
+ 	  } else {
+ 	    return true;
+ 	  }
+ 	}
+ 
+ 	// Attempting to create the directory may clutter up our display.
+ 	if (@mkdir($target)) {
+ 	  return true;
+ 	}
+ 
+ 	// If the above failed, attempt to create the parent node, then try again.
+ 	if (mkdir_p(dirname($target))) {
+ 	  return mkdir_p($target);
+ 	}
+ 
+ 	return false;
+ }
+ 
+ 
  class wp_xmlrpc_server extends IXR_Server {
  
***************
*** 85,89 ****
  	function login_pass_ok($user_login, $user_pass) {
  	  if (!user_pass_ok($user_login, $user_pass)) {
! 	    $this->error = new IXR_Error(403, 'Bad login/pass combination.'.$user_login);
  	    return false;
  	  }
--- 110,114 ----
  	function login_pass_ok($user_login, $user_pass) {
  	  if (!user_pass_ok($user_login, $user_pass)) {
! 	    $this->error = new IXR_Error(403, 'Bad login/pass combination.');
  	    return false;
  	  }
***************
*** 616,620 ****
  				'postid' => $postdata['ID'],
  				'content' => $postdata['post_content'],
! 				'permalink' => $link,
  				'categories' => $categories,
  				'mt_excerpt' => $postdata['post_excerpt'],
--- 641,645 ----
  				'postid' => $postdata['ID'],
  				'content' => $postdata['post_content'],
! 				'permaLink' => $link,
  				'categories' => $categories,
  				'mt_excerpt' => $postdata['post_excerpt'],
***************
*** 759,763 ****
  	    // User has not enough privileges
  	    logIO('O', '(MW) Not enough privilege: user level too low');
! 	    $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.sdff'.$user_data->user_level);
  	    return $this->error;
  	  }
--- 784,788 ----
  	    // User has not enough privileges
  	    logIO('O', '(MW) Not enough privilege: user level too low');
! 	    $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
  	    return $this->error;
  	  }
***************
*** 777,792 ****
  	    $url = $file_url.$prefix.$name;
  
! 	    /* encode & write data (binary) */
! 	    $ifp = fopen($localpath, 'wb');
! 	    $success = fwrite($ifp, $bits);
! 	    fclose($ifp);
! 	    @chmod($localpath, 0666);
  
- 	    if($success) {
- 	      $resp = array($url);
- 	      return $resp;
  	    } else {
! 	      logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
! 	      return new IXR_Error(500, 'Could not write file '.$name.' to '.$localpath);
  	    }
  	  }
--- 802,823 ----
  	    $url = $file_url.$prefix.$name;
  
! 	    if (mkdir_p(dirname($localpath))) {
! 
! 	      /* encode & write data (binary) */
! 	      $ifp = fopen($localpath, 'wb');
! 	      $success = fwrite($ifp, $bits);
! 	      fclose($ifp);
! 	      @chmod($localpath, 0666);
! 
! 	      if($success) {
! 	        $resp = array($url);
! 	        return $resp;
! 	      } else {
! 	        logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
! 	        return new IXR_Error(500, 'Could not write file '.$name);
! 	      }
  
  	    } else {
! 	      return new IXR_Error(500, 'Could not create directories for '.$name);
  	    }
  	  }




More information about the cvs mailing list