46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
//Get parameters
|
||
|
|
$parameters = $_SERVER['REQUEST_URI'];
|
||
|
|
$regex = '/^\/winapp\/((\w{2})\/)?([\w-]+)\/(\d{4})\/?$/m';
|
||
|
|
preg_match_all($regex, $parameters, $matches, PREG_SET_ORDER, 0);
|
||
|
|
|
||
|
|
$isOK = true;
|
||
|
|
|
||
|
|
if (sizeof($matches) === 1 && sizeof($matches[0]) === 5) {
|
||
|
|
//Init parameters
|
||
|
|
$lang = $matches[0][2];
|
||
|
|
$product = $matches[0][3];
|
||
|
|
$year = $matches[0][4];
|
||
|
|
|
||
|
|
$acceptLang = ['bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr',
|
||
|
|
'ga', 'hr', 'hu', 'it', 'lt', 'lv', 'mt', 'pl', 'ro', 'sk',
|
||
|
|
'sl', 'sv'];
|
||
|
|
|
||
|
|
if ($lang != null) {
|
||
|
|
$isOK = in_array($lang, $acceptLang);
|
||
|
|
} else {
|
||
|
|
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($isOK) {
|
||
|
|
require 'core/core.php';
|
||
|
|
$lang = in_array($lang, $acceptLang) ? $lang : 'en';
|
||
|
|
$isOK = file_exists(dirname(__FILE__) . "/" . $data_path);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
$isOK = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$isOK) {
|
||
|
|
http_response_code(404);
|
||
|
|
require '404.html';
|
||
|
|
} else {
|
||
|
|
require 'core/layout.php';
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
?>
|
||
|
|
|