Changeset 18728 for branches/version-2_4


Ignore:
Timestamp:
2010/06/22 15:32:10 (14 years ago)
Author:
nanasess
bzr:base-revision:
ohkouchi@loop-az.jp-20100622060942-plqe8f98tkb1kl17
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/class/util/SC_Utils.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Futil%2FSC_Utils.php
bzr:mapping-version:
v4
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20100622063206-gth1n3w4ppkb7o7a
bzr:revno:
1935
bzr:revprop:branch-nick:
branches/version-2_4
bzr:root:
branches/version-2_4
bzr:text-parents:

data/class/util/SC_Utils.php ohkouchi@loop-az.jp-20100621063531-bkg4neoa8q5vx7lu
bzr:timestamp:
2010-06-22 15:32:06.346999884 +0900
bzr:user-agent:
bzr2.1.1+bzr-svn1.0.2
svn:original-date:
2010-06-22T06:32:06.347000Z
Message:

merged r18676, r18709

  • インストーラへのリダイレクトを修正(#348, #603)
File:
1 edited

Legend:

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

    r18719 r18728  
    8181        // インストールが完了していない時 
    8282        if( !defined('ECCUBE_INSTALL') ) { 
    83             if( !ereg('/install/', $_SERVER['PHP_SELF']) ) { 
     83            $phpself = $_SERVER['PHP_SELF']; 
     84            if( !ereg('/install/', $phpself) ) { 
    8485                // インストールページに遷移させる 
    85  
    86                 $script_filename = $_SERVER['SCRIPT_FILENAME']; 
    87                 list($real_root, $tmp) = explode('/html/', $script_filename); 
    88                 $real_root = $real_root . '/html/'; 
    89                 $script_name = $_SERVER['SCRIPT_NAME']; 
    90                 $url_dir = rtrim($script_name, basename($script_name)); 
    91  
    92                 if ($dh = opendir($real_root)) { 
    93                     $arrDir = array(); 
    94                     while ($entry = readdir($dh)) { 
    95                         if (is_dir($real_root.$entry) && !in_array($entry, array('.', '..', '.svn', 'install'))) { 
    96                             $url_dir = rtrim($url_dir, $entry.'/'); 
    97                         } 
    98                     } 
    99                     closedir($dh); 
    100                 } 
    101  
    102                 $location = $url_dir . '/install/'; 
    103                 header('Location: ' . $location); 
     86                $path = substr($phpself, 0, strpos($phpself, basename($phpself))); 
     87                $install_url = SC_Utils::searchInstallerPath($path); 
     88                header('Location: ' . $install_url); 
    10489                exit; 
    10590            } 
     
    11095            } 
    11196        } 
     97    } 
     98 
     99    /** 
     100     * インストーラのパスを検索し, URL を返す. 
     101     * 
     102     * $path と同階層に install/index.php があるか検索する. 
     103     * 存在しない場合は上位階層を再帰的に検索する. 
     104     * インストーラのパスが見つかった場合は, その URL を返す. 
     105     * DocumentRoot まで検索しても見つからない場合は /install/index.php を返す. 
     106     * 
     107     * @param string $path 検索対象のパス 
     108     * @return string インストーラの URL 
     109     */ 
     110    function searchInstallerPath($path) { 
     111        $installer = 'install/index.php'; 
     112 
     113        if (SC_Utils::sfIsHTTPS()) { 
     114            $proto = "https://"; 
     115        } else { 
     116            $proto = "http://"; 
     117        } 
     118        $host = $proto . $_SERVER['SERVER_NAME']; 
     119        if ($path == '/') { 
     120            return $host . $path . $installer; 
     121        } 
     122        if (substr($path, -1, 1) != '/') { 
     123            $path .= $path . '/'; 
     124        } 
     125        $installer_url = $host . $path . $installer; 
     126        $resources = fopen(SC_Utils::getRealURL($installer_url), 'r'); 
     127        if ($resources === false) { 
     128            $installer_url = SC_Utils::searchInstallerPath($path . '../'); 
     129        } 
     130        return $installer_url; 
     131    } 
     132 
     133    /** 
     134     * 相対パスで記述された URL から絶対パスの URL を取得する. 
     135     * 
     136     * この関数は, http(s):// から始まる URL を解析し, 相対パスで記述されていた 
     137     * 場合, 絶対パスに変換して返す 
     138     * 
     139     * 例) 
     140     * http://www.example.jp/aaa/../index.php 
     141     * ↓ 
     142     * http://www.example.jp/index.php 
     143     * 
     144     * @param string $url http(s):// から始まる URL 
     145     * @return string $url を絶対パスに変換した URL 
     146     */ 
     147    function getRealURL($url) { 
     148        $parse = parse_url($url); 
     149        $tmp = split('/', $parse['path']); 
     150        $results = array(); 
     151        foreach ($tmp as $v) { 
     152            if ($v == '' || $v == '.') { 
     153                // queit. 
     154            } elseif ($v == '..') { 
     155                array_pop($results); 
     156            } else { 
     157                array_push($results, $v); 
     158            } 
     159        } 
     160 
     161        $path = join('/', $results); 
     162        return $parse['scheme'] . '://' . $parse['host'] . '/' . $path; 
    112163    } 
    113164 
Note: See TracChangeset for help on using the changeset viewer.