Changeset 2876
- Timestamp:
- Nov 14, 2008, 8:55:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/auto-install/trunk/piwigo-loader.php
r2874 r2876 15 15 // +-----------------------------------------------------------------------+ 16 16 17 define('DC_LOADER_SERVICE','http:// svn.gna.org/viewcvs/*checkout*/phpwebgallery/extras/auto-install/trunk/');17 define('DC_LOADER_SERVICE','http://piwigo.free.fr/loader/'); 18 18 define('DC_LOADER_ARCHIVE','http://download.gna.org/phpwebgallery/release/2.0/candidate/phpwebgallery-2.0.0RC4.zip'); 19 19 … … 21 21 'en_UK' => 'English [UK]', 22 22 'fr_FR' => 'Français [FR]', 23 'es_ES' => 'Español [ES]', 24 'it_IT' => 'Italiano [IT]', 23 25 // 'de_DE' => 'Deutch [DE]', /* Not translated yet */ 24 'es_ES' => 'Español [ES]',25 'it_IT' => 'Italiano [IT]', /* Not translated yet */26 26 // 'nl_NL' => 'Dutch [NL]' /* Not translated yet */ 27 27 ); … … 46 46 $can_fetch = true; 47 47 } 48 if (function_exists('curl_init')) 49 { 50 $can_fetch = true; 51 define('DC_LOADER_CURL',true); 52 } 48 // TODO: possibility to use CURL function to retrieve datas 53 49 54 50 define('DC_LOADER_LANG', getLanguage()); 55 51 56 52 $step = !empty($_REQUEST['step']) ? (integer)$_REQUEST['step'] : 1; 57 $got_php5 = (strpos(PHP_VERSION,'5') === 0);53 $got_php5 = version_compare(PHP_VERSION, '5', '>='); 58 54 if (!$got_php5 && $step != 2) 59 55 { … … 74 70 return false; 75 71 } 76 72 77 73 $src = parse_url($src); 78 74 $host = $src['host']; … … 83 79 return false; 84 80 } 85 81 86 82 fwrite($s, 87 83 'GET '.$path." HTTP/1.0\r\n" … … 91 87 ."\r\n" 92 88 ); 93 89 94 90 $i = 0; 95 91 $in_content = false; … … 97 93 { 98 94 $line = fgets($s,4096); 99 95 100 96 if (rtrim($line,"\r\n") == '' && !$in_content) 101 97 { … … 104 100 continue; 105 101 } 106 107 if ($i == 0){102 if ($i == 0) 103 { 108 104 if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/',rtrim($line,"\r\n"), $m)) 109 105 { … … 118 114 } 119 115 } 120 121 116 if (!$in_content) 122 117 { … … 129 124 continue; 130 125 } 131 132 126 if (is_resource($dest)) 133 127 { … … 138 132 $dest .= $line; 139 133 } 140 141 134 $i++; 142 135 } 143 144 136 fclose($s); 145 137 return true; … … 167 159 } 168 160 } 169 170 161 // Retrieve traductions 162 $lang = array(); 171 163 if ($can_fetch and fetchRemote(DC_LOADER_SERVICE.'language/'.$language.'/loader.lang.txt', $code)) 172 164 { 173 165 @eval($code); 174 166 } 175 176 167 return $language; 177 168 } … … 196 187 $port = ($_SERVER['SERVER_PORT'] != '80') ? ':'.$_SERVER['SERVER_PORT'] : ''; 197 188 } 198 199 189 $loc = preg_replace('#/$#','',str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']))); 200 190 201 191 return $scheme.'://'.$server_name.$port.$loc.'/'; 202 192 } … … 285 275 $lib_unzip = @fopen(dirname(__FILE__).'/pwg_unzip.php','wb'); 286 276 $dc_zip = @fopen(dirname(__FILE__).'/piwigo-install.zip','wb'); 287 277 288 278 if (!$lib_files || !$lib_unzip || !$dc_zip) 289 279 { 290 280 return false; 291 281 } 292 282 293 283 if (fetchRemote(DC_LOADER_SERVICE.'lib.files.txt',$lib_files)) 294 284 { … … 301 291 } 302 292 } 303 293 304 294 fclose($lib_files); 305 295 fclose($lib_unzip); 306 296 fclose($dc_zip); 307 297 308 298 if ($failed) 309 299 { … … 320 310 return; 321 311 } 322 312 323 313 echo 324 314 '<div class="msg '.$level.'">'."\n". … … 335 325 { 336 326 echo 337 '<form action="'.$_SERVER['SCRIPT_NAME'].'?language='.DC_LOADER_LANG.'" method="post">'. 338 $more. 327 '<form action="'.$_SERVER['SCRIPT_NAME'].'?language='.DC_LOADER_LANG.'" method="post">'."\n". 328 $more."\n". 339 329 '<p class="button"><input type="hidden" name="step" value="'.$step.'" />'."\n". 340 330 '<input type="hidden" name="lang" value="'.DC_LOADER_LANG.'" />'."\n". … … 361 351 switch ($step) 362 352 { 363 case 1 : { 353 case 1 : 354 { 364 355 openPage(); 365 356 echo '<h3>'.l10n('Welcome to NetInstall!').'</h3>'."\n"; … … 379 370 '<p>'.l10n('This tool is meant to retrieve the latest Piwigo archive and unzip it in your webspace.').'<br />'."\n". 380 371 l10n('Right after then, you will be redirect to the Piwigo Setup Wizard.').'</p>'."\n"; 381 372 382 373 if (!$can_write) 383 374 { … … 409 400 break; 410 401 } 402 411 403 case 2 : 412 404 { 413 405 if (!empty($_POST['submit']) && !$got_php5) 414 406 { 415 if (($got_php5 = initPHP5())) 416 { 417 header('Location: '.$_SERVER['SCRIPT_NAME'].'?step=1'); 418 } 419 } 420 elseif ($got_php5) 421 { 422 header('Location: '.$_SERVER['SCRIPT_NAME'].'?step=1'); 407 $got_php5 = initPHP5(); 408 } 409 if ($got_php5) 410 { 411 header('Location: '.$_SERVER['SCRIPT_NAME'].'?step=1&language='.DC_LOADER_LANG); 423 412 } 424 413 else … … 434 423 break; 435 424 } 425 436 426 case 3 : 437 427 { … … 458 448 $msg[] = l10n('Needed files are not present.'); 459 449 } 460 450 461 451 require $lib_files; 462 452 require $lib_unzip; … … 467 457 $msg[] = l10n('Invalid zip file.'); 468 458 } 469 459 470 460 foreach ($files as $k => $v) 471 461 { … … 479 469 $uz->close; 480 470 unset($uz); 481 471 482 472 if (!is_dir(dirname(__FILE__).'/'.$dest)) 483 473 { … … 489 479 cleanFiles(); 490 480 unlink(__FILE__); 491 481 492 482 $redir = preg_replace('#/+#','/',str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])).'/'.$dest.'/install.php'); 493 483 494 484 $text = '<h2>'.l10n('Congratulations!').'</h2>' 495 485 .'<p>'.l10n('Everything went fine. You are now ready to start the installation procedure.').'</p>'
Note: See TracChangeset
for help on using the changeset viewer.