Index: /branches/comu-ver2/html/admin/require.php
===================================================================
--- /branches/comu-ver2/html/admin/require.php	(revision 18360)
+++ /branches/comu-ver2/html/admin/require.php	(revision 18538)
@@ -24,7 +24,9 @@
 // rtrim は PHP バージョン依存対策
 define('HTML_PATH', rtrim(realpath(rtrim(realpath(dirname(__FILE__)), '/\\') . '/../'), '/\\') . '/');
+define('ADMIN_FUNCTION', true);
 
+require_once HTML_PATH . 'handle_error.php';
 require_once HTML_PATH . 'define.php';
-define('ADMIN_FUNCTION', true);
+
 require_once HTML_PATH . HTML2DATA_DIR . 'require_base.php';
 
Index: /branches/comu-ver2/html/require.php
===================================================================
--- /branches/comu-ver2/html/require.php	(revision 18318)
+++ /branches/comu-ver2/html/require.php	(revision 18538)
@@ -25,4 +25,5 @@
 define("HTML_PATH", rtrim(realpath(rtrim(realpath(dirname(__FILE__)), '/\\') . '/'), '/\\') . '/');
 
+require_once HTML_PATH . 'handle_error.php';
 require_once HTML_PATH . 'define.php';
 define('FRONT_FUNCTION_PC_SITE', true);
Index: /branches/comu-ver2/html/mobile/require.php
===================================================================
--- /branches/comu-ver2/html/mobile/require.php	(revision 18360)
+++ /branches/comu-ver2/html/mobile/require.php	(revision 18538)
@@ -25,4 +25,5 @@
 define("HTML_PATH", rtrim(realpath(rtrim(realpath(dirname(__FILE__)), '/\\') . '/../'), '/\\') . '/');
 
+require_once HTML_PATH . 'handle_error.php';
 require_once HTML_PATH . 'define.php';
 define('MOBILE_SITE', true);
