Changeset 405


Ignore:
Timestamp:
Mar 31, 2004, 10:43:09 PM (21 years ago)
Author:
z0rglub
Message:

redirections modification : use of a HTML refresh page instead of header PHP
function. The purpose is to avoid redirections failure when extra characters
are found in included PHP files.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r403 r405  
    3737  setcookie( 'id', '', 0, cookie_path() );
    3838  $url = 'category.php';
    39   header( 'Request-URI: '.$url ); 
    40   header( 'Content-Location: '.$url ); 
    41   header( 'Location: '.$url );
    42   exit();
     39  redirect( $url );
    4340}
    4441//-------------------------------------------------- access authorization check
  • trunk/identification.php

    r404 r405  
    4343    $session_id = session_create( $_POST['username'] );
    4444    $url = 'category.php?id='.$session_id;
    45     header( 'Request-URI: '.$url );
    46     header( 'Content-Location: '.$url ); 
    47     header( 'Location: '.$url );
    48     exit();
     45    redirect( $url );
    4946  }
    5047  else
  • trunk/include/functions.inc.php

    r394 r405  
    2525// | USA.                                                                  |
    2626// +-----------------------------------------------------------------------+
     27
    2728include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' );
    2829include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' );
     
    463464}
    464465
     466/**
     467 * Redirects to the given URL
     468 *
     469 * Note : once this function called, the execution doesn't go further
     470 * (presence of an exit() instruction.
     471 *
     472 * @param string $url
     473 * @return void
     474 */
     475function redirect( $url )
     476{
     477  global $user, $template, $lang_info, $conf, $lang, $t2;
     478
     479  // $refresh, $url_link and $title are required for creating an automated
     480  // refresh page in header.tpl
     481  $refresh = 5;
     482  $url_link = $url;
     483  $title = 'redirection';
     484  include( PHPWG_ROOT_PATH.'include/page_header.php' );
     485 
     486  $template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
     487  $template->pparse('redirect');
     488 
     489  include( PHPWG_ROOT_PATH.'include/page_tail.php' );
     490
     491  exit();
     492}
    465493?>
  • trunk/include/page_header.php

    r398 r405  
    3131$template->set_filenames(array('header'=>'header.tpl'));
    3232
    33 $css = PHPWG_ROOT_PATH.'template/'.$user['template'].'/'.$user['template'].'.css';
    34 $template->assign_vars(array(
    35   'CONTENT_ENCODING' => $lang_info['charset'],
    36   'PAGE_TITLE' => $title,
    37   'LANG'=>$lang_info['code'],
    38   'DIR'=>$lang_info['direction'],
    39  
    40   'T_STYLE' => $css
    41   ));
     33$css = PHPWG_ROOT_PATH.'template/'.$user['template'];
     34$css.= '/'.$user['template'].'.css';
     35
     36$template->assign_vars(
     37  array(
     38    'CONTENT_ENCODING' => $lang_info['charset'],
     39    'PAGE_TITLE' => $title,
     40    'LANG'=>$lang_info['code'],
     41    'DIR'=>$lang_info['direction'],
     42   
     43    'T_STYLE' => $css
     44    ));
    4245
    4346// refresh
    44 if ( isset( $refresh ) && $refresh >0 && isset($url_link))
     47if ( isset( $refresh ) and $refresh > 0 and isset( $url_link ) )
    4548{
    46   $url = $url_link.'&slideshow='.$refresh;
    47   $template->assign_vars(array(
    48                            'REFRESH_TIME' => $refresh,
    49                            'U_REFRESH' => add_session_id( $url )
    50                            ));
     49  $template->assign_vars(
     50    array(
     51      'REFRESH_TIME' => $refresh,
     52      'U_REFRESH' => add_session_id( $url_link )
     53      ));
    5154  $template->assign_block_vars('refresh', array());
    5255}
    5356
    54 // Work around for "current" Apache 2 + PHP module which seems to not
    55 // cope with private cache control setting
    56 if (!empty( $_SERVER['SERVER_SOFTWARE'] )
    57     and strstr( $_SERVER['SERVER_SOFTWARE'], 'Apache/2'))
    58 {
    59   header( 'Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0' );
    60 }
    61 else
    62 {
    63   header( 'Cache-Control: private, pre-check=0, post-check=0, max-age=0' );
    64 }
    65 header( 'Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT' );
    66 header( 'Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT' );
    67 
    6857$template->pparse('header');
    6958?>
  • trunk/include/user.inc.php

    r397 r405  
    4646  setcookie( 'id', '', 0, cookie_path() );
    4747  $url = 'category.php';
    48   header( 'Request-URI: '.$url ); 
    49   header( 'Content-Location: '.$url ); 
    50   header( 'Location: '.$url );
    51   exit();
     48  redirect( $url );
    5249}
    5350
  • trunk/index.php

    r364 r405  
    3737// redirection
    3838$url.= '.php';
    39 header( 'Request-URI: '.$url ); 
    40 header( 'Content-Location: '.$url ); 
    41 header( 'Location: '.$url );
    42 exit();
     39redirect( $url );
    4340?>
  • trunk/install.php

    r400 r405  
    181181// Is phpBB already installed? Yes? Redirect to the index
    182182if (defined("PHPWG_INSTALLED"))
    183 
    184   header( 'Location: index.php' );
    185   exit;
     183{
     184  die( 'PhpWebGallery is already installed' );
    186185}
    187186
  • trunk/picture.php

    r402 r405  
    181181      // category page
    182182      $url = add_session_id( $url_home );
    183       header( 'Request-URI: '.$url );
    184       header( 'Content-Location: '.$url ); 
    185       header( 'Location: '.$url );
    186       exit();
     183      redirect( $url );
    187184    }
    188185    else if ( $prev < 0 )
     
    196193      $url = add_session_id( $url, true);
    197194    }
    198     header( 'Request-URI: '.$url );
    199     header( 'Content-Location: '.$url ); 
    200     header( 'Location: '.$url );
    201     exit();
     195    redirect( $url );
    202196  }
    203197}
     
    297291{
    298292  $refresh= $_GET['slideshow'];
    299   $url_link = $picture['next']['url'];
     293  $url_link = $picture['next']['url'].'&amp;slideshow='.$refresh;
    300294}
    301295
  • trunk/profile.php

    r393 r405  
    121121    $url = 'category.php';
    122122    if ( !isset($_POST['create_cookie']) ) $url = add_session_id( $url,true );
    123     header( 'Request-URI: '.$url ); 
    124     header( 'Content-Location: '.$url ); 
    125     header( 'Location: '.$url );
    126     exit();
     123    redirect( $url );
    127124  }
    128125}
  • trunk/register.php

    r393 r405  
    4545    $session_id = session_create( $_POST['login'] );
    4646    $url = 'category.php?id='.$session_id;
    47     header( 'Request-URI: '.$url );
    48     header( 'Content-Location: '.$url ); 
    49     header( 'Location: '.$url );
    50     exit();
     47    redirect( $url );
    5148  }
    5249}
  • trunk/search.php

    r393 r405  
    5656    $url = 'category.php?cat=search&search='.$search.'&mode='.$_POST['mode'];
    5757    $url = add_session_id( $url, true );
    58     header( 'Request-URI: '.$url );
    59     header( 'Content-Location: '.$url ); 
    60     header( 'Location: '.$url );
    61     exit();
     58    redirect( $url );
    6259  }
    6360}
Note: See TracChangeset for help on using the changeset viewer.