CVS: spip_gen spip_loader.php3,1.5,1.6

Update of /home/spip-cvs/spip_gen
In directory miel:/tmp/cvs-serv3812

Modified Files:
  spip_loader.php3
Log Message:
bug www.spip.net

Index: spip_loader.php3

RCS file: /home/spip-cvs/spip_gen/spip_loader.php3,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- spip_loader.php3 2 Sep 2002 21:21:36 -0000 1.5
+++ spip_loader.php3 25 Sep 2003 16:54:28 -0000 1.6
@@ -29,7 +29,7 @@
             }
     }
   }
-
+
   feed_globals('HTTP_GET_VARS');
   feed_globals('HTTP_POST_VARS');
   feed_globals('HTTP_COOKIE_VARS');
@@ -40,7 +40,7 @@
function debut_html($titre = "Installation du système de publication...") {
   ?>
   <HTML>
-
+
   <HTML>
   <HEAD>
   <TITLE><?php echo $titre; ?></TITLE>
@@ -48,8 +48,8 @@
   <META HTTP-EQUIV="cache-control" CONTENT="no-cache,no-store">
   <META HTTP-EQUIV="pragma" CONTENT="no-cache">
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
-
-
+
+
   <style>
   <!--
     a {text-decoration: none; }
@@ -62,15 +62,15 @@
   -->
   </style>
   </HEAD>
-
+
   <body bgcolor="#FFFFFF" text="#000000" link="#E86519" vlink="#6E003A" alink="#FF9900" TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
-
+
   <BR><BR><BR>
   <CENTER>
   <TABLE WIDTH=450>
   <TR><TD WIDTH=450>
   <FONT FACE="Verdana,Arial,Helvetica,sans-serif" SIZE=4 COLOR="#970038"><B><?php
- echo $titre;
+ echo $titre;
   ?></B></FONT>
   <FONT FACE="Georgia,Garamond,Times,serif" SIZE=3>
   <?php
@@ -114,9 +114,6 @@
// modifiable par le webmestre (squelettes, etc)

function test_fichier_config($fichier) {
- // Squelettes
-// if (ereg("^[^/]*\.html$", $fichier)) return true;
-
   // Fichiers graphiques modifiables (racine du site)
   if (ereg("^[^/]*\.(gif|jpe?g|png)$", $fichier)) return true;

@@ -145,10 +142,8 @@
     if (!$n) {
       @mkdir($chemin, 0777);
       @chmod($chemin, 0777);
-// echo "<li><font color='blue'>$fichier</font>";
     }
     else {
-// echo "<li>$fichier";
       $bin = $_fread($f, $n);
       if (!(test_fichier_config($fichier) AND file_exists($chemin))) {
         $dest = fopen($chemin, "wb");
@@ -166,15 +161,7 @@
// Verifier si la ZLib est utilisable
//

-$php_version = explode('.', phpversion());
-$php_version_maj = (int) $php_version[0];
-$php_version_med = (int) $php_version[1];
-if (ereg('([0-9]+)', $php_version[2], $match)) $php_version_min = (int) $match[1];
-
-$flag_function_exists = ($php_version_maj > 3 OR $php_version_min >= 7);
-if ($flag_function_exists) $gz = function_exists("gzopen");
-else $gz = false;
-
+$gz = function_exists("gzopen");
if ($gz) {
   $_fwrite = gzwrite;
   $_fread = gzread;
@@ -277,17 +264,39 @@

$fichier = ".spip.bin";
if ($gz) $fichier .= ".gz";
+$url = "http://www.spip.net/spip-dev/DISTRIB/$fichier";

// Tenter un chargement direct par fopen
-$http = @fopen("http://rezo.net/spip-dev/DISTRIB/$fichier", "rb");
+$http = @fopen($url, "rb");
if (!$http) {
   // En cas d'echec faire la requete HTTP a la main
- $http = @fsockopen("rezo.net", 80);
- @fputs($http, "GET /spip-dev/DISTRIB/$fichier HTTP/1.1\nHost: rezo.net\n\n");
- // Passer les en-tetes (termines par une ligne vide)
- while (!feof($http)) {
- $s = fgets($http, 16384);
- if (!trim($s)) break;
+ for ($i = 0; $i < 5; $i++) {
+ $t = parse_url($url);
+ $host = $t['host'];
+ if (!($port = $t['port'])) $port = 80;
+ if (!($path = $t['path'])) $path = "/";
+
+ $http = @fsockopen($host, $port);
+ if (!$http) break;
+ @fputs($http, "GET $path HTTP/1.1\nHost: $host\n\n");
+
+ $status = 0;
+ $location = '';
+
+ // Passer les en-tetes (termines par une ligne vide)
+ $s = trim(fgets($http, 16384));
+ if (ereg('^HTTP/[0-9]+\.[0-9]+ ([0-9]+)', $s, $r)) $status = $r[1];
+ while ($s = trim(fgets($http, 16384))) {
+ if (ereg('^Location: (.*)', $s, $r)) {
+ $location = $r[1];
+ }
+ }
+ if ($status != 200) {
+ fclose($http);
+ unset($http);
+ }
+ if ($status >= 300 AND $status < 400 AND $location) $url = $location;
+ else break;
   }
}

@@ -308,4 +317,4 @@

die ("<h4>Le chargement a &eacute;chou&eacute;. Veuillez r&eacute;essayer, ou utiliser l'installation manuelle.</h4>");

-?>
\ No newline at end of file
+?>