Index: /branches/comu-ver2/html/error.php
===================================================================
--- /branches/comu-ver2/html/error.php	(revision 18538)
+++ /branches/comu-ver2/html/error.php	(revision 18538)
@@ -0,0 +1,38 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+// {{{ requires
+$require_php_dir = realpath(dirname( __FILE__));
+require_once($require_php_dir . "/define.php");
+require_once($require_php_dir . "/" . HTML2DATA_DIR . "require_safe.php");
+require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_SystemError_Ex.php");
+
+if (isset($_GET['admin'])) {
+    define("ADMIN_FUNCTION", true);
+}
+// }}}
+// {{{ generate page
+$objPage = new LC_Page_Error_SystemError_Ex();
+register_shutdown_function(array($objPage, "destroy"));
+$objPage->init();
+$objPage->process();
+?>
Index: /branches/comu-ver2/html/handle_error.php
===================================================================
--- /branches/comu-ver2/html/handle_error.php	(revision 18538)
+++ /branches/comu-ver2/html/handle_error.php	(revision 18538)
@@ -0,0 +1,92 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// エラー捕捉用の出力バッファリング
+ob_start('_fatal_error_handler');
+
+// エラー画面を表示させるためのエラーハンドラ
+set_error_handler('handle_error');
+
+/**
+ * エラーを捕捉するための関数.
+ *
+ * PHP4 では, try/catch が使用できず, かつ set_error_handler で Fatal Error は
+ * 捕捉できないため, ob_start にこの関数を定義し, Fatal Error が発生した場合
+ * に出力される HTML 出力を捕捉する.
+ * この関数が実行され, エラーが捕捉されると, エラーページへリダイレクトする.
+ *
+ * @param string $buffer 出力バッファリングの内容
+ * @return string|void エラーが捕捉された場合は, エラーページへリダイレクトする;
+ *                     エラーが捕捉されない場合は, 出力バッファリングの内容を返す
+ */
+function &_fatal_error_handler(&$buffer) {
+    if (preg_match('/<b>(Fatal) error<\/b>: +(.+) in <b>(.+)<\/b> on line <b>(\d+)<\/b><br \/>/i', $buffer, $matches)) {
+
+        $admin = "";
+        if (defined('ADMIN_FUNCTION') && ADMIN_FUNCTION) {
+            $admin = "?admin";
+        }
+        header("Location: " . SITE_URL . "error.php" . $admin);
+        exit;
+    }
+    return $buffer;
+}
+
+/**
+ * エラー画面を表示させるための関数.
+ *
+ * この関数は, set_error_handler() 関数に登録するための関数である.
+ * trigger_error にて E_USER_ERROR が生成されると, ob_end_clean() 関数によって
+ * 出力バッファリングが無効にされ, エラーログを出力した後, エラーページへ
+ * リダイレクトする.
+ *
+ * E_USER_ERROR 以外のエラーが生成された場合, この関数は true を返す.
+ *
+ * @param integer $errno エラーコード
+ * @param string $errstr エラーメッセージ
+ * @param string $errfile エラーが発生したファイル名
+ * @param integer $errline エラーが発生した行番号
+ * @return void|boolean E_USER_ERROR が発生した場合は, エラーページへリダイレクト;
+ *                      E_USER_ERROR 以外の場合は true
+ */
+function handle_error($errno, $errstr, $errfile, $errline) {
+    switch ($errno) {
+    case E_USER_ERROR:
+        ob_end_clean();
+        error_log("FATAL Error($errno) $errfile:$errline $errstr");
+
+        $admin = "";
+        if (defined('ADMIN_FUNCTION') && ADMIN_FUNCTION) {
+            $admin = "?admin";
+        }
+        header("Location: " . SITE_URL . "error.php" . $admin);
+        exit(1);
+        break;
+
+    case E_USER_WARNING:
+    case E_USER_NOTICE:
+    default:
+    }
+    return true;
+}
+?>
Index: /branches/comu-ver2/data/class/SC_DbConn.php
===================================================================
--- /branches/comu-ver2/data/class/SC_DbConn.php	(revision 18487)
+++ /branches/comu-ver2/data/class/SC_DbConn.php	(revision 18538)
@@ -221,14 +221,20 @@
 
     function send_err_mail($pearResult, $sql){
-        require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_SystemError_Ex.php");
-        
-        $objPage = new LC_Page_Error_SystemError_Ex();
-        register_shutdown_function(array($objPage, "destroy"));
-        $objPage->init();
-        $objPage->addDebugMsg($sql);
-        $objPage->pearResult = $pearResult;
-        GC_Utils_Ex::gfPrintLog($objPage->sfGetErrMsg());
-        $objPage->process();
-        
+
+        $errmsg = $sql . "\n\n";
+
+        // PEAR エラーを伴う場合
+        if (!is_null($pearResult)) {
+            $errmsg .= $pearResult->message . "\n\n";
+            $errmsg .= $pearResult->userinfo . "\n\n";
+            $errmsg .= SC_Utils_Ex::sfBacktraceToString($pearResult->backtrace);
+        }
+        // (上に該当せず)バックトレースを生成できる環境(一般的には PHP 4 >= 4.3.0, PHP 5)の場合
+        else if (function_exists("debug_backtrace")) {
+            $errmsg .= SC_Utils_Ex::sfBacktraceToString(array_slice(debug_backtrace(), 2));
+        }
+
+        GC_Utils_Ex::gfPrintLog($errmsg);
+        trigger_error($errmsg, E_USER_ERROR);
         exit();
     }
@@ -248,4 +254,3 @@
     }
 }
-
 ?>
