[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/inc/ -> headers.php (source)

   1  <?php
   2  
   3  /***************************************************************************\
   4   *  SPIP, Systeme de publication pour l'internet                           *
   5   *                                                                         *
   6   *  Copyright (c) 2001-2007                                                *
   7   *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
   8   *                                                                         *
   9   *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  10   *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  11  \***************************************************************************/
  12  
  13  
  14  if (!defined("_ECRIRE_INC_VERSION")) return;
  15  
  16  // envoyer le navigateur sur une nouvelle adresse
  17  // en evitant les attaques par la redirection (souvent indique par 1 $_GET)
  18  
  19  // http://doc.spip.org/@redirige_par_entete
  20  function redirige_par_entete($url, $equiv='') {
  21  
  22      $url = strtr($url, "\n\r", "  ");
  23      # en theorie on devrait faire ca tout le temps, mais quand la chaine
  24      # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
  25      if ($url[0]=='?')
  26          $url = url_de_base().$url;
  27  
  28      if ($x = _request('transformer_xml'))
  29          $url = parametre_url($url, 'transformer_xml', $x, '&');
  30      // Il n'y a que sous Apache que setcookie puis redirection fonctionne
  31  
  32      if (!$equiv OR ereg("^Apache", $GLOBALS['SERVER_SOFTWARE'])) {
  33          @header("Location: " . $url);
  34      } else {
  35          @header("Refresh: 0; url=" . $url);
  36          $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
  37      }
  38      include_spip('inc/lang');
  39      echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
  40        html_lang_attributes(),'
  41  <head>',
  42        $equiv,'
  43  <title>HTTP 302</title>
  44  </head>
  45  <body>
  46  <h1>HTTP 302</h1>
  47  <a href="',
  48        quote_amp($url),
  49        '">',
  50        _T('navigateur_pas_redirige'),
  51        '</a></body></html>';
  52  
  53      spip_log("redirige: $url");
  54  
  55      exit;
  56  }
  57  
  58  // http://doc.spip.org/@http_status
  59  function http_status($status) {
  60      global $REDIRECT_STATUS, $flag_sapi_name;
  61      static $status_string = array(
  62          200 => '200 OK',
  63          301 => '301 Moved Permanently',
  64          302 => '302 Found',
  65          304 => '304 Not Modified',
  66          401 => '401 Unauthorized',
  67          403 => '403 Forbidden',
  68          404 => '404 Not Found'
  69      );
  70  
  71      if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
  72  
  73      $php_cgi = ($flag_sapi_name AND eregi("cgi", @php_sapi_name()));
  74      if ($php_cgi)
  75          header("Status: ".$status_string[$status]);
  76      else
  77          header("HTTP/1.0 ".$status_string[$status]);
  78  }
  79  
  80  // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
  81  // http://doc.spip.org/@http_no_cache
  82  function http_no_cache() {
  83      if (headers_sent()) return;
  84      if (!$charset = $GLOBALS['meta']['charset']) $charset = 'utf-8';
  85  
  86      // selon http://developer.apple.com/internet/safari/faq.html#anchor5
  87      // il faudrait aussi pour Safari
  88      // header("Cache-Control: post-check=0, pre-check=0", false)
  89      // mais ca ne respecte pas
  90      // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
  91  
  92      header("Content-Type: text/html; charset=$charset");
  93      header("Expires: 0");
  94      header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
  95      header("Cache-Control: no-store, no-cache, must-revalidate");
  96      header("Pragma: no-cache");
  97  }
  98  
  99  
 100  // envoi de l'image demandee dans le code ci-dessus
 101  // http://doc.spip.org/@envoie_image_vide
 102  function envoie_image_vide() {
 103      $image = pack("H*", "47494638396118001800800000ffffff00000021f90401000000002c0000000018001800000216848fa9cbed0fa39cb4da8bb3debcfb0f86e248965301003b");
 104      header("Content-Type: image/gif");
 105      header("Content-Length: ".strlen($image));
 106      header("Cache-Control: no-cache,no-store");
 107      header("Pragma: no-cache");
 108      header("Connection: close");
 109      echo $image;
 110      flush();
 111  }
 112  
 113  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics