Advertisement
Guest User

use core functions to detect SSL.patch

a guest
Nov 17th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.64 KB | None | 0 0
  1. Index: domain_mapping.php
  2. ===================================================================
  3. --- domain_mapping.php  (revision 464429)
  4. +++ domain_mapping.php  (working copy)
  5. @@ -449,9 +449,7 @@
  6.         return false;
  7.     }
  8.  
  9. -   if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
  10. -       $_SERVER[ 'HTTPS' ] = 'Off';
  11. -   $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
  12. +   $protocol = is_ssl() ? 'https://' : 'http://';
  13.     $domains = $wpdb->get_results( "SELECT * FROM {$wpdb->dmtable} WHERE blog_id = '{$wpdb->blogid}'", ARRAY_A );
  14.     if ( is_array( $domains ) && !empty( $domains ) ) {
  15.         $orig_url = parse_url( get_original_url( 'siteurl' ) );
  16. @@ -542,9 +540,7 @@
  17.         }
  18.  
  19.         $wpdb->suppress_errors( $s );
  20. -       if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
  21. -           $_SERVER[ 'HTTPS' ] = 'Off';
  22. -       $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
  23. +       $protocol = is_ssl() ? 'https://' : 'http://';
  24.         if ( $domain ) {
  25.             $return_url[ $wpdb->blogid ] = untrailingslashit( $protocol . $domain  );
  26.             $setting = $return_url[ $wpdb->blogid ];
  27. @@ -577,7 +573,7 @@
  28.         } else {
  29.             $orig_url = get_blog_option( $blog_id, $url );
  30.         }
  31. -       if ( isset( $_SERVER[ 'HTTPS' ] ) && 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) {
  32. +       if ( is_ssl() ) {
  33.             $orig_url = str_replace( "http://", "https://", $orig_url );
  34.         } else {
  35.             $orig_url = str_replace( "https://", "http://", $orig_url );
  36. @@ -690,9 +686,7 @@
  37.  function remote_logout_loader() {
  38.     global $current_site, $current_blog, $wpdb;
  39.     $wpdb->dmtablelogins = $wpdb->base_prefix . 'domain_mapping_logins';
  40. -   if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
  41. -       $_SERVER[ 'HTTPS' ] = 'Off';
  42. -   $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
  43. +   $protocol = is_ssl() ? 'https://' : 'http://';
  44.     $hash = get_dm_hash();
  45.     $key = md5( time() );
  46.     $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->dmtablelogins} ( `id`, `user_id`, `blog_id`, `t` ) VALUES( %s, 0, %d, NOW() )", $key, $current_blog->blog_id ) );
  47. @@ -704,9 +698,7 @@
  48.  
  49.  function redirect_to_mapped_domain() {
  50.     global $current_blog, $wpdb;
  51. -   if ( !isset( $_SERVER[ 'HTTPS' ] ) )
  52. -       $_SERVER[ 'HTTPS' ] = 'off';
  53. -   $protocol = ( 'on' == strtolower($_SERVER['HTTPS']) ) ? 'https://' : 'http://';
  54. +   $protocol = is_ssl() ? 'https://' : 'http://';
  55.     $url = domain_mapping_siteurl( false );
  56.     if ( $url && $url != untrailingslashit( $protocol . $current_blog->domain . $current_blog->path ) ) {
  57.         $redirect = get_site_option( 'dm_301_redirect' ) ? '301' : '302';
  58. @@ -736,9 +728,7 @@
  59.  
  60.     $wpdb->dmtablelogins = $wpdb->base_prefix . 'domain_mapping_logins';
  61.     $hash = get_dm_hash();
  62. -   if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
  63. -       $_SERVER[ 'HTTPS' ] = 'Off';
  64. -   $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
  65. +   $protocol = is_ssl() ? 'https://' : 'http://';
  66.     if ( $_GET[ 'dm' ] == $hash ) {
  67.         if ( $_GET[ 'action' ] == 'load' ) {
  68.             if ( !is_user_logged_in() )
  69. @@ -782,9 +772,7 @@
  70.     if ( 0 == get_site_option( 'dm_remote_login' ) || is_user_logged_in() )
  71.         return false;
  72.  
  73. -   if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
  74. -       $_SERVER[ 'HTTPS' ] = 'Off';
  75. -   $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
  76. +   $protocol = is_ssl() ? 'https://' : 'http://';
  77.     $hash = get_dm_hash();
  78.     echo "<script src='{$protocol}{$current_site->domain}{$current_site->path}?dm={$hash}&amp;action=load&amp;blogid={$current_blog->blog_id}&amp;siteid={$current_blog->site_id}&amp;t=" . mt_rand() . "&amp;back=" . urlencode( $protocol . $current_blog->domain . $_SERVER[ 'REQUEST_URI' ] ) . "' type='text/javascript'></script>";
  79.  }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement