Make WordPress Core

Changeset 1580


Ignore:
Timestamp:
09/01/2004 04:13:35 PM (21 years ago)
Author:
michelvaldrighi
Message:

added Emmanuel Frecon's fix to create directories in mw.newMediaObject, removed some useless (and/or potentially dangerous) debug strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r1569 r1580  
    3535logIO("I", $HTTP_RAW_POST_DATA);
    3636
     37
    3738function printr($var, $do_not_echo = false) {
    3839    // from php.net/print_r user contributed notes
     
    4647    return $code;
    4748}
     49
     50function 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      }
     58    }
     59
     60    // Attempting to create the directory may clutter up our display.
     61    if (@mkdir($target)) {
     62      return true;
     63    }
     64
     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);
     68    }
     69
     70    return false;
     71}
     72
    4873
    4974class wp_xmlrpc_server extends IXR_Server {
     
    85110    function login_pass_ok($user_login, $user_pass) {
    86111      if (!user_pass_ok($user_login, $user_pass)) {
    87         $this->error = new IXR_Error(403, 'Bad login/pass combination.'.$user_login);
     112        $this->error = new IXR_Error(403, 'Bad login/pass combination.');
    88113        return false;
    89114      }
     
    616641                'postid' => $postdata['ID'],
    617642                'content' => $postdata['post_content'],
    618                 'permalink' => $link,
     643                'permaLink' => $link,
    619644                'categories' => $categories,
    620645                'mt_excerpt' => $postdata['post_excerpt'],
     
    759784        // User has not enough privileges
    760785        logIO('O', '(MW) Not enough privilege: user level too low');
    761         $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.sdff'.$user_data->user_level);
     786        $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
    762787        return $this->error;
    763788      }
     
    777802        $url = $file_url.$prefix.$name;
    778803
    779         /* encode & write data (binary) */
    780         $ifp = fopen($localpath, 'wb');
    781         $success = fwrite($ifp, $bits);
    782         fclose($ifp);
    783         @chmod($localpath, 0666);
    784 
    785         if($success) {
    786           $resp = array($url);
    787           return $resp;
     804        if (mkdir_p(dirname($localpath))) {
     805
     806          /* encode & write data (binary) */
     807          $ifp = fopen($localpath, 'wb');
     808          $success = fwrite($ifp, $bits);
     809          fclose($ifp);
     810          @chmod($localpath, 0666);
     811
     812          if($success) {
     813            $resp = array($url);
     814            return $resp;
     815          } else {
     816            logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
     817            return new IXR_Error(500, 'Could not write file '.$name);
     818          }
     819
    788820        } else {
    789           logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
    790           return new IXR_Error(500, 'Could not write file '.$name.' to '.$localpath);
     821          return new IXR_Error(500, 'Could not create directories for '.$name);
    791822        }
    792823      }
Note: See TracChangeset for help on using the changeset viewer.