Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Correctly reload or redirect upon Ajax requests (see #5647)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Apr 18, 2013
1 parent dad0c20 commit 708fd9c
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions contao/library/Contao/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,13 @@ public static function reload()
// Ajax request
if (\Environment::get('isAjaxRequest'))
{
echo $strLocation;
exit;
echo '<script>location.replace("' . $strLocation . '")</script>';
}

if (headers_sent())
elseif (!headers_sent())
{
exit;
header('Location: ' . $strLocation);
}

header('Location: ' . $strLocation);
exit;
}

Expand All @@ -240,39 +237,42 @@ public static function redirect($strLocation, $intStatus=303)
// Ajax request
if (\Environment::get('isAjaxRequest'))
{
echo $strLocation;
exit;
}

if (headers_sent())
{
exit;
if (preg_match('@^https?://@i', $strLocation))
{
echo '<script>location.replace("' . $strLocation . '")</script>';
}
else
{
echo '<script>location.replace("' . \Environment::get('base') . $strLocation . '")</script>';
}
}

// Header
switch ($intStatus)
elseif (!headers_sent())
{
case 301:
header('HTTP/1.1 301 Moved Permanently');
break;
// Header
switch ($intStatus)
{
case 301:
header('HTTP/1.1 301 Moved Permanently');
break;

case 302:
header('HTTP/1.1 302 Found');
break;
case 302:
header('HTTP/1.1 302 Found');
break;

case 303:
header('HTTP/1.1 303 See Other');
break;
}
case 303:
header('HTTP/1.1 303 See Other');
break;
}

// Check the target address
if (preg_match('@^https?://@i', $strLocation))
{
header('Location: ' . $strLocation);
}
else
{
header('Location: ' . \Environment::get('base') . $strLocation);
// Check the target address
if (preg_match('@^https?://@i', $strLocation))
{
header('Location: ' . $strLocation);
}
else
{
header('Location: ' . \Environment::get('base') . $strLocation);
}
}

exit;
Expand Down

0 comments on commit 708fd9c

Please sign in to comment.