diff --git a/wp-app.php b/wp-app.php index dee5cb04d..9a34fffcc 100644 --- a/wp-app.php +++ b/wp-app.php @@ -68,7 +68,6 @@ class AtomServer { var $MEDIA_SINGLE_PATH = "attachment"; var $params = array(); - var $script_name = "wp-app.php"; var $media_content_types = array('image/*','audio/*','video/*'); var $atom_content_types = array('application/atom+xml'); @@ -80,6 +79,10 @@ class AtomServer { function AtomServer() { $this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME'])); + $this->app_base = get_bloginfo('url') . '/' . $this->script_name . '/'; + if ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) { + $this->app_base = preg_replace( '/^http:\/\//', 'https://', $this->app_base ); + } $this->selectors = array( '@/service$@' => @@ -594,7 +597,7 @@ EOD; } else { $path = $this->ENTRIES_PATH; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $path; + $url = $this->app_base . $path; if(isset($page) && is_int($page)) { $url .= "/$page"; } @@ -607,7 +610,7 @@ EOD; } function get_categories_url($page = NULL) { - return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->CATEGORIES_PATH; + return $this->app_base . $this->CATEGORIES_PATH; } function the_categories_url() { @@ -616,7 +619,7 @@ EOD; } function get_attachments_url($page = NULL) { - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_PATH; + $url = $this->app_base . $this->MEDIA_PATH; if(isset($page) && is_int($page)) { $url .= "/$page"; } @@ -629,7 +632,7 @@ EOD; } function get_service_url() { - return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->SERVICE_PATH; + return $this->app_base . $this->SERVICE_PATH; } function get_entry_url($postID = NULL) { @@ -638,7 +641,7 @@ EOD; $postID = (int) $GLOBALS['post']->ID; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID"; + $url = $this->app_base . $this->ENTRY_PATH . "/$postID"; log_app('function',"get_entry_url() = $url"); return $url; @@ -655,7 +658,7 @@ EOD; $postID = (int) $GLOBALS['post']->ID; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/file/$postID"; + $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID"; log_app('function',"get_media_url() = $url"); return $url; @@ -919,7 +922,7 @@ EOD; $ctloc = $this->get_entry_url($post_ID); break; case 'attachment': - $edit = get_bloginfo('url') . '/' . $this->script_name . "/attachments/$post_ID"; + $edit = $this->app_base . "attachments/$post_ID"; break; } header("Content-Type: $this->ATOM_CONTENT_TYPE"); diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 15fab157c..18b6dde46 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -134,6 +134,9 @@ add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); add_filter('pre_comment_content', 'wp_rel_nofollow', 15); add_filter('comment_email', 'antispambot'); +//Atom SSL support +add_filter('atom_service_url','atom_service_url_filter'); + // Actions add_action('wp_head', 'rsd_link'); add_action('wp_head', 'wlwmanifest_link'); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 12ec9198b..ff531ff79 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1484,4 +1484,36 @@ function absint( $maybeint ) { return abs( intval( $maybeint ) ); } -?> \ No newline at end of file +/** + * Determines if the blog can be accessed over SSL + * @return bool whether of not SSL access is available + */ +function url_is_accessable_via_ssl($url) +{ + if (in_array('curl', get_loaded_extensions())) { + $ssl = preg_replace( '/^http:\/\//', 'https://', $url ); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $ssl); + curl_setopt($ch, CURLOPT_FAILONERROR, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + $data = curl_exec ($ch); + + $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close ($ch); + + if ($status == 200 || $status == 401) { + return true; + } + } + return false; +} + +function atom_service_url_filter($url) +{ + if ( url_is_accessable_via_ssl($url) ) + return preg_replace( '/^http:\/\//', 'https://', $url ); +} +?> diff --git a/xmlrpc.php b/xmlrpc.php index 26ef29ce1..0deb015b8 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -19,7 +19,6 @@ include('./wp-config.php'); if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); - ?> '; ?> @@ -32,7 +31,7 @@ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); - + " />