Ignore:
Timestamp:
2010/07/20 13:25:33 (14 years ago)
Author:
kajiwara
Message:

EC-CUBE Ver2.4.4 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=223

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/class/util/SC_Utils.php

    r18562 r18758  
    33 * This file is part of EC-CUBE 
    44 * 
    5  * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 
     5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. 
    66 * 
    77 * http://www.lockon.co.jp/ 
     
    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 
     
    543594            foreach($array as $key => $val) { 
    544595                $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE); 
     596                $val = ereg_replace("\"", "\"\"", $val); 
    545597                $line .= "\"".$val."\","; 
    546598            } 
     
    716768            $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )"; 
    717769            //登録(更新)日付順 
    718             $objQuery->setorder('update_date DESC'); 
     770            $objQuery->setOrder('update_date DESC'); 
    719771            //キャンペーンポイントの取得 
    720772            $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id)); 
     
    762814        $sql.= "group by dtb_class.class_id, dtb_class.name"; 
    763815        $objQuery = new SC_Query(); 
    764         $arrList = $objQuery->getall($sql); 
     816        $arrList = $objQuery->getAll($sql); 
    765817        // キーと値をセットした配列を取得 
    766818        $arrRet = SC_Utils::sfArrKeyValue($arrList, 'class_id', 'count'); 
Note: See TracChangeset for help on using the changeset viewer.