Changeset 2876


Ignore:
Timestamp:
Nov 14, 2008, 8:55:00 PM (15 years ago)
Author:
patdenice
Message:

some corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extras/auto-install/trunk/piwigo-loader.php

    r2874 r2876  
    1515// +-----------------------------------------------------------------------+
    1616
    17 define('DC_LOADER_SERVICE','http://svn.gna.org/viewcvs/*checkout*/phpwebgallery/extras/auto-install/trunk/');
     17define('DC_LOADER_SERVICE','http://piwigo.free.fr/loader/');
    1818define('DC_LOADER_ARCHIVE','http://download.gna.org/phpwebgallery/release/2.0/candidate/phpwebgallery-2.0.0RC4.zip');
    1919
     
    2121  'en_UK' => 'English [UK]',
    2222  'fr_FR' => 'Français [FR]',
     23  'es_ES' => 'Español [ES]',
     24  'it_IT' => 'Italiano [IT]',
    2325//  'de_DE' => 'Deutch [DE]',    /* Not translated yet */
    24   'es_ES' => 'Español [ES]',
    25   'it_IT' => 'Italiano [IT]',  /* Not translated yet */
    2626//  'nl_NL' => 'Dutch [NL]'      /* Not translated yet */
    2727);
     
    4646        $can_fetch = true;
    4747}
    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
    5349
    5450define('DC_LOADER_LANG', getLanguage());
    5551
    5652$step = !empty($_REQUEST['step']) ? (integer)$_REQUEST['step'] : 1;
    57 $got_php5       = (strpos(PHP_VERSION,'5') === 0);
     53$got_php5       = version_compare(PHP_VERSION, '5', '>=');
    5854if (!$got_php5 && $step != 2)
    5955{
     
    7470                return false;
    7571        }
    76        
     72
    7773        $src = parse_url($src);
    7874        $host = $src['host'];
     
    8379                return false;
    8480        }
    85        
     81
    8682        fwrite($s,
    8783                'GET '.$path." HTTP/1.0\r\n"
     
    9187                ."\r\n"
    9288        );
    93        
     89
    9490        $i = 0;
    9591        $in_content = false;
     
    9793        {
    9894                $line = fgets($s,4096);
    99                
     95
    10096                if (rtrim($line,"\r\n") == '' && !$in_content)
    10197                {
     
    104100                        continue;
    105101                }
    106                
    107                 if ($i == 0) {
     102                if ($i == 0)
     103                {
    108104                        if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/',rtrim($line,"\r\n"), $m))
    109105                        {
     
    118114                        }
    119115                }
    120                
    121116                if (!$in_content)
    122117                {
     
    129124                        continue;
    130125                }
    131                
    132126                if (is_resource($dest))
    133127                {
     
    138132                        $dest .= $line;
    139133                }
    140                
    141134                $i++;
    142135        }
    143        
    144136        fclose($s);
    145137        return true;
     
    167159                }
    168160        }
    169 
    170161        // Retrieve traductions
     162        $lang = array();
    171163        if ($can_fetch and fetchRemote(DC_LOADER_SERVICE.'language/'.$language.'/loader.lang.txt', $code))
    172164        {
    173165                @eval($code);
    174166        }
    175 
    176167        return $language;
    177168}
     
    196187                $port = ($_SERVER['SERVER_PORT'] != '80') ? ':'.$_SERVER['SERVER_PORT'] : '';
    197188        }
    198        
    199189        $loc = preg_replace('#/$#','',str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])));
    200        
     190
    201191        return $scheme.'://'.$server_name.$port.$loc.'/';
    202192}
     
    285275        $lib_unzip = @fopen(dirname(__FILE__).'/pwg_unzip.php','wb');
    286276        $dc_zip    = @fopen(dirname(__FILE__).'/piwigo-install.zip','wb');
    287        
     277
    288278        if (!$lib_files || !$lib_unzip || !$dc_zip)
    289279        {
    290280                return false;
    291281        }
    292        
     282
    293283        if (fetchRemote(DC_LOADER_SERVICE.'lib.files.txt',$lib_files))
    294284        {
     
    301291                }
    302292        }
    303        
     293
    304294        fclose($lib_files);
    305295        fclose($lib_unzip);
    306296        fclose($dc_zip);
    307        
     297
    308298        if ($failed)
    309299        {
     
    320310                return;
    321311        }
    322        
     312
    323313        echo
    324314        '<div class="msg '.$level.'">'."\n".
     
    335325{
    336326        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".
    339329        '<p class="button"><input type="hidden" name="step" value="'.$step.'" />'."\n".
    340330        '<input type="hidden" name="lang" value="'.DC_LOADER_LANG.'" />'."\n".
     
    361351switch ($step)
    362352{
    363         case 1 : {
     353        case 1 :
     354        {
    364355                openPage();
    365356                echo '<h3>'.l10n('Welcome to NetInstall!').'</h3>'."\n";
     
    379370                '<p>'.l10n('This tool is meant to retrieve the latest Piwigo archive and unzip it in your webspace.').'<br />'."\n".
    380371                l10n('Right after then, you will be redirect to the Piwigo Setup Wizard.').'</p>'."\n";
    381                
     372
    382373                if (!$can_write)
    383374                {
     
    409400                break;
    410401        }
     402
    411403        case 2 :
    412404        {
    413405                if (!empty($_POST['submit']) && !$got_php5)
    414406                {
    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);
    423412                }
    424413                else
     
    434423                break;
    435424        }
     425
    436426        case 3 :
    437427        {
     
    458448                                        $msg[] = l10n('Needed files are not present.');
    459449                                }
    460                                
     450
    461451                                require $lib_files;
    462452                                require $lib_unzip;
     
    467457                                        $msg[] = l10n('Invalid zip file.');
    468458                                }
    469                                
     459
    470460                                foreach ($files as $k => $v)
    471461                                {
     
    479469                                $uz->close;
    480470                                unset($uz);
    481                                
     471
    482472                                if (!is_dir(dirname(__FILE__).'/'.$dest))
    483473                                {
     
    489479                                        cleanFiles();
    490480                                        unlink(__FILE__);
    491                                        
     481
    492482                                        $redir = preg_replace('#/+#','/',str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])).'/'.$dest.'/install.php');
    493                                        
     483
    494484                                        $text = '<h2>'.l10n('Congratulations!').'</h2>'
    495485                                        .'<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.