Changeset 23678


Ignore:
Timestamp:
2014/11/04 23:01:10 (9 years ago)
Author:
Seasoft
Message:

#2648 (環境により SC_Utils::searchInstallerPath で無限ループ)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/util/SC_Utils.php

    r23609 r23678  
    3838    public static function sfInitInstall() 
    3939    { 
    40         // インストール済みが定義されていない。 
    41         if (!defined('ECCUBE_INSTALL')) { 
    42             $phpself = $_SERVER['SCRIPT_NAME']; 
    43             if (strpos('/install/', $phpself) === false) { 
    44                 $path = substr($phpself, 0, strpos($phpself, basename($phpself))); 
    45                 $install_url = SC_Utils_Ex::searchInstallerPath($path); 
    46                 header('Location: ' . $install_url); 
    47                 exit; 
    48             } 
     40        if ( 
     41            !defined('ECCUBE_INSTALL')              // インストール済みが定義されていない。 
     42            && !GC_Utils_Ex::isInstallFunction()    // インストール中でない。 
     43        ) { 
     44            $install_url = SC_Utils_Ex::getInstallerPath(); 
     45            header('Location: ' . $install_url); 
     46            exit; 
    4947        } 
    5048        $path = HTML_REALDIR . 'install/' . DIR_INDEX_FILE; 
     
    5553 
    5654    /** 
    57      * インストーラのパスを検索し, URL を返す. 
    58      * 
    59      * $path と同階層に install/index.php があるか検索する. 
    60      * 存在しない場合は上位階層を再帰的に検索する. 
    61      * インストーラのパスが見つかった場合は, その URL を返す. 
    62      * DocumentRoot まで検索しても見つからない場合は /install/index.php を返す. 
    63      * 
    64      * @param  string $path 検索対象のパス 
    65      * @return string インストーラの URL 
    66      */ 
    67     public static function searchInstallerPath($path) 
    68     { 
     55     * インストーラーの URL を返す 
     56     * 
     57     * @return string インストーラーの URL 
     58     */ 
     59    public static function getInstallerPath() 
     60    { 
     61        $netUrl = new Net_URL(); 
     62 
    6963        $installer = 'install/' . DIR_INDEX_PATH; 
    70  
    71         if (SC_Utils_Ex::sfIsHTTPS()) { 
    72             $proto = 'https://'; 
    73         } else { 
    74             $proto = 'http://'; 
    75         } 
    76         $host = $proto . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']; 
    77         if ($path == '/') { 
    78             return $host . $path . $installer; 
    79         } 
    80         if (substr($path, -1, 1) != '/') { 
    81             $path .= $path . '/'; 
    82         } 
    83         $installer_url = $host . $path . $installer; 
    84         $resources = fopen(SC_Utils_Ex::getRealURL($installer_url), 'r'); 
    85         if ($resources === false) { 
    86             $installer_url = SC_Utils_Ex::searchInstallerPath($path . '../'); 
    87         } 
     64        // XXX メソッド名は add で始まるが、実際には置換を行う 
     65        $netUrl->addRawQueryString(''); 
     66        $current_url = $netUrl->getURL(); 
     67        $current_url = dirname($current_url) . '/'; 
     68        // XXX 先頭の / を含まない。 
     69        $urlpath = substr($_SERVER['SCRIPT_FILENAME'], strlen(HTML_REALDIR)); 
     70        // / を 0、/foo/ を 1 としたディレクトリー階層数 
     71        $dir_level = substr_count($urlpath, '/'); 
     72        $installer_url .= str_repeat('../', $dir_level) . $installer; 
    8873 
    8974        return $installer_url; 
Note: See TracChangeset for help on using the changeset viewer.