Index: /branches/comu-ver2/data/app_initial.php
===================================================================
--- /branches/comu-ver2/data/app_initial.php	(revision 18538)
+++ /branches/comu-ver2/data/app_initial.php	(revision 18538)
@@ -0,0 +1,43 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+if (!defined("CLASS_PATH")) {
+    /** クラスパス */
+    define("CLASS_PATH", DATA_PATH . "class/");
+}
+
+if (!defined("CLASS_EX_PATH")) {
+    /** クラスパス */
+    define("CLASS_EX_PATH", DATA_PATH . "class_extends/");
+}
+
+if (!defined("CACHE_PATH")) {
+    /** キャッシュ生成ディレクトリ */
+    define("CACHE_PATH", DATA_PATH . "cache/");
+}
+
+require_once(CLASS_EX_PATH . "SC_Initial_Ex.php");
+// アプリケーション初期化処理
+$objInit = new SC_Initial_Ex();
+$objInit->init();
+?>
Index: /branches/comu-ver2/data/require_classes.php
===================================================================
--- /branches/comu-ver2/data/require_classes.php	(revision 18538)
+++ /branches/comu-ver2/data/require_classes.php	(revision 18538)
@@ -0,0 +1,55 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+require_once(CLASS_EX_PATH . "util_extends/GC_Utils_Ex.php");
+require_once(CLASS_EX_PATH . "util_extends/SC_Utils_Ex.php");
+require_once(CLASS_EX_PATH . "db_extends/SC_DB_MasterData_Ex.php");
+require_once(CLASS_EX_PATH . "db_extends/SC_DB_DBFactory_Ex.php");
+require_once(CLASS_PATH . "SC_View.php");
+require_once(CLASS_PATH . "SC_DbConn.php");
+require_once(CLASS_PATH . "SC_Session.php");
+require_once(CLASS_PATH . "SC_Query.php");
+require_once(CLASS_PATH . "SC_SelectSql.php");
+require_once(CLASS_PATH . "SC_CheckError.php");
+require_once(CLASS_PATH . "SC_PageNavi.php");
+require_once(CLASS_PATH . "SC_Date.php");
+require_once(CLASS_PATH . "SC_Image.php");
+require_once(CLASS_PATH . "SC_UploadFile.php");
+require_once(CLASS_PATH . "SC_SiteInfo.php");
+require_once(CLASS_EX_PATH . "SC_SendMail_Ex.php");
+require_once(CLASS_PATH . "SC_FormParam.php");
+require_once(CLASS_PATH . "SC_CartSession.php");
+require_once(CLASS_PATH . "SC_SiteSession.php");
+require_once(CLASS_PATH . "SC_CampaignSession.php");
+require_once(CLASS_PATH . "SC_Customer.php");
+require_once(CLASS_PATH . "SC_CustomerList.php");
+require_once(CLASS_PATH . "SC_Cookie.php");
+require_once(CLASS_PATH . "SC_Pdf.php");
+require_once(CLASS_PATH . "SC_MobileUserAgent.php");
+require_once(CLASS_PATH . "SC_MobileEmoji.php");
+require_once(CLASS_PATH . "SC_MobileImage.php");
+require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_PageLayout_Ex.php");
+require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_DB_Ex.php");
+require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mail_Ex.php");
+require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mobile_Ex.php");
+?>
Index: /branches/comu-ver2/data/install.php
===================================================================
--- /branches/comu-ver2/data/install.php	(revision 18234)
+++ /branches/comu-ver2/data/install.php	(revision 18538)
@@ -1,2 +1,17 @@
 <?php
+    define ('ECCUBE_INSTALL', 'ON');
+    define ('SITE_URL', 'http://k-1.comu-ver2.ec-cube.net/');
+    define ('SSL_URL', 'http://k-1.comu-ver2.ec-cube.net/');
+    define ('URL_DIR', '/');
+    define ('DOMAIN_NAME', '');
+    define ('DB_TYPE', 'pgsql');
+    define ('DB_USER', 'nanasess');
+    define ('DB_PASSWORD', 'nanasess');
+    define ('DB_SERVER', '127.0.0.1');
+    define ('DB_NAME', 'eccube_db_comu_ver2');
+    define ('DB_PORT', '');
+    define ('MOBILE_HTML_PATH', HTML_PATH . 'mobile/');
+    define ('MOBILE_SITE_URL', SITE_URL . 'mobile/');
+    define ('MOBILE_SSL_URL', SSL_URL . 'mobile/');
+    define ('MOBILE_URL_DIR', URL_DIR . 'mobile/');
 ?>
Index: /branches/comu-ver2/data/require_base.php
===================================================================
--- /branches/comu-ver2/data/require_base.php	(revision 18370)
+++ /branches/comu-ver2/data/require_base.php	(revision 18538)
@@ -26,55 +26,11 @@
 }
 
