WordPress.org

Make WordPress Core

Changeset 1349


Ignore:
Timestamp:
05/23/04 15:46:43 (10 years ago)
Author:
michelvaldrighi
Message:

added blogger.getTemplate and blogger.setTemplate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r1348 r1349  
    4444          'blogger.getPost' => 'this:blogger_getPost', 
    4545          'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', 
     46          'blogger.getTemplate' => 'this:blogger_getTemplate', 
     47          'blogger.setTemplate' => 'this:blogger_setTemplate', 
    4648          'demo.sayHello' => 'this:sayHello', 
    4749          'demo.addTwoNumbers' => 'this:addTwoNumbers' 
     
    247249      return $recent_posts; 
    248250    } 
    249 } 
     251 
     252 
     253    /* blogger.getTemplate returns your blog_filename */ 
     254    function blogger_getTemplate($args) { 
     255 
     256      $blog_ID    = $args[1]; 
     257      $user_login = $args[2]; 
     258      $user_pass  = $args[3]; 
     259      $template   = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ 
     260 
     261      if (!$this->login_pass_ok($user_login, $user_pass)) { 
     262        return $this->error; 
     263      } 
     264 
     265      $user_data = get_userdatabylogin($user_login); 
     266 
     267      if ($user_data->user_level < 3) { 
     268        return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.'); 
     269      } 
     270 
     271      /* warning: here we make the assumption that the weblog's URI is on the same server */ 
     272      $filename = get_settings('home').'/'.get_settings('blogfilename'); 
     273      $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); 
     274       
     275      $f = fopen($filename, 'r'); 
     276      $content = fread($f, filesize($filename)); 
     277      fclose($f); 
     278 
     279      /* so it is actually editable with a windows/mac client */ 
     280      $content = str_replace("\n", "\r\n", $content);  
     281 
     282      return $content; 
     283    } 
     284 
     285 
     286    /* blogger.setTemplate updates the content of blog_filename */ 
     287    function blogger_setTemplate($args) { 
     288 
     289      $blog_ID    = $args[1]; 
     290      $user_login = $args[2]; 
     291      $user_pass  = $args[3]; 
     292      $content    = $args[4]; 
     293      $template   = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ 
     294 
     295      if (!$this->login_pass_ok($user_login, $user_pass)) { 
     296        return $this->error; 
     297      } 
     298 
     299      $user_data = get_userdatabylogin($user_login); 
     300 
     301      if ($user_data->user_level < 3) { 
     302        return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.'); 
     303      } 
     304 
     305      /* warning: here we make the assumption that the weblog's URI is on the same server */ 
     306      $filename = get_settings('home').'/'.get_settings('blogfilename'); 
     307      $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); 
     308       
     309      if ($f = fopen($filename, 'w+')) { 
     310        fwrite($f, $content); 
     311        fclose($f); 
     312      } else { 
     313        return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.'); 
     314      } 
     315 
     316      return true; 
     317    } 
     318 
     319}} 
    250320 
    251321$wp_xmlrpc_server = new wp_xmlrpc_server(); 
Note: See TracChangeset for help on using the changeset viewer.