Unbounce Landing Pages - Version 1.0.21

Version Description

Download this release

Release Info

Developer unbouncewordpress
Plugin Icon Unbounce Landing Pages
Version 1.0.21
Comparing to
See all releases

Code changes from version 1.0.20 to 1.0.21

UBCompatibility.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
 
 
3
  // For 4.3.0 <= PHP <= 5.4.0
4
  if (!function_exists('http_response_code')) {
5
  function http_response_code($code = NULL) {
@@ -66,4 +67,21 @@ if (!function_exists('http_response_code')) {
66
  }
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  ?>
1
  <?php
2
 
3
+ // taken from: http://php.net/manual/en/function.http-response-code.php
4
  // For 4.3.0 <= PHP <= 5.4.0
5
  if (!function_exists('http_response_code')) {
6
  function http_response_code($code = NULL) {
67
  }
68
  }
69
 
70
+ // taken from: http://php.net/manual/en/function.getallheaders.php
71
+ if (!function_exists('getallheaders'))
72
+ {
73
+ function getallheaders()
74
+ {
75
+ $headers = '';
76
+ foreach ($_SERVER as $name => $value)
77
+ {
78
+ if (substr($name, 0, 5) == 'HTTP_')
79
+ {
80
+ $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
81
+ }
82
+ }
83
+ return $headers;
84
+ }
85
+ }
86
+
87
  ?>
UBConfig.php CHANGED
@@ -4,8 +4,8 @@ class UBConfig {
4
 
5
  const UB_PLUGIN_NAME = 'ub-wordpress';
6
  const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
7
- const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.20';
8
- const UB_VERSION = '1.0.20';
9
 
10
  # Option keys
11
  const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
@@ -285,7 +285,7 @@ class UBConfig {
285
 
286
  $cache_max_time_default = 10;
287
 
288
- $ps_domain = $options_getter(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY);
289
  $domains_info = $options_getter(UBConfig::UB_ROUTES_CACHE_KEY);
290
  $domain_info = UBUtil::array_fetch($domains_info, $domain, array());
291
 
4
 
5
  const UB_PLUGIN_NAME = 'ub-wordpress';
6
  const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
7
+ const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.21';
8
+ const UB_VERSION = '1.0.21';
9
 
10
  # Option keys
11
  const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
285
 
286
  $cache_max_time_default = 10;
287
 
288
+ $ps_domain = $options_getter(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY, UBConfig::default_page_server_domain());
289
  $domains_info = $options_getter(UBConfig::UB_ROUTES_CACHE_KEY);
290
  $domain_info = UBUtil::array_fetch($domains_info, $domain, array());
291
 
UBDiagnostics.php CHANGED
@@ -28,7 +28,7 @@ class UBDiagnostics {
28
  return array(
29
  'PHP Version' => phpversion(),
30
  'WordPress Version' => UBDiagnostics::wordpress_version(),
31
- 'Unbounce Plugin Version' => "1.0.20",
32
  'Permalink Structure' => get_option('permalink_structure', ''),
33
  'Domain' => $domain,
34
  'Domain Authorized' => print_r(UBConfig::is_authorized_domain($domain), true),
28
  return array(
29
  'PHP Version' => phpversion(),
30
  'WordPress Version' => UBDiagnostics::wordpress_version(),
31
+ 'Unbounce Plugin Version' => "1.0.21",
32
  'Permalink Structure' => get_option('permalink_structure', ''),
33
  'Domain' => $domain,
34
  'Domain Authorized' => print_r(UBConfig::is_authorized_domain($domain), true),
UBHTTP.php CHANGED
@@ -7,7 +7,8 @@ class UBHTTP {
7
  public static $variant_url_regex = '/(.+)\/[a-z]+\.html/i';
8
  public static $pie_htc_url = '/PIE.htc';
9
  // Suppress Etag and Last-Modified so that browser doesn't send If-None-Match and If-Modified-Since header (to bypass front-end caches)
10
- public static $forward_headers = '/^(Content-Type:|Location:|Link:|Content-Location:|Set-Cookie:|X-Server-Instance:|X-Unbounce-PageId:|X-Unbounce-Variant:|X-Unbounce-VisitorID:)/i';
 
11
 
12
  public static function is_private_ip_address($ip_address) {
13
  return !filter_var($ip_address,
@@ -70,7 +71,7 @@ class UBHTTP {
70
  $result = UBHTTP::rewrite_x_powered_by_header($header_string, $existing_headers);
71
  header($result);
72
 
73
- } elseif (preg_match(UBHTTP::$forward_headers, $header_string)) {
74
  // false means don't replace the exsisting header
75
  header($header_string, false);
76
  }
@@ -126,6 +127,17 @@ class UBHTTP {
126
  return $protocol === 'http' || $protocol === 'https';
127
  }
128
 
 
 
 
 
 
 
 
 
 
 
 
129
  public static function stream_request($method,
130
  $target_url,
131
  $cookie_string,
@@ -136,10 +148,14 @@ class UBHTTP {
136
  $forwarded_for = UBUtil::array_fetch($_SERVER, 'HTTP_X_FORWARDED_FOR');
137
  $remote_ip = UBUtil::array_fetch($_SERVER, 'REMOTE_ADDR');
138
 
139
- $headers = UBHTTP::get_proxied_for_header($headers0,
 
 
 
 
 
140
  $forwarded_for,
141
  $remote_ip);
142
-
143
  UBLogger::debug_var('target_url', $target_url);
144
 
145
  $stream_headers = UBHTTP::stream_headers_function($existing_headers);
7
  public static $variant_url_regex = '/(.+)\/[a-z]+\.html/i';
8
  public static $pie_htc_url = '/PIE.htc';
9
  // Suppress Etag and Last-Modified so that browser doesn't send If-None-Match and If-Modified-Since header (to bypass front-end caches)
10
+ public static $response_header_whitelist = '/^(Content-Type:|Location:|Link:|Content-Location:|Set-Cookie:|X-Server-Instance:|X-Unbounce-PageId:|X-Unbounce-Variant:|X-Unbounce-VisitorID:)/i';
11
+ public static $request_header_blacklist = '/^(Accept-Encoding:)/i';
12
 
13
  public static function is_private_ip_address($ip_address) {
14
  return !filter_var($ip_address,
71
  $result = UBHTTP::rewrite_x_powered_by_header($header_string, $existing_headers);
72
  header($result);
73
 
74
+ } elseif (preg_match(UBHTTP::$response_header_whitelist, $header_string)) {
75
  // false means don't replace the exsisting header
76
  header($header_string, false);
77
  }
127
  return $protocol === 'http' || $protocol === 'https';
128
  }
129
 
130
+ // taken from: http://stackoverflow.com/a/13036310/322727
131
+ private static function convert_headers_to_curl($headers) {
132
+ // map to curl-friendly format
133
+ $req_headers = array();
134
+ array_walk($headers, function(&$v, $k) use (&$req_headers) {
135
+ array_push($req_headers, $k . ": " . $v);
136
+ });
137
+
138
+ return $req_headers;
139
+ }
140
+
141
  public static function stream_request($method,
142
  $target_url,
143
  $cookie_string,
148
  $forwarded_for = UBUtil::array_fetch($_SERVER, 'HTTP_X_FORWARDED_FOR');
149
  $remote_ip = UBUtil::array_fetch($_SERVER, 'REMOTE_ADDR');
150
 
151
+ $headers1 = UBHTTP::convert_headers_to_curl($headers0);
152
+ $curl_headers = array_filter($headers1, function($key) {
153
+ return !preg_match(UBHTTP::$request_header_blacklist, $key);
154
+ });
155
+
156
+ $headers = UBHTTP::get_proxied_for_header($curl_headers,
157
  $forwarded_for,
158
  $remote_ip);
 
159
  UBLogger::debug_var('target_url', $target_url);
160
 
161
  $stream_headers = UBHTTP::stream_headers_function($existing_headers);
Unbounce-Page.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Unbounce Landing Pages
4
  Plugin URI: http://unbounce.com
5
  Description: Unbounce is the most powerful standalone landing page builder available.
6
- Version: 1.0.20
7
  Author: Unbounce
8
  Author URI: http://unbounce.com
9
  License: GPLv2
@@ -21,25 +21,25 @@ require_once dirname(__FILE__) . '/UBEvents.php';
21
  require_once dirname(__FILE__) . '/UBTemplate.php';
22
 
23
  register_activation_hook(__FILE__, function() {
24
- add_site_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
25
- add_site_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0);
26
- add_site_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY,
27
- UBConfig::default_page_server_domain());
28
- add_site_option(UBConfig::UB_REMOTE_LOG_URL_KEY,
29
- UBConfig::default_remote_log_url());
30
- add_site_option(UBConfig::UB_API_URL_KEY,
31
- UBConfig::default_api_url());
32
- add_site_option(UBConfig::UB_API_CLIENT_ID_KEY,
33
- UBConfig::default_api_client_id());
34
- add_site_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY,
35
- UBConfig::default_authorized_domains());
36
- add_site_option(UBConfig::UB_HAS_AUTHORIZED_KEY, '');
37
- add_site_option(UBConfig::UB_REMOTE_EVENTS_URL_KEY,
38
- UBConfig::default_remote_events_url());
39
- add_site_option(UBConfig::UB_USER_ID_KEY, '');
40
- add_site_option(UBConfig::UB_DOMAIN_ID_KEY, '');
41
- add_site_option(UBConfig::UB_CLIENT_ID_KEY, '');
42
- add_site_option(UBConfig::UB_PROXY_ERROR_MESSAGE_KEY, '');
43
  });
44
 
45
  register_deactivation_hook(__FILE__, function() {
@@ -134,7 +134,8 @@ add_action('init', function() {
134
 
135
  $cookie_string = UBHTTP::cookie_string_from_array($cookies_to_forward);
136
 
137
- $req_headers = $referer == null ? array('Host: ' . $domain) : array('Referer: ' . $referer, 'Host: ' . $domain);
 
138
 
139
  // Make sure we don't get cached by Wordpress hosts like WPEngine
140
  header('Cache-Control: max-age=0; private');
@@ -142,7 +143,7 @@ add_action('init', function() {
142
  list($success, $message) = UBHTTP::stream_request($http_method,
143
  $raw_url,
144
  $cookie_string,
145
- $req_headers,
146
  $user_agent);
147
 
148
  if($success === false) {
3
  Plugin Name: Unbounce Landing Pages
4
  Plugin URI: http://unbounce.com
5
  Description: Unbounce is the most powerful standalone landing page builder available.
6
+ Version: 1.0.21
7
  Author: Unbounce
8
  Author URI: http://unbounce.com
9
  License: GPLv2
21
  require_once dirname(__FILE__) . '/UBTemplate.php';
22
 
23
  register_activation_hook(__FILE__, function() {
24
+ add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
25
+ add_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0);
26
+ add_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY,
27
+ UBConfig::default_page_server_domain());
28
+ add_option(UBConfig::UB_REMOTE_LOG_URL_KEY,
29
+ UBConfig::default_remote_log_url());
30
+ add_option(UBConfig::UB_API_URL_KEY,
31
+ UBConfig::default_api_url());
32
+ add_option(UBConfig::UB_API_CLIENT_ID_KEY,
33
+ UBConfig::default_api_client_id());
34
+ add_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY,
35
+ UBConfig::default_authorized_domains());
36
+ add_option(UBConfig::UB_HAS_AUTHORIZED_KEY, '');
37
+ add_option(UBConfig::UB_REMOTE_EVENTS_URL_KEY,
38
+ UBConfig::default_remote_events_url());
39
+ add_option(UBConfig::UB_USER_ID_KEY, '');
40
+ add_option(UBConfig::UB_DOMAIN_ID_KEY, '');
41
+ add_option(UBConfig::UB_CLIENT_ID_KEY, '');
42
+ add_option(UBConfig::UB_PROXY_ERROR_MESSAGE_KEY, '');
43
  });
44
 
45
  register_deactivation_hook(__FILE__, function() {
134
 
135
  $cookie_string = UBHTTP::cookie_string_from_array($cookies_to_forward);
136
 
137
+ $all_headers = getallheaders();
138
+ $all_headers['Host'] = $domain;
139
 
140
  // Make sure we don't get cached by Wordpress hosts like WPEngine
141
  header('Cache-Control: max-age=0; private');
143
  list($success, $message) = UBHTTP::stream_request($http_method,
144
  $raw_url,
145
  $cookie_string,
146
+ $all_headers,
147
  $user_agent);
148
 
149
  if($success === false) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: unbouncewordpress
3
  Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
4
  Requires at least: 4.1.5
5
  Tested up to: 4.4
6
- Stable tag: 1.0.20
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
3
  Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
4
  Requires at least: 4.1.5
5
  Tested up to: 4.4
6
+ Stable tag: 1.0.21
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
templates/main_authorized_footer.php CHANGED
@@ -17,4 +17,4 @@ $refresh_button = get_submit_button('refreshing the Published Pages list', 'seco
17
  Check out our knowledge base.
18
  </a>
19
  <br/><a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">Click here for troubleshooting and plugin diagnostics</a>
20
- <p class="ub-version">Unbounce Version 1.0.20</p>
17
  Check out our knowledge base.
18
  </a>
19
  <br/><a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">Click here for troubleshooting and plugin diagnostics</a>
20
+ <p class="ub-version">Unbounce Version 1.0.21</p>
templates/main_unauthorized_footer.php CHANGED
@@ -4,4 +4,4 @@
4
  <a class="ub-diagnostics-link" href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">
5
  Click here for troubleshooting and plugin diagnostics
6
  </a>
7
- <p class="ub-version">Unbounce Version 1.0.20</p>
4
  <a class="ub-diagnostics-link" href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">
5
  Click here for troubleshooting and plugin diagnostics
6
  </a>
7
+ <p class="ub-version">Unbounce Version 1.0.21</p>