| version 1.1, 2002/11/26 15:56:42 |
version 1.2, 2002/11/27 22:25:39 |
|
|
| */ |
*/ |
| function redirect_test($file, $url) /* {{{ */ |
function redirect_test($file, $url) /* {{{ */ |
| { |
{ |
| global $PHP_SELF; |
global $HTTP_SERVER_VARS; |
| if (eregi($file, $PHP_SELF)) { |
if (! isset($HTTP_SERVER_VARS['PHP_SELF']) |
| return true; |
|| ! eregi($file, $HTTP_SERVER_VARS['PHP_SELF'])) { |
| } |
return true; |
| if (strlen($url) <= 0) |
} |
| die('empty $url in redirect_test()'); |
if (strlen($url) <= 0) { |
| |
die('empty $url in redirect_test()'); |
| |
} |
| $schema = ''; |
$schema = ''; |
| if (strncmp($url, "http://", 7)) { |
if (strncmp($url, "http://", 7)) { |
| $schema = 'http'; |
$schema = 'http'; |
| } elseif (strncmp($url, "https://", 8)) { |
} elseif (strncmp($url, "https://", 8)) { |
| $schema = 'https'; |
$schema = 'https'; |
| } |
} |
| |
|
| global $HTTP_HOST; |
|
| global $SERVER_NAME; |
|
| if (strlen($schema) > 0) { |
if (strlen($schema) > 0) { |
| // TODO: create delim according to $SCRIPT_NAME |
// TODO: create delim according to $HTTP_SERVER_VARS['SCRIPT_NAME'] |
| $delim = $url[0] == '/' ? '' : '/'; |
$delim = $url[0] == '/' ? '' : '/'; |
| |
$http_host = @$HTTP_SERVER_VARS['HTTP_HOST']; |
| |
$server_name = @$HTTP_SERVER_VARS['SERVER_NAME']; |
| |
|
| if (isset($HTTP_HOST) |
if (isset($http_host) |
| && is_string($HTTP_HOST) |
&& is_string($http_host) |
| && strlen($HTTP_HOST) > 0) { |
&& strlen($http_host) > 0) { |
| $url = "$schema://$HTTP_HOST$delim$url"; |
$url = "$schema://$http_host$delim$url"; |
| } |
} elseif (isset($server_name) |
| elseif (isset($SERVER_NAME) |
&& is_string($server_name) |
| && is_string($SERVER_NAME) |
&& strlen($server_name) > 0) { |
| && strlen($SERVER_NAME) > 0) { |
$url = "$schema://$server_name$delim$url"; |
| $url = "$schema://$SERVER_NAME$delim$url"; |
|
| } |
} |
| } |
} |
| |
//echo("Location: $url [$file][".$HTTP_SERVER_VARS['PHP_SELF']."]"); |
| header("Location: $url"); |
header("Location: $url"); |
| die(); |
exit; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| /** common/misc/fnc.write_origvars_html.php - creates HTML hidden |
/** common/misc/fnc.write_origvars_html.php - creates HTML hidden |