Changeset 6339

Show
Ignore:
Timestamp:
11/17/07 11:21:34 (10 months ago)
Author:
westi
Message:

Ensure that we offer https access to atom if it is available. Fixes #5298 props rubys.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-app.php

    r6273 r6339  
    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'); 
     
    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( 
     
    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"; 
     
    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 
     
    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"; 
     
    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 
     
    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"); 
     
    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"); 
     
    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        } 
  • trunk/wp-includes/default-filters.php

    r6195 r6339  
    135135add_filter('comment_email', 'antispambot'); 
    136136 
     137//Atom SSL support 
     138add_filter('atom_service_url','atom_service_url_filter'); 
     139 
    137140// Actions 
    138141add_action('wp_head', 'rsd_link'); 
  • trunk/wp-includes/functions.php

    r6250 r6339  
    14851485} 
    14861486 
     1487/** 
     1488 * Determines if the blog can be accessed over SSL 
     1489 * @return bool whether of not SSL access is available 
     1490 */ 
     1491function url_is_accessable_via_ssl($url) 
     1492{ 
     1493    if (in_array('curl', get_loaded_extensions())) { 
     1494         $ssl = preg_replace( '/^http:\/\//', 'https://',  $url ); 
     1495 
     1496         $ch = curl_init(); 
     1497         curl_setopt($ch, CURLOPT_URL, $ssl); 
     1498         curl_setopt($ch, CURLOPT_FAILONERROR, true); 
     1499         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     1500         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
     1501 
     1502         $data = curl_exec ($ch); 
     1503 
     1504         $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
     1505         curl_close ($ch); 
     1506 
     1507         if ($status == 200 || $status == 401) { 
     1508             return true; 
     1509         } 
     1510    } 
     1511    return false; 
     1512} 
     1513 
     1514function atom_service_url_filter($url) 
     1515{ 
     1516    if ( url_is_accessable_via_ssl($url) ) 
     1517        return  preg_replace( '/^http:\/\//', 'https://',  $url ); 
     1518} 
    14871519?> 
  • trunk/xmlrpc.php

    r6262 r6339  
    2020if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd 
    2121header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 
    22  
    2322?> 
    2423<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 
     
    3332      <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" /> 
    3433      <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" />  
     34      <api name="Atom" blogID="" preferred="false" apiLink="<?php echo apply_filters('atom_service_url', (get_bloginfo('url')."/wp-app.php/service"))?>" />  
    3635    </apis> 
    3736  </service>