Welcome to mirror list, hosted at ThFree Co, Russian Federation.

redirector.php « resources « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 160f24508d886f02f7485675ac94519658fde5ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

/**
 * Script used to test redirects. If no redirect is left, the script will simply output the current url
 */

$redirect = $_GET['redirects'] ?? 0;
$target = $_GET['target'] ?? '';

$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
        "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
    $_SERVER['REQUEST_URI'];

if ($target) {
    header('HTTP/1.1 302 Found');
    header('Location: ' . $target);
    exit;
}

if ($redirect > 0) {
    header('HTTP/1.1 302 Found');
    header('Location: ' . preg_replace('/(redirects=[0-9]+)/', 'redirects=' . ($redirect-1), $url));
    exit;
}

echo $url;