Пример #1
0
 public static function get_url_purpose($proxyable_url_set, $http_method, $url)
 {
     $host = parse_url($url, PHP_URL_HOST);
     $path = rtrim(parse_url($url, PHP_URL_PATH), '/');
     $url_without_protocol = $host . $path;
     UBLogger::debug_var('get_url_purpose $host', $host);
     UBLogger::debug_var('get_url_purpose $path', $path);
     UBLogger::debug_var('get_url_purpose $url_without_protocol', $url_without_protocol);
     if ($http_method == 'GET' && $path == '/_ubhc') {
         return 'HealthCheck';
     } elseif ($http_method == "POST" && preg_match("/^\\/(fsn|fsg|fs)\\/?\$/", $path)) {
         return "SubmitLead";
     } elseif ($http_method == "GET" && UBHTTP::is_tracking_link($proxyable_url_set, $url_without_protocol)) {
         return "TrackClick";
     } elseif (($http_method == "GET" || $http_method == "POST") && (in_array($url_without_protocol, $proxyable_url_set) || UBHTTP::is_confirmation_dialog($proxyable_url_set, $url_without_protocol) || UBHTTP::is_lightbox($proxyable_url_set, $url_without_protocol) || UBHTTP::is_variant($proxyable_url_set, $url_without_protocol))) {
         return "ViewLandingPage";
     } else {
         if ($http_method == "GET" && $path == UBHTTP::$pie_htc_url) {
             // proxy PIE.htc
             return "ViewLandingPage";
         } else {
             return null;
         }
     }
 }
        if (!defined('DONOTCACHEOBJECT')) {
            define('DONOTCACHEOBJECT', true);
        }
        UBLogger::debug("perform ''" . $url_purpose . "'' on received URL " . $current_url);
        $cookies_to_forward = UBUtil::array_select_by_key($_COOKIE, array('ubvs', 'ubpv', 'ubvt'));
        $cookie_string = UBHTTP::cookie_string_from_array($cookies_to_forward);
        $req_headers = $referer == null ? array('Host: ' . $domain) : array('Referer: ' . $referer, 'Host: ' . $domain);
        // Make sure we don't get cached by Wordpress hosts like WPEngine
        header('Cache-Control: max-age=0; private');
        list($success, $message) = UBHTTP::stream_request($http_method, $raw_url, $cookie_string, $req_headers, $user_agent);
        if ($success === false) {
            update_option(UBConfig::UB_PROXY_ERROR_MESSAGE_KEY, $message);
        }
        $end = microtime(true);
        $time_taken = ($end - $start) * 1000;
        UBLogger::debug_var('time_taken', $time_taken);
        UBLogger::debug("proxying for {$current_url} done successfuly -- took {$time_taken} ms");
        exit(0);
    }
}, UBConfig::int_min());
add_action('admin_init', function () {
    UBUtil::clear_flash();
    # Disable incompatible scripts
    # WPML
    wp_dequeue_script('installer-admin');
    # Enqueue our own scripts
    # Main page
    wp_enqueue_script('ub-rx', plugins_url('js/rx.lite.compat.min.js', __FILE__));
    wp_enqueue_script('set-unbounce-domains-js', plugins_url('js/set-unbounce-domains.js', __FILE__), array('jquery', 'ub-rx'));
    wp_enqueue_script('unbounce-page-js', plugins_url('js/unbounce-page.js', __FILE__), array('jquery'));
    # Diagnostics page