Make WordPress Core

Ticket #5298: https-app.patch

File https-app.patch, 4.3 KB (added by rubys, 16 years ago)

Original patch did not check for https correctly in the RSD

  • wp-app.php

     
    6868        var $MEDIA_SINGLE_PATH = "attachment";
    6969
    7070        var $params = array();
    71         var $script_name = "wp-app.php";
    7271        var $media_content_types = array('image/*','audio/*','video/*');
    7372        var $atom_content_types = array('application/atom+xml');
    7473
     
    8079        function AtomServer() {
    8180
    8281                $this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME']));
     82                $this->app_base = get_bloginfo('url') . '/' . $this->script_name . '/';
     83                if ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) {
     84                        $this->app_base = preg_replace( '/^http:\/\//', 'https://', $this->app_base );
     85                }
    8386
    8487                $this->selectors = array(
    8588                        '@/service$@' =>
     
    594597                } else {
    595598                        $path = $this->ENTRIES_PATH;
    596599                }
    597                 $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $path;
     600                $url = $this->app_base . $path;
    598601                if(isset($page) && is_int($page)) {
    599602                        $url .= "/$page";
    600603                }
     
    607610        }
    608611
    609612        function get_categories_url($page = NULL) {
    610                 return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->CATEGORIES_PATH;
     613                return $this->app_base . $this->CATEGORIES_PATH;
    611614        }
    612615
    613616        function the_categories_url() {
     
    616619        }
    617620
    618621        function get_attachments_url($page = NULL) {
    619                 $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_PATH;
     622                $url = $this->app_base . $this->MEDIA_PATH;
    620623                if(isset($page) && is_int($page)) {
    621624                        $url .= "/$page";
    622625                }
     
    629632        }
    630633
    631634        function get_service_url() {
    632                 return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->SERVICE_PATH;
     635                return $this->app_base . $this->SERVICE_PATH;
    633636        }
    634637
    635638        function get_entry_url($postID = NULL) {
     
    638641                        $postID = (int) $GLOBALS['post']->ID;
    639642                }
    640643
    641                 $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID";
     644                $url = $this->app_base . $this->ENTRY_PATH . "/$postID";
    642645
    643646                log_app('function',"get_entry_url() = $url");
    644647                return $url;
     
    655658                        $postID = (int) $GLOBALS['post']->ID;
    656659                }
    657660
    658                 $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/file/$postID";
     661                $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID";
    659662
    660663                log_app('function',"get_media_url() = $url");
    661664                return $url;
     
    919922                                $ctloc = $this->get_entry_url($post_ID);
    920923                                break;
    921924                        case 'attachment':
    922                                 $edit = get_bloginfo('url') . '/' . $this->script_name . "/attachments/$post_ID";
     925                                $edit = $this->app_base . "attachments/$post_ID";
    923926                                break;
    924927                }
    925928                header("Content-Type: $this->ATOM_CONTENT_TYPE");
  • xmlrpc.php

     
    2020if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
    2121header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
    2222
     23$app = get_bloginfo('url') . "/wp-app.php/service";
     24
     25// Determine if this host supports TLS/SSL
     26if (in_array('curl', get_loaded_extensions())) {
     27        $apps = preg_replace( '/^http:\/\//', 'https://', $app );
     28
     29        $ch = curl_init();
     30        curl_setopt($ch, CURLOPT_URL, $apps);
     31        curl_setopt($ch, CURLOPT_FAILONERROR, true);
     32        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     33        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     34
     35        $data = curl_exec ($ch);
     36
     37        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     38        curl_close ($ch);
     39
     40        if ($status == 200 || $status == 401) {
     41                $app = $apps;
     42        }
     43}
     44
    2345?>
    2446<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
    2547<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
     
    3254      <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
    3355      <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
    3456      <api name="Blogger" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
    35       <api name="Atom" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/wp-app.php/service" />
     57      <api name="Atom" blogID="" preferred="false" apiLink="<?php echo $app ?>" />
    3658    </apis>
    3759  </service>
    3860</rsd>