Line 9... |
Line 9... |
9 |
// (c)miho2007 / www.mlab.cz |
9 |
// (c)miho2007 / www.mlab.cz |
10 |
|
10 |
|
11 |
|
11 |
|
12 |
// Clear variables |
12 |
// Clear variables |
13 |
unset($Redirect); |
13 |
unset($Redirect); |
- |
|
14 |
unset($RedirectUpper); |
14 |
unset($RedirectToPage); |
15 |
unset($RedirectToPage); |
15 |
unset($Lang); |
16 |
unset($Lang); |
16 |
|
17 |
|
17 |
// Include redirect definitions (as an array) |
18 |
// Include redirect definitions (as an array) |
18 |
include_once("DirectLink.inc"); |
19 |
include_once("DirectLink.inc"); |
19 |
|
20 |
|
20 |
// Do all upcase |
21 |
// Do all upcase |
21 |
foreach($Redirect as $Key => $Value) |
22 |
foreach($Redirect as $Key => $Value) |
22 |
{ |
23 |
{ |
23 |
$RedirectNew[strtoupper($Key)]=$Value; |
24 |
$RedirectUpper[strtoupper($Key)]=$Value; |
24 |
} |
25 |
} |
25 |
$Redirect=$RedirectNew; |
- |
|
26 |
unset($RedirectNew); |
- |
|
27 |
|
26 |
|
28 |
// Process language |
27 |
// Process language |
29 |
$Lang=$_SERVER[SCRIPT_FILENAME]; |
28 |
$Lang=$_SERVER[SCRIPT_FILENAME]; |
30 |
$Lang=preg_replace("/(?:.+)\.(.+)\.(.*)/i","$1",$Lang); |
29 |
$Lang=preg_replace("/(?:.+)\.(.+)\.(.*)/i","$1",$Lang); |
31 |
if ($Lang==$_SERVER[SCRIPT_FILENAME]) $Lang=""; |
30 |
if ($Lang==$_SERVER[SCRIPT_FILENAME]) $Lang=""; |
32 |
|
31 |
|
33 |
// Find redirect |
32 |
// Find redirect |
34 |
$RedirectToPage=$Redirect[strtoupper(urldecode($_SERVER[QUERY_STRING]))]; |
33 |
$RedirectToPage=$RedirectUpper[strtoupper(urldecode($_SERVER[QUERY_STRING]))]; |
35 |
|
34 |
|
36 |
// If not found -> list all posibilities |
35 |
// If not found -> list all posibilities |
37 |
if ($RedirectToPage=="") |
36 |
if ($RedirectToPage=="") |
38 |
{ |
37 |
{ |
- |
|
38 |
// File Name |
- |
|
39 |
if ($Lang=="") |
- |
|
40 |
$Lang="en"; |
- |
|
41 |
$FileName="DirectLink.$Lang.tmpl"; |
- |
|
42 |
// Read Template |
- |
|
43 |
$Template=@file($FileName); |
- |
|
44 |
// Trim Lines |
- |
|
45 |
if ($Template<>FALSE) |
- |
|
46 |
{ |
39 |
$RedirectToPage="/"; // DOPSAT |
47 |
foreach($Template as $Key => $Line) |
- |
|
48 |
{ |
- |
|
49 |
$Template[$Key]=rtrim($Line); |
- |
|
50 |
} |
- |
|
51 |
$Template=implode("\n",$Template); |
- |
|
52 |
} |
40 |
// VYPIS a KONEC |
53 |
// Generate List |
- |
|
54 |
$Table =""; |
- |
|
55 |
$Table.="<table>\n"; |
- |
|
56 |
$Table.=" <tr>\n"; |
- |
|
57 |
$Table.=" <th> Direct Link </th>\n"; |
- |
|
58 |
$Table.=" <th> Redirected to </th>\n"; |
- |
|
59 |
$Table.=" </tr>\n"; |
- |
|
60 |
foreach($Redirect as $Key => $Value) |
- |
|
61 |
{ |
- |
|
62 |
$Table.=" <tr>\n"; |
- |
|
63 |
$Table.=" <td> $Key </td>\n"; |
- |
|
64 |
$Table.=" <td> $Value </td>\n"; |
- |
|
65 |
$Table.=" </tr>\n"; |
- |
|
66 |
} |
- |
|
67 |
$Table.="<table>\n"; |
- |
|
68 |
// Put it into Template |
- |
|
69 |
if ($Template<>"") |
- |
|
70 |
print str_ireplace("<<Table>>", $Table, $Template); |
- |
|
71 |
else |
- |
|
72 |
print $Table; |
- |
|
73 |
// Finished |
- |
|
74 |
return 0; |
41 |
} |
75 |
} |
42 |
else |
76 |
else |
43 |
{ |
77 |
{ |
44 |
if ($Lang<>"") |
78 |
if ($Lang<>"") |
45 |
if (file_exists($RedirectToPage.".".$Lang.".html")) |
79 |
if (file_exists($_SERVER["DOCUMENT_ROOT"].$RedirectToPage.".".$Lang.".html")) |
46 |
$RedirectToPage.=".".$Lang.".html"; |
80 |
$RedirectToPage.=".".$Lang.".html"; |
47 |
// DOPSAT - zkusit ENG/CZE verzi |
- |
|
48 |
} |
81 |
} |
49 |
|
82 |
|
50 |
// Redirect page |
83 |
// Redirect page |
51 |
header("HTTP/1.1 301 Moved Permanently"); |
84 |
header("HTTP/1.1 301 Moved Permanently"); |
52 |
header("Location: ".$RedirectToPage); |
85 |
header("Location: ".$RedirectToPage); |