/Web/DirectLink.php/DirectLink.php
0,0 → 1,55
<?php
 
// Process supplied parameters as direct link (link to some deep place
// in the web structure).
//
// This script is usualy called via mod_rewrite when user enter
// no page with some parameter.
//
// (c)miho2007 / www.mlab.cz
 
 
// Clear variables
unset($Redirect);
unset($RedirectToPage);
unset($Lang);
 
// Include redirect definitions (as an array)
include_once("DirectLink.inc");
 
// Do all upcase
foreach($Redirect as $Key => $Value)
{
$RedirectNew[strtoupper($Key)]=$Value;
}
$Redirect=$RedirectNew;
unset($RedirectNew);
 
// Process language
$Lang=$_SERVER[SCRIPT_FILENAME];
$Lang=preg_replace("/(?:.+)\.(.+)\.(.*)/i","$1",$Lang);
if ($Lang==$_SERVER[SCRIPT_FILENAME]) $Lang="";
 
// Find redirect
$RedirectToPage=$Redirect[strtoupper(urldecode($_SERVER[QUERY_STRING]))];
 
// If not found -> list all posibilities
if ($RedirectToPage=="")
{
$RedirectToPage="/"; // DOPSAT
// VYPIS a KONEC
}
else
{
if ($Lang<>"")
if (file_exists($RedirectToPage.".".$Lang.".html"))
$RedirectToPage.=".".$Lang.".html";
// DOPSAT - zkusit ENG/CZE verzi
}
 
// Redirect page
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".$RedirectToPage);
header("Connection: close");
 
?>