Changeset 1649


Ignore:
Timestamp:
Dec 11, 2006, 7:04:53 AM (17 years ago)
Author:
rub
Message:

Feature Issue ID 0000602: Redirect must be done by html or http

Redirect it's only done by the html method but must be done too with http method.
Creation of two functions redirect_http and redirect_html.
Function redirect calls one or other functions follow $conf or parameters.

$conf value are true on BSF, in order to check modifications.
Must be set to false on RC.

Location:
trunk/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/config_default.inc.php

    r1642 r1649  
    241241$conf['rate_items'] = array(0,1,2,3,4,5);
    242242
     243// Define default method to use ('http' or 'html' in order to do redirect)
     244$conf['default_redirect_method'] = 'http';
     245
    243246// +-----------------------------------------------------------------------+
    244247// |                               metadata                                |
  • trunk/include/functions.inc.php

    r1637 r1649  
    601601
    602602/**
    603  * Redirects to the given URL
     603 * Redirects to the given URL (HTTP method)
     604 *
     605 * Note : once this function called, the execution doesn't go further
     606 * (presence of an exit() instruction.
     607 *
     608 * @param string $url
     609 * @return void
     610 */
     611function redirect_http( $url )
     612{
     613  if (ob_get_length () !== FALSE)
     614  {
     615    ob_clean();
     616  }
     617  header('Request-URI: '.$url);
     618  header('Content-Location: '.$url);
     619  header('Location: '.$url);
     620  exit();
     621}
     622
     623/**
     624 * Redirects to the given URL (HTML method)
    604625 *
    605626 * Note : once this function called, the execution doesn't go further
     
    611632 * @return void
    612633 */
    613 function redirect( $url , $msg = '', $refresh_time = 0)
     634function redirect_html( $url , $msg = '', $refresh_time = 0)
    614635{
    615636  global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
     
    651672
    652673  exit();
     674}
     675
     676/**
     677 * Redirects to the given URL (Switch to HTTP method or HTML method)
     678 *
     679 * Note : once this function called, the execution doesn't go further
     680 * (presence of an exit() instruction.
     681 *
     682 * @param string $url
     683 * @param string $title_msg
     684 * @param integer $refreh_time
     685 * @return void
     686 */
     687function redirect( $url , $msg = '', $refresh_time = 0)
     688{
     689  global $conf;
     690
     691  // with RefeshTime <> 0, only html must be used
     692  if (($conf['default_redirect_method'] == 'http') and ($refresh_time == 0))
     693  {
     694    redirect_http($url);
     695  }
     696  else
     697  {
     698    redirect_html($url, $msg, $refresh_time);
     699  }
    653700}
    654701
  • trunk/include/functions_html.inc.php

    r1643 r1649  
    610610  {
    611611    set_status_header(401);
    612     redirect($login_url);
     612    redirect_html($login_url);
    613613  }
    614614}
     
    624624  if ($alternate_url==null)
    625625    $alternate_url = make_index_url();
    626   redirect( $alternate_url,
     626  redirect_html( $alternate_url,
    627627    '<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
    628628<h1 style="text-align:left; font-size:36px;">Page not found</h1><br/>'
Note: See TracChangeset for help on using the changeset viewer.