Index: trunk/data/class/util/SC_Utils.php
===================================================================
--- trunk/data/class/util/SC_Utils.php	(revision 18562)
+++ trunk/data/class/util/SC_Utils.php	(revision 18758)
@@ -3,5 +3,5 @@
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -81,25 +81,10 @@
         // インストールが完了していない時
         if( !defined('ECCUBE_INSTALL') ) {
-            if( !ereg('/install/', $_SERVER['PHP_SELF']) ) {
+            $phpself = $_SERVER['PHP_SELF'];
+            if( !ereg('/install/', $phpself) ) {
                 // インストールページに遷移させる
-
-                $script_filename = $_SERVER['SCRIPT_FILENAME'];
-                list($real_root, $tmp) = explode('/html/', $script_filename);
-                $real_root = $real_root . '/html/';
-                $script_name = $_SERVER['SCRIPT_NAME'];
-                $url_dir = rtrim($script_name, basename($script_name));
-
-                if ($dh = opendir($real_root)) {
-                    $arrDir = array();
-                    while ($entry = readdir($dh)) {
-                        if (is_dir($real_root.$entry) && !in_array($entry, array('.', '..', '.svn', 'install'))) {
-                            $url_dir = rtrim($url_dir, $entry.'/');
-                        }
-                    }
-                    closedir($dh);
-                }
-
-                $location = $url_dir . '/install/';
-                header('Location: ' . $location);
+                $path = substr($phpself, 0, strpos($phpself, basename($phpself)));
+                $install_url = SC_Utils::searchInstallerPath($path);
+                header('Location: ' . $install_url);
                 exit;
             }
@@ -110,4 +95,70 @@
             }
         }
+    }
+
+    /**
+     * インストーラのパスを検索し, URL を返す.
+     *
+     * $path と同階層に install/index.php があるか検索する.
+     * 存在しない場合は上位階層を再帰的に検索する.
+     * インストーラのパスが見つかった場合は, その URL を返す.
+     * DocumentRoot まで検索しても見つからない場合は /install/index.php を返す.
+     *
+     * @param string $path 検索対象のパス
+     * @return string インストーラの URL
+     */
+    function searchInstallerPath($path) {
+        $installer = 'install/index.php';
+
+        if (SC_Utils::sfIsHTTPS()) {
+            $proto = "https://";
+        } else {
+            $proto = "http://";
+        }
+        $host = $proto . $_SERVER['SERVER_NAME'];
+        if ($path == '/') {
+            return $host . $path . $installer;
+        }
+        if (substr($path, -1, 1) != '/') {
+            $path .= $path . '/';
+        }
+        $installer_url = $host . $path . $installer;
+        $resources = fopen(SC_Utils::getRealURL($installer_url), 'r');
+        if ($resources === false) {
+            $installer_url = SC_Utils::searchInstallerPath($path . '../');
+        }
+        return $installer_url;
+    }
+
+    /**
+     * 相対パスで記述された URL から絶対パスの URL を取得する.
+     *
+     * この関数は, http(s):// から始まる URL を解析し, 相対パスで記述されていた
+     * 場合, 絶対パスに変換して返す
+     *
+     * 例)
+     * http://www.example.jp/aaa/../index.php
+     * ↓
+     * http://www.example.jp/index.php
+     *
+     * @param string $url http(s):// から始まる URL
+     * @return string $url を絶対パスに変換した URL
+     */
+    function getRealURL($url) {
+        $parse = parse_url($url);
+        $tmp = split('/', $parse['path']);
+        $results = array();
+        foreach ($tmp as $v) {
+            if ($v == '' || $v == '.') {
+                // queit.
+            } elseif ($v == '..') {
+                array_pop($results);
+            } else {
+                array_push($results, $v);
+            }
+        }
+
+        $path = join('/', $results);
+        return $parse['scheme'] . '://' . $parse['host'] . '/' . $path;
     }
 
@@ -543,4 +594,5 @@
             foreach($array as $key => $val) {
                 $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
+                $val = ereg_replace("\"", "\"\"", $val);
                 $line .= "\"".$val."\",";
             }
@@ -716,5 +768,5 @@
             $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
             //登録(更新)日付順
-            $objQuery->setorder('update_date DESC');
+            $objQuery->setOrder('update_date DESC');
             //キャンペーンポイントの取得
             $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
@@ -762,5 +814,5 @@
         $sql.= "group by dtb_class.class_id, dtb_class.name";
         $objQuery = new SC_Query();
-        $arrList = $objQuery->getall($sql);
+        $arrList = $objQuery->getAll($sql);
         // キーと値をセットした配列を取得
         $arrRet = SC_Utils::sfArrKeyValue($arrList, 'class_id', 'count');
