531 |
miho |
1 |
<?php |
|
|
2 |
|
|
|
3 |
// Process supplied parameters as direct link (link to some deep place |
|
|
4 |
// in the web structure). |
|
|
5 |
// |
|
|
6 |
// This script is usualy called via mod_rewrite when user enter |
|
|
7 |
// no page with some parameter. |
|
|
8 |
// |
|
|
9 |
// (c)miho2007 / www.mlab.cz |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
// Clear variables |
|
|
13 |
unset($Redirect); |
|
|
14 |
unset($RedirectToPage); |
|
|
15 |
unset($Lang); |
|
|
16 |
|
|
|
17 |
// Include redirect definitions (as an array) |
|
|
18 |
include_once("DirectLink.inc"); |
|
|
19 |
|
|
|
20 |
// Do all upcase |
|
|
21 |
foreach($Redirect as $Key => $Value) |
|
|
22 |
{ |
|
|
23 |
$RedirectNew[strtoupper($Key)]=$Value; |
|
|
24 |
} |
|
|
25 |
$Redirect=$RedirectNew; |
|
|
26 |
unset($RedirectNew); |
|
|
27 |
|
|
|
28 |
// Process language |
|
|
29 |
$Lang=$_SERVER[SCRIPT_FILENAME]; |
|
|
30 |
$Lang=preg_replace("/(?:.+)\.(.+)\.(.*)/i","$1",$Lang); |
|
|
31 |
if ($Lang==$_SERVER[SCRIPT_FILENAME]) $Lang=""; |
|
|
32 |
|
|
|
33 |
// Find redirect |
|
|
34 |
$RedirectToPage=$Redirect[strtoupper(urldecode($_SERVER[QUERY_STRING]))]; |
|
|
35 |
|
|
|
36 |
// If not found -> list all posibilities |
|
|
37 |
if ($RedirectToPage=="") |
|
|
38 |
{ |
|
|
39 |
$RedirectToPage="/"; // DOPSAT |
|
|
40 |
// VYPIS a KONEC |
|
|
41 |
} |
|
|
42 |
else |
|
|
43 |
{ |
|
|
44 |
if ($Lang<>"") |
|
|
45 |
if (file_exists($RedirectToPage.".".$Lang.".html")) |
|
|
46 |
$RedirectToPage.=".".$Lang.".html"; |
|
|
47 |
// DOPSAT - zkusit ENG/CZE verzi |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
// Redirect page |
|
|
51 |
header("HTTP/1.1 301 Moved Permanently"); |
|
|
52 |
header("Location: ".$RedirectToPage); |
|
|
53 |
header("Connection: close"); |
|
|
54 |
|
|
|
55 |
?> |