Changed redirectTo to use new link-class

Signed-off-by: Florian Aders (EleRas) <eleras@froxlor.org>
This commit is contained in:
Florian Aders (EleRas)
2011-06-13 21:55:46 +02:00
parent 4d10c72ae9
commit b88246b112

View File

@@ -29,7 +29,6 @@
* *
* @author Florian Lippert <flo@syscp.org> * @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <eremit@syscp.org> * @author Martin Burchert <eremit@syscp.org>
*
* @changes martin@2005-01-29 * @changes martin@2005-01-29
* - added isRelative parameter * - added isRelative parameter
* - speed up the url generation * - speed up the url generation
@@ -40,19 +39,20 @@ function redirectTo($destination, $get_variables = array(), $isRelative = false)
{ {
$params = array(); $params = array();
$linker = new linker();
$linker->filename = $destination;
if(is_array($get_variables)) if(is_array($get_variables))
{ {
foreach($get_variables as $key => $value) foreach($get_variables as $key => $value)
{ {
$params[] = urlencode($key) . '=' . urlencode($value); $linker->add($key, $value);
} }
$params = '?' . implode($params, '&');
if($isRelative) if($isRelative)
{ {
$protocol = ''; $linker->protocol = '';
$host = ''; $linker->host = '';
$path = './'; $path = './';
} }
else else
@@ -60,15 +60,12 @@ function redirectTo($destination, $get_variables = array(), $isRelative = false)
if(isset($_SERVER['HTTPS']) if(isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS']) == 'on') && strtolower($_SERVER['HTTPS']) == 'on')
{ {
$protocol = 'https://'; $linker->protocol = 'https';
} }
else else
{ {
$protocol = 'http://'; $linker->protocol = 'http';
} }
$host = $_SERVER['HTTP_HOST'];
if(dirname($_SERVER['PHP_SELF']) == '/') if(dirname($_SERVER['PHP_SELF']) == '/')
{ {
$path = '/'; $path = '/';
@@ -77,14 +74,15 @@ function redirectTo($destination, $get_variables = array(), $isRelative = false)
{ {
$path = dirname($_SERVER['PHP_SELF']) . '/'; $path = dirname($_SERVER['PHP_SELF']) . '/';
} }
$linker->host = $_SERVER['HTTP_HOST'];
} }
$linker->filename = $path . $destination;
header('Location: ' . $protocol . $host . $path . $destination . $params); header('Location: ' . $linker->getLink());
exit; exit;
} }
elseif($get_variables == null) elseif($get_variables == null)
{ {
header('Location: ' . $destination); header('Location: ' . $linker->getLink());
exit; exit;
} }