1 rocketdude Oct 21, 2007 16:02
3 rocketdude Oct 21, 2007 18:07
Yabba,
Where you able to fix the problem in inc/_misc/_misc.functions.php? If so, do you remember what the fix was?
Thanks,
RocketDude
4 yabba Oct 21, 2007 18:11
I changed the following snippet of function header_redirect() to add the baseurl to $redirect_to :
if( preg_match( '~^/~', $redirect_to ) ) $redirect_to = $baseurl.$redirect_to; // relative redirect barfs on IIS6 & php 4.x
//pre_dump( $redirect_to );
header( 'Location: '.$redirect_to, true, $status ); // explictly setting the status is required for (fast)cgi
¥
5 rocketdude Oct 21, 2007 21:35
Yabba,
I'm a little slow today javascript:emoticon(':D')
Very Happy
My function header_redirect() contains:
function header_redirect( $redirect_to = NULL, $permanent = false )
{
global $Hit, $baseurl, $Blog, $htsrv_url_sensitive;
global $Session, $Debuglog, $Messages;
if( empty($redirect_to) )
{ // see if there's a redirect_to request param given (where & is encoded as &):
$redirect_to = param( 'redirect_to', 'string', '' );
if( empty($redirect_to) )
{
if( ! empty($Hit->referer) )
{
$redirect_to = $Hit->referer;
}
elseif( isset($Blog) && is_object($Blog) )
{
$redirect_to = $Blog->get('url');
}
else
{
$redirect_to = $baseurl;
}
}
}
if( substr($redirect_to, 0, 1) == '/' )
{ // relative URL, prepend current host:
global $ReqHost;
$redirect_to = $ReqHost.$redirect_to;
}
if( strpos($redirect_to, $htsrv_url_sensitive) === 0 /* we're going somewhere on $htsrv_url_sensitive */
|| strpos($redirect_to, $baseurl) === 0 /* we're going somewhere on $baseurl */ )
{
// Remove login and pwd parameters from URL, so that they do not trigger the login screen again:
// Also remove "action" get param to avoid unwanted actions
// blueyed> Removed the removing of "action" here, as it is used to trigger certain views. Instead, "confirm(ed)?" gets removed now
// fp> which views please (important to list in order to remove asap)
// dh> sorry, don't remember
// TODO: fp> action should actually not be used to trigger views. This should be changed at some point.
$redirect_to = preg_replace( '~(?<=\?|&) (login|pwd|confirm(ed)?) = [^&]+ ~x', '', $redirect_to );
}
$status = $permanent ? 301 : 303;
$Debuglog->add('Redirecting to '.$redirect_to.' (status '.$status.')');
// Transfer of Debuglog to next page:
if( $Debuglog->count('all') )
{ // Save Debuglog into Session, so that it's available after redirect (gets loaded by Session constructor):
$sess_Debuglogs = $Session->get('Debuglogs');
if( empty($sess_Debuglogs) )
$sess_Debuglogs = array();
$sess_Debuglogs[] = $Debuglog;
$Session->set( 'Debuglogs', $sess_Debuglogs, 60 /* expire in 60 seconds */ );
}
// Transfer of Messages to next page:
if( $Messages->count('all') )
{ // Set Messages into user's session, so they get restored on the next page (after redirect):
$Session->set( 'Messages', $Messages );
}
$Session->dbsave(); // If we don't save now, we run the risk that the redirect goes faster than the PHP script shutdown.
// see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
if( $permanent )
{ // This should be a permanent move redirect!
header( 'HTTP/1.1 301 Moved Permanently' );
}
else
{ // This should be a "follow up" redirect
// Note: Also see http://de3.php.net/manual/en/function.header.php#50588 and the other comments around
header( 'HTTP/1.1 303 See Other' );
}
header( 'Location: '.$redirect_to, true, $status ); // explictly setting the status is required for (fast)cgi
exit();
}
So I'm not sure where to change the code you reference. Or am I supposed to insert
"if( preg_match( '~^/~', $redirect_to ) ) $redirect_to = $baseurl.$redirect_to; // relative redirect barfs on IIS6 & php 4.x
//pre_dump( $redirect_to );"
right before the second to last line:
"header( 'Location: '.$redirect_to, true, $status ); // explictly setting the status is required for (fast)cgi"
Thanks,
RocketDude
6 yabba Oct 22, 2007 08:54
Yep, just insert the if( preg_match() ) line and see if it helps ;)
¥
7 rocketdude Oct 25, 2007 16:31
Yabba,
Thanks for the help, but it didn't solve my problem :(
Rocketdude
Weird, I get a 404 for that url as well ;)
I did find a problem on a windows box where comment_post.php returned a 403 or summat, it was due to relative redirects in inc/_misc/_misc.functions.php
¥