-if (!defined("CLASS_PATH")) {
-    /** クラスパス */
-    define("CLASS_PATH", DATA_PATH . "class/");
-}
+// アプリケーション初期化処理
+require_once(DATA_PATH . "app_initial.php");
 
-if (!defined("CLASS_EX_PATH")) {
-    /** クラスパス */
-    define("CLASS_EX_PATH", DATA_PATH . "class_extends/");
-}
+// 各種クラス読み込み
+require_once(DATA_PATH . "require_classes.php");
 
-if (!defined("CACHE_PATH")) {
-    /** キャッシュ生成ディレクトリ */
-    define("CACHE_PATH", DATA_PATH . "cache/");
-}
-
-require_once(CLASS_EX_PATH . "SC_Initial_Ex.php");
-// アプリケーション初期化処理
-$objInit = new SC_Initial_Ex();
-$objInit->init();
-
-require_once(CLASS_EX_PATH . "util_extends/GC_Utils_Ex.php");
-require_once(CLASS_EX_PATH . "util_extends/SC_Utils_Ex.php");
-require_once(CLASS_EX_PATH . "db_extends/SC_DB_MasterData_Ex.php");
-require_once(CLASS_EX_PATH . "db_extends/SC_DB_DBFactory_Ex.php");
-require_once(CLASS_PATH . "SC_View.php");
-require_once(CLASS_PATH . "SC_DbConn.php");
-require_once(CLASS_PATH . "SC_Session.php");
-require_once(CLASS_PATH . "SC_Query.php");
-require_once(CLASS_PATH . "SC_SelectSql.php");
-require_once(CLASS_PATH . "SC_CheckError.php");
-require_once(CLASS_PATH . "SC_PageNavi.php");
-require_once(CLASS_PATH . "SC_Date.php");
-require_once(CLASS_PATH . "SC_Image.php");
-require_once(CLASS_PATH . "SC_UploadFile.php");
-require_once(CLASS_PATH . "SC_SiteInfo.php");
-require_once(CLASS_EX_PATH . "SC_SendMail_Ex.php");
-require_once(CLASS_PATH . "SC_FormParam.php");
-require_once(CLASS_PATH . "SC_CartSession.php");
-require_once(CLASS_PATH . "SC_SiteSession.php");
-require_once(CLASS_PATH . "SC_CampaignSession.php");
-require_once(CLASS_PATH . "SC_Customer.php");
-require_once(CLASS_PATH . "SC_CustomerList.php");
-require_once(CLASS_PATH . "SC_Cookie.php");
-require_once(CLASS_PATH . "SC_Pdf.php");
-require_once(CLASS_PATH . "SC_MobileUserAgent.php");
-require_once(CLASS_PATH . "SC_MobileEmoji.php");
-require_once(CLASS_PATH . "SC_MobileImage.php");
-require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_PageLayout_Ex.php");
-require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_DB_Ex.php");
-require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mail_Ex.php");
-require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mobile_Ex.php");
+// モジュールの読み込み
 require_once(DATA_PATH . "include/module.inc");
 
Index: /branches/comu-ver2/data/require_safe.php
===================================================================
--- /branches/comu-ver2/data/require_safe.php	(revision 18538)
+++ /branches/comu-ver2/data/require_safe.php	(revision 18538)
@@ -0,0 +1,46 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * 必要最低限の require を行うファイル.
+ * このファイルを使用した場合は, DBアクセスを伴わない.
+ * 主に, エラー画面などに使用する.
+ */
+
+// rtrim は PHP バージョン依存対策
+define("HTML_PATH", rtrim(realpath(rtrim(realpath(dirname(__FILE__)), '/\\') . '/'), '/\\') . '/');
+
+if (!defined("DATA_PATH")) {
+    define("DATA_PATH", HTML_PATH . HTML2DATA_DIR);
+}
+
+// アプリケーションの初期化処理
+require_once(DATA_PATH . "app_initial.php");
+
+// 各種クラス読み込み
+require_once(DATA_PATH . "require_classes.php");
+
+// FIXME 互換性保持のため空の関数を残しておく
+function sfPrintEbisTag() {}
+function sfPrintAffTag() {}
+?>
