aboutsummaryrefslogtreecommitdiffstats
path: root/index.php
blob: c42a17151a0cededf5151b0bfb6b7d8a5b9794c3 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
 *
*/

require_once 'langs.inc.php';

// NOTE, this should go to the main controller in the next platform
// (catching all requests)
$domain     = 'hiebel.eu';
$www_domain = '' . $domain;

if (G_VHOST == $domain) {
    // rewrite "//mageia.org/" to "//www.mageia.org/"
    header ('HTTP/1.1 301 Moved Permanently');
    header(sprintf('Location: %s://%s%s', 'https', $www_domain, $_SERVER['REQUEST_URI']));
    die;
}
elseif (isset($_GET['fromtld'])) {
    // rewrite "//mageia.org/?fromtld=it" to "//www.mageia.org/it/"
    tld_redirect($_GET['fromtld'], $domains_lang, $www_domain);
}
elseif (isset($_SERVER['APP_MODE']) && $_SERVER['APP_MODE'] !== 'prod') {
    // don't change domain in developer mode
    header(sprintf('Location: //%s%s', $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']));
    die;
}
elseif (G_VHOST != $www_domain) {
    // rewrite "//mageia.it/" to "//www.mageia.org/it/"
    domain_redirect($_SERVER['SERVER_NAME'], $domains_lang, $www_domain);
}

if (isset($_GET['langs'])) {
    die(show_langs($langs));
}

if (isset($_GET['flang']))
{
    $lang = array_key_exists($_GET['flang'], $langs) ? $_GET['flang'] : 'en';
    if (isset($_GET['furl']))
    {
        $url = explode('/', $_GET['furl']);
        array_shift($url);
        array_shift($url);
        $url = '/' . $lang . '/' . implode($url, '/');
        //$url = substr_replace($_GET['furl'], $lang, 1, 2);
    }
    else
        $url = '/' . $lang . '/';

    header(sprintf('Location: %s', $url));
    die;
}

relocate($langs);