<?php

namespace Extension\KonnektiveUtilPack;

require_once sprintf('%s%svendor%sautoload.php', dirname(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);

use Application\Request;

$postData = Request::form()->all();

$AJAX_PATH = isNginxServer() ? 'ajax.php?route=/' : 'ajax.php/';

$redirectionLink = Request::getOfferUrl() . $AJAX_PATH . 'extensions/konnektiveutilpack/paypal-commerce-response?' . http_build_query($postData);

header('Location: ' . $redirectionLink);
exit;

function isNginxServer()
{
    return preg_match('/nginx/i', Request::server()->get('SERVER_SOFTWARE'));
}
