diff options
Diffstat (limited to '')
-rw-r--r-- | include/config_default.inc.php | 3 | ||||
-rw-r--r-- | include/functions.inc.php | 51 | ||||
-rw-r--r-- | include/functions_html.inc.php | 4 |
3 files changed, 54 insertions, 4 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 1f572fe91..a2a06ab75 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -240,6 +240,9 @@ $conf['check_upgrade_feed'] = true; // rate_items: available rates for a picture $conf['rate_items'] = array(0,1,2,3,4,5); +// Define default method to use ('http' or 'html' in order to do redirect) +$conf['default_redirect_method'] = 'http'; + // +-----------------------------------------------------------------------+ // | metadata | // +-----------------------------------------------------------------------+ diff --git a/include/functions.inc.php b/include/functions.inc.php index bfa7ad28f..e62960ad2 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -600,7 +600,28 @@ function pwg_debug( $string ) } /** - * Redirects to the given URL + * Redirects to the given URL (HTTP method) + * + * Note : once this function called, the execution doesn't go further + * (presence of an exit() instruction. + * + * @param string $url + * @return void + */ +function redirect_http( $url ) +{ + if (ob_get_length () !== FALSE) + { + ob_clean(); + } + header('Request-URI: '.$url); + header('Content-Location: '.$url); + header('Location: '.$url); + exit(); +} + +/** + * Redirects to the given URL (HTML method) * * Note : once this function called, the execution doesn't go further * (presence of an exit() instruction. @@ -610,7 +631,7 @@ function pwg_debug( $string ) * @param integer $refreh_time * @return void */ -function redirect( $url , $msg = '', $refresh_time = 0) +function redirect_html( $url , $msg = '', $refresh_time = 0) { global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug; @@ -653,6 +674,32 @@ function redirect( $url , $msg = '', $refresh_time = 0) } /** + * Redirects to the given URL (Switch to HTTP method or HTML method) + * + * Note : once this function called, the execution doesn't go further + * (presence of an exit() instruction. + * + * @param string $url + * @param string $title_msg + * @param integer $refreh_time + * @return void + */ +function redirect( $url , $msg = '', $refresh_time = 0) +{ + global $conf; + + // with RefeshTime <> 0, only html must be used + if (($conf['default_redirect_method'] == 'http') and ($refresh_time == 0)) + { + redirect_http($url); + } + else + { + redirect_html($url, $msg, $refresh_time); + } +} + +/** * returns $_SERVER['QUERY_STRING'] whitout keys given in parameters * * @param array $rejects diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index d39a4cf09..f3ad7f700 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -609,7 +609,7 @@ function access_denied() else { set_status_header(401); - redirect($login_url); + redirect_html($login_url); } } @@ -623,7 +623,7 @@ function page_not_found($msg, $alternate_url=null) set_status_header(404); if ($alternate_url==null) $alternate_url = make_index_url(); - redirect( $alternate_url, + redirect_html( $alternate_url, '<div style="text-align:left; margin-left:5em;margin-bottom:5em;"> <h1 style="text-align:left; font-size:36px;">Page not found</h1><br/>' .$msg.'</div>', |