public static function upload_logs_to_unbounce($url)
 {
     if (UBConfig::remote_debug_logging_enabled()) {
         $data = array('messages' => $GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME], 'vars' => $GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME . '-vars']);
         UBHTTP::send_event_to_events_gateway($url, UBEvents::log_event($data));
     }
 }
Example #2
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;
         }
     }
 }
add_action('admin_post_set_unbounce_domains', function () {
    $domains_list = UBUtil::array_fetch($_POST, 'domains', '');
    $domains = array_filter(explode(',', $domains_list), function ($domain) {
        return $domain == UBConfig::domain();
    });
    if ($domains && is_array($domains)) {
        $authorization = 'success';
        $has_authorized = get_option(UBConfig::UB_HAS_AUTHORIZED_KEY, false);
        $data = array('domain_name' => UBConfig::domain(), 'first_authorization' => !$has_authorized, 'user_id' => UBUtil::array_fetch($_POST, 'user_id', ''), 'client_id' => UBUtil::array_fetch($_POST, 'client_id', ''), 'domain_id' => UBUtil::array_fetch($_POST, 'domain_id', ''));
        UBConfig::update_authorization_options($domains, $data);
        if (UBConfig::is_authorized_domain(UBConfig::domain())) {
            $event = UBEvents::successful_authorization_event($data);
        } else {
            $event = UBEvents::failed_authorization_event($data);
        }
        UBHTTP::send_event_to_events_gateway(UBConfig::remote_events_url(), $event);
    } else {
        $authorization = 'failure';
    }
    UBUtil::set_flash('authorization', $authorization);
    status_header(301);
    $location = admin_url('admin.php?page=unbounce-pages');
    header("Location: {$location}");
});
add_action('admin_post_flush_unbounce_pages', function () {
    $domain = UBConfig::domain();
    // Expire cache and redirect
    $_domain_info = UBConfig::read_unbounce_domain_info($domain, true);
    status_header(301);
    $location = admin_url('admin.php?page=unbounce-pages');
    header("Location: {$location}");