Index: branches/comu-utf8/data/Smarty/templates/rss/index.tpl
===================================================================
--- branches/comu-utf8/data/Smarty/templates/rss/index.tpl	(revision 15099)
+++ branches/comu-utf8/data/Smarty/templates/rss/index.tpl	(revision 16016)
@@ -29,6 +29,6 @@
 				<link> <!--{$arrNews[cnt].news_url|escape}--></link>
 			<!--{/if}-->
-			<title> <!--{ $arrNews[cnt].news_title|sf_mb_convert_encoding:$encode }--> </title>
-			<description><!--{$arrNews[cnt].news_comment|truncate:256|sf_mb_convert_encoding:$encode}--></description>
+			<title> <!--{ $arrNews[cnt].news_title|sf_mb_convert_encoding:$encode|escape }--> </title>
+			<description><!--{$arrNews[cnt].news_comment|truncate:256|sf_mb_convert_encoding:$encode|escape}--></description>
 			<!--{* <pubDate><!--{"r"|sf_mktime:$arrNews[cnt].hour:$arrNews[cnt].minute:$arrNews[cnt].second:$arrNews[cnt].month:$arrNews[cnt].day:$arrNews[cnt].year}--></pubDate> *}-->
 			<pubDate><!--{$timestamp}--></pubDate>
Index: branches/comu-utf8/data/conf/conf.php
===================================================================
--- branches/comu-utf8/data/conf/conf.php	(revision 15099)
+++ branches/comu-utf8/data/conf/conf.php	(revision 16016)
@@ -119,5 +119,5 @@
 
 // EC-CUBEバージョン情報
-define("ECCUBE_VERSION", "1.3.4");
+define("ECCUBE_VERSION", "1.3.4-comu");
 
 // 決済モジュール付与文言
Index: branches/comu-utf8/data/lib/slib.php
===================================================================
--- branches/comu-utf8/data/lib/slib.php	(revision 15099)
+++ branches/comu-utf8/data/lib/slib.php	(revision 16016)
@@ -22,177 +22,177 @@
 /* データベースのバージョン所得 */
 function sfGetDBVersion($dsn = "") {
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-	
-	$objQuery = new SC_Query($dsn, true, true);
-	list($db_type) = split(":", $dsn);
-	if($db_type == 'mysql') {
-		$val = $objQuery->getOne("select version()");
-		$version = "MySQL " . $val;
-	}	
-	if($db_type == 'pgsql') {
-		$val = $objQuery->getOne("select version()");
-		$arrLine = split(" " , $val);
-		$version = $arrLine[0] . " " . $arrLine[1];
-	}
-	return $version;
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+
+    $objQuery = new SC_Query($dsn, true, true);
+    list($db_type) = split(":", $dsn);
+    if($db_type == 'mysql') {
+        $val = $objQuery->getOne("select version()");
+        $version = "MySQL " . $val;
+    }
+    if($db_type == 'pgsql') {
+        $val = $objQuery->getOne("select version()");
+        $arrLine = split(" " , $val);
+        $version = $arrLine[0] . " " . $arrLine[1];
+    }
+    return $version;
 }
 
 /* テーブルの存在チェック */
 function sfTabaleExists($table_name, $dsn = "") {
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-	
-	$objQuery = new SC_Query($dsn, true, true);
-	// 正常に接続されている場合
-	if(!$objQuery->isError()) {
-		list($db_type) = split(":", $dsn);
-		// postgresqlとmysqlとで処理を分ける
-		if ($db_type == "pgsql") {
-			$sql = "SELECT
-						relname
-					FROM
-					    pg_class
-					WHERE
-						(relkind = 'r' OR relkind = 'v') AND 
-					    relname = ? 
-					GROUP BY
-						relname";
-			$arrRet = $objQuery->getAll($sql, array($table_name));
-			if(count($arrRet) > 0) {
-				return true;
-			}
-		}else if ($db_type == "mysql") {
-			$sql = "SHOW TABLE STATUS LIKE ?";
-			$arrRet = $objQuery->getAll($sql, array($table_name));
-			if(count($arrRet) > 0) {
-				return true;
-			}
-		}
-	}
-	return false;
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+
+    $objQuery = new SC_Query($dsn, true, true);
+    // 正常に接続されている場合
+    if(!$objQuery->isError()) {
+        list($db_type) = split(":", $dsn);
+        // postgresqlとmysqlとで処理を分ける
+        if ($db_type == "pgsql") {
+            $sql = "SELECT
+                        relname
+                    FROM
+                        pg_class
+                    WHERE
+                        (relkind = 'r' OR relkind = 'v') AND
+                        relname = ?
+                    GROUP BY
+                        relname";
+            $arrRet = $objQuery->getAll($sql, array($table_name));
+            if(count($arrRet) > 0) {
+                return true;
+            }
+        }else if ($db_type == "mysql") {
+            $sql = "SHOW TABLE STATUS LIKE ?";
+            $arrRet = $objQuery->getAll($sql, array($table_name));
+            if(count($arrRet) > 0) {
+                return true;
+            }
+        }
+    }
+    return false;
 }
 
 // カラムの存在チェックと作成
 function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) {
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-
-	// テーブルが無ければエラー
-	if(!sfTabaleExists($table_name, $dsn)) return false;
-	
-	$objQuery = new SC_Query($dsn, true, true);
-	// 正常に接続されている場合
-	if(!$objQuery->isError()) {
-		list($db_type) = split(":", $dsn);
-		
-		// カラムリストを取得
-		$arrRet = sfGetColumnList($table_name, $objQuery, $db_type);
-		if(count($arrRet) > 0) {
-			if(in_array($col_name, $arrRet)){
-				return true;
-			}
-		}
-	}
-	
-	// カラムを追加する
-	if($add){
-		$objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type ");
-		return true;
-	}
-	
-	return false;
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+
+    // テーブルが無ければエラー
+    if(!sfTabaleExists($table_name, $dsn)) return false;
+
+    $objQuery = new SC_Query($dsn, true, true);
+    // 正常に接続されている場合
+    if(!$objQuery->isError()) {
+        list($db_type) = split(":", $dsn);
+
+        // カラムリストを取得
+        $arrRet = sfGetColumnList($table_name, $objQuery, $db_type);
+        if(count($arrRet) > 0) {
+            if(in_array($col_name, $arrRet)){
+                return true;
+            }
+        }
+    }
+
+    // カラムを追加する
+    if($add){
+        $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type ");
+        return true;
+    }
+
+    return false;
 }
 
 // インデックスの存在チェックと作成
 function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) {
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-
-	// テーブルが無ければエラー
-	if(!sfTabaleExists($table_name, $dsn)) return false;
-	
-	$objQuery = new SC_Query($dsn, true, true);
-	// 正常に接続されている場合
-	if(!$objQuery->isError()) {
-		list($db_type) = split(":", $dsn);		
-		switch($db_type) {
-		case 'pgsql':
-			// インデックスの存在確認
-			$arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name));
-			break;
-		case 'mysql':
-			// インデックスの存在確認
-			$arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name));			
-			break;
-		default:
-			return false;
-		}
-		// すでにインデックスが存在する場合
-		if(count($arrRet) > 0) {
-			return true;
-		}
-	}
-	
-	// インデックスを作成する
-	if($add){
-		switch($db_type) {
-		case 'pgsql':
-			$objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name));
-			break;
-		case 'mysql':
-			$objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length));			
-			break;
-		default:
-			return false;
-		}
-		return true;
-	}	
-	return false;
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+
+    // テーブルが無ければエラー
+    if(!sfTabaleExists($table_name, $dsn)) return false;
+
+    $objQuery = new SC_Query($dsn, true, true);
+    // 正常に接続されている場合
+    if(!$objQuery->isError()) {
+        list($db_type) = split(":", $dsn);
+        switch($db_type) {
+        case 'pgsql':
+            // インデックスの存在確認
+            $arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name));
+            break;
+        case 'mysql':
+            // インデックスの存在確認
+            $arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name));
+            break;
+        default:
+            return false;
+        }
+        // すでにインデックスが存在する場合
+        if(count($arrRet) > 0) {
+            return true;
+        }
+    }
+
+    // インデックスを作成する
+    if($add){
+        switch($db_type) {
+        case 'pgsql':
+            $objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name));
+            break;
+        case 'mysql':
+            $objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length));
+            break;
+        default:
+            return false;
+        }
+        return true;
+    }
+    return false;
 }
 
 // データの存在チェック
 function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) {
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-	$objQuery = new SC_Query($dsn, true, true);
-	$count = $objQuery->count($table_name, $where, $arrval);
-
-	if($count > 0) {
-		$ret = true;
-	} else {
-		$ret = false;
-	}
-	// データを追加する
-	if(!$ret && $add) {
-		$objQuery->exec($sql);
-	}
-	
-	return $ret;
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+    $objQuery = new SC_Query($dsn, true, true);
+    $count = $objQuery->count($table_name, $where, $arrval);
+
+    if($count > 0) {
+        $ret = true;
+    } else {
+        $ret = false;
+    }
+    // データを追加する
+    if(!$ret && $add) {
+        $objQuery->exec($sql);
+    }
+
+    return $ret;
 }
 
@@ -201,5 +201,5 @@
  * データが存在する場合、必ず1以上の数値が設定されている。
  * 0を返した場合は、呼び出し元で対応すること。
- * 
+ *
  * @param $control_id 管理ID
  * @param $dsn DataSource
@@ -208,270 +208,270 @@
 function sfGetSiteControlFlg($control_id, $dsn = "") {
 
-	// データソース
-	if($dsn == "") {
-		if(defined('DEFAULT_DSN')) {
-			$dsn = DEFAULT_DSN;
-		} else {
-			return;
-		}
-	}
-
-	// クエリ生成
-	$target_column = "control_flg";
-	$table_name = "dtb_site_control";
-	$where = "control_id = ?";
-	$arrval = array($control_id);
-	$control_flg = 0;
-
-	// クエリ発行
-	$objQuery = new SC_Query($dsn, true, true);
-	$arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval);
-
-	// データが存在すればフラグを取得する
-	if (count($arrSiteControl) > 0) {
-		$control_flg = $arrSiteControl[0]["control_flg"];
-	}
-	
-	return $control_flg;
+    // データソース
+    if($dsn == "") {
+        if(defined('DEFAULT_DSN')) {
+            $dsn = DEFAULT_DSN;
+        } else {
+            return;
+        }
+    }
+
+    // クエリ生成
+    $target_column = "control_flg";
+    $table_name = "dtb_site_control";
+    $where = "control_id = ?";
+    $arrval = array($control_id);
+    $control_flg = 0;
+
+    // クエリ発行
+    $objQuery = new SC_Query($dsn, true, true);
+    $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval);
+
+    // データが存在すればフラグを取得する
+    if (count($arrSiteControl) > 0) {
+        $control_flg = $arrSiteControl[0]["control_flg"];
+    }
+
+    return $control_flg;
 }
 
 // テーブルのカラム一覧を取得する
 function sfGetColumnList($table_name, $objQuery = "", $db_type = DB_TYPE){
-	if($objQuery == "") $objQuery = new SC_Query();
-	$arrRet = array();
-	
-	// postgresqlとmysqlとで処理を分ける
-	if ($db_type == "pgsql") {
-		$sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 AND not a.attname like '........pg.dropped.%........' ORDER BY a.attnum";
-		$arrColList = $objQuery->getAll($sql, array($table_name));
-		$arrColList = sfswaparray($arrColList);
-		$arrRet = $arrColList["attname"];
-	}else if ($db_type == "mysql") {
-		$sql = "SHOW COLUMNS FROM $table_name";
-		$arrColList = $objQuery->getAll($sql);
-		$arrColList = sfswaparray($arrColList);
-		$arrRet = $arrColList["Field"];
-	}
-	return $arrRet;
+    if($objQuery == "") $objQuery = new SC_Query();
+    $arrRet = array();
+
+    // postgresqlとmysqlとで処理を分ける
+    if ($db_type == "pgsql") {
+        $sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 AND not a.attname like '........pg.dropped.%........' ORDER BY a.attnum";
+        $arrColList = $objQuery->getAll($sql, array($table_name));
+        $arrColList = sfswaparray($arrColList);
+        $arrRet = $arrColList["attname"];
+    }else if ($db_type == "mysql") {
+        $sql = "SHOW COLUMNS FROM $table_name";
+        $arrColList = $objQuery->getAll($sql);
+        $arrColList = sfswaparray($arrColList);
+        $arrRet = $arrColList["Field"];
+    }
+    return $arrRet;
 }
 
 // インストール初期処理
 function sfInitInstall() {
-	// インストール済みが定義されていない。
-	if(!defined('ECCUBE_INSTALL')) {
-		if(!ereg("/install/", $_SERVER['PHP_SELF'])) {
-			header("Location: ./install/");
-		}
-	} else {
-		$path = HTML_PATH . "install/index.php";
-		if(file_exists($path)) {
-			sfErrorHeader(">> /install/index.phpは、インストール完了後にファイルを削除してください。");
-		}
-		
-		// 旧バージョンのinstall.phpのチェック
-		$path = HTML_PATH . "install.php";
-		if(file_exists($path)) {
-			sfErrorHeader(">> /install.phpはセキュリティーホールとなります。削除してください。");
-		}		
-	}
+    // インストール済みが定義されていない。
+    if(!defined('ECCUBE_INSTALL')) {
+        if(!ereg("/install/", $_SERVER['PHP_SELF'])) {
+			header("Location: " . sfGetCurrentUri() . "/install/");
+        }
+    } else {
+        $path = HTML_PATH . "install/index.php";
+        if(file_exists($path)) {
+            sfErrorHeader(">> /install/index.phpは、インストール完了後にファイルを削除してください。");
+        }
+
+        // 旧バージョンのinstall.phpのチェック
+        $path = HTML_PATH . "install.php";
+        if(file_exists($path)) {
+            sfErrorHeader(">> /install.phpはセキュリティーホールとなります。削除してください。");
+        }
+    }
 }
 
 // アップデートで生成されたPHPを読み出し
 function sfLoadUpdateModule() {
-	// URL設定ディレクトリを削除
-	$main_php = ereg_replace(URL_DIR, "", $_SERVER['PHP_SELF']);
-	$extern_php = UPDATE_PATH . $main_php;
-	if(file_exists($extern_php)) {
-		require_once($extern_php);
-	}
+    // URL設定ディレクトリを削除
+    $main_php = ereg_replace(URL_DIR, "", $_SERVER['PHP_SELF']);
+    $extern_php = UPDATE_PATH . $main_php;
+    if(file_exists($extern_php)) {
+        require_once($extern_php);
+    }
 }
 
 function sf_getBasisData() {
-	//DBから設定情報を取得
-	$objConn = new SC_DbConn(DEFAULT_DSN);
-	$result = $objConn->getAll("SELECT * FROM dtb_baseinfo");
-	if(is_array($result[0])) {
-		foreach ( $result[0] as $key=>$value ){
-			$CONF["$key"] = $value;
-		}
-	}
-	return $CONF;
+    //DBから設定情報を取得
+    $objConn = new SC_DbConn(DEFAULT_DSN);
+    $result = $objConn->getAll("SELECT * FROM dtb_baseinfo");
+    if(is_array($result[0])) {
+        foreach ( $result[0] as $key=>$value ){
+            $CONF["$key"] = $value;
+        }
+    }
+    return $CONF;
 }
 
 // 装飾付きエラーメッセージの表示
 function sfErrorHeader($mess, $print = false) {
-	global $GLOBAL_ERR;
-	if($GLOBAL_ERR == "") {
-		$GLOBAL_ERR = "<meta http-equiv='Content-Type' content='text/html; charset=" . CHAR_CODE . "'>\n";
-	}
-	$GLOBAL_ERR.= "<table width='100%' border='0' cellspacing='0' cellpadding='0' summary=' '>\n";
-	$GLOBAL_ERR.= "<tr>\n";
-	$GLOBAL_ERR.= "<td bgcolor='#ffeebb' height='25' colspan='2' align='center'>\n";
-	$GLOBAL_ERR.= "<SPAN style='color:red; font-size:12px'><strong>" . $mess . "</strong></span>\n";
-	$GLOBAL_ERR.= "</td>\n";
-	$GLOBAL_ERR.= "	</tr>\n";
-	$GLOBAL_ERR.= "</table>\n";
-	
-	if($print) {
-		print($GLOBAL_ERR);
-	}
+    global $GLOBAL_ERR;
+    if($GLOBAL_ERR == "") {
+        $GLOBAL_ERR = "<meta http-equiv='Content-Type' content='text/html; charset=" . CHAR_CODE . "'>\n";
+    }
+    $GLOBAL_ERR.= "<table width='100%' border='0' cellspacing='0' cellpadding='0' summary=' '>\n";
+    $GLOBAL_ERR.= "<tr>\n";
+    $GLOBAL_ERR.= "<td bgcolor='#ffeebb' height='25' colspan='2' align='center'>\n";
+    $GLOBAL_ERR.= "<SPAN style='color:red; font-size:12px'><strong>" . $mess . "</strong></span>\n";
+    $GLOBAL_ERR.= "</td>\n";
+    $GLOBAL_ERR.= "	</tr>\n";
+    $GLOBAL_ERR.= "</table>\n";
+
+    if($print) {
+        print($GLOBAL_ERR);
+    }
 }
 
 /* エラーページの表示 */
 function sfDispError($type) {
-	
-	class LC_ErrorPage {
-		function LC_ErrorPage() {
-			$this->tpl_mainpage = 'login_error.tpl';
-			$this->tpl_title = 'エラー';
-		}
-	}
-
-	$objPage = new LC_ErrorPage();
-	$objView = new SC_AdminView();
-	
-	switch ($type) {
-	    case LOGIN_ERROR:
-			$objPage->tpl_error="ＩＤまたはパスワードが正しくありません。<br />もう一度ご確認のうえ、再度入力してください。";
-	    	break;
-		case ACCESS_ERROR:
-			$objPage->tpl_error="ログイン認証の有効期限切れの可能性があります。<br />もう一度ご確認のうえ、再度ログインしてください。";
-			break;
-		case AUTH_ERROR:
-			$objPage->tpl_error="このファイルにはアクセス権限がありません。<br />もう一度ご確認のうえ、再度ログインしてください。";
-			break;
-		case INVALID_MOVE_ERRORR:
-			$objPage->tpl_error="不正なページ移動です。<br />もう一度ご確認のうえ、再度入力してください。";
-			break;
-		default:
-	    	$objPage->tpl_error="エラーが発生しました。<br />もう一度ご確認のうえ、再度ログインしてください。";
-			break;
-	}
-	
-	$objView->assignobj($objPage);
-	$objView->display(LOGIN_FRAME);
-	
-	exit;
+
+    class LC_ErrorPage {
+        function LC_ErrorPage() {
+            $this->tpl_mainpage = 'login_error.tpl';
+            $this->tpl_title = 'エラー';
+        }
+    }
+
+    $objPage = new LC_ErrorPage();
+    $objView = new SC_AdminView();
+
+    switch ($type) {
+        case LOGIN_ERROR:
+            $objPage->tpl_error="ＩＤまたはパスワードが正しくありません。<br />もう一度ご確認のうえ、再度入力してください。";
+            break;
+        case ACCESS_ERROR:
+            $objPage->tpl_error="ログイン認証の有効期限切れの可能性があります。<br />もう一度ご確認のうえ、再度ログインしてください。";
+            break;
+        case AUTH_ERROR:
+            $objPage->tpl_error="このファイルにはアクセス権限がありません。<br />もう一度ご確認のうえ、再度ログインしてください。";
+            break;
+        case INVALID_MOVE_ERRORR:
+            $objPage->tpl_error="不正なページ移動です。<br />もう一度ご確認のうえ、再度入力してください。";
+            break;
+        default:
+            $objPage->tpl_error="エラーが発生しました。<br />もう一度ご確認のうえ、再度ログインしてください。";
+            break;
+    }
+
+    $objView->assignobj($objPage);
+    $objView->display(LOGIN_FRAME);
+
+    exit;
 }
 
 /* サイトエラーページの表示 */
 function sfDispSiteError($type, $objSiteSess = "", $return_top = false, $err_msg = "", $is_mobile = false) {
-	global $objCampaignSess;
-	
-	if ($objSiteSess != "") {
-		$objSiteSess->setNowPage('error');
-	}
-	
-	class LC_ErrorPage {
-		function LC_ErrorPage() {
-			$this->tpl_mainpage = 'error.tpl';
-			$this->tpl_css = URL_DIR.'css/layout/error.css';
-			$this->tpl_title = 'エラー';
-		}
-	}
-	
-	$objPage = new LC_ErrorPage();
-	
-	if($is_mobile === true) {
-		$objView = new SC_MobileView();		
-	} else {
-		$objView = new SC_SiteView();
-	}
-	
-	switch ($type) {
-	    case PRODUCT_NOT_FOUND:
-			$objPage->tpl_error="ご指定のページはございません。";
-			break;
-		case PAGE_ERROR:
-			$objPage->tpl_error="不正なページ移動です。";
-			break;
-		case CART_EMPTY:
-			$objPage->tpl_error="カートに商品ががありません。";
-			break;
-	    case CART_ADD_ERROR:
-			$objPage->tpl_error="購入処理中は、カートに商品を追加することはできません。";
-			break;
-		case CANCEL_PURCHASE:
-			$objPage->tpl_error="この手続きは無効となりました。以下の要因が考えられます。<br />・セッション情報の有効期限が切れてる場合<br />・購入手続き中に新しい購入手続きを実行した場合<br />・すでに購入手続きを完了している場合";
-			break;
-		case CATEGORY_NOT_FOUND:
-			$objPage->tpl_error="ご指定のカテゴリは存在しません。";
-			break;
-		case SITE_LOGIN_ERROR:
-			$objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。";
-			break;
-		case TEMP_LOGIN_ERROR:
-			$objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。<br />本登録がお済みでない場合は、仮登録メールに記載されている<br />URLより本登録を行ってください。";
-			break;
-		case CUSTOMER_ERROR:
-			$objPage->tpl_error="不正なアクセスです。";
-			break;
-		case SOLD_OUT:
-			$objPage->tpl_error="申し訳ございませんが、ご購入の直前で売り切れた商品があります。この手続きは無効となりました。";
-			break;
-		case CART_NOT_FOUND:
-			$objPage->tpl_error="申し訳ございませんが、カート内の商品情報の取得に失敗しました。この手続きは無効となりました。";
-			break;
-		case LACK_POINT:
-			$objPage->tpl_error="申し訳ございませんが、ポイントが不足しております。この手続きは無効となりました。";
-			break;
-		case FAVORITE_ERROR:
-			$objPage->tpl_error="既にお気に入りに追加されている商品です。";
-			break;
-		case EXTRACT_ERROR:
-			$objPage->tpl_error="ファイルの解凍に失敗しました。\n指定のディレクトリに書き込み権限が与えられていない可能性があります。";
-			break;
-		case FTP_DOWNLOAD_ERROR:
-			$objPage->tpl_error="ファイルのFTPダウンロードに失敗しました。";
-			break;
-		case FTP_LOGIN_ERROR:
-			$objPage->tpl_error="FTPログインに失敗しました。";
-			break;
-		case FTP_CONNECT_ERROR:
-			$objPage->tpl_error="FTPログインに失敗しました。";
-			break;
-		case CREATE_DB_ERROR:
-			$objPage->tpl_error="DBの作成に失敗しました。\n指定のユーザーには、DB作成の権限が与えられていない可能性があります。";
-			break;
-		case DB_IMPORT_ERROR:
-			$objPage->tpl_error="データベース構造のインポートに失敗しました。\nsqlファイルが壊れている可能性があります。";
-			break;
-		case FILE_NOT_FOUND:
-			$objPage->tpl_error="指定のパスに、設定ファイルが存在しません。";
-			break;
-		case WRITE_FILE_ERROR:
-			$objPage->tpl_error="設定ファイルに書き込めません。\n設定ファイルに書き込み権限を与えてください。";
-			break;
-		case FREE_ERROR_MSG:
-			$objPage->tpl_error=$err_msg;
-			break;
- 		default:
-	    	$objPage->tpl_error="エラーが発生しました。";
-			break;
-	}
-	
-	$objPage->return_top = $return_top;
-	
-	$objView->assignobj($objPage);
-	
-	if(is_object($objCampaignSess)) {
-		// フレームを選択(キャンペーンページから遷移なら変更)
-		$objCampaignSess->pageView($objView);
-	} else {
-		$objView->display(SITE_FRAME);
-	}	
-	exit;
+    global $objCampaignSess;
+
+    if ($objSiteSess != "") {
+        $objSiteSess->setNowPage('error');
+    }
+
+    class LC_ErrorPage {
+        function LC_ErrorPage() {
+            $this->tpl_mainpage = 'error.tpl';
+            $this->tpl_css = URL_DIR.'css/layout/error.css';
+            $this->tpl_title = 'エラー';
+        }
+    }
+
+    $objPage = new LC_ErrorPage();
+
+    if($is_mobile === true) {
+        $objView = new SC_MobileView();
+    } else {
+        $objView = new SC_SiteView();
+    }
+
+    switch ($type) {
+        case PRODUCT_NOT_FOUND:
+            $objPage->tpl_error="ご指定のページはございません。";
+            break;
+        case PAGE_ERROR:
+            $objPage->tpl_error="不正なページ移動です。";
+            break;
+        case CART_EMPTY:
+            $objPage->tpl_error="カートに商品ががありません。";
+            break;
+        case CART_ADD_ERROR:
+            $objPage->tpl_error="購入処理中は、カートに商品を追加することはできません。";
+            break;
+        case CANCEL_PURCHASE:
+            $objPage->tpl_error="この手続きは無効となりました。以下の要因が考えられます。<br />・セッション情報の有効期限が切れてる場合<br />・購入手続き中に新しい購入手続きを実行した場合<br />・すでに購入手続きを完了している場合";
+            break;
+        case CATEGORY_NOT_FOUND:
+            $objPage->tpl_error="ご指定のカテゴリは存在しません。";
+            break;
+        case SITE_LOGIN_ERROR:
+            $objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。";
+            break;
+        case TEMP_LOGIN_ERROR:
+            $objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。<br />本登録がお済みでない場合は、仮登録メールに記載されている<br />URLより本登録を行ってください。";
+            break;
+        case CUSTOMER_ERROR:
+            $objPage->tpl_error="不正なアクセスです。";
+            break;
+        case SOLD_OUT:
+            $objPage->tpl_error="申し訳ございませんが、ご購入の直前で売り切れた商品があります。この手続きは無効となりました。";
+            break;
+        case CART_NOT_FOUND:
+            $objPage->tpl_error="申し訳ございませんが、カート内の商品情報の取得に失敗しました。この手続きは無効となりました。";
+            break;
+        case LACK_POINT:
+            $objPage->tpl_error="申し訳ございませんが、ポイントが不足しております。この手続きは無効となりました。";
+            break;
+        case FAVORITE_ERROR:
+            $objPage->tpl_error="既にお気に入りに追加されている商品です。";
+            break;
+        case EXTRACT_ERROR:
+            $objPage->tpl_error="ファイルの解凍に失敗しました。\n指定のディレクトリに書き込み権限が与えられていない可能性があります。";
+            break;
+        case FTP_DOWNLOAD_ERROR:
+            $objPage->tpl_error="ファイルのFTPダウンロードに失敗しました。";
+            break;
+        case FTP_LOGIN_ERROR:
+            $objPage->tpl_error="FTPログインに失敗しました。";
+            break;
+        case FTP_CONNECT_ERROR:
+            $objPage->tpl_error="FTPログインに失敗しました。";
+            break;
+        case CREATE_DB_ERROR:
+            $objPage->tpl_error="DBの作成に失敗しました。\n指定のユーザーには、DB作成の権限が与えられていない可能性があります。";
+            break;
+        case DB_IMPORT_ERROR:
+            $objPage->tpl_error="データベース構造のインポートに失敗しました。\nsqlファイルが壊れている可能性があります。";
+            break;
+        case FILE_NOT_FOUND:
+            $objPage->tpl_error="指定のパスに、設定ファイルが存在しません。";
+            break;
+        case WRITE_FILE_ERROR:
+            $objPage->tpl_error="設定ファイルに書き込めません。\n設定ファイルに書き込み権限を与えてください。";
+            break;
+        case FREE_ERROR_MSG:
+            $objPage->tpl_error=$err_msg;
+            break;
+         default:
+            $objPage->tpl_error="エラーが発生しました。";
+            break;
+    }
+
+    $objPage->return_top = $return_top;
+
+    $objView->assignobj($objPage);
+
+    if(is_object($objCampaignSess)) {
+        // フレームを選択(キャンペーンページから遷移なら変更)
+        $objCampaignSess->pageView($objView);
+    } else {
+        $objView->display(SITE_FRAME);
+    }
+    exit;
 }
 
 /* 認証の可否判定 */
 function sfIsSuccess($objSess, $disp_error = true) {
-	$ret = $objSess->IsSuccess();
-	if($ret != SUCCESS) {
-		if($disp_error) {
-			// エラーページの表示
-			sfDispError($ret);
-		}
-		return false;
-	}
+    $ret = $objSess->IsSuccess();
+    if($ret != SUCCESS) {
+        if($disp_error) {
+            // エラーページの表示
+            sfDispError($ret);
+        }
+        return false;
+    }
     // リファラーチェック(CSRFの暫定的な対策)
     // 「リファラ無」 の場合はスルー
@@ -496,5 +496,5 @@
 /**
  * HTTPSかどうかを判定
- * 
+ *
  * @return bool
  */
@@ -527,204 +527,204 @@
 /* 前のページで正しく登録が行われたか判定 */
 function sfIsPrePage($objSiteSess, $is_mobile = false) {
-	$ret = $objSiteSess->isPrePage();
-	if($ret != true) {
-		// エラーページの表示
-		sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile);			
-	}
+    $ret = $objSiteSess->isPrePage();
+    if($ret != true) {
+        // エラーページの表示
+        sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile);
+    }
 }
 
 function sfCheckNormalAccess($objSiteSess, $objCartSess) {
-	// ユーザユニークIDの取得
-	$uniqid = $objSiteSess->getUniqId();
-	// 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。
-	$objCartSess->saveCurrentCart($uniqid);
-	// POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー)
-	$ret = $objSiteSess->checkUniqId();
-	if($ret != true) {
-		// エラーページの表示
-		sfDispSiteError(CANCEL_PURCHASE, $objSiteSess);
-	}
-	
-	// カート内が空でないか || 購入ボタンを押してから変化がないか
-	$quantity = $objCartSess->getTotalQuantity();
-	$ret = $objCartSess->checkChangeCart();
-	if($ret == true || !($quantity > 0)) {
-		// カート情報表示に強制移動する
-		header("Location: ".URL_CART_TOP);
-		exit;
-	}
-	return $uniqid;
+    // ユーザユニークIDの取得
+    $uniqid = $objSiteSess->getUniqId();
+    // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。
+    $objCartSess->saveCurrentCart($uniqid);
+    // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー)
+    $ret = $objSiteSess->checkUniqId();
+    if($ret != true) {
+        // エラーページの表示
+        sfDispSiteError(CANCEL_PURCHASE, $objSiteSess);
+    }
+
+    // カート内が空でないか || 購入ボタンを押してから変化がないか
+    $quantity = $objCartSess->getTotalQuantity();
+    $ret = $objCartSess->checkChangeCart();
+    if($ret == true || !($quantity > 0)) {
+        // カート情報表示に強制移動する
+        header("Location: ".URL_CART_TOP);
+        exit;
+    }
+    return $uniqid;
 }
 
 /* DB用日付文字列取得 */
 function sfGetTimestamp($year, $month, $day, $last = false) {
-	if($year != "" && $month != "" && $day != "") {	
-		if($last) {
-			$time = "23:59:59";
-		} else {
-			$time = "00:00:00";
-		}
-		$date = $year."-".$month."-".$day." ".$time;
-	} else {
-		$date = "";
-	}
-	return 	$date;
+    if($year != "" && $month != "" && $day != "") {
+        if($last) {
+            $time = "23:59:59";
+        } else {
+            $time = "00:00:00";
+        }
+        $date = $year."-".$month."-".$day." ".$time;
+    } else {
+        $date = "";
+    }
+    return 	$date;
 }
 
 // INT型の数値チェック
 function sfIsInt($value) {
-	if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) {
-		return true;
-	}
-	return false;
+    if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) {
+        return true;
+    }
+    return false;
 }
 
 function sfCSVDownload($data, $prefix = ""){
-	
-	if($prefix == "") {
-		$dir_name = sfUpDirName();
-		$file_name = $dir_name . date("ymdHis") .".csv";
-	} else {
-		$file_name = $prefix . date("ymdHis") .".csv";
-	}
-	
-	/* HTTPヘッダの出力 */
-	Header("Content-disposition: attachment; filename=${file_name}");
-	Header("Content-type: application/octet-stream; name=${file_name}");
-	Header("Cache-Control: ");
-	Header("Pragma: ");
-	
-	/* i18n~ だと正常に動作しないため、mb~ に変更
-	if (i18n_discover_encoding($data) == CHAR_CODE){
-		$data = i18n_convert($data,'SJIS',CHAR_CODE);
-	}
-	*/
-	if (mb_internal_encoding() == CHAR_CODE){
-		$data = mb_convert_encoding($data,'SJIS',CHAR_CODE);
-	}
-	
-	/* データを出力 */
-	echo $data;
+
+    if($prefix == "") {
+        $dir_name = sfUpDirName();
+        $file_name = $dir_name . date("ymdHis") .".csv";
+    } else {
+        $file_name = $prefix . date("ymdHis") .".csv";
+    }
+
+    /* HTTPヘッダの出力 */
+    Header("Content-disposition: attachment; filename=${file_name}");
+    Header("Content-type: application/octet-stream; name=${file_name}");
+    Header("Cache-Control: ");
+    Header("Pragma: ");
+
+    /* i18n~ だと正常に動作しないため、mb~ に変更
+    if (i18n_discover_encoding($data) == CHAR_CODE){
+        $data = i18n_convert($data,'SJIS',CHAR_CODE);
+    }
+    */
+    if (mb_internal_encoding() == CHAR_CODE){
+        $data = mb_convert_encoding($data,'SJIS',CHAR_CODE);
+    }
+
+    /* データを出力 */
+    echo $data;
 }
 
 /* 1階層上のディレクトリ名を取得する */
 function sfUpDirName() {
-	$path = $_SERVER['PHP_SELF'];
-	$arrVal = split("/", $path);
-	$cnt = count($arrVal);
-	return $arrVal[($cnt - 2)];
+    $path = $_SERVER['PHP_SELF'];
+    $arrVal = split("/", $path);
+    $cnt = count($arrVal);
+    return $arrVal[($cnt - 2)];
 }
 
 // 現在のサイトを更新（ただしポストは行わない）
 function sfReload($get = "") {
-	if ($_SERVER["SERVER_PORT"] == "443" ){
-		$url = ereg_replace(URL_DIR . "$", "", SSL_URL);
-	} else {
-		$url = ereg_replace(URL_DIR . "$", "", SITE_URL);
-	}
-	
-	if($get != "") {
-		header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get);
-	} else {
-		header("Location: ". $url . $_SERVER['PHP_SELF']);
-	}
-	exit;
+    if ($_SERVER["SERVER_PORT"] == "443" ){
+        $url = ereg_replace(URL_DIR . "$", "", SSL_URL);
+    } else {
+        $url = ereg_replace(URL_DIR . "$", "", SITE_URL);
+    }
+
+    if($get != "") {
+        header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get);
+    } else {
+        header("Location: ". $url . $_SERVER['PHP_SELF']);
+    }
+    exit;
 }
 
 // ランキングを上げる。
 function sfRankUp($table, $colname, $id, $andwhere = "") {
-	$objQuery = new SC_Query();
-	$objQuery->begin();
-	$where = "$colname = ?";
-	if($andwhere != "") {
-		$where.= " AND $andwhere";
-	}
-	// 対象項目のランクを取得
-	$rank = $objQuery->get($table, "rank", $where, array($id));
-	// ランクの最大値を取得
-	$maxrank = $objQuery->max($table, "rank", $andwhere);
-	// ランクが最大値よりも小さい場合に実行する。
-	if($rank < $maxrank) {
-		// ランクが一つ上のIDを取得する。
-		$where = "rank = ?";
-		if($andwhere != "") {
-			$where.= " AND $andwhere";
-		}
-		$uprank = $rank + 1;
-		$up_id = $objQuery->get($table, $colname, $where, array($uprank));
-		// ランク入れ替えの実行
-		$sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
-		$objQuery->exec($sqlup, array($rank + 1, $id));
-		$objQuery->exec($sqlup, array($rank, $up_id));
-	}
-	$objQuery->commit();
+    $objQuery = new SC_Query();
+    $objQuery->begin();
+    $where = "$colname = ?";
+    if($andwhere != "") {
+        $where.= " AND $andwhere";
+    }
+    // 対象項目のランクを取得
+    $rank = $objQuery->get($table, "rank", $where, array($id));
+    // ランクの最大値を取得
+    $maxrank = $objQuery->max($table, "rank", $andwhere);
+    // ランクが最大値よりも小さい場合に実行する。
+    if($rank < $maxrank) {
+        // ランクが一つ上のIDを取得する。
+        $where = "rank = ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        $uprank = $rank + 1;
+        $up_id = $objQuery->get($table, $colname, $where, array($uprank));
+        // ランク入れ替えの実行
+        $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
+        $objQuery->exec($sqlup, array($rank + 1, $id));
+        $objQuery->exec($sqlup, array($rank, $up_id));
+    }
+    $objQuery->commit();
 }
 
 // ランキングを下げる。
 function sfRankDown($table, $colname, $id, $andwhere = "") {
-	$objQuery = new SC_Query();
-	$objQuery->begin();
-	$where = "$colname = ?";
-	if($andwhere != "") {
-		$where.= " AND $andwhere";
-	}
-	// 対象項目のランクを取得
-	$rank = $objQuery->get($table, "rank", $where, array($id));
-		
-	// ランクが1(最小値)よりも大きい場合に実行する。
-	if($rank > 1) {
-		// ランクが一つ下のIDを取得する。
-		$where = "rank = ?";
-		if($andwhere != "") {
-			$where.= " AND $andwhere";
-		}
-		$downrank = $rank - 1;
-		$down_id = $objQuery->get($table, $colname, $where, array($downrank));
-		// ランク入れ替えの実行
-		$sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
-		$objQuery->exec($sqlup, array($rank - 1, $id));
-		$objQuery->exec($sqlup, array($rank, $down_id));
-	}
-	$objQuery->commit();
+    $objQuery = new SC_Query();
+    $objQuery->begin();
+    $where = "$colname = ?";
+    if($andwhere != "") {
+        $where.= " AND $andwhere";
+    }
+    // 対象項目のランクを取得
+    $rank = $objQuery->get($table, "rank", $where, array($id));
+
+    // ランクが1(最小値)よりも大きい場合に実行する。
+    if($rank > 1) {
+        // ランクが一つ下のIDを取得する。
+        $where = "rank = ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        $downrank = $rank - 1;
+        $down_id = $objQuery->get($table, $colname, $where, array($downrank));
+        // ランク入れ替えの実行
+        $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
+        $objQuery->exec($sqlup, array($rank - 1, $id));
+        $objQuery->exec($sqlup, array($rank, $down_id));
+    }
+    $objQuery->commit();
 }
 
 //----　指定順位へ移動
 function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") {
-	$objQuery = new SC_Query();
-	$objQuery->begin();
-		
-	// 自身のランクを取得する
-	$rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId));	
-	$max = $objQuery->max($tableName, "rank", $where);
-		
-	// 値の調整（逆順）
-	if($pos > $max) {
-		$position = 1;
-	} else if($pos < 1) {
-		$position = $max;
-	} else {
-		$position = $max - $pos + 1;
-	}
-	
-	if( $position > $rank ) $term = "rank - 1";	//入れ替え先の順位が入れ換え元の順位より大きい場合
-	if( $position < $rank ) $term = "rank + 1";	//入れ替え先の順位が入れ換え元の順位より小さい場合
-
-	//--　指定した順位の商品から移動させる商品までのrankを１つずらす
-	$sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0";
-	if($where != "") {
-		$sql.= " AND $where";
-	}
-	
-	if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position ));
-	if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 ));
-
-	//-- 指定した順位へrankを書き換える。
-	$sql  = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 ";
-	if($where != "") {
-		$sql.= " AND $where";
-	}
-	
-	$objQuery->exec( $sql, array( $position, $keyId ) );
-	$objQuery->commit();
+    $objQuery = new SC_Query();
+    $objQuery->begin();
+
+    // 自身のランクを取得する
+    $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId));
+    $max = $objQuery->max($tableName, "rank", $where);
+
+    // 値の調整（逆順）
+    if($pos > $max) {
+        $position = 1;
+    } else if($pos < 1) {
+        $position = $max;
+    } else {
+        $position = $max - $pos + 1;
+    }
+
+    if( $position > $rank ) $term = "rank - 1";	//入れ替え先の順位が入れ換え元の順位より大きい場合
+    if( $position < $rank ) $term = "rank + 1";	//入れ替え先の順位が入れ換え元の順位より小さい場合
+
+    //--　指定した順位の商品から移動させる商品までのrankを１つずらす
+    $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0";
+    if($where != "") {
+        $sql.= " AND $where";
+    }
+
+    if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position ));
+    if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 ));
+
+    //-- 指定した順位へrankを書き換える。
+    $sql  = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 ";
+    if($where != "") {
+        $sql.= " AND $where";
+    }
+
+    $objQuery->exec( $sql, array( $position, $keyId ) );
+    $objQuery->commit();
 }
 
@@ -732,91 +732,91 @@
 // レコードごと削除する場合は、$deleteをtrueにする。
 function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", $delete = false) {
-	$objQuery = new SC_Query();
-	$objQuery->begin();
-	// 削除レコードのランクを取得する。		
-	$where = "$colname = ?";
-	if($andwhere != "") {
-		$where.= " AND $andwhere";
-	}
-	$rank = $objQuery->get($table, "rank", $where, array($id));
-
-	if(!$delete) {
-		// ランクを最下位にする、DELフラグON
-		$sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() ";
-		$sqlup.= "WHERE $colname = ?";
-		// UPDATEの実行
-		$objQuery->exec($sqlup, array($id));
-	} else {
-		$objQuery->delete($table, "$colname = ?", array($id));
-	}
-	
-	// 追加レコードのランクより上のレコードを一つずらす。
-	$where = "rank > ?";
-	if($andwhere != "") {
-		$where.= " AND $andwhere";
-	}
-	$sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
-	$objQuery->exec($sqlup, array($rank));
-	$objQuery->commit();
+    $objQuery = new SC_Query();
+    $objQuery->begin();
+    // 削除レコードのランクを取得する。
+    $where = "$colname = ?";
+    if($andwhere != "") {
+        $where.= " AND $andwhere";
+    }
+    $rank = $objQuery->get($table, "rank", $where, array($id));
+
+    if(!$delete) {
+        // ランクを最下位にする、DELフラグON
+        $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() ";
+        $sqlup.= "WHERE $colname = ?";
+        // UPDATEの実行
+        $objQuery->exec($sqlup, array($id));
+    } else {
+        $objQuery->delete($table, "$colname = ?", array($id));
+    }
+
+    // 追加レコードのランクより上のレコードを一つずらす。
+    $where = "rank > ?";
+    if($andwhere != "") {
+        $where.= " AND $andwhere";
+    }
+    $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
+    $objQuery->exec($sqlup, array($rank));
+    $objQuery->commit();
 }
 
 // レコードの存在チェック
 function sfIsRecord($table, $col, $arrval, $addwhere = "") {
-	$objQuery = new SC_Query();
-	$arrCol = split("[, ]", $col);
-		
-	$where = "del_flg = 0";
-	
-	if($addwhere != "") {
-		$where.= " AND $addwhere";
-	}
-		
-	foreach($arrCol as $val) {
-		if($val != "") {
-			if($where == "") {
-				$where = "$val = ?";
-			} else {
-				$where.= " AND $val = ?";
-			}
-		}
-	}
-	$ret = $objQuery->get($table, $col, $where, $arrval);
-	
-	if($ret != "") {
-		return true;
-	}
-	return false;
+    $objQuery = new SC_Query();
+    $arrCol = split("[, ]", $col);
+
+    $where = "del_flg = 0";
+
+    if($addwhere != "") {
+        $where.= " AND $addwhere";
+    }
+
+    foreach($arrCol as $val) {
+        if($val != "") {
+            if($where == "") {
+                $where = "$val = ?";
+            } else {
+                $where.= " AND $val = ?";
+            }
+        }
+    }
+    $ret = $objQuery->get($table, $col, $where, $arrval);
+
+    if($ret != "") {
+        return true;
+    }
+    return false;
 }
 
 // チェックボックスの値をマージ
 function sfMergeCBValue($keyname, $max) {
-	$conv = "";
-	$cnt = 1;
-	for($cnt = 1; $cnt <= $max; $cnt++) {
-		if ($_POST[$keyname . $cnt] == "1") {
-			$conv.= "1";
-		} else {
-			$conv.= "0";
-		}
-	}
-	return $conv;
+    $conv = "";
+    $cnt = 1;
+    for($cnt = 1; $cnt <= $max; $cnt++) {
+        if ($_POST[$keyname . $cnt] == "1") {
+            $conv.= "1";
+        } else {
+            $conv.= "0";
+        }
+    }
+    return $conv;
 }
 
 // html_checkboxesの値をマージして2進数形式に変更する。
 function sfMergeCheckBoxes($array, $max) {
-	$ret = "";
-	if(is_array($array)) {	
-		foreach($array as $val) {
-			$arrTmp[$val] = "1";
-		}
-	}
-	for($i = 1; $i <= $max; $i++) {	
-		if($arrTmp[$i] == "1") {
-			$ret.= "1";
-		} else {
-			$ret.= "0";
-		}
-	}
-	return $ret;
+    $ret = "";
+    if(is_array($array)) {
+        foreach($array as $val) {
+            $arrTmp[$val] = "1";
+        }
+    }
+    for($i = 1; $i <= $max; $i++) {
+        if($arrTmp[$i] == "1") {
+            $ret.= "1";
+        } else {
+            $ret.= "0";
+        }
+    }
+    return $ret;
 }
 
@@ -825,177 +825,177 @@
 function sfMergeParamCheckBoxes($array) {
     $ret = '';
-	if(is_array($array)) {
-		foreach($array as $val) {
-			if($ret != "") {
-				$ret.= "-$val";
-			} else {
-				$ret = $val;			
-			}
-		}
-	} else {
-		$ret = $array;
-	}
-	return $ret;
+    if(is_array($array)) {
+        foreach($array as $val) {
+            if($ret != "") {
+                $ret.= "-$val";
+            } else {
+                $ret = $val;
+            }
+        }
+    } else {
+        $ret = $array;
+    }
+    return $ret;
 }
 
 // html_checkboxesの値をマージしてSQL検索用に変更する。
 function sfSearchCheckBoxes($array) {
-	$max = 0;
-	$ret = "";
-	foreach($array as $val) {
-		$arrTmp[$val] = "1";
-		if($val > $max) {
-			$max = $val;
-		}
-	}
-	for($i = 1; $i <= $max; $i++) {	
-		if($arrTmp[$i] == "1") {
-			$ret.= "1";
-		} else {
-			$ret.= "_";
-		}
-	}
-	
-	if($ret != "") {	
-		$ret.= "%";
-	}
-	return $ret;
+    $max = 0;
+    $ret = "";
+    foreach($array as $val) {
+        $arrTmp[$val] = "1";
+        if($val > $max) {
+            $max = $val;
+        }
+    }
+    for($i = 1; $i <= $max; $i++) {
+        if($arrTmp[$i] == "1") {
+            $ret.= "1";
+        } else {
+            $ret.= "_";
+        }
+    }
+
+    if($ret != "") {
+        $ret.= "%";
+    }
+    return $ret;
 }
 
 // 2進数形式の値をhtml_checkboxes対応の値に切り替える
 function sfSplitCheckBoxes($val) {
-	$len = strlen($val);
-	for($i = 0; $i < $len; $i++) {
-		if(substr($val, $i, 1) == "1") {
-			$arrRet[] = ($i + 1);
-		}
-	}
-	return $arrRet;
+    $len = strlen($val);
+    for($i = 0; $i < $len; $i++) {
+        if(substr($val, $i, 1) == "1") {
+            $arrRet[] = ($i + 1);
+        }
+    }
+    return $arrRet;
 }
 
 // チェックボックスの値をマージ
 function sfMergeCBSearchValue($keyname, $max) {
-	$conv = "";
-	$cnt = 1;
-	for($cnt = 1; $cnt <= $max; $cnt++) {
-		if ($_POST[$keyname . $cnt] == "1") {
-			$conv.= "1";
-		} else {
-			$conv.= "_";
-		}
-	}
-	return $conv;
+    $conv = "";
+    $cnt = 1;
+    for($cnt = 1; $cnt <= $max; $cnt++) {
+        if ($_POST[$keyname . $cnt] == "1") {
+            $conv.= "1";
+        } else {
+            $conv.= "_";
+        }
+    }
+    return $conv;
 }
 
 // チェックボックスの値を分解
 function sfSplitCBValue($val, $keyname = "") {
-	$len = strlen($val);
-	$no = 1;
-	for ($cnt = 0; $cnt < $len; $cnt++) {
-		if($keyname != "") {
-			$arr[$keyname . $no] = substr($val, $cnt, 1);
-		} else {
-			$arr[] = substr($val, $cnt, 1);
-		}
-		$no++;
-	}
-	return $arr;
+    $len = strlen($val);
+    $no = 1;
+    for ($cnt = 0; $cnt < $len; $cnt++) {
+        if($keyname != "") {
+            $arr[$keyname . $no] = substr($val, $cnt, 1);
+        } else {
+            $arr[] = substr($val, $cnt, 1);
+        }
+        $no++;
+    }
+    return $arr;
 }
 
 // キーと値をセットした配列を取得
 function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") {
-	
-	$max = count($arrList);
-	
-	if($len_max != "" && $max > $len_max) {
-		$max = $len_max;
-	}
-	
-	for($cnt = 0; $cnt < $max; $cnt++) {
-		if($keysize != "") {
-			$key = sfCutString($arrList[$cnt][$keyname], $keysize);
-		} else {
-			$key = $arrList[$cnt][$keyname];
-		}
-		$val = $arrList[$cnt][$valname];
-		
-		if(!isset($arrRet[$key])) {
-			$arrRet[$key] = $val;
-		}
-		
-	}
-	return $arrRet;
+
+    $max = count($arrList);
+
+    if($len_max != "" && $max > $len_max) {
+        $max = $len_max;
+    }
+
+    for($cnt = 0; $cnt < $max; $cnt++) {
+        if($keysize != "") {
+            $key = sfCutString($arrList[$cnt][$keyname], $keysize);
+        } else {
+            $key = $arrList[$cnt][$keyname];
+        }
+        $val = $arrList[$cnt][$valname];
+
+        if(!isset($arrRet[$key])) {
+            $arrRet[$key] = $val;
+        }
+
+    }
+    return $arrRet;
 }
 
 // キーと値をセットした配列を取得(値が複数の場合)
 function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") {
-	
-	$max = count($arrList);
-	
-	if($len_max != "" && $max > $len_max) {
-		$max = $len_max;
-	}
-	
-	for($cnt = 0; $cnt < $max; $cnt++) {
-		if($keysize != "") {
-			$key = sfCutString($arrList[$cnt][$keyname], $keysize);
-		} else {
-			$key = $arrList[$cnt][$keyname];
-		}
-		$val = $arrList[$cnt][$valname];
-		
-		if($connect != "") {
-			$arrRet[$key].= "$val".$connect;
-		} else {
-			$arrRet[$key][] = $val;		
-		}
-	}
-	return $arrRet;
+
+    $max = count($arrList);
+
+    if($len_max != "" && $max > $len_max) {
+        $max = $len_max;
+    }
+
+    for($cnt = 0; $cnt < $max; $cnt++) {
+        if($keysize != "") {
+            $key = sfCutString($arrList[$cnt][$keyname], $keysize);
+        } else {
+            $key = $arrList[$cnt][$keyname];
+        }
+        $val = $arrList[$cnt][$valname];
+
+        if($connect != "") {
+            $arrRet[$key].= "$val".$connect;
+        } else {
+            $arrRet[$key][] = $val;
+        }
+    }
+    return $arrRet;
 }
 
 // 配列の値をカンマ区切りで返す。
 function sfGetCommaList($array, $space=true) {
-	if (count($array) > 0) {
-		$line = "";
-		foreach($array as $val) {
-			if ($space) {
-				$line .= $val . ", ";
-			}else{
-				$line .= $val . ",";
-			}
-		}
-		if ($space) {
-			$line = ereg_replace(", $", "", $line);
-		}else{
-			$line = ereg_replace(",$", "", $line);
-		}
-		return $line;
-	}else{
-		return false;
-	}
-	
+    if (count($array) > 0) {
+        $line = "";
+        foreach($array as $val) {
+            if ($space) {
+                $line .= $val . ", ";
+            }else{
+                $line .= $val . ",";
+            }
+        }
+        if ($space) {
+            $line = ereg_replace(", $", "", $line);
+        }else{
+            $line = ereg_replace(",$", "", $line);
+        }
+        return $line;
+    }else{
+        return false;
+    }
+
 }
 
 /* 配列の要素をCSVフォーマットで出力する。*/
 function sfGetCSVList($array) {
-	if (count($array) > 0) {
-		foreach($array as $key => $val) {
-			$val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
-			$line .= "\"".$val."\",";
-		}
-		$line = ereg_replace(",$", "\n", $line);
-	}else{
-		return false;
-	}
-	return $line;
+    if (count($array) > 0) {
+        foreach($array as $key => $val) {
+            $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
+            $line .= "\"".$val."\",";
+        }
+        $line = ereg_replace(",$", "\n", $line);
+    }else{
+        return false;
+    }
+    return $line;
 }
 
 /* 配列の要素をPDFフォーマットで出力する。*/
 function sfGetPDFList($array) {
-	foreach($array as $key => $val) {
-		$line .= "\t".$val;
-	}
-	$line.="\n";
-	return $line;
+    foreach($array as $key => $val) {
+        $line .= "\t".$val;
+    }
+    $line.="\n";
+    return $line;
 }
 
@@ -1013,27 +1013,27 @@
 function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) {
 
-	// 期間指定
-	$error = 0;
-	if ( $start_month || $start_day || $start_year){
-		if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1;
-	} else {
-		$error = 1;
-	}
-	if ( $end_month || $end_day || $end_year){
-		if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2;
-	}
-	if ( ! $error ){
-		$date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000";
-		$date2 = $end_year   ."/".sprintf("%02d",$end_month)   ."/".sprintf("%02d",$end_day)   ." 235959";
-		if ($date1 > $date2) $error = 3;
-	} else {
-		$error = 1;
-	}
-	return array($date1, $date2, $error);
+    // 期間指定
+    $error = 0;
+    if ( $start_month || $start_day || $start_year){
+        if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1;
+    } else {
+        $error = 1;
+    }
+    if ( $end_month || $end_day || $end_year){
+        if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2;
+    }
+    if ( ! $error ){
+        $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000";
+        $date2 = $end_year   ."/".sprintf("%02d",$end_month)   ."/".sprintf("%02d",$end_day)   ." 235959";
+        if ($date1 > $date2) $error = 3;
+    } else {
+        $error = 1;
+    }
+    return array($date1, $date2, $error);
 }
 
 // エラー箇所の背景色を変更するためのfunction SC_Viewで読み込む
 function sfSetErrorStyle(){
-	return 'style="background-color:'.ERR_COLOR.'"';
+    return 'style="background-color:'.ERR_COLOR.'"';
 }
 
@@ -1042,149 +1042,149 @@
  */
 function sfCheckNumLength( $value ){
-	if ( ! is_numeric($value)  ){
-		return false;
-	} 
-	
-	if ( strlen($value) > 9 ) {
-		return false;
-	}
-	
-	return true;
+    if ( ! is_numeric($value)  ){
+        return false;
+    }
+
+    if ( strlen($value) > 9 ) {
+        return false;
+    }
+
+    return true;
 }
 
 // 一致した値のキー名を取得
 function sfSearchKey($array, $word, $default) {
-	foreach($array as $key => $val) {
-		if($val == $word) {
-			return $key;
-		}
-	}
-	return $default;
+    foreach($array as $key => $val) {
+        if($val == $word) {
+            return $key;
+        }
+    }
+    return $default;
 }
 
 // カテゴリツリーの取得($products_check:true商品登録済みのものだけ取得)
 function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) {
-	$objQuery = new SC_Query();
-	$where = "del_flg = 0";
-	
-	if($addwhere != "") {
-		$where.= " AND $addwhere";
-	}
-		
-	$objQuery->setoption("ORDER BY rank DESC");
-	
-	if($products_check) {
-		$col = "T1.category_id, category_name, level";
-		$from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id";
-		$where .= " AND product_count > 0";
-	} else {
-		$col = "category_id, category_name, level";
-		$from = "dtb_category";
-	}
-	
-	$arrRet = $objQuery->select($col, $from, $where);
-			
-	$max = count($arrRet);
-	for($cnt = 0; $cnt < $max; $cnt++) {
-		$id = $arrRet[$cnt]['category_id'];
-		$name = $arrRet[$cnt]['category_name'];
-		$arrList[$id] = "";
-		/*
-		for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
-			$arrList[$id].= "　";
-		}
-		*/
-		for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
-			$arrList[$id].= $head;
-		}
-		$arrList[$id].= $name;
-	}
-	return $arrList;
+    $objQuery = new SC_Query();
+    $where = "del_flg = 0";
+
+    if($addwhere != "") {
+        $where.= " AND $addwhere";
+    }
+
+    $objQuery->setoption("ORDER BY rank DESC");
+
+    if($products_check) {
+        $col = "T1.category_id, category_name, level";
+        $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id";
+        $where .= " AND product_count > 0";
+    } else {
+        $col = "category_id, category_name, level";
+        $from = "dtb_category";
+    }
+
+    $arrRet = $objQuery->select($col, $from, $where);
+
+    $max = count($arrRet);
+    for($cnt = 0; $cnt < $max; $cnt++) {
+        $id = $arrRet[$cnt]['category_id'];
+        $name = $arrRet[$cnt]['category_name'];
+        $arrList[$id] = "";
+        /*
+        for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
+            $arrList[$id].= "　";
+        }
+        */
+        for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
+            $arrList[$id].= $head;
+        }
+        $arrList[$id].= $name;
+    }
+    return $arrList;
 }
 
 // カテゴリツリーの取得（親カテゴリのValue:0)
 function sfGetLevelCatList($parent_zero = true) {
-	$objQuery = new SC_Query();
-	$col = "category_id, category_name, level";
-	$where = "del_flg = 0";
-	$objQuery->setoption("ORDER BY rank DESC");
-	$arrRet = $objQuery->select($col, "dtb_category", $where);
-	$max = count($arrRet);
-	
-	for($cnt = 0; $cnt < $max; $cnt++) {
-		if($parent_zero) {
-			if($arrRet[$cnt]['level'] == LEVEL_MAX) {
-				$arrValue[$cnt] = $arrRet[$cnt]['category_id'];
-			} else {
-				$arrValue[$cnt] = ""; 
-			}
-		} else {
-			$arrValue[$cnt] = $arrRet[$cnt]['category_id'];
-		}
-		
-		$arrOutput[$cnt] = "";
-		/*	 		
-		for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
-			$arrOutput[$cnt].= "　";
-		}
-		*/
-		for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
-			$arrOutput[$cnt].= CATEGORY_HEAD;
-		}
-		$arrOutput[$cnt].= $arrRet[$cnt]['category_name'];
-	}
-	return array($arrValue, $arrOutput);
+    $objQuery = new SC_Query();
+    $col = "category_id, category_name, level";
+    $where = "del_flg = 0";
+    $objQuery->setoption("ORDER BY rank DESC");
+    $arrRet = $objQuery->select($col, "dtb_category", $where);
+    $max = count($arrRet);
+
+    for($cnt = 0; $cnt < $max; $cnt++) {
+        if($parent_zero) {
+            if($arrRet[$cnt]['level'] == LEVEL_MAX) {
+                $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
+            } else {
+                $arrValue[$cnt] = "";
+            }
+        } else {
+            $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
+        }
+
+        $arrOutput[$cnt] = "";
+        /*
+        for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
+            $arrOutput[$cnt].= "　";
+        }
+        */
+        for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
+            $arrOutput[$cnt].= CATEGORY_HEAD;
+        }
+        $arrOutput[$cnt].= $arrRet[$cnt]['category_name'];
+    }
+    return array($arrValue, $arrOutput);
 }
 
 function sfGetErrorColor($val) {
-	if($val != "") {
-		return "background-color:" . ERR_COLOR;
-	}
-	return "";
+    if($val != "") {
+        return "background-color:" . ERR_COLOR;
+    }
+    return "";
 }
 
 
 function sfGetEnabled($val) {
-	if( ! $val ) {
-		return " disabled=\"disabled\"";
-	}
-	return "";
+    if( ! $val ) {
+        return " disabled=\"disabled\"";
+    }
+    return "";
 }
 
 function sfGetChecked($param, $value) {
-	if($param == $value) {
-		return "checked=\"checked\"";
-	}
-	return "";
+    if($param == $value) {
+        return "checked=\"checked\"";
+    }
+    return "";
 }
 
 // SELECTボックス用リストの作成
 function sfGetIDValueList($table, $keyname, $valname) {
-	$objQuery = new SC_Query();
-	$col = "$keyname, $valname";
-	$objQuery->setwhere("del_flg = 0");
-	$objQuery->setorder("rank DESC");
-	$arrList = $objQuery->select($col, $table);
-	$count = count($arrList);
-	for($cnt = 0; $cnt < $count; $cnt++) {
-		$key = $arrList[$cnt][$keyname];
-		$val = $arrList[$cnt][$valname];
-		$arrRet[$key] = $val;
-	}
-	return $arrRet;
+    $objQuery = new SC_Query();
+    $col = "$keyname, $valname";
+    $objQuery->setwhere("del_flg = 0");
+    $objQuery->setorder("rank DESC");
+    $arrList = $objQuery->select($col, $table);
+    $count = count($arrList);
+    for($cnt = 0; $cnt < $count; $cnt++) {
+        $key = $arrList[$cnt][$keyname];
+        $val = $arrList[$cnt][$valname];
+        $arrRet[$key] = $val;
+    }
+    return $arrRet;
 }
 
 function sfTrim($str) {
-	$ret = ereg_replace("^[　 \n\r]*", "", $str);
-	$ret = ereg_replace("[　 \n\r]*$", "", $ret);
-	return $ret;
+    $ret = ereg_replace("^[　 \n\r]*", "", $str);
+    $ret = ereg_replace("[　 \n\r]*$", "", $ret);
+    return $ret;
 }
 
 /* 所属するすべての階層の親IDを配列で返す */
 function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) {
-	$arrRet = sfGetParentsArray($table, $pid_name, $id_name, $id);
-	// 配列の先頭1つを削除する。
-	array_shift($arrRet);
-	return $arrRet;
+    $arrRet = sfGetParentsArray($table, $pid_name, $id_name, $id);
+    // 配列の先頭1つを削除する。
+    array_shift($arrRet);
+    return $arrRet;
 }
 
@@ -1192,427 +1192,427 @@
 /* 親IDの配列を元に特定のカラムを取得する。*/
 function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) {
-	$col = $col_name;
-	$len = count($arrId);
-	$where = "";
-	
-	for($cnt = 0; $cnt < $len; $cnt++) {
-		if($where == "") {
-			$where = "$id_name = ?";
-		} else {
-			$where.= " OR $id_name = ?";
-		}
-	}
-	
-	$objQuery->setorder("level");
-	$arrRet = $objQuery->select($col, $table, $where, $arrId);
-	return $arrRet;	
+    $col = $col_name;
+    $len = count($arrId);
+    $where = "";
+
+    for($cnt = 0; $cnt < $len; $cnt++) {
+        if($where == "") {
+            $where = "$id_name = ?";
+        } else {
+            $where.= " OR $id_name = ?";
+        }
+    }
+
+    $objQuery->setorder("level");
+    $arrRet = $objQuery->select($col, $table, $where, $arrId);
+    return $arrRet;
 }
 
 /* 子IDの配列を返す */
 function sfGetChildsID($table, $pid_name, $id_name, $id) {
-	$arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);
-	return $arrRet;
+    $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);
+    return $arrRet;
 }
 
 /* カテゴリ変更時の移動処理 */
 function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) {
-	if ($old_catid == $new_catid) {
-		return;
-	}
-	// 旧カテゴリでのランク削除処理
-	// 移動レコードのランクを取得する。		
-	$where = "$id_name = ?";
-	$rank = $objQuery->get($table, "rank", $where, array($id));
-	// 削除レコードのランクより上のレコードを一つ下にずらす。
-	$where = "rank > ? AND $cat_name = ?";
-	$sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
-	$objQuery->exec($sqlup, array($rank, $old_catid));
-	// 新カテゴリでの登録処理
-	// 新カテゴリの最大ランクを取得する。
-	$max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1;
-	$where = "$id_name = ?";
-	$sqlup = "UPDATE $table SET rank = ? WHERE $where";
-	$objQuery->exec($sqlup, array($max_rank, $id));
+    if ($old_catid == $new_catid) {
+        return;
+    }
+    // 旧カテゴリでのランク削除処理
+    // 移動レコードのランクを取得する。
+    $where = "$id_name = ?";
+    $rank = $objQuery->get($table, "rank", $where, array($id));
+    // 削除レコードのランクより上のレコードを一つ下にずらす。
+    $where = "rank > ? AND $cat_name = ?";
+    $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
+    $objQuery->exec($sqlup, array($rank, $old_catid));
+    // 新カテゴリでの登録処理
+    // 新カテゴリの最大ランクを取得する。
+    $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1;
+    $where = "$id_name = ?";
+    $sqlup = "UPDATE $table SET rank = ? WHERE $where";
+    $objQuery->exec($sqlup, array($max_rank, $id));
 }
 
 /* 税金計算 */
 function sfTax($price, $tax, $tax_rule) {
-	$real_tax = $tax / 100;
-	$ret = $price * $real_tax;
-	switch($tax_rule) {
-	// 四捨五入
-	case 1:
-		$ret = round($ret);
-		break;
-	// 切り捨て
-	case 2:
-		$ret = floor($ret);
-		break;
-	// 切り上げ
-	case 3:
-		$ret = ceil($ret);
-		break;
-	// デフォルト:切り上げ
-	default:
-		$ret = ceil($ret);
-		break;
-	}
-	return $ret;
+    $real_tax = $tax / 100;
+    $ret = $price * $real_tax;
+    switch($tax_rule) {
+    // 四捨五入
+    case 1:
+        $ret = round($ret);
+        break;
+    // 切り捨て
+    case 2:
+        $ret = floor($ret);
+        break;
+    // 切り上げ
+    case 3:
+        $ret = ceil($ret);
+        break;
+    // デフォルト:切り上げ
+    default:
+        $ret = ceil($ret);
+        break;
+    }
+    return $ret;
 }
 
 /* 税金付与 */
 function sfPreTax($price, $tax, $tax_rule) {
-	$real_tax = $tax / 100;
-	$ret = $price * (1 + $real_tax);
-	
-	switch($tax_rule) {
-	// 四捨五入
-	case 1:
-		$ret = round($ret);
-		break;
-	// 切り捨て
-	case 2:
-		$ret = floor($ret);
-		break;
-	// 切り上げ
-	case 3:
-		$ret = ceil($ret);
-		break;
-	// デフォルト:切り上げ
-	default:
-		$ret = ceil($ret);
-		break;
-	}
-	return $ret;
+    $real_tax = $tax / 100;
+    $ret = $price * (1 + $real_tax);
+
+    switch($tax_rule) {
+    // 四捨五入
+    case 1:
+        $ret = round($ret);
+        break;
+    // 切り捨て
+    case 2:
+        $ret = floor($ret);
+        break;
+    // 切り上げ
+    case 3:
+        $ret = ceil($ret);
+        break;
+    // デフォルト:切り上げ
+    default:
+        $ret = ceil($ret);
+        break;
+    }
+    return $ret;
 }
 
 // 桁数を指定して四捨五入
 function sfRound($value, $pow = 0){
-	$adjust = pow(10 ,$pow-1);
-
-	// 整数且つ0出なければ桁数指定を行う
-	if(sfIsInt($adjust) and $pow > 1){
-		$ret = (round($value * $adjust)/$adjust);
-	}
-	
-	$ret = round($ret);
-
-	return $ret;
+    $adjust = pow(10 ,$pow-1);
+
+    // 整数且つ0出なければ桁数指定を行う
+    if(sfIsInt($adjust) and $pow > 1){
+        $ret = (round($value * $adjust)/$adjust);
+    }
+
+    $ret = round($ret);
+
+    return $ret;
 }
 
 /* ポイント付与 */
 function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") {
-	if(sfIsInt($product_id)) {
-		$objQuery = new SC_Query();
-	    $where = "now() >= cast(start_date as date) AND ";
-	    $where .= "now() < cast(end_date as date) AND ";
-		
-		$where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
-		//登録(更新)日付順
-		$objQuery->setorder('update_date DESC');
-		//キャンペーンポイントの取得
-		$arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
-	}
-	//複数のキャンペーンに登録されている商品は、最新のキャンペーンからポイントを取得
-	if($arrRet[0]['campaign_point_rate'] != "") {
-		$campaign_point_rate = $arrRet[0]['campaign_point_rate'];
-		$real_point = $campaign_point_rate / 100;
-	} else {
-		$real_point = $point_rate / 100;
-	}
-	$ret = $price * $real_point;
-	switch($rule) {
-	// 四捨五入
-	case 1:
-		$ret = round($ret);
-		break;
-	// 切り捨て
-	case 2:
-		$ret = floor($ret);
-		break;
-	// 切り上げ
-	case 3:
-		$ret = ceil($ret);
-		break;
-	// デフォルト:切り上げ
-	default:
-		$ret = ceil($ret);
-		break;
-	}
-	//キャンペーン商品の場合
-	if($campaign_point_rate != "") {
-		$ret = "(".$arrRet[0]['campaign_name']."ポイント率".$campaign_point_rate."%)".$ret;
-	}
-	return $ret;
+    if(sfIsInt($product_id)) {
+        $objQuery = new SC_Query();
+        $where = "now() >= cast(start_date as date) AND ";
+        $where .= "now() < cast(end_date as date) AND ";
+
+        $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
+        //登録(更新)日付順
+        $objQuery->setorder('update_date DESC');
+        //キャンペーンポイントの取得
+        $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
+    }
+    //複数のキャンペーンに登録されている商品は、最新のキャンペーンからポイントを取得
+    if($arrRet[0]['campaign_point_rate'] != "") {
+        $campaign_point_rate = $arrRet[0]['campaign_point_rate'];
+        $real_point = $campaign_point_rate / 100;
+    } else {
+        $real_point = $point_rate / 100;
+    }
+    $ret = $price * $real_point;
+    switch($rule) {
+    // 四捨五入
+    case 1:
+        $ret = round($ret);
+        break;
+    // 切り捨て
+    case 2:
+        $ret = floor($ret);
+        break;
+    // 切り上げ
+    case 3:
+        $ret = ceil($ret);
+        break;
+    // デフォルト:切り上げ
+    default:
+        $ret = ceil($ret);
+        break;
+    }
+    //キャンペーン商品の場合
+    if($campaign_point_rate != "") {
+        $ret = "(".$arrRet[0]['campaign_name']."ポイント率".$campaign_point_rate."%)".$ret;
+    }
+    return $ret;
 }
 
 /* 規格分類の件数取得 */
 function sfGetClassCatCount() {
-	$sql = "select count(dtb_class.class_id) as count, dtb_class.class_id ";
-	$sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id ";
-	$sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 ";
-	$sql.= "group by dtb_class.class_id, dtb_class.name";
-	$objQuery = new SC_Query();
-	$arrList = $objQuery->getall($sql);
-	// キーと値をセットした配列を取得
-	$arrRet = sfArrKeyValue($arrList, 'class_id', 'count');
-	
-	return $arrRet;
+    $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id ";
+    $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id ";
+    $sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 ";
+    $sql.= "group by dtb_class.class_id, dtb_class.name";
+    $objQuery = new SC_Query();
+    $arrList = $objQuery->getall($sql);
+    // キーと値をセットした配列を取得
+    $arrRet = sfArrKeyValue($arrList, 'class_id', 'count');
+
+    return $arrRet;
 }
 
 /* 規格の登録 */
 function sfInsertProductClass($objQuery, $arrList, $product_id) {
-	// すでに規格登録があるかどうかをチェックする。
-	$where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
-	$count = $objQuery->count("dtb_products_class", $where,  array($product_id));
-	
-	// すでに規格登録がない場合
-	if($count == 0) {
-		// 既存規格の削除
-		$where = "product_id = ?";
-		$objQuery->delete("dtb_products_class", $where, array($product_id));
-		$sqlval['product_id'] = $product_id;
-		$sqlval['classcategory_id1'] = '0';
-		$sqlval['classcategory_id2'] = '0';
-		$sqlval['product_code'] = $arrList["product_code"];
-		$sqlval['stock'] = $arrList["stock"];
-		$sqlval['stock_unlimited'] = $arrList["stock_unlimited"];
-		$sqlval['price01'] = $arrList['price01'];
-		$sqlval['price02'] = $arrList['price02'];
-		$sqlval['creator_id'] = $_SESSION['member_id'];
-		$sqlval['create_date'] = "now()";
-		
-		if($_SESSION['member_id'] == "") {
-			$sqlval['creator_id'] = '0';
-		}
-		
-		// INSERTの実行
-		$objQuery->insert("dtb_products_class", $sqlval);
-	}
+    // すでに規格登録があるかどうかをチェックする。
+    $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
+    $count = $objQuery->count("dtb_products_class", $where,  array($product_id));
+
+    // すでに規格登録がない場合
+    if($count == 0) {
+        // 既存規格の削除
+        $where = "product_id = ?";
+        $objQuery->delete("dtb_products_class", $where, array($product_id));
+        $sqlval['product_id'] = $product_id;
+        $sqlval['classcategory_id1'] = '0';
+        $sqlval['classcategory_id2'] = '0';
+        $sqlval['product_code'] = $arrList["product_code"];
+        $sqlval['stock'] = $arrList["stock"];
+        $sqlval['stock_unlimited'] = $arrList["stock_unlimited"];
+        $sqlval['price01'] = $arrList['price01'];
+        $sqlval['price02'] = $arrList['price02'];
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+        $sqlval['create_date'] = "now()";
+
+        if($_SESSION['member_id'] == "") {
+            $sqlval['creator_id'] = '0';
+        }
+
+        // INSERTの実行
+        $objQuery->insert("dtb_products_class", $sqlval);
+    }
 }
 
 function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) {
-	$where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
-	$objQuery = new SC_Query();
-	$ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2));
-	return $ret;
+    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
+    $objQuery = new SC_Query();
+    $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2));
+    return $ret;
 }
 
 /* 文末の「/」をなくす */
 function sfTrimURL($url) {
-	$ret = ereg_replace("[/]+$", "", $url);
-	return $ret;
+    $ret = ereg_replace("[/]+$", "", $url);
+    return $ret;
 }
 
 /* 商品規格情報の取得 */
 function sfGetProductsClass($arrID) {
-	list($product_id, $classcategory_id1, $classcategory_id2) = $arrID;	
-	
-	if($classcategory_id1 == "") {
-		$classcategory_id1 = '0';
-	}
-	if($classcategory_id2 == "") {
-		$classcategory_id2 = '0';
-	}
-		
-	// 商品規格取得
-	$objQuery = new SC_Query();
-	$col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited";
-	$table = "vw_product_class AS prdcls";
-	$where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
-	$objQuery->setorder("rank1 DESC, rank2 DESC");
-	$arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2));
-	return $arrRet[0];
+    list($product_id, $classcategory_id1, $classcategory_id2) = $arrID;
+
+    if($classcategory_id1 == "") {
+        $classcategory_id1 = '0';
+    }
+    if($classcategory_id2 == "") {
+        $classcategory_id2 = '0';
+    }
+
+    // 商品規格取得
+    $objQuery = new SC_Query();
+    $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited";
+    $table = "vw_product_class AS prdcls";
+    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
+    $objQuery->setorder("rank1 DESC, rank2 DESC");
+    $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2));
+    return $arrRet[0];
 }
 
 /* 集計情報を元に最終計算 */
 function sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo, $objCustomer = "") {
-	// 商品の合計個数
-	$total_quantity = $objCartSess->getTotalQuantity(true);
-	
-	// 税金の取得
-	$arrData['tax'] = $objPage->tpl_total_tax;
-	// 小計の取得
-	$arrData['subtotal'] = $objPage->tpl_total_pretax;	
-	
-	// 合計送料の取得
-	$arrData['deliv_fee'] = 0;
-		
-	// 商品ごとの送料が有効の場合
-	if (OPTION_PRODUCT_DELIV_FEE == 1) {
-		$arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee();
-	}
-	
-	// 配送業者の送料が有効の場合
-	if (OPTION_DELIV_FEE == 1) {
-		// 送料の合計を計算する
-		$arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']);
-	}
-	
-	// 送料無料の購入数が設定されている場合
-	if(DELIV_FREE_AMOUNT > 0) {
-		if($total_quantity >= DELIV_FREE_AMOUNT) {
-			$arrData['deliv_fee'] = 0;
-		}	
-	}
-		
-	// 送料無料条件が設定されている場合
-	if($arrInfo['free_rule'] > 0) {
-		// 小計が無料条件を超えている場合
-		if($arrData['subtotal'] >= $arrInfo['free_rule']) {
-			$arrData['deliv_fee'] = 0;
-		}
-	}
-
-	// 合計の計算
-	$arrData['total'] = $objPage->tpl_total_pretax;	// 商品合計
-	$arrData['total']+= $arrData['deliv_fee'];		// 送料
-	$arrData['total']+= $arrData['charge'];			// 手数料
-	// お支払い合計
-	$arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE);
-	// 加算ポイントの計算
-	$arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo);
-	
-	if($objCustomer != "") {
-		// 誕生日月であった場合
-		if($objCustomer->isBirthMonth()) {
-			$arrData['birth_point'] = BIRTH_MONTH_POINT;
-			$arrData['add_point'] += $arrData['birth_point'];
-		}
-	}
-	
-	if($arrData['add_point'] < 0) {
-		$arrData['add_point'] = 0;
-	}
-	
-	return $arrData;
+    // 商品の合計個数
+    $total_quantity = $objCartSess->getTotalQuantity(true);
+
+    // 税金の取得
+    $arrData['tax'] = $objPage->tpl_total_tax;
+    // 小計の取得
+    $arrData['subtotal'] = $objPage->tpl_total_pretax;
+
+    // 合計送料の取得
+    $arrData['deliv_fee'] = 0;
+
+    // 商品ごとの送料が有効の場合
+    if (OPTION_PRODUCT_DELIV_FEE == 1) {
+        $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee();
+    }
+
+    // 配送業者の送料が有効の場合
+    if (OPTION_DELIV_FEE == 1) {
+        // 送料の合計を計算する
+        $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']);
+    }
+
+    // 送料無料の購入数が設定されている場合
+    if(DELIV_FREE_AMOUNT > 0) {
+        if($total_quantity >= DELIV_FREE_AMOUNT) {
+            $arrData['deliv_fee'] = 0;
+        }
+    }
+
+    // 送料無料条件が設定されている場合
+    if($arrInfo['free_rule'] > 0) {
+        // 小計が無料条件を超えている場合
+        if($arrData['subtotal'] >= $arrInfo['free_rule']) {
+            $arrData['deliv_fee'] = 0;
+        }
+    }
+
+    // 合計の計算
+    $arrData['total'] = $objPage->tpl_total_pretax;	// 商品合計
+    $arrData['total']+= $arrData['deliv_fee'];		// 送料
+    $arrData['total']+= $arrData['charge'];			// 手数料
+    // お支払い合計
+    $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE);
+    // 加算ポイントの計算
+    $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo);
+
+    if($objCustomer != "") {
+        // 誕生日月であった場合
+        if($objCustomer->isBirthMonth()) {
+            $arrData['birth_point'] = BIRTH_MONTH_POINT;
+            $arrData['add_point'] += $arrData['birth_point'];
+        }
+    }
+
+    if($arrData['add_point'] < 0) {
+        $arrData['add_point'] = 0;
+    }
+
+    return $arrData;
 }
 
 /* カート内商品の集計処理 */
 function sfTotalCart($objPage, $objCartSess, $arrInfo) {
-	// 規格名一覧
-	$arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
-	// 規格分類名一覧
-	$arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
-	
-	$objPage->tpl_total_pretax = 0;		// 費用合計(税込み)
-	$objPage->tpl_total_tax = 0;		// 消費税合計
-	$objPage->tpl_total_point = 0;		// ポイント合計
-	
-	// カート内情報の取得
-	$arrCart = $objCartSess->getCartList();
-	$max = count($arrCart);
-	$cnt = 0;
-
-	for ($i = 0; $i < $max; $i++) {
-		// 商品規格情報の取得	
-		$arrData = sfGetProductsClass($arrCart[$i]['id']);
-		$limit = "";
-		// DBに存在する商品
-		if (count($arrData) > 0) {
-			
-			// 購入制限数を求める。			
-			if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') {
-				if($arrData['sale_limit'] < $arrData['stock']) {
-					$limit = $arrData['sale_limit'];
-				} else {
-					$limit = $arrData['stock'];
-				}
-			} else {
-				if ($arrData['sale_unlimited'] != '1') {
-					$limit = $arrData['sale_limit'];
-				}
-				if ($arrData['stock_unlimited'] != '1') {
-					$limit = $arrData['stock'];
-				}
-			}
-						
-			if($limit != "" && $limit < $arrCart[$i]['quantity']) {
-				// カート内商品数を制限に合わせる
-				$objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit);
-				$quantity = $limit;
-				$objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。";
-			} else {
-				$quantity = $arrCart[$i]['quantity'];
-			}
-			
-			$objPage->arrProductsClass[$cnt] = $arrData;
-			$objPage->arrProductsClass[$cnt]['quantity'] = $quantity;
-			$objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no'];
-			$objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']];
-			$objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']];
-			$objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
-			$objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
-			
-			// 画像サイズ
-			list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"]));
-			$objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60;
-			$objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80;
-			
-			// 価格の登録
-			if ($arrData['price02'] != "") {
-				$objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']);
-				$objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02'];
-			} else {
-				$objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']);
-				$objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01'];
-			}
-			// ポイント付与率の登録
-			$objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']);
-			// 商品ごとの合計金額
-			$objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']);
-			// 送料の合計を計算する
-			$objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']);
-			$cnt++;
-		} else {
-			// DBに商品が見つからない場合はカート商品の削除
-			$objCartSess->delProductKey('id', $arrCart[$i]['id']);
-		}
-	}
-	
-	// 全商品合計金額(税込み)
-	$objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
-	// 全商品合計消費税
-	$objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo);
-	// 全商品合計ポイント
-	$objPage->tpl_total_point = $objCartSess->getAllProductsPoint();
-	
-	return $objPage;	
+    // 規格名一覧
+    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
+    // 規格分類名一覧
+    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+
+    $objPage->tpl_total_pretax = 0;		// 費用合計(税込み)
+    $objPage->tpl_total_tax = 0;		// 消費税合計
+    $objPage->tpl_total_point = 0;		// ポイント合計
+
+    // カート内情報の取得
+    $arrCart = $objCartSess->getCartList();
+    $max = count($arrCart);
+    $cnt = 0;
+
+    for ($i = 0; $i < $max; $i++) {
+        // 商品規格情報の取得
+        $arrData = sfGetProductsClass($arrCart[$i]['id']);
+        $limit = "";
+        // DBに存在する商品
+        if (count($arrData) > 0) {
+
+            // 購入制限数を求める。
+            if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') {
+                if($arrData['sale_limit'] < $arrData['stock']) {
+                    $limit = $arrData['sale_limit'];
+                } else {
+                    $limit = $arrData['stock'];
+                }
+            } else {
+                if ($arrData['sale_unlimited'] != '1') {
+                    $limit = $arrData['sale_limit'];
+                }
+                if ($arrData['stock_unlimited'] != '1') {
+                    $limit = $arrData['stock'];
+                }
+            }
+
+            if($limit != "" && $limit < $arrCart[$i]['quantity']) {
+                // カート内商品数を制限に合わせる
+                $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit);
+                $quantity = $limit;
+                $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。";
+            } else {
+                $quantity = $arrCart[$i]['quantity'];
+            }
+
+            $objPage->arrProductsClass[$cnt] = $arrData;
+            $objPage->arrProductsClass[$cnt]['quantity'] = $quantity;
+            $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no'];
+            $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']];
+            $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']];
+            $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
+            $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
+
+            // 画像サイズ
+            list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"]));
+            $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60;
+            $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80;
+
+            // 価格の登録
+            if ($arrData['price02'] != "") {
+                $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']);
+                $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02'];
+            } else {
+                $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']);
+                $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01'];
+            }
+            // ポイント付与率の登録
+            $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']);
+            // 商品ごとの合計金額
+            $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']);
+            // 送料の合計を計算する
+            $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']);
+            $cnt++;
+        } else {
+            // DBに商品が見つからない場合はカート商品の削除
+            $objCartSess->delProductKey('id', $arrCart[$i]['id']);
+        }
+    }
+
+    // 全商品合計金額(税込み)
+    $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
+    // 全商品合計消費税
+    $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo);
+    // 全商品合計ポイント
+    $objPage->tpl_total_point = $objCartSess->getAllProductsPoint();
+
+    return $objPage;
 }
 
 /* DBから取り出した日付の文字列を調整する。*/
 function sfDispDBDate($dbdate, $time = true) {
-	list($y, $m, $d, $H, $M) = split("[- :]", $dbdate);
-
-	if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) {
-		if ($time) {
-			$str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M);
-		} else {
-			$str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M);						
-		}
-	} else {
-		$str = "";
-	}
-	return $str;
+    list($y, $m, $d, $H, $M) = split("[- :]", $dbdate);
+
+    if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) {
+        if ($time) {
+            $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M);
+        } else {
+            $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M);
+        }
+    } else {
+        $str = "";
+    }
+    return $str;
 }
 
 function sfGetDelivTime($payment_id = "") {
-	$objQuery = new SC_Query();
-	
-	$deliv_id = "";
-	
-	if($payment_id != "") {
-		$where = "del_flg = 0 AND payment_id = ?";
-		$arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
-		$deliv_id = $arrRet[0]['deliv_id'];
-	}
-	
-	if($deliv_id != "") {
-		$objQuery->setorder("time_id");
-		$where = "deliv_id = ?";
-		$arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id));
-	}
-	
-	return $arrRet;	
+    $objQuery = new SC_Query();
+
+    $deliv_id = "";
+
+    if($payment_id != "") {
+        $where = "del_flg = 0 AND payment_id = ?";
+        $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
+        $deliv_id = $arrRet[0]['deliv_id'];
+    }
+
+    if($deliv_id != "") {
+        $objQuery->setorder("time_id");
+        $where = "deliv_id = ?";
+        $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id));
+    }
+
+    return $arrRet;
 }
 
@@ -1620,312 +1620,312 @@
 // 都道府県、支払い方法から配送料金を取得する
 function sfGetDelivFee($pref, $payment_id = "") {
-	$objQuery = new SC_Query();
-	
-	$deliv_id = "";
-	
-	// 支払い方法が指定されている場合は、対応した配送業者を取得する
-	if($payment_id != "") {
-		$where = "del_flg = 0 AND payment_id = ?";
-		$arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
-		$deliv_id = $arrRet[0]['deliv_id'];
-	// 支払い方法が指定されていない場合は、先頭の配送業者を取得する
-	} else {
-		$where = "del_flg = 0";
-		$objQuery->setOrder("rank DESC");
-		$objQuery->setLimitOffset(1);
-		$arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where);
-		$deliv_id = $arrRet[0]['deliv_id'];	
-	}
-	
-	// 配送業者から配送料を取得
-	if($deliv_id != "") {
-		
-		// 都道府県が指定されていない場合は、東京都の番号を指定しておく
-		if($pref == "") {
-			$pref = 13;
-		}
-		
-		$objQuery = new SC_Query();
-		$where = "deliv_id = ? AND pref = ?";
-		$arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref));
-	}	
-	return $arrRet[0]['fee'];	
+    $objQuery = new SC_Query();
+
+    $deliv_id = "";
+
+    // 支払い方法が指定されている場合は、対応した配送業者を取得する
+    if($payment_id != "") {
+        $where = "del_flg = 0 AND payment_id = ?";
+        $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
+        $deliv_id = $arrRet[0]['deliv_id'];
+    // 支払い方法が指定されていない場合は、先頭の配送業者を取得する
+    } else {
+        $where = "del_flg = 0";
+        $objQuery->setOrder("rank DESC");
+        $objQuery->setLimitOffset(1);
+        $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where);
+        $deliv_id = $arrRet[0]['deliv_id'];
+    }
+
+    // 配送業者から配送料を取得
+    if($deliv_id != "") {
+
+        // 都道府県が指定されていない場合は、東京都の番号を指定しておく
+        if($pref == "") {
+            $pref = 13;
+        }
+
+        $objQuery = new SC_Query();
+        $where = "deliv_id = ? AND pref = ?";
+        $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref));
+    }
+    return $arrRet[0]['fee'];
 }
 
 /* 支払い方法の取得 */
 function sfGetPayment() {
-	$objQuery = new SC_Query();
-	// 購入金額が条件額以下の項目を取得
-	$where = "del_flg = 0";
-	$objQuery->setorder("fix, rank DESC");
-	$arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where);
-	return $arrRet;	
+    $objQuery = new SC_Query();
+    // 購入金額が条件額以下の項目を取得
+    $where = "del_flg = 0";
+    $objQuery->setorder("fix, rank DESC");
+    $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where);
+    return $arrRet;
 }
 
 /* 配列をキー名ごとの配列に変更する */
 function sfSwapArray($array) {
-	$max = count($array);
-	for($i = 0; $i < $max; $i++) {
-		foreach($array[$i] as $key => $val) {
-			$arrRet[$key][] = $val;
-		}
-	}
-	return $arrRet;
+    $max = count($array);
+    for($i = 0; $i < $max; $i++) {
+        foreach($array[$i] as $key => $val) {
+            $arrRet[$key][] = $val;
+        }
+    }
+    return $arrRet;
 }
 
 /* かけ算をする（Smarty用) */
 function sfMultiply($num1, $num2) {
-	return ($num1 * $num2);
+    return ($num1 * $num2);
 }
 
 /* DBに登録されたテンプレートメールの送信 */
 function sfSendTemplateMail($to, $to_name, $template_id, $objPage) {
-	global $arrMAILTPLPATH;
-	$objQuery = new SC_Query();
-	// メールテンプレート情報の取得
-	$where = "template_id = ?";
-	$arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id));
-	$objPage->tpl_header = $arrRet[0]['header'];
-	$objPage->tpl_footer = $arrRet[0]['footer'];
-	$tmp_subject = $arrRet[0]['subject'];
-	
-	$objSiteInfo = new SC_SiteInfo();
-	$arrInfo = $objSiteInfo->data;
-	
-	$objMailView = new SC_SiteView();
-	// メール本文の取得
-	$objMailView->assignobj($objPage);
-	$body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
-	
-	// メール送信処理
-	$objSendMail = new GC_SendMail();
-	$from = $arrInfo['email03'];
-	$error = $arrInfo['email04'];
-	$tosubject = $tmp_subject;
-	$objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error);
-	$objSendMail->setTo($to, $to_name);
-	$objSendMail->sendMail();	// メール送信
+    global $arrMAILTPLPATH;
+    $objQuery = new SC_Query();
+    // メールテンプレート情報の取得
+    $where = "template_id = ?";
+    $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id));
+    $objPage->tpl_header = $arrRet[0]['header'];
+    $objPage->tpl_footer = $arrRet[0]['footer'];
+    $tmp_subject = $arrRet[0]['subject'];
+
+    $objSiteInfo = new SC_SiteInfo();
+    $arrInfo = $objSiteInfo->data;
+
+    $objMailView = new SC_SiteView();
+    // メール本文の取得
+    $objMailView->assignobj($objPage);
+    $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
+
+    // メール送信処理
+    $objSendMail = new GC_SendMail();
+    $from = $arrInfo['email03'];
+    $error = $arrInfo['email04'];
+    $tosubject = $tmp_subject;
+    $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error);
+    $objSendMail->setTo($to, $to_name);
+    $objSendMail->sendMail();	// メール送信
 }
 
 /* 受注完了メール送信 */
 function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true) {
-	global $arrMAILTPLPATH;
-	
-	$objPage = new LC_Page();
-	$objSiteInfo = new SC_SiteInfo();
-	$arrInfo = $objSiteInfo->data;
-	$objPage->arrInfo = $arrInfo;
-	
-	$objQuery = new SC_Query();
-		
-	if($subject == "" && $header == "" && $footer == "") {
-		// メールテンプレート情報の取得
-		$where = "template_id = ?";
-		$arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1'));
-		$objPage->tpl_header = $arrRet[0]['header'];
-		$objPage->tpl_footer = $arrRet[0]['footer'];
-		$tmp_subject = $arrRet[0]['subject'];
-	} else {
-		$objPage->tpl_header = $header;
-		$objPage->tpl_footer = $footer;
-		$tmp_subject = $subject;
-	}
-	
-	// 受注情報の取得
-	$where = "order_id = ?";
-	$arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
-	$arrOrder = $arrRet[0];
-	$arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id));
-	
-	$objPage->Message_tmp = $arrOrder['message'];
-		
-	// 顧客情報の取得
-	$customer_id = $arrOrder['customer_id'];
-	$arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
-	$arrCustomer = $arrRet[0];
-
-	$objPage->arrCustomer = $arrCustomer;
-	$objPage->arrOrder = $arrOrder;
-
-	//その他決済情報
-	if($arrOrder['memo02'] != "") {
-		$arrOther = unserialize($arrOrder['memo02']);
-		
-		foreach($arrOther as $other_key => $other_val){
-			if(sfTrim($other_val["value"]) == ""){
-				$arrOther[$other_key]["value"] = "";
-			}
-		}
-		
-		$objPage->arrOther = $arrOther;
-	}
-
-	// 都道府県変換
-	global $arrPref;
-	$objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']];
-	
-	$objPage->arrOrderDetail = $arrOrderDetail;
-	
-	$objCustomer = new SC_Customer();
-	$objPage->tpl_user_point = $objCustomer->getValue('point');
-	
-	$objMailView = new SC_SiteView();
-	// メール本文の取得
-	$objMailView->assignobj($objPage);
-	$body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
-	
-	// メール送信処理
-	$objSendMail = new GC_SendMail();
-	$bcc = $arrInfo['email01'];
-	$from = $arrInfo['email03'];
-	$error = $arrInfo['email04'];
-
-	$tosubject = sfMakeSubject($tmp_subject);
-	
-	$objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
-	$objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." 様");
-
-
-	// 送信フラグ:trueの場合は、送信する。
-	if($send) {
-		if ($objSendMail->sendMail()) {
-			sfSaveMailHistory($order_id, $template_id, $tosubject, $body);
-		}
-	}
-
-	return $objSendMail;
+    global $arrMAILTPLPATH;
+
+    $objPage = new LC_Page();
+    $objSiteInfo = new SC_SiteInfo();
+    $arrInfo = $objSiteInfo->data;
+    $objPage->arrInfo = $arrInfo;
+
+    $objQuery = new SC_Query();
+
+    if($subject == "" && $header == "" && $footer == "") {
+        // メールテンプレート情報の取得
+        $where = "template_id = ?";
+        $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1'));
+        $objPage->tpl_header = $arrRet[0]['header'];
+        $objPage->tpl_footer = $arrRet[0]['footer'];
+        $tmp_subject = $arrRet[0]['subject'];
+    } else {
+        $objPage->tpl_header = $header;
+        $objPage->tpl_footer = $footer;
+        $tmp_subject = $subject;
+    }
+
+    // 受注情報の取得
+    $where = "order_id = ?";
+    $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
+    $arrOrder = $arrRet[0];
+    $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id));
+
+    $objPage->Message_tmp = $arrOrder['message'];
+
+    // 顧客情報の取得
+    $customer_id = $arrOrder['customer_id'];
+    $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
+    $arrCustomer = $arrRet[0];
+
+    $objPage->arrCustomer = $arrCustomer;
+    $objPage->arrOrder = $arrOrder;
+
+    //その他決済情報
+    if($arrOrder['memo02'] != "") {
+        $arrOther = unserialize($arrOrder['memo02']);
+
+        foreach($arrOther as $other_key => $other_val){
+            if(sfTrim($other_val["value"]) == ""){
+                $arrOther[$other_key]["value"] = "";
+            }
+        }
+
+        $objPage->arrOther = $arrOther;
+    }
+
+    // 都道府県変換
+    global $arrPref;
+    $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']];
+
+    $objPage->arrOrderDetail = $arrOrderDetail;
+
+    $objCustomer = new SC_Customer();
+    $objPage->tpl_user_point = $objCustomer->getValue('point');
+
+    $objMailView = new SC_SiteView();
+    // メール本文の取得
+    $objMailView->assignobj($objPage);
+    $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
+
+    // メール送信処理
+    $objSendMail = new GC_SendMail();
+    $bcc = $arrInfo['email01'];
+    $from = $arrInfo['email03'];
+    $error = $arrInfo['email04'];
+
+    $tosubject = sfMakeSubject($tmp_subject);
+
+    $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+    $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." 様");
+
+
+    // 送信フラグ:trueの場合は、送信する。
+    if($send) {
+        if ($objSendMail->sendMail()) {
+            sfSaveMailHistory($order_id, $template_id, $tosubject, $body);
+        }
+    }
+
+    return $objSendMail;
 }
 
 // テンプレートを使用したメールの送信
 function sfSendTplMail($to, $subject, $tplpath, $objPage) {
-	$objMailView = new SC_SiteView();
-	$objSiteInfo = new SC_SiteInfo();
-	$arrInfo = $objSiteInfo->data;
-	// メール本文の取得
-	$objPage->tpl_shopname=$arrInfo['shop_name'];
-	$objPage->tpl_infoemail = $arrInfo['email02'];
-	$objMailView->assignobj($objPage);
-	$body = $objMailView->fetch($tplpath);
-	// メール送信処理
-	$objSendMail = new GC_SendMail();
-	$to = mb_encode_mimeheader($to);
-	$bcc = $arrInfo['email01'];
-	$from = $arrInfo['email03'];
-	$error = $arrInfo['email04'];
-	$objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
-	$objSendMail->sendMail();	
+    $objMailView = new SC_SiteView();
+    $objSiteInfo = new SC_SiteInfo();
+    $arrInfo = $objSiteInfo->data;
+    // メール本文の取得
+    $objPage->tpl_shopname=$arrInfo['shop_name'];
+    $objPage->tpl_infoemail = $arrInfo['email02'];
+    $objMailView->assignobj($objPage);
+    $body = $objMailView->fetch($tplpath);
+    // メール送信処理
+    $objSendMail = new GC_SendMail();
+    $to = mb_encode_mimeheader($to);
+    $bcc = $arrInfo['email01'];
+    $from = $arrInfo['email03'];
+    $error = $arrInfo['email04'];
+    $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+    $objSendMail->sendMail();
 }
 
 // 通常のメール送信
 function sfSendMail($to, $subject, $body) {
-	$objSiteInfo = new SC_SiteInfo();
-	$arrInfo = $objSiteInfo->data;
-	// メール送信処理
-	$objSendMail = new GC_SendMail();
-	$bcc = $arrInfo['email01'];
-	$from = $arrInfo['email03'];
-	$error = $arrInfo['email04'];
-	$objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
-	$objSendMail->sendMail();
+    $objSiteInfo = new SC_SiteInfo();
+    $arrInfo = $objSiteInfo->data;
+    // メール送信処理
+    $objSendMail = new GC_SendMail();
+    $bcc = $arrInfo['email01'];
+    $from = $arrInfo['email03'];
+    $error = $arrInfo['email04'];
+    $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+    $objSendMail->sendMail();
 }
 
 //件名にテンプレートを用いる
 function sfMakeSubject($subject){
-	
-	$objQuery = new SC_Query();
-	$objMailView = new SC_SiteView();
-	$objPage = new LC_Page();
-	
-	$arrInfo = $objQuery->select("*","dtb_baseinfo");
-	$arrInfo = $arrInfo[0];
-	$objPage->tpl_shopname=$arrInfo['shop_name'];
-	$objPage->tpl_infoemail=$subject;
-	$objMailView->assignobj($objPage);
-	$mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl');
-	$ret = $mailtitle.$subject;
-	return $ret; 
+
+    $objQuery = new SC_Query();
+    $objMailView = new SC_SiteView();
+    $objPage = new LC_Page();
+
+    $arrInfo = $objQuery->select("*","dtb_baseinfo");
+    $arrInfo = $arrInfo[0];
+    $objPage->tpl_shopname=$arrInfo['shop_name'];
+    $objPage->tpl_infoemail=$subject;
+    $objMailView->assignobj($objPage);
+    $mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl');
+    $ret = $mailtitle.$subject;
+    return $ret;
 }
 
 // メール配信履歴への登録
 function sfSaveMailHistory($order_id, $template_id, $subject, $body) {
-	$sqlval['subject'] = $subject;
-	$sqlval['order_id'] = $order_id;
-	$sqlval['template_id'] = $template_id;
-	$sqlval['send_date'] = "Now()";
-	if($_SESSION['member_id'] != "") {
-		$sqlval['creator_id'] = $_SESSION['member_id'];
-	} else {
-		$sqlval['creator_id'] = '0';
-	}
-	$sqlval['mail_body'] = $body;
-	
-	$objQuery = new SC_Query();
-	$objQuery->insert("dtb_mail_history", $sqlval);
+    $sqlval['subject'] = $subject;
+    $sqlval['order_id'] = $order_id;
+    $sqlval['template_id'] = $template_id;
+    $sqlval['send_date'] = "Now()";
+    if($_SESSION['member_id'] != "") {
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+    } else {
+        $sqlval['creator_id'] = '0';
+    }
+    $sqlval['mail_body'] = $body;
+
+    $objQuery = new SC_Query();
+    $objQuery->insert("dtb_mail_history", $sqlval);
 }
 
 /* 会員情報を一時受注テーブルへ */
 function sfGetCustomerSqlVal($uniqid, $sqlval) {
-	$objCustomer = new SC_Customer();
-	// 会員情報登録処理
-	if ($objCustomer->isLoginSuccess()) {
-		// 登録データの作成
-		$sqlval['order_temp_id'] = $uniqid;
-		$sqlval['update_date'] = 'Now()';
-		$sqlval['customer_id'] = $objCustomer->getValue('customer_id');
-	    $sqlval['order_name01'] = $objCustomer->getValue('name01');
-	    $sqlval['order_name02'] = $objCustomer->getValue('name02');
-	    $sqlval['order_kana01'] = $objCustomer->getValue('kana01');
-	    $sqlval['order_kana02'] = $objCustomer->getValue('kana02');
-	    $sqlval['order_sex'] = $objCustomer->getValue('sex');
-	    $sqlval['order_zip01'] = $objCustomer->getValue('zip01');
-	    $sqlval['order_zip02'] = $objCustomer->getValue('zip02');
-	    $sqlval['order_pref'] = $objCustomer->getValue('pref');
-	    $sqlval['order_addr01'] = $objCustomer->getValue('addr01');
-	    $sqlval['order_addr02'] = $objCustomer->getValue('addr02');
-	    $sqlval['order_tel01'] = $objCustomer->getValue('tel01');
-	    $sqlval['order_tel02'] = $objCustomer->getValue('tel02');
-		$sqlval['order_tel03'] = $objCustomer->getValue('tel03');
-		if (defined('MOBILE_SITE')) {
-			$sqlval['order_email'] = $objCustomer->getValue('email_mobile');
-		} else {
-			$sqlval['order_email'] = $objCustomer->getValue('email');
-		}
-		$sqlval['order_job'] = $objCustomer->getValue('job');
-		$sqlval['order_birth'] = $objCustomer->getValue('birth');
-	}
-	return $sqlval;
+    $objCustomer = new SC_Customer();
+    // 会員情報登録処理
+    if ($objCustomer->isLoginSuccess()) {
+        // 登録データの作成
+        $sqlval['order_temp_id'] = $uniqid;
+        $sqlval['update_date'] = 'Now()';
+        $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
+        $sqlval['order_name01'] = $objCustomer->getValue('name01');
+        $sqlval['order_name02'] = $objCustomer->getValue('name02');
+        $sqlval['order_kana01'] = $objCustomer->getValue('kana01');
+        $sqlval['order_kana02'] = $objCustomer->getValue('kana02');
+        $sqlval['order_sex'] = $objCustomer->getValue('sex');
+        $sqlval['order_zip01'] = $objCustomer->getValue('zip01');
+        $sqlval['order_zip02'] = $objCustomer->getValue('zip02');
+        $sqlval['order_pref'] = $objCustomer->getValue('pref');
+        $sqlval['order_addr01'] = $objCustomer->getValue('addr01');
+        $sqlval['order_addr02'] = $objCustomer->getValue('addr02');
+        $sqlval['order_tel01'] = $objCustomer->getValue('tel01');
+        $sqlval['order_tel02'] = $objCustomer->getValue('tel02');
+        $sqlval['order_tel03'] = $objCustomer->getValue('tel03');
+        if (defined('MOBILE_SITE')) {
+            $sqlval['order_email'] = $objCustomer->getValue('email_mobile');
+        } else {
+            $sqlval['order_email'] = $objCustomer->getValue('email');
+        }
+        $sqlval['order_job'] = $objCustomer->getValue('job');
+        $sqlval['order_birth'] = $objCustomer->getValue('birth');
+    }
+    return $sqlval;
 }
 
 // 受注一時テーブルへの書き込み処理
 function sfRegistTempOrder($uniqid, $sqlval) {
-	if($uniqid != "") {
-		// 既存データのチェック
-		$objQuery = new SC_Query();
-		$where = "order_temp_id = ?";
-		$cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
-		// 既存データがない場合
-		if ($cnt == 0) {
-			// 初回書き込み時に会員の登録済み情報を取り込む
-			$sqlval = sfGetCustomerSqlVal($uniqid, $sqlval);
-			$sqlval['create_date'] = "now()";
-			$objQuery->insert("dtb_order_temp", $sqlval);
-		} else {
-			$objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
-		}
-	}
+    if($uniqid != "") {
+        // 既存データのチェック
+        $objQuery = new SC_Query();
+        $where = "order_temp_id = ?";
+        $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
+        // 既存データがない場合
+        if ($cnt == 0) {
+            // 初回書き込み時に会員の登録済み情報を取り込む
+            $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval);
+            $sqlval['create_date'] = "now()";
+            $objQuery->insert("dtb_order_temp", $sqlval);
+        } else {
+            $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
+        }
+    }
 }
 
 /* 会員のメルマガ登録があるかどうかのチェック(仮会員を含まない) */
 function sfCheckCustomerMailMaga($email) {
-	$col = "email, mailmaga_flg, customer_id";
-	$from = "dtb_customer";
-	$where = "email = ? AND status = 2";
-	$objQuery = new SC_Query();
-	$arrRet = $objQuery->select($col, $from, $where, array($email));
-	// 会員のメールアドレスが登録されている
-	if($arrRet[0]['customer_id'] != "") {
-		return true;
-	}
-	return false;
+    $col = "email, mailmaga_flg, customer_id";
+    $from = "dtb_customer";
+    $where = "email = ? AND status = 2";
+    $objQuery = new SC_Query();
+    $arrRet = $objQuery->select($col, $from, $where, array($email));
+    // 会員のメールアドレスが登録されている
+    if($arrRet[0]['customer_id'] != "") {
+        return true;
+    }
+    return false;
 }
 
@@ -1933,36 +1933,36 @@
 function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){
 
-	$path = $dir .$file_name;		// cgiファイルのフルパス生成
-	$now_dir = getcwd();			// requireがうまくいかないので、cgi実行ディレクトリに移動する
-	chdir($dir);
-	
-	// パイプ渡しでコマンドラインからcgi起動
-	$cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info";
-
-	$tmpResult = popen($cmd, "r");
-	
-	// 結果取得
-	while( ! FEOF ( $tmpResult ) ) {
-		$result .= FGETS($tmpResult);
-	}
-	pclose($tmpResult);				// 	パイプを閉じる
-	chdir($now_dir);				//　元にいたディレクトリに帰る
-	
-	// 結果を連想配列へ格納
-	$result = ereg_replace("&$", "", $result);
-	foreach (explode("&",$result) as $data) {
-		list($key, $val) = explode("=", $data, 2);
-		$return[$key] = $val;
-	}
-	
-	return $return;
+    $path = $dir .$file_name;		// cgiファイルのフルパス生成
+    $now_dir = getcwd();			// requireがうまくいかないので、cgi実行ディレクトリに移動する
+    chdir($dir);
+
+    // パイプ渡しでコマンドラインからcgi起動
+    $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info";
+
+    $tmpResult = popen($cmd, "r");
+
+    // 結果取得
+    while( ! FEOF ( $tmpResult ) ) {
+        $result .= FGETS($tmpResult);
+    }
+    pclose($tmpResult);				// 	パイプを閉じる
+    chdir($now_dir);				//　元にいたディレクトリに帰る
+
+    // 結果を連想配列へ格納
+    $result = ereg_replace("&$", "", $result);
+    foreach (explode("&",$result) as $data) {
+        list($key, $val) = explode("=", $data, 2);
+        $return[$key] = $val;
+    }
+
+    return $return;
 }
 
 // 受注一時テーブルから情報を取得する
 function sfGetOrderTemp($order_temp_id) {
-	$objQuery = new SC_Query();
-	$where = "order_temp_id = ?";
-	$arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id));
-	return $arrRet[0];
+    $objQuery = new SC_Query();
+    $where = "order_temp_id = ?";
+    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id));
+    return $arrRet[0];
 }
 
@@ -1973,23 +1973,23 @@
 /* 選択中のカテゴリを取得する */
 function sfGetCategoryId($product_id, $category_id) {
-	global $g_category_on;
-	global $g_category_id;
-	if(!$g_category_on)	{
-		$g_category_on = true;
-		$category_id = (int) $category_id;
-		$product_id = (int) $product_id;
-		if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) {
-			$g_category_id = $category_id;
-		} else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) {
-			$objQuery = new SC_Query();
-			$where = "product_id = ?";
-			$category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id));
-			$g_category_id = $category_id;
-		} else {
-			// 不正な場合は、0を返す。
-			$g_category_id = 0;
-		}
-	}
-	return $g_category_id;
+    global $g_category_on;
+    global $g_category_id;
+    if(!$g_category_on)	{
+        $g_category_on = true;
+        $category_id = (int) $category_id;
+        $product_id = (int) $product_id;
+        if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) {
+            $g_category_id = $category_id;
+        } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) {
+            $objQuery = new SC_Query();
+            $where = "product_id = ?";
+            $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id));
+            $g_category_id = $category_id;
+        } else {
+            // 不正な場合は、0を返す。
+            $g_category_id = 0;
+        }
+    }
+    return $g_category_id;
 }
 
@@ -2000,511 +2000,511 @@
 /* 選択中のアイテムのルートカテゴリIDを取得する */
 function sfGetRootId() {
-	global $g_root_on;
-	global $g_root_id;
-	if(!$g_root_on)	{
-		$g_root_on = true;
-		$objQuery = new SC_Query();
-		if($_GET['product_id'] != "" || $_GET['category_id'] != "") {
-			// 選択中のカテゴリIDを判定する
-			$category_id = sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
-			// ROOTカテゴリIDの取得
-			 $arrRet = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
-			 $root_id = $arrRet[0];
-		} else {
-			// ROOTカテゴリIDをなしに設定する
-			$root_id = "";
-		}
-		$g_root_id = $root_id;
-	}
-	return $g_root_id;
+    global $g_root_on;
+    global $g_root_id;
+    if(!$g_root_on)	{
+        $g_root_on = true;
+        $objQuery = new SC_Query();
+        if($_GET['product_id'] != "" || $_GET['category_id'] != "") {
+            // 選択中のカテゴリIDを判定する
+            $category_id = sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
+            // ROOTカテゴリIDの取得
+             $arrRet = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
+             $root_id = $arrRet[0];
+        } else {
+            // ROOTカテゴリIDをなしに設定する
+            $root_id = "";
+        }
+        $g_root_id = $root_id;
+    }
+    return $g_root_id;
 }
 
 /* カテゴリから商品を検索する場合のWHERE文と値を返す */
 function sfGetCatWhere($category_id) {
-	// 子カテゴリIDの取得
-	$arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id);
-	$tmp_where = "";
-	foreach ($arrRet as $val) {
-		if($tmp_where == "") {
-			$tmp_where.= " category_id IN ( ?";
-		} else {
-			$tmp_where.= ",? ";
-		}
-		$arrval[] = $val;
-	}
-	$tmp_where.= " ) ";
-	return array($tmp_where, $arrval);
+    // 子カテゴリIDの取得
+    $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id);
+    $tmp_where = "";
+    foreach ($arrRet as $val) {
+        if($tmp_where == "") {
+            $tmp_where.= " category_id IN ( ?";
+        } else {
+            $tmp_where.= ",? ";
+        }
+        $arrval[] = $val;
+    }
+    $tmp_where.= " ) ";
+    return array($tmp_where, $arrval);
 }
 
 /* 加算ポイントの計算式 */
 function sfGetAddPoint($totalpoint, $use_point, $arrInfo) {
-	// 購入商品の合計ポイントから利用したポイントのポイント換算価値を引く方式
-	$add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100));
-	
-	if($add_point < 0) {
-		$add_point = '0';
-	}
-	return $add_point;
+    // 購入商品の合計ポイントから利用したポイントのポイント換算価値を引く方式
+    $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100));
+
+    if($add_point < 0) {
+        $add_point = '0';
+    }
+    return $add_point;
 }
 
 /* 一意かつ予測されにくいID */
 function sfGetUniqRandomId($head = "") {
-	// 予測されないようにランダム文字列を付与する。
-	$random = gfMakePassword(8);
-	// 同一ホスト内で一意なIDを生成
-	$id = uniqid($head);
-	return ($id . $random);
+    // 予測されないようにランダム文字列を付与する。
+    $random = gfMakePassword(8);
+    // 同一ホスト内で一意なIDを生成
+    $id = uniqid($head);
+    return ($id . $random);
 }
 
 // カテゴリ別オススメ品の取得
 function sfGetBestProducts( $conn, $category_id = 0){
-	// 既に登録されている内容を取得する
-	$sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate,
-			 A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls 
-			USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank";
-	$arrItems = $conn->getAll($sql, array($category_id));
-
-	return $arrItems;
+    // 既に登録されている内容を取得する
+    $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate,
+             A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls
+            USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank";
+    $arrItems = $conn->getAll($sql, array($category_id));
+
+    return $arrItems;
 }
 
 // 特殊制御文字の手動エスケープ
 function sfManualEscape($data) {
-	// 配列でない場合
-	if(!is_array($data)) {
-		if (DB_TYPE == "pgsql") {
-			$ret = pg_escape_string($data);
-		}else if(DB_TYPE == "mysql"){
-			$ret = mysql_real_escape_string($data);
-		}
-		$ret = ereg_replace("%", "\\%", $ret);
-		$ret = ereg_replace("_", "\\_", $ret);
-		return $ret;
-	}
-	
-	// 配列の場合
-	foreach($data as $val) {
-		if (DB_TYPE == "pgsql") {
-			$ret = pg_escape_string($val);
-		}else if(DB_TYPE == "mysql"){
-			$ret = mysql_real_escape_string($val);
-		}
-
-		$ret = ereg_replace("%", "\\%", $ret);
-		$ret = ereg_replace("_", "\\_", $ret);
-		$arrRet[] = $ret;
-	}
-
-	return $arrRet;
+    // 配列でない場合
+    if(!is_array($data)) {
+        if (DB_TYPE == "pgsql") {
+            $ret = pg_escape_string($data);
+        }else if(DB_TYPE == "mysql"){
+            $ret = mysql_real_escape_string($data);
+        }
+        $ret = ereg_replace("%", "\\%", $ret);
+        $ret = ereg_replace("_", "\\_", $ret);
+        return $ret;
+    }
+
+    // 配列の場合
+    foreach($data as $val) {
+        if (DB_TYPE == "pgsql") {
+            $ret = pg_escape_string($val);
+        }else if(DB_TYPE == "mysql"){
+            $ret = mysql_real_escape_string($val);
+        }
+
+        $ret = ereg_replace("%", "\\%", $ret);
+        $ret = ereg_replace("_", "\\_", $ret);
+        $arrRet[] = $ret;
+    }
+
+    return $arrRet;
 }
 
 // 受注番号、利用ポイント、加算ポイントから最終ポイントを取得
 function sfGetCustomerPoint($order_id, $use_point, $add_point) {
-	$objQuery = new SC_Query();
-	$arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id));
-	$customer_id = $arrRet[0]['customer_id'];
-	if($customer_id != "" && $customer_id >= 1) {
-		$arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
-		$point = $arrRet[0]['point'];
-		$total_point = $arrRet[0]['point'] - $use_point + $add_point;
-	} else {
-		$total_point = "";
-		$point = "";
-	}
-	return array($point, $total_point);
+    $objQuery = new SC_Query();
+    $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id));
+    $customer_id = $arrRet[0]['customer_id'];
+    if($customer_id != "" && $customer_id >= 1) {
+        $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
+        $point = $arrRet[0]['point'];
+        $total_point = $arrRet[0]['point'] - $use_point + $add_point;
+    } else {
+        $total_point = "";
+        $point = "";
+    }
+    return array($point, $total_point);
 }
 
 /* ドメイン間で有効なセッションのスタート */
 function sfDomainSessionStart() {
-	$ret = session_id();
+    $ret = session_id();
 /*
-	ヘッダーを送信していてもsession_start()が必要なページがあるので
-	コメントアウトしておく
-	if($ret == "" && !headers_sent()) {
+    ヘッダーを送信していてもsession_start()が必要なページがあるので
+    コメントアウトしておく
+    if($ret == "" && !headers_sent()) {
 */
-	if($ret == "") {
-		/* セッションパラメータの指定
-		 ・ブラウザを閉じるまで有効
-		 ・すべてのパスで有効
-		 ・同じドメイン間で共有 */
-		session_set_cookie_params (0, "/", DOMAIN_NAME);
-
-		if(!ini_get("session.auto_start")){
-			// セッション開始
-			session_start();
-		}
-	}
+    if($ret == "") {
+        /* セッションパラメータの指定
+         ・ブラウザを閉じるまで有効
+         ・すべてのパスで有効
+         ・同じドメイン間で共有 */
+        session_set_cookie_params (0, "/", DOMAIN_NAME);
+
+        if(!ini_get("session.auto_start")){
+            // セッション開始
+            session_start();
+        }
+    }
 }
 
 /* 文字列に強制的に改行を入れる */
 function sfPutBR($str, $size) {
-	$i = 0;
-	$cnt = 0;
-	$line = array();
-	$ret = "";
-	
-	while($str[$i] != "") {
-		$line[$cnt].=$str[$i];
-		$i++;
-		if(strlen($line[$cnt]) > $size) {
-			$line[$cnt].="<br />";
-			$cnt++;
-		}
-	}
-	
-	foreach($line as $val) {
-		$ret.=$val;
-	}
-	return $ret;
+    $i = 0;
+    $cnt = 0;
+    $line = array();
+    $ret = "";
+
+    while($str[$i] != "") {
+        $line[$cnt].=$str[$i];
+        $i++;
+        if(strlen($line[$cnt]) > $size) {
+            $line[$cnt].="<br />";
+            $cnt++;
+        }
+    }
+
+    foreach($line as $val) {
+        $ret.=$val;
+    }
+    return $ret;
 }
 
 // 二回以上繰り返されているスラッシュ[/]を一つに変換する。
 function sfRmDupSlash($istr){
-	if(ereg("^http://", $istr)) {
-		$str = substr($istr, 7);
-		$head = "http://";
-	} else if(ereg("^https://", $istr)) {
-		$str = substr($istr, 8);
-		$head = "https://";
-	} else {
-		$str = $istr;
-	}
-	$str = ereg_replace("[/]+", "/", $str);
-	$ret = $head . $str;
-	return $ret;	
+    if(ereg("^http://", $istr)) {
+        $str = substr($istr, 7);
+        $head = "http://";
+    } else if(ereg("^https://", $istr)) {
+        $str = substr($istr, 8);
+        $head = "https://";
+    } else {
+        $str = $istr;
+    }
+    $str = ereg_replace("[/]+", "/", $str);
+    $ret = $head . $str;
+    return $ret;
 }
 
 function sfEncodeFile($filepath, $enc_type, $out_dir) {
-	$ifp = fopen($filepath, "r");
-	
-	$basename = basename($filepath);
-	$outpath = $out_dir . "enc_" . $basename;
-	
-	$ofp = fopen($outpath, "w+");
-	
-	while(!feof($ifp)) {
-		$line = fgets($ifp);
-		$line = mb_convert_encoding($line, $enc_type, "auto");
-		fwrite($ofp,  $line);
-	}
-	
-	fclose($ofp);
-	fclose($ifp);
-	
-	return 	$outpath;
+    $ifp = fopen($filepath, "r");
+
+    $basename = basename($filepath);
+    $outpath = $out_dir . "enc_" . $basename;
+
+    $ofp = fopen($outpath, "w+");
+
+    while(!feof($ifp)) {
+        $line = fgets($ifp);
+        $line = mb_convert_encoding($line, $enc_type, "auto");
+        fwrite($ofp,  $line);
+    }
+
+    fclose($ofp);
+    fclose($ifp);
+
+    return 	$outpath;
 }
 
 function sfCutString($str, $len, $byte = true, $commadisp = true) {
-	if($byte) {
-		if(strlen($str) > ($len + 2)) {
-			$ret =substr($str, 0, $len);
-			$cut = substr($str, $len);
-		} else {
-			$ret = $str;
-			$commadisp = false;
-		}
-	} else {
-		if(mb_strlen($str) > ($len + 1)) {
-			$ret = mb_substr($str, 0, $len);
-			$cut = mb_substr($str, $len);
-		} else {
-			$ret = $str;
-			$commadisp = false;
-		}
-	}
-
-	// 絵文字タグの途中で分断されないようにする。
-	if (isset($cut)) {
-		// 分割位置より前の最後の [ 以降を取得する。
-		$head = strrchr($ret, '[');
-
-		// 分割位置より後の最初の ] 以前を取得する。
-		$tail_pos = strpos($cut, ']');
-		if ($tail_pos !== false) {
-			$tail = substr($cut, 0, $tail_pos + 1);
-		}
-
-		// 分割位置より前に [、後に ] が見つかった場合は、[ から ] までを
-		// 接続して絵文字タグ1個分になるかどうかをチェックする。
-		if ($head !== false && $tail_pos !== false) {
-			$subject = $head . $tail;
-			if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) {
-				// 絵文字タグが見つかったので削除する。
-				$ret = substr($ret, 0, -strlen($head));
-			}
-		}
-	}
-
-	if($commadisp){
-		$ret = $ret . "...";
-	}
-	return $ret;
+    if($byte) {
+        if(strlen($str) > ($len + 2)) {
+            $ret =substr($str, 0, $len);
+            $cut = substr($str, $len);
+        } else {
+            $ret = $str;
+            $commadisp = false;
+        }
+    } else {
+        if(mb_strlen($str) > ($len + 1)) {
+            $ret = mb_substr($str, 0, $len);
+            $cut = mb_substr($str, $len);
+        } else {
+            $ret = $str;
+            $commadisp = false;
+        }
+    }
+
+    // 絵文字タグの途中で分断されないようにする。
+    if (isset($cut)) {
+        // 分割位置より前の最後の [ 以降を取得する。
+        $head = strrchr($ret, '[');
+
+        // 分割位置より後の最初の ] 以前を取得する。
+        $tail_pos = strpos($cut, ']');
+        if ($tail_pos !== false) {
+            $tail = substr($cut, 0, $tail_pos + 1);
+        }
+
+        // 分割位置より前に [、後に ] が見つかった場合は、[ から ] までを
+        // 接続して絵文字タグ1個分になるかどうかをチェックする。
+        if ($head !== false && $tail_pos !== false) {
+            $subject = $head . $tail;
+            if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) {
+                // 絵文字タグが見つかったので削除する。
+                $ret = substr($ret, 0, -strlen($head));
+            }
+        }
+    }
+
+    if($commadisp){
+        $ret = $ret . "...";
+    }
+    return $ret;
 }
 
 // 年、月、締め日から、先月の締め日+1、今月の締め日を求める。
 function sfTermMonth($year, $month, $close_day) {
-	$end_year = $year;
-	$end_month = $month;
-	
-	// 開始月が終了月と同じか否か
-	$same_month = false;
-	
-	// 該当月の末日を求める。
-	$end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
-	
-	// 月の末日が締め日より少ない場合
-	if($end_last_day < $close_day) {
-		// 締め日を月末日に合わせる
-		$end_day = $end_last_day;
-	} else {
-		$end_day = $close_day;
-	}
-	
-	// 前月の取得
-	$tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year));
-	$tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year));
-	// 前月の末日を求める。
-	$start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year));
-	
-	// 前月の末日が締め日より少ない場合
-	if ($start_last_day < $close_day) {
-		// 月末日に合わせる
-		$tmp_day = $start_last_day;
-	} else {
-		$tmp_day = $close_day;
-	}
-	
-	// 先月の末日の翌日を取得する
-	$start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
-	$start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
-	$start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
-	
-	// 日付の作成
-	$start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day);
-	$end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day);
-	
-	return array($start_date, $end_date);
+    $end_year = $year;
+    $end_month = $month;
+
+    // 開始月が終了月と同じか否か
+    $same_month = false;
+
+    // 該当月の末日を求める。
+    $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
+
+    // 月の末日が締め日より少ない場合
+    if($end_last_day < $close_day) {
+        // 締め日を月末日に合わせる
+        $end_day = $end_last_day;
+    } else {
+        $end_day = $close_day;
+    }
+
+    // 前月の取得
+    $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year));
+    $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year));
+    // 前月の末日を求める。
+    $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year));
+
+    // 前月の末日が締め日より少ない場合
+    if ($start_last_day < $close_day) {
+        // 月末日に合わせる
+        $tmp_day = $start_last_day;
+    } else {
+        $tmp_day = $close_day;
+    }
+
+    // 先月の末日の翌日を取得する
+    $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+    $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+    $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+
+    // 日付の作成
+    $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day);
+    $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day);
+
+    return array($start_date, $end_date);
 }
 
 // PDF用のRGBカラーを返す
 function sfGetPdfRgb($hexrgb) {
-	$hex = substr($hexrgb, 0, 2);
-	$r = hexdec($hex) / 255;
-	
-	$hex = substr($hexrgb, 2, 2);
-	$g = hexdec($hex) / 255;
-	
-	$hex = substr($hexrgb, 4, 2);
-	$b = hexdec($hex) / 255;
-	
-	return array($r, $g, $b);	
+    $hex = substr($hexrgb, 0, 2);
+    $r = hexdec($hex) / 255;
+
+    $hex = substr($hexrgb, 2, 2);
+    $g = hexdec($hex) / 255;
+
+    $hex = substr($hexrgb, 4, 2);
+    $b = hexdec($hex) / 255;
+
+    return array($r, $g, $b);
 }
 
 //メルマガ仮登録とメール配信
 function sfRegistTmpMailData($mail_flag, $email){
-	$objQuery = new SC_Query();
-	$objConn = new SC_DBConn();
-	$objPage = new LC_Page();
-	
-	$random_id = sfGetUniqRandomId();
-	$arrRegistMailMagazine["mail_flag"] = $mail_flag;
-	$arrRegistMailMagazine["email"] = $email;
-	$arrRegistMailMagazine["temp_id"] =$random_id;
-	$arrRegistMailMagazine["end_flag"]='0';
-	$arrRegistMailMagazine["update_date"] = 'now()';
-	
-	//メルマガ仮登録用フラグ
-	$flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email));
-	$objConn->query("BEGIN");
-	switch ($flag){
-		case '0':
-		$objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine);
-		break;
-	
-		case '1':
-		$objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'");
-		break;
-	}
-	$objConn->query("COMMIT");
-	$subject = sfMakeSubject('メルマガ仮登録が完了しました。');
-	$objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id'];
-	switch ($mail_flag){
-		case '1':
-		$objPage->tpl_name = "登録";
-		$objPage->tpl_kindname = "HTML";
-		break;
-		
-		case '2':
-		$objPage->tpl_name = "登録";
-		$objPage->tpl_kindname = "テキスト";
-		break;
-		
-		case '3':
-		$objPage->tpl_name = "解除";
-		break;
-	}
-		$objPage->tpl_email = $email;
-	sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage);
+    $objQuery = new SC_Query();
+    $objConn = new SC_DBConn();
+    $objPage = new LC_Page();
+
+    $random_id = sfGetUniqRandomId();
+    $arrRegistMailMagazine["mail_flag"] = $mail_flag;
+    $arrRegistMailMagazine["email"] = $email;
+    $arrRegistMailMagazine["temp_id"] =$random_id;
+    $arrRegistMailMagazine["end_flag"]='0';
+    $arrRegistMailMagazine["update_date"] = 'now()';
+
+    //メルマガ仮登録用フラグ
+    $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email));
+    $objConn->query("BEGIN");
+    switch ($flag){
+        case '0':
+        $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine);
+        break;
+
+        case '1':
+        $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'");
+        break;
+    }
+    $objConn->query("COMMIT");
+    $subject = sfMakeSubject('メルマガ仮登録が完了しました。');
+    $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id'];
+    switch ($mail_flag){
+        case '1':
+        $objPage->tpl_name = "登録";
+        $objPage->tpl_kindname = "HTML";
+        break;
+
+        case '2':
+        $objPage->tpl_name = "登録";
+        $objPage->tpl_kindname = "テキスト";
+        break;
+
+        case '3':
+        $objPage->tpl_name = "解除";
+        break;
+    }
+        $objPage->tpl_email = $email;
+    sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage);
 }
 
 // 再帰的に多段配列を検索して一次元配列(Hidden引渡し用配列)に変換する。
 function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") {
-	if(is_array($arrSrc)) {
-		foreach($arrSrc as $key => $val) {
-			if($parent_key != "") {
-				$keyname = $parent_key . "[". $key . "]";
-			} else {
-				$keyname = $key;
-			}
-			if(is_array($val)) {
-				$arrDst = sfMakeHiddenArray($val, $arrDst, $keyname);
-			} else {
-				$arrDst[$keyname] = $val;
-			}
-		}
-	}
-	return $arrDst;
+    if(is_array($arrSrc)) {
+        foreach($arrSrc as $key => $val) {
+            if($parent_key != "") {
+                $keyname = $parent_key . "[". $key . "]";
+            } else {
+                $keyname = $key;
+            }
+            if(is_array($val)) {
+                $arrDst = sfMakeHiddenArray($val, $arrDst, $keyname);
+            } else {
+                $arrDst[$keyname] = $val;
+            }
+        }
+    }
+    return $arrDst;
 }
 
 // DB取得日時をタイムに変換
 function sfDBDatetoTime($db_date) {
-	$date = ereg_replace("\..*$","",$db_date);
-	$time = strtotime($date);
-	return $time;
+    $date = ereg_replace("\..*$","",$db_date);
+    $time = strtotime($date);
+    return $time;
 }
 
 // 出力の際にテンプレートを切り替えられる
 /*
-	index.php?tpl=test.tpl
+    index.php?tpl=test.tpl
 */
 function sfCustomDisplay($objPage, $is_mobile = false) {
-	$basename = basename($_SERVER["REQUEST_URI"]);
-
-	if($basename == "") {
-		$path = $_SERVER["REQUEST_URI"] . "index.php";
-	} else {
-		$path = $_SERVER["REQUEST_URI"];
-	}	
-
-	if($_GET['tpl'] != "") {
-		$tpl_name = $_GET['tpl'];
-	} else {
-		$tpl_name = ereg_replace("^/", "", $path);
-		$tpl_name = ereg_replace("/", "_", $tpl_name);
-		$tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name);
-	}
-
-	$template_path = TEMPLATE_FTP_DIR . $tpl_name;
-
-	if($is_mobile === true) {
-		$objView = new SC_MobileView();			
-		$objView->assignobj($objPage);
-		$objView->display(SITE_FRAME);		
-	} else if(file_exists($template_path)) {
-		$objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR);
-		$objView->assignobj($objPage);
-		$objView->display($tpl_name);
-	} else {
-		$objView = new SC_SiteView();
-		$objView->assignobj($objPage);
-		$objView->display(SITE_FRAME);
-	}
+    $basename = basename($_SERVER["REQUEST_URI"]);
+
+    if($basename == "") {
+        $path = $_SERVER["REQUEST_URI"] . "index.php";
+    } else {
+        $path = $_SERVER["REQUEST_URI"];
+    }
+
+    if($_GET['tpl'] != "") {
+        $tpl_name = $_GET['tpl'];
+    } else {
+        $tpl_name = ereg_replace("^/", "", $path);
+        $tpl_name = ereg_replace("/", "_", $tpl_name);
+        $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name);
+    }
+
+    $template_path = TEMPLATE_FTP_DIR . $tpl_name;
+
+    if($is_mobile === true) {
+        $objView = new SC_MobileView();
+        $objView->assignobj($objPage);
+        $objView->display(SITE_FRAME);
+    } else if(file_exists($template_path)) {
+        $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR);
+        $objView->assignobj($objPage);
+        $objView->display($tpl_name);
+    } else {
+        $objView = new SC_SiteView();
+        $objView->assignobj($objPage);
+        $objView->display(SITE_FRAME);
+    }
 }
 
 //会員編集登録処理
 function sfEditCustomerData($array, $arrRegistColumn) {
-	$objQuery = new SC_Query();
-	
-	foreach ($arrRegistColumn as $data) {
-		if ($data["column"] != "password") {
-			if($array[ $data['column'] ] != "") {
-				$arrRegist[ $data["column"] ] = $array[ $data["column"] ];
-			} else {
-				$arrRegist[ $data['column'] ] = NULL;
-			}
-		}
-	}
-	if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) {
-		$arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
-	} else {
-		$arrRegist["birth"] = NULL;
-	}
-
-	//-- パスワードの更新がある場合は暗号化。（更新がない場合はUPDATE文を構成しない）
-	if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); 
-	$arrRegist["update_date"] = "NOW()";
-	
-	//-- 編集登録実行
-	if (defined('MOBILE_SITE')) {
-		$arrRegist['email_mobile'] = $arrRegist['email'];
-		unset($arrRegist['email']);
-	}
-	$objQuery->begin();
-	$objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id']));
-	$objQuery->commit();
+    $objQuery = new SC_Query();
+
+    foreach ($arrRegistColumn as $data) {
+        if ($data["column"] != "password") {
+            if($array[ $data['column'] ] != "") {
+                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+            } else {
+                $arrRegist[ $data['column'] ] = NULL;
+            }
+        }
+    }
+    if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) {
+        $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
+    } else {
+        $arrRegist["birth"] = NULL;
+    }
+
+    //-- パスワードの更新がある場合は暗号化。（更新がない場合はUPDATE文を構成しない）
+    if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC);
+    $arrRegist["update_date"] = "NOW()";
+
+    //-- 編集登録実行
+    if (defined('MOBILE_SITE')) {
+        $arrRegist['email_mobile'] = $arrRegist['email'];
+        unset($arrRegist['email']);
+    }
+    $objQuery->begin();
+    $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id']));
+    $objQuery->commit();
 }
 
 // PHPのmb_convert_encoding関数をSmartyでも使えるようにする
 function sf_mb_convert_encoding($str, $encode = 'CHAR_CODE') {
-	return  mb_convert_encoding($str, $encode);
-}	
+    return  mb_convert_encoding($str, $encode);
+}
 
 // PHPのmktime関数をSmartyでも使えるようにする
 function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) {
-	return  date($format,mktime($hour, $minute, $second, $month, $day, $year));
-}	
+    return  date($format,mktime($hour, $minute, $second, $month, $day, $year));
+}
 
 // PHPのdate関数をSmartyでも使えるようにする
 function sf_date($format, $timestamp = '') {
-	return  date( $format, $timestamp);
+    return  date( $format, $timestamp);
 }
 
 // チェックボックスの型を変換する
 function sfChangeCheckBox($data , $tpl = false){
-	if ($tpl) {
-		if ($data == 1){
-			return 'checked';
-		}else{
-			return "";
-		}
-	}else{
-		if ($data == "on"){
-			return 1;
-		}else{
-			return 2;
-		}
-	}
+    if ($tpl) {
+        if ($data == 1){
+            return 'checked';
+        }else{
+            return "";
+        }
+    }else{
+        if ($data == "on"){
+            return 1;
+        }else{
+            return 2;
+        }
+    }
 }
 
 function sfCategory_Count($objQuery){
-	$sql = "";
-	
-	//テーブル内容の削除
-	$objQuery->query("DELETE FROM dtb_category_count");
-	$objQuery->query("DELETE FROM dtb_category_total_count");
-	
-	//各カテゴリ内の商品数を数えて格納
-	$sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) ";
-	$sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 ";
-	$sql .= " ON T1.category_id = T2.category_id  ";
-	$sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 ";
-	$sql .= " GROUP BY T1.category_id, T2.category_id ";
-	$objQuery->query($sql);
-	
-	//子カテゴリ内の商品数を集計する
-	$arrCat = $objQuery->getAll("SELECT * FROM dtb_category");
-	
-	$sql = "";
-	foreach($arrCat as $key => $val){
-		
-		// 子ID一覧を取得
-		$arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']);	
-		$line = sfGetCommaList($arrRet);
-		
-		$sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) ";
-		$sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count ";
-		$sql .= " WHERE category_id IN (" . $line . ")";
-				
-		$objQuery->query($sql, array($val['category_id']));
-	}
+    $sql = "";
+
+    //テーブル内容の削除
+    $objQuery->query("DELETE FROM dtb_category_count");
+    $objQuery->query("DELETE FROM dtb_category_total_count");
+
+    //各カテゴリ内の商品数を数えて格納
+    $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) ";
+    $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 ";
+    $sql .= " ON T1.category_id = T2.category_id  ";
+    $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 ";
+    $sql .= " GROUP BY T1.category_id, T2.category_id ";
+    $objQuery->query($sql);
+
+    //子カテゴリ内の商品数を集計する
+    $arrCat = $objQuery->getAll("SELECT * FROM dtb_category");
+
+    $sql = "";
+    foreach($arrCat as $key => $val){
+
+        // 子ID一覧を取得
+        $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']);
+        $line = sfGetCommaList($arrRet);
+
+        $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) ";
+        $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count ";
+        $sql .= " WHERE category_id IN (" . $line . ")";
+
+        $objQuery->query($sql, array($val['category_id']));
+    }
 }
 
@@ -2512,53 +2512,53 @@
 function sfarrCombine($arrKeys, $arrValues) {
 
-	if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array();
-	
+    if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array();
+
     $keys = array_values($arrKeys);
-    $vals = array_values($arrValues); 
-	
-    $max = max( count( $keys ), count( $vals ) ); 
-    $combine_ary = array(); 
-    for($i=0; $i<$max; $i++) { 
-        $combine_ary[$keys[$i]] = $vals[$i]; 
-    } 
-    if(is_array($combine_ary)) return $combine_ary; 
-    
-	return false; 
+    $vals = array_values($arrValues);
+
+    $max = max( count( $keys ), count( $vals ) );
+    $combine_ary = array();
+    for($i=0; $i<$max; $i++) {
+        $combine_ary[$keys[$i]] = $vals[$i];
+    }
+    if(is_array($combine_ary)) return $combine_ary;
+
+    return false;
 }
 
 /* 階層構造のテーブルから子ID配列を取得する */
 function sfGetChildrenArray($table, $pid_name, $id_name, $id) {
-	$objQuery = new SC_Query();
-	$col = $pid_name . "," . $id_name;
- 	$arrData = $objQuery->select($col, $table);
-	
-	$arrPID = array();
-	$arrPID[] = $id;
-	$arrChildren = array();
-	$arrChildren[] = $id;
-	
-	$arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID);
-	
-	while(count($arrRet) > 0) {
-		$arrChildren = array_merge($arrChildren, $arrRet);
-		$arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet);
-	}
-	
-	return $arrChildren;
+    $objQuery = new SC_Query();
+    $col = $pid_name . "," . $id_name;
+     $arrData = $objQuery->select($col, $table);
+
+    $arrPID = array();
+    $arrPID[] = $id;
+    $arrChildren = array();
+    $arrChildren[] = $id;
+
+    $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID);
+
+    while(count($arrRet) > 0) {
+        $arrChildren = array_merge($arrChildren, $arrRet);
+        $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet);
+    }
+
+    return $arrChildren;
 }
 
 /* 親ID直下の子IDをすべて取得する */
 function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) {
-	$arrChildren = array();
-	$max = count($arrData);
-	
-	for($i = 0; $i < $max; $i++) {
-		foreach($arrPID as $val) {
-			if($arrData[$i][$pid_name] == $val) {
-				$arrChildren[] = $arrData[$i][$id_name];
-			}
-		}
-	}	
-	return $arrChildren;
+    $arrChildren = array();
+    $max = count($arrData);
+
+    for($i = 0; $i < $max; $i++) {
+        foreach($arrPID as $val) {
+            if($arrData[$i][$pid_name] == $val) {
+                $arrChildren[] = $arrData[$i][$id_name];
+            }
+        }
+    }
+    return $arrChildren;
 }
 
@@ -2566,72 +2566,72 @@
 /* 階層構造のテーブルから親ID配列を取得する */
 function sfGetParentsArray($table, $pid_name, $id_name, $id) {
-	$objQuery = new SC_Query();
-	$col = $pid_name . "," . $id_name;
- 	$arrData = $objQuery->select($col, $table);
-	
-	$arrParents = array();
-	$arrParents[] = $id;
-	$child = $id;
-	
-	$ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $child);
-
-	while($ret != "") {
-		$arrParents[] = $ret;
-		$ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret);
-	}
-	
-	$arrParents = array_reverse($arrParents);
-	
-	return $arrParents;
+    $objQuery = new SC_Query();
+    $col = $pid_name . "," . $id_name;
+     $arrData = $objQuery->select($col, $table);
+
+    $arrParents = array();
+    $arrParents[] = $id;
+    $child = $id;
+
+    $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $child);
+
+    while($ret != "") {
+        $arrParents[] = $ret;
+        $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret);
+    }
+
+    $arrParents = array_reverse($arrParents);
+
+    return $arrParents;
 }
 
 /* 子ID所属する親IDを取得する */
 function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) {
-	$max = count($arrData);
-	$parent = "";
-	for($i = 0; $i < $max; $i++) {
-		if($arrData[$i][$id_name] == $child) {
-			$parent = $arrData[$i][$pid_name];
-			break;
-		}
-	}
-	return $parent;
+    $max = count($arrData);
+    $parent = "";
+    for($i = 0; $i < $max; $i++) {
+        if($arrData[$i][$id_name] == $child) {
+            $parent = $arrData[$i][$pid_name];
+            break;
+        }
+    }
+    return $parent;
 }
 
 /* 階層構造のテーブルから与えられたIDの兄弟を取得する */
 function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) {
-	$max = count($arrData);
-	
-	$arrBrothers = array();
-	foreach($arrPID as $id) {
-		// 親IDを検索する
-		for($i = 0; $i < $max; $i++) {
-			if($arrData[$i][$id_name] == $id) {
-				$parent = $arrData[$i][$pid_name];
-				break;
-			}
-		}
-		// 兄弟IDを検索する
-		for($i = 0; $i < $max; $i++) {
-			if($arrData[$i][$pid_name] == $parent) {
-				$arrBrothers[] = $arrData[$i][$id_name];
-			}
-		}					
-	}
-	return $arrBrothers;
+    $max = count($arrData);
+
+    $arrBrothers = array();
+    foreach($arrPID as $id) {
+        // 親IDを検索する
+        for($i = 0; $i < $max; $i++) {
+            if($arrData[$i][$id_name] == $id) {
+                $parent = $arrData[$i][$pid_name];
+                break;
+            }
+        }
+        // 兄弟IDを検索する
+        for($i = 0; $i < $max; $i++) {
+            if($arrData[$i][$pid_name] == $parent) {
+                $arrBrothers[] = $arrData[$i][$id_name];
+            }
+        }
+    }
+    return $arrBrothers;
 }
 
 /* 階層構造のテーブルから与えられたIDの直属の子を取得する */
 function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) {
-	$max = count($arrData);
-	
-	$arrChildren = array();
-	// 子IDを検索する
-	for($i = 0; $i < $max; $i++) {
-		if($arrData[$i][$pid_name] == $parent) {
-			$arrChildren[] = $arrData[$i][$id_name];
-		}
-	}					
-	return $arrChildren;
+    $max = count($arrData);
+
+    $arrChildren = array();
+    // 子IDを検索する
+    for($i = 0; $i < $max; $i++) {
+        if($arrData[$i][$pid_name] == $parent) {
+            $arrChildren[] = $arrData[$i][$id_name];
+        }
+    }
+    return $arrChildren;
 }
 
@@ -2639,104 +2639,104 @@
 // カテゴリツリーの取得
 function sfGetCatTree($parent_category_id, $count_check = false) {
-	$objQuery = new SC_Query();
-	$col = "";
-	$col .= " cat.category_id,";
-	$col .= " cat.category_name,";
-	$col .= " cat.parent_category_id,";
-	$col .= " cat.level,";
-	$col .= " cat.rank,";
-	$col .= " cat.creator_id,";
-	$col .= " cat.create_date,";
-	$col .= " cat.update_date,";
-	$col .= " cat.del_flg, ";
-	$col .= " ttl.product_count";	
-	$from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id";
-	// 登録商品数のチェック
-	if($count_check) {
-		$where = "del_flg = 0 AND product_count > 0";
-	} else {
-		$where = "del_flg = 0";
-	}
-	$objQuery->setoption("ORDER BY rank DESC");
-	$arrRet = $objQuery->select($col, $from, $where);
-	
-	$arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
-	
-	foreach($arrRet as $key => $array) {
-		foreach($arrParentID as $val) {
-			if($array['category_id'] == $val) {
-				$arrRet[$key]['display'] = 1;
-				break;
-			}
-		}
-	}
-
-	return $arrRet;
+    $objQuery = new SC_Query();
+    $col = "";
+    $col .= " cat.category_id,";
+    $col .= " cat.category_name,";
+    $col .= " cat.parent_category_id,";
+    $col .= " cat.level,";
+    $col .= " cat.rank,";
+    $col .= " cat.creator_id,";
+    $col .= " cat.create_date,";
+    $col .= " cat.update_date,";
+    $col .= " cat.del_flg, ";
+    $col .= " ttl.product_count";
+    $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id";
+    // 登録商品数のチェック
+    if($count_check) {
+        $where = "del_flg = 0 AND product_count > 0";
+    } else {
+        $where = "del_flg = 0";
+    }
+    $objQuery->setoption("ORDER BY rank DESC");
+    $arrRet = $objQuery->select($col, $from, $where);
+
+    $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
+
+    foreach($arrRet as $key => $array) {
+        foreach($arrParentID as $val) {
+            if($array['category_id'] == $val) {
+                $arrRet[$key]['display'] = 1;
+                break;
+            }
+        }
+    }
+
+    return $arrRet;
 }
 
 // 親カテゴリーを連結した文字列を取得する
 function sfGetCatCombName($category_id){
-	// 商品が属するカテゴリIDを縦に取得
-	$objQuery = new SC_Query();
-	$arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);	
-	$ConbName = "";
-	
-	// カテゴリー名称を取得する
-	foreach($arrCatID as $key => $val){
-		$sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
-		$arrVal = array($val);
-		$CatName = $objQuery->getOne($sql,$arrVal);
-		$ConbName .= $CatName . ' | ';
-	}
-	// 最後の ｜ をカットする
-	$ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2);
-	
-	return $ConbName;
+    // 商品が属するカテゴリIDを縦に取得
+    $objQuery = new SC_Query();
+    $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
+    $ConbName = "";
+
+    // カテゴリー名称を取得する
+    foreach($arrCatID as $key => $val){
+        $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
+        $arrVal = array($val);
+        $CatName = $objQuery->getOne($sql,$arrVal);
+        $ConbName .= $CatName . ' | ';
+    }
+    // 最後の ｜ をカットする
+    $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2);
+
+    return $ConbName;
 }
 
 // 指定したカテゴリーIDの大カテゴリーを取得する
 function sfGetFirstCat($category_id){
-	// 商品が属するカテゴリIDを縦に取得
-	$objQuery = new SC_Query();
-	$arrRet = array();
-	$arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);	
-	$arrRet['id'] = $arrCatID[0];
-	
-	// カテゴリー名称を取得する
-	$sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
-	$arrVal = array($arrRet['id']);
-	$arrRet['name'] = $objQuery->getOne($sql,$arrVal);
-	
-	return $arrRet;
+    // 商品が属するカテゴリIDを縦に取得
+    $objQuery = new SC_Query();
+    $arrRet = array();
+    $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
+    $arrRet['id'] = $arrCatID[0];
+
+    // カテゴリー名称を取得する
+    $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
+    $arrVal = array($arrRet['id']);
+    $arrRet['name'] = $objQuery->getOne($sql,$arrVal);
+
+    return $arrRet;
 }
 
 //MySQL用のSQL文に変更する
 function sfChangeMySQL($sql){
-	// 改行、タブを1スペースに変換
-	$sql = preg_replace("/[\r\n\t]/"," ",$sql);
-	
-	$sql = sfChangeView($sql);		// view表をインラインビューに変換する
-	$sql = sfChangeILIKE($sql);		// ILIKE検索をLIKE検索に変換する
-	$sql = sfChangeRANDOM($sql);	// RANDOM()をRAND()に変換する
-
-	return $sql;
+    // 改行、タブを1スペースに変換
+    $sql = preg_replace("/[\r\n\t]/"," ",$sql);
+
+    $sql = sfChangeView($sql);		// view表をインラインビューに変換する
+    $sql = sfChangeILIKE($sql);		// ILIKE検索をLIKE検索に変換する
+    $sql = sfChangeRANDOM($sql);	// RANDOM()をRAND()に変換する
+
+    return $sql;
 }
 
 // SQLの中にviewが存在しているかチェックを行う。
 function sfInArray($sql){
-	global $arrView;
-
-	foreach($arrView as $key => $val){
-		if (strcasecmp($sql, $val) == 0){
-			$changesql = eregi_replace("($key)", "$val", $sql);
-			sfInArray($changesql);
-		}
-	}
-	return false;
+    global $arrView;
+
+    foreach($arrView as $key => $val){
+        if (strcasecmp($sql, $val) == 0){
+            $changesql = eregi_replace("($key)", "$val", $sql);
+            sfInArray($changesql);
+        }
+    }
+    return false;
 }
 
 // SQLシングルクォート対応
 function sfQuoteSmart($in){
-	
+
     if (is_int($in) || is_double($in)) {
         return $in;
@@ -2749,122 +2749,122 @@
     }
 }
-	
+
 // view表をインラインビューに変換する
 function sfChangeView($sql){
-	global $arrView;
-	global $arrViewWhere;
-	
-	$arrViewTmp = $arrView;
-
-	// viewのwhereを変換
-	foreach($arrViewTmp as $key => $val){
-		$arrViewTmp[$key] = strtr($arrViewTmp[$key], $arrViewWhere);
-	}
-	
-	// viewを変換
-	$changesql = strtr($sql, $arrViewTmp);
-
-	return $changesql;
+    global $arrView;
+    global $arrViewWhere;
+
+    $arrViewTmp = $arrView;
+
+    // viewのwhereを変換
+    foreach($arrViewTmp as $key => $val){
+        $arrViewTmp[$key] = strtr($arrViewTmp[$key], $arrViewWhere);
+    }
+
+    // viewを変換
+    $changesql = strtr($sql, $arrViewTmp);
+
+    return $changesql;
 }
 
 // ILIKE検索をLIKE検索に変換する
 function sfChangeILIKE($sql){
-	$changesql = eregi_replace("(ILIKE )", "LIKE BINARY ", $sql);
-	return $changesql;
+    $changesql = eregi_replace("(ILIKE )", "LIKE BINARY ", $sql);
+    return $changesql;
 }
 
 // RANDOM()をRAND()に変換する
 function sfChangeRANDOM($sql){
-	$changesql = eregi_replace("( RANDOM)", " RAND", $sql);
-	return $changesql;
+    $changesql = eregi_replace("( RANDOM)", " RAND", $sql);
+    return $changesql;
 }
 
 // viewのwhereを置換する
 function sfViewWhere($target, $where = "", $arrval = array(), $option = ""){
-	global $arrViewWhere;
-	$arrWhere = split("[?]", $where);
-	$where_tmp = " WHERE " . $arrWhere[0];
-	for($i = 1; $i < count($arrWhere); $i++){
-		$where_tmp .= sfQuoteSmart($arrval[$i - 1]) . $arrWhere[$i];
-	}
-	$arrViewWhere[$target] = $where_tmp . " " . $option;
+    global $arrViewWhere;
+    $arrWhere = split("[?]", $where);
+    $where_tmp = " WHERE " . $arrWhere[0];
+    for($i = 1; $i < count($arrWhere); $i++){
+        $where_tmp .= sfQuoteSmart($arrval[$i - 1]) . $arrWhere[$i];
+    }
+    $arrViewWhere[$target] = $where_tmp . " " . $option;
 }
 
 // ディレクトリ以下のファイルを再帰的にコピー
 function sfCopyDir($src, $des, $mess, $override = false){
-	if(!is_dir($src)){
-		return false;
-	}
-
-	$oldmask = umask(0);
-	$mod= stat($src);
-	
-	// ディレクトリがなければ作成する
-	if(!file_exists($des)) {
-		if(!mkdir($des, $mod[2])) {
-			print("path:" . $des);
-		}
-	}
-	
-	$fileArray=glob( $src."*" );
-	foreach( $fileArray as $key => $data_ ){
-		// CVS管理ファイルはコピーしない
-		if(ereg("/CVS/Entries", $data_)) {
-			break;
-		}
-		if(ereg("/CVS/Repository", $data_)) {
-			break;
-		}
-		if(ereg("/CVS/Root", $data_)) {
-			break;
-		}
-		
-		mb_ereg("^(.*[\/])(.*)",$data_, $matches);
-		$data=$matches[2];
-		if( is_dir( $data_ ) ){
-			$mess = sfCopyDir( $data_.'/', $des.$data.'/', $mess);
-		}else{
-			if(!$override && file_exists($des.$data)) {
-				$mess.= $des.$data . "：ファイルが存在します\n";
-			} else {
-				if(@copy( $data_, $des.$data)) {
-					$mess.= $des.$data . "：コピー成功\n";
-				} else {
-					$mess.= $des.$data . "：コピー失敗\n";
-				}
-			}
-			$mod=stat($data_ );
-		}
-	}
-	umask($oldmask);
-	return $mess;
+    if(!is_dir($src)){
+        return false;
+    }
+
+    $oldmask = umask(0);
+    $mod= stat($src);
+
+    // ディレクトリがなければ作成する
+    if(!file_exists($des)) {
+        if(!mkdir($des, $mod[2])) {
+            print("path:" . $des);
+        }
+    }
+
+    $fileArray=glob( $src."*" );
+    foreach( $fileArray as $key => $data_ ){
+        // CVS管理ファイルはコピーしない
+        if(ereg("/CVS/Entries", $data_)) {
+            break;
+        }
+        if(ereg("/CVS/Repository", $data_)) {
+            break;
+        }
+        if(ereg("/CVS/Root", $data_)) {
+            break;
+        }
+
+        mb_ereg("^(.*[\/])(.*)",$data_, $matches);
+        $data=$matches[2];
+        if( is_dir( $data_ ) ){
+            $mess = sfCopyDir( $data_.'/', $des.$data.'/', $mess);
+        }else{
+            if(!$override && file_exists($des.$data)) {
+                $mess.= $des.$data . "：ファイルが存在します\n";
+            } else {
+                if(@copy( $data_, $des.$data)) {
+                    $mess.= $des.$data . "：コピー成功\n";
+                } else {
+                    $mess.= $des.$data . "：コピー失敗\n";
+                }
+            }
+            $mod=stat($data_ );
+        }
+    }
+    umask($oldmask);
+    return $mess;
 }
 
 // 指定したフォルダ内のファイルを全て削除する
 function sfDelFile($dir){
-	$dh = opendir($dir);
-	// フォルダ内のファイルを削除
-	while($file = readdir($dh)){
-		if ($file == "." or $file == "..") continue;
-		$del_file = $dir . "/" . $file;
-		if(is_file($del_file)){
-			$ret = unlink($dir . "/" . $file);
-		}else if (is_dir($del_file)){
-			$ret = sfDelFile($del_file);
-		}
-		
-		if(!$ret){
-			return $ret;
-		}
-	}
-    
+    $dh = opendir($dir);
+    // フォルダ内のファイルを削除
+    while($file = readdir($dh)){
+        if ($file == "." or $file == "..") continue;
+        $del_file = $dir . "/" . $file;
+        if(is_file($del_file)){
+            $ret = unlink($dir . "/" . $file);
+        }else if (is_dir($del_file)){
+            $ret = sfDelFile($del_file);
+        }
+
+        if(!$ret){
+            return $ret;
+        }
+    }
+
     // 閉じる
     closedir($dh);
-    
-	// フォルダを削除
-	return rmdir($dir);
-}
-
-/* 
+
+    // フォルダを削除
+    return rmdir($dir);
+}
+
+/*
  * 関数名：sfWriteFile
  * 引数1 ：書き込むデータ
@@ -2876,107 +2876,147 @@
  */
 function sfWriteFile($str, $path, $type, $permission = "") {
-	//ファイルを開く
-	if (!($file = fopen ($path, $type))) {
-		return false;
-	}
-
-	//ファイルロック
-	flock ($file, LOCK_EX);
-	//ファイルの書き込み
-	fputs ($file, $str);
-	//ファイルロックの解除
-	flock ($file, LOCK_UN);
-	//ファイルを閉じる
-	fclose ($file);
-	// 権限を指定
-	if($permission != "") {
-		chmod($path, $permission);
-	}
-	
-	return true;
-}
-	
+    //ファイルを開く
+    if (!($file = fopen ($path, $type))) {
+        return false;
+    }
+
+    //ファイルロック
+    flock ($file, LOCK_EX);
+    //ファイルの書き込み
+    fputs ($file, $str);
+    //ファイルロックの解除
+    flock ($file, LOCK_UN);
+    //ファイルを閉じる
+    fclose ($file);
+    // 権限を指定
+    if($permission != "") {
+        chmod($path, $permission);
+    }
+
+    return true;
+}
+
 function sfFlush($output = " ", $sleep = 0){
-	// 実行時間を制限しない
-	set_time_limit(0);
-	// 出力をバッファリングしない(==日本語自動変換もしない)
-	ob_end_clean();
-	
-	// IEのために256バイト空文字出力
-	echo str_pad('',256);
-	
-	// 出力はブランクだけでもいいと思う
-	echo $output;
-	// 出力をフラッシュする
-	flush();
-	
-	ob_end_flush();
-	ob_start();	
-	
-	// 時間のかかる処理
-	sleep($sleep);
+    // 実行時間を制限しない
+    set_time_limit(0);
+    // 出力をバッファリングしない(==日本語自動変換もしない)
+    ob_end_clean();
+
+    // IEのために256バイト空文字出力
+    echo str_pad('',256);
+
+    // 出力はブランクだけでもいいと思う
+    echo $output;
+    // 出力をフラッシュする
+    flush();
+
+    ob_end_flush();
+    ob_start();
+
+    // 時間のかかる処理
+    sleep($sleep);
 }
 
 // @versionの記載があるファイルからバージョンを取得する。
 function sfGetFileVersion($path) {
-	if(file_exists($path)) {
-		$src_fp = fopen($path, "rb");
-		if($src_fp) {
-			while (!feof($src_fp)) {
-				$line = fgets($src_fp);
-				if(ereg("@version", $line)) {
-					$arrLine = split(" ", $line);
-					$version = $arrLine[5];
-				}
-			}
-			fclose($src_fp);
-		}
-	}
-	return $version;
+    if(file_exists($path)) {
+        $src_fp = fopen($path, "rb");
+        if($src_fp) {
+            while (!feof($src_fp)) {
+                $line = fgets($src_fp);
+                if(ereg("@version", $line)) {
+                    $arrLine = split(" ", $line);
+                    $version = $arrLine[5];
+                }
+            }
+            fclose($src_fp);
+        }
+    }
+    return $version;
 }
 
 // 指定したURLに対してPOSTでデータを送信する
 function sfSendPostData($url, $arrData, $arrOkCode = array()){
-	require_once(DATA_PATH . "module/Request.php");
-	
-	// 送信インスタンス生成
-	$req = new HTTP_Request($url);
-	
-	$req->addHeader('User-Agent', 'DoCoMo/2.0　P2101V(c100)');
-	$req->setMethod(HTTP_REQUEST_METHOD_POST);
-	
-	// POSTデータ送信
-	$req->addPostDataArray($arrData);
-	
-	// エラーが無ければ、応答情報を取得する
-	if (!PEAR::isError($req->sendRequest())) {
-		
-		// レスポンスコードがエラー判定なら、空を返す
-		$res_code = $req->getResponseCode();
-		
-		if(!in_array($res_code, $arrOkCode)){
-			$response = "";
-		}else{
-			$response = $req->getResponseBody();
-		}
-		
-	} else {
-		$response = "";
-	}
-	
-	// POSTデータクリア
-	$req->clearPostData();	
-	
-	return $response;
+    require_once(DATA_PATH . "module/Request.php");
+
+    // 送信インスタンス生成
+    $req = new HTTP_Request($url);
+
+    $req->addHeader('User-Agent', 'DoCoMo/2.0　P2101V(c100)');
+    $req->setMethod(HTTP_REQUEST_METHOD_POST);
+
+    // POSTデータ送信
+    $req->addPostDataArray($arrData);
+
+    // エラーが無ければ、応答情報を取得する
+    if (!PEAR::isError($req->sendRequest())) {
+
+        // レスポンスコードがエラー判定なら、空を返す
+        $res_code = $req->getResponseCode();
+
+        if(!in_array($res_code, $arrOkCode)){
+            $response = "";
+        }else{
+            $response = $req->getResponseBody();
+        }
+
+    } else {
+        $response = "";
+    }
+
+    // POSTデータクリア
+    $req->clearPostData();
+
+    return $response;
+}
+
+/**
+ * 現在の URI を取得する.
+ *
+ * <p>
+ * $_SERVER["SERVER_PORT"] が 443 の場合は, スキーマに https:// を使用.
+ * それ以外は http:// を使用する.
+ * <strong>URI 末尾の / は削除されます.</strong>
+ * </p>
+ * @param boolean $hasFileName ファイル名を含める場合 true
+ * @return string 現在の URI
+ */
+function sfGetCurrentUri($hasFileName = false) {
+    $host = $_SERVER["HTTP_HOST"];
+    $path = rtrim(dirname($_SERVER["SCRIPT_NAME"]), "/\\");
+
+    if ($hasFileName === true) {
+        return sfGetCurrentSchema() . $host . $_SERVER["SCRIPT_NAME"];
+    } else {
+        return sfGetCurrentSchema() . $host . $path;
+    }
+}
+
+/**
+ * 現在の スキーマ名を返す.
+ *
+ * <p>
+ * $_SERVER["SERVER_PORT"] が 443 の場合は, https:// を返す.
+ * それ以外は http:// を返す.
+ * </p>
+ * @return string http:// または https:// の string.
+ */
+function sfGetCurrentSchema() {
+
+    if ($_SERVER["SERVER_PORT"] == 443) {
+        return "https://";
+    } else {
+        return "http://";
+    }
 }
 
 /* デバッグ用 ------------------------------------------------------------------------------------------------*/
 function sfPrintR($obj) {
-	print("<div style='font-size: 12px;color: #00FF00;'>\n");
-	print("<strong>**デバッグ中**</strong><br />\n");
-	print("<pre>\n");
-	print_r($obj);
-	print("</pre>\n");
-	print("<strong>**デバッグ中**</strong></div>\n");
+    print("<div style='font-size: 12px;color: #00FF00;'>\n");
+    print("<strong>**デバッグ中**</strong><br />\n");
+    print("<pre>\n");
+    print_r($obj);
+    print("</pre>\n");
+    print("<strong>**デバッグ中**</strong></div>\n");
 }
 
Index: branches/comu-utf8/html/mypage/login.php
===================================================================
--- branches/comu-utf8/html/mypage/login.php	(revision 15099)
+++ branches/comu-utf8/html/mypage/login.php	(revision 16016)
@@ -33,5 +33,5 @@
 // ログイン判定
 if($objCustomer->isLoginSuccess()) {
-	header("location: ./index.php");
+	header("location: " . sfGetCurrentUri() . "/index.php");
 } else {
 	// クッキー判定
Index: branches/comu-utf8/html/mypage/refusal.php
===================================================================
--- branches/comu-utf8/html/mypage/refusal.php	(revision 15099)
+++ branches/comu-utf8/html/mypage/refusal.php	(revision 16016)
@@ -60,5 +60,5 @@
 	$objCustomer->EndSession();
 	//完了ページへ
-	header("Location: ./refusal_complete.php");
+	header("Location: " . sfGetCurrentUri() . "/refusal_complete.php");
 	exit;
 }
Index: branches/comu-utf8/html/mypage/change.php
===================================================================
--- branches/comu-utf8/html/mypage/change.php	(revision 15099)
+++ branches/comu-utf8/html/mypage/change.php	(revision 16016)
@@ -159,5 +159,5 @@
 			$objCustomer->updateSession();
 			//完了ページへ
-			header("Location: ./change_complete.php");
+			header("Location: " . sfGetCurrentUri() . "/change_complete.php");
 			exit;
 		} else {
Index: branches/comu-utf8/html/mypage/login_check.php
===================================================================
--- branches/comu-utf8/html/mypage/login_check.php	(revision 15099)
+++ branches/comu-utf8/html/mypage/login_check.php	(revision 16016)
@@ -31,5 +31,5 @@
 	if ($count == 0){
 		if($objCustomer->getCustomerDataFromEmailPass($arrForm['mypage_login_pass'], $arrForm['mypage_login_email'])) {
-			header("Location: ./index.php");
+			header("Location: " . sfGetCurrentUri() . "/index.php");
 			exit;
 		} else {
Index: branches/comu-utf8/html/admin/design/index.php
===================================================================
--- branches/comu-utf8/html/admin/design/index.php	(revision 15099)
+++ branches/comu-utf8/html/admin/design/index.php	(revision 16016)
@@ -65,10 +65,10 @@
 // 新規ブロック作成
 if ($_POST['mode'] == 'new_bloc') {
-	header("location: ./bloc.php");
+	header("location: " . sfGetCurrentUri() . "/bloc.php");
 }
 
 // 新規ページ作成
 if ($_POST['mode'] == 'new_page') {
-	header("location: ./main_edit.php");
+	header("location: " . sfGetCurrentUri() . "/main_edit.php");
 }
 
@@ -154,5 +154,5 @@
 		header("Location: ". URL_DIR . "preview/index.php");
 	}else{
-		header("Location: ./index.php?page_id=$page_id&msg=on");
+		header("Location: " . sfGetCurrentUri() . "/index.php?page_id=$page_id&msg=on");
 	}
 }
Index: branches/comu-utf8/html/admin/design/main_edit.php
===================================================================
--- branches/comu-utf8/html/admin/design/main_edit.php	(revision 15099)
+++ branches/comu-utf8/html/admin/design/main_edit.php	(revision 16016)
@@ -168,5 +168,5 @@
 		}
 
-		header("location: ./main_edit.php?page_id=$page_id&msg=on");
+		header("location: " . sfGetCurrentUri() . "/main_edit.php?page_id=$page_id&msg=on");
 	}else{
 		// エラーがあれば入力時のデータを表示する
Index: branches/comu-utf8/html/admin/system/input.php
===================================================================
--- branches/comu-utf8/html/admin/system/input.php	(revision 15099)
+++ branches/comu-utf8/html/admin/system/input.php	(revision 16016)
@@ -72,5 +72,5 @@
 			fnInsertMember();
 			// リロードによる二重登録対策のため、同じページに飛ばす。
-			header("Location: ". $_SERVER['PHP_SELF'] . "?mode=reload");	
+			header("Location: " . sfGetCurrentUri(true) . "?mode=reload");	
 			exit;
 		}
Index: branches/comu-utf8/html/admin/contents/csv_sql.php
===================================================================
--- branches/comu-utf8/html/admin/contents/csv_sql.php	(revision 15099)
+++ branches/comu-utf8/html/admin/contents/csv_sql.php	(revision 16016)
@@ -81,5 +81,5 @@
 	// 新規作成
 	case "new_page":
-		header("location: ./csv_sql.php");
+		header("location: " . sfGetCurrentUri() . "/csv_sql.php");
 		break;
 		
@@ -87,5 +87,5 @@
 	case "delete":
 		lfDelData($sql_id);
-		header("location: ./csv_sql.php");
+		header("location: " . sfGetCurrentUri() . "/csv_sql.php");
 		break;
 		
Index: branches/comu-utf8/html/contact/index.php
===================================================================
--- branches/comu-utf8/html/contact/index.php	(revision 15099)
+++ branches/comu-utf8/html/contact/index.php	(revision 16016)
@@ -92,5 +92,5 @@
 		lfSendMail($CONF, $objPage);
 		//完了ページへ移動する
-		header("location: ./complete.php");
+		header("location: " . sfGetCurrentUri() . "/complete.php");
 		exit;
 	} else {
Index: branches/comu-utf8/html/regist/index.php
===================================================================
--- branches/comu-utf8/html/regist/index.php	(revision 15099)
+++ branches/comu-utf8/html/regist/index.php	(revision 16016)
@@ -53,5 +53,5 @@
 		$email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
 		$objCustomer->setLogin($email);
-		header("Location: ./complete.php$etc_val");
+		header("Location: " . sfGetCurrentUri() . "/complete.php$etc_val");
 		exit;
 	}
Index: branches/comu-utf8/html/entry/index.php
===================================================================
--- branches/comu-utf8/html/entry/index.php	(revision 15099)
+++ branches/comu-utf8/html/entry/index.php	(revision 16016)
@@ -164,5 +164,5 @@
 
 			// 完了ページに移動させる。
-			header("Location: ./complete.php");
+			header("Location: " . sfGetCurrentUri() . "/complete.php");
 			exit;
 		}
Index: branches/comu-utf8/html/install/user_data/include/campaign/default/src/entry.php
===================================================================
--- branches/comu-utf8/html/install/user_data/include/campaign/default/src/entry.php	(revision 15099)
+++ branches/comu-utf8/html/install/user_data/include/campaign/default/src/entry.php	(revision 16016)
@@ -157,5 +157,5 @@
 			
 			// 完了ページに移動させる。
-			header("Location: ./complete.php");
+			header("Location: " . sfGetCurrentUri() . "/complete.php");
 			exit;
 		}
Index: branches/comu-utf8/html/mobile/mypage/index.php
===================================================================
--- branches/comu-utf8/html/mobile/mypage/index.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/mypage/index.php	(revision 16016)
@@ -63,5 +63,5 @@
 			// 携帯のメールアドレスが登録されていない場合
 			if (!$objCustomer->hasValue('email_mobile')) {
-				header('Location: ' . gfAddSessionId('../entry/email_mobile.php'));
+				header('Location: ' . gfAddSessionId(sfGetCurrentUri() . "/../entry/email_mobile.php"));
 				exit;
 			}
Index: branches/comu-utf8/html/mobile/mypage/refusal.php
===================================================================
--- branches/comu-utf8/html/mobile/mypage/refusal.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/mypage/refusal.php	(revision 16016)
@@ -39,5 +39,5 @@
 
 if (isset($_POST['no'])) {
-	header("Location: " . gfAddSessionId("index.php"));
+	header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/index.php"));
 	exit;
 } elseif (isset($_POST['complete'])){
@@ -49,5 +49,5 @@
 	$objCustomer->EndSession();
 	//完了ページへ
-	header("Location: " . gfAddSessionId("refusal_complete.php"));
+	header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/refusal_complete.php"));
 	exit;
 }
Index: branches/comu-utf8/html/mobile/mypage/change.php
===================================================================
--- branches/comu-utf8/html/mobile/mypage/change.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/mypage/change.php	(revision 16016)
@@ -205,5 +205,5 @@
 				$objCustomer->updateSession();
 				//完了ページへ
-				header("Location: " . gfAddSessionId("change_complete.php"));
+				header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/change_complete.php"));
 				exit;
 			} else {
Index: branches/comu-utf8/html/mobile/shopping/index.php
===================================================================
--- branches/comu-utf8/html/mobile/shopping/index.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/shopping/index.php	(revision 16016)
@@ -52,5 +52,5 @@
 if($objCustomer->isLoginSuccess()) {
 	// すでにログインされている場合は、お届け先設定画面に転送
-	header("Location: " . gfAddSessionId('deliv.php'));
+	header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/deliv.php"));
 	exit;
 }
Index: branches/comu-utf8/html/mobile/shopping/deliv_addr.php
===================================================================
--- branches/comu-utf8/html/mobile/shopping/deliv_addr.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/shopping/deliv_addr.php	(revision 16016)
@@ -67,5 +67,5 @@
 		break;
 	default:
-		header("Location: " . gfAddSessionId('deliv.php'));
+		header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/deliv.php"));
 		exit;
 	}
Index: branches/comu-utf8/html/mobile/magazine/confirm.php
===================================================================
--- branches/comu-utf8/html/mobile/magazine/confirm.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/magazine/confirm.php	(revision 16016)
@@ -88,5 +88,5 @@
 
 	// 完了ページに移動させる。
-	header("Location:" . gfAddSessionId("./complete.php"));
+	header("Location:" . gfAddSessionId(sfGetCurrentUri() . "/complete.php"));
 	exit;
 } else {
Index: branches/comu-utf8/html/mobile/regist/index.php
===================================================================
--- branches/comu-utf8/html/mobile/regist/index.php	(revision 15099)
+++ branches/comu-utf8/html/mobile/regist/index.php	(revision 16016)
@@ -48,5 +48,5 @@
 		$email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
 		$objCustomer->setLogin($email);
-		header("Location: " . gfAddSessionId("./complete.php"));
+		header("Location: " . gfAddSessionId(sfGetCurrentUri() . "/complete.php"));
 		exit;
 	}
Index: branches/comu-utf8/html/shopping/index.php
===================================================================
--- branches/comu-utf8/html/shopping/index.php	(revision 15099)
+++ branches/comu-utf8/html/shopping/index.php	(revision 16016)
@@ -51,5 +51,5 @@
 if($objCustomer->isLoginSuccess()) {
 	// すでにログインされている場合は、お届け先設定画面に転送
-	header("Location: ./deliv.php");
+	header("Location: " . sfGetCurrentUri() . "/deliv.php");
 	exit;
 }
Index: branches/comu-utf8/html/sitemap.php
===================================================================
--- branches/comu-utf8/html/sitemap.php	(revision 16016)
+++ branches/comu-utf8/html/sitemap.php	(revision 16016)
@@ -0,0 +1,299 @@
+<?php
+/**
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ */
+
+/**
+ * Sitemapプロトコル ファイル生成モジュール.
+ * PHP versions 4 and 5
+ *
+ * <pre>
+ * このモジュールは Sitemapプロトコルに対応した XMLファイルを出力する.
+ * EC-CUBE インストールディレクトリの htmlディレクトリへ配置することにより動作する.
+ *
+ * このモジュールにより, 以下のページのサイトマップが生成される.
+ * 1. $staticURL で指定したページ
+ * 2. 管理画面のデザイン管理から生成したページ
+ * 3. 公開されているすべての商品一覧ページ
+ * 4. 公開されているすべての商品詳細ページ
+ * 5. html/mobile 以下の上記ページ
+ *
+ * このモジュールを設置後, 各検索エンジンにサイトマップを登録することにより, 検索エンジンの
+ * インデックス化が促進される.
+ * </pre>
+ * @see https://www.google.com/webmasters/tools/siteoverview?hl=ja
+ * @see https://siteexplorer.search.yahoo.com/mysites
+ *
+ * @author Kentaro Ohkouchi
+ * @version $Id$
+ */
+require_once("require.php");
+// --------------------------------------------------------------------- 初期設定
+// :TODO: filemtime 関数を使えば、静的なページの更新時間も取得するようにできそう
+//
+// 動的に生成されないページを配列で指定
+$staticURL = array(SITE_URL, MOBILE_SITE_URL, SITE_URL . "rss/index.php");
+// :TODO: 各ページの changefreq や priority を指定できるようにする
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// }}}
+// {{{ View Logic
+
+/**
+ * Sitemap の <url /> を生成する.
+ *
+ * @param string $loc ページの URL ※必須
+ * @param string $lastmod ファイルの最終更新日 YYYY-MM-DD or  W3C Datetime 形式
+ * @param string $changefreq ページの更新頻度
+ * @param double $priority URL の優先度
+ * @return Sitemap 形式の <url />
+ * @see https://www.google.com/webmasters/tools/docs/ja/protocol.html#xmlTagDefinitions
+ */
+function createSitemap($loc, $lastmod = "", $changefreq = "", $priority = "") {
+    printf("\t<url>\n");
+    printf("\t\t<loc>%s</loc>\n", htmlentities($loc, ENT_QUOTES, "UTF-8"));
+    if (!empty($lastmod)) {
+        printf("\t\t<lastmod>%s</lastmod>\n", $lastmod);
+    }
+    if (!empty($changefreq)) {
+        printf("\t\t<changefreq>%s</changefreq>\n", $changefreq);
+    }
+    if(!empty($priority)) {
+        printf("\t\t<priority>%01.1f</priority>\n", $priority);
+    }
+    printf("\t</url>\n");
+}
+
+$objQuery = new SC_Query();
+
+//キャッシュしない(念のため)
+header("Paragrama: no-cache");
+
+//XMLテキスト
+header("Content-type: application/xml; charset=utf-8");
+
+// 必ず UTF-8 として出力
+mb_http_output("UTF-8");
+ob_start('mb_output_handler');
+
+print("<?xml version='1.0' encoding='UTF-8'?>\n");
+print("<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>\n");
+
+// ----------------------------------------------------------------------------
+// }}}
+// {{{ Controller Logic
+
+// 静的なページを処理
+foreach($staticURL as $url) {
+    createSitemap($url, '', 'daily', 1.0);
+}
+// ページのデータを取得
+$objPageData = new LC_PageLayout;
+
+// TOPページを処理
+$topPage = getTopPage($objPageData->arrPageList);
+createSitemap($topPage[0]['url'], date2W3CDatetime($topPage[0]['update_date']),
+                'daily', 1.0);
+
+// 編集可能ページを処理
+$editablePages = getEditablePage($objPageData->arrPageList);
+foreach($editablePages as $editablePage) {
+    createSitemap($editablePage['url'], date2W3CDatetime($editablePage['update_date']));
+}
+
+// 商品一覧ページを処理
+$products = getAllProducts();
+foreach($products as $product) {
+    createSitemap($product['url'], '', 'daily');
+}
+$mobileProducts = getAllProducts(true);
+foreach($mobileProducts as $mobileProduct) {
+    createSitemap($mobileProduct['url'], '', 'daily');
+}
+
+// 商品詳細ページを処理
+$details = getAllDetail();
+foreach($details as $detail) {
+    createSitemap($detail['url'], date2W3CDatetime($detail['update_date']));
+}
+$mobileDetails = getAllDetail(true);
+foreach($mobileDetails as $mobileDetail) {
+    createSitemap($mobileDetail['url'], date2W3CDatetime($mobileDetail['update_date']));
+}
+
+print("</urlset>\n");
+
+// ----------------------------------------------------------------------------
+// }}}
+// {{{ Model Logic
+
+/**
+ * TOPページの情報を取得
+ *
+ * @param array $pageData すべてのページ情報の配列
+ * @return TOPページの情報
+ */
+function getTopPage($pageData) {
+    $arrRet = array();
+    foreach($pageData as $page) {
+        if ($page['page_id'] == "1") {
+            $page['url'] = SITE_URL . $page['url'];
+            $arrRet[0] = $page;
+            return $arrRet;
+        }
+    }
+}
+
+/**
+ * すべての編集可能ページの情報を取得する.
+ *
+ * @param array $pageData すべてのページ情報の配列
+ * @return 編集可能ページ
+ */
+function getEditablePage($pageData) {
+    $arrRet = array();
+    $i = 0;
+    foreach($pageData as $page) {
+        if ($page['page_id'] > 4) {
+            $arrRet[$i] = $page;
+            $i++;
+        }
+    }
+    return $arrRet;
+}
+
+/**
+ * date形式の文字列を W3C Datetime 形式に変換して出力する.
+ *
+ * @param date $date 変換する日付
+ */
+function date2W3CDatetime($date) {
+    $arr = array();
+    // 正規表現で文字列を抽出
+    ereg("^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})",
+        $date, $arr);
+    // :TODO: time zone も取得するべき...
+    return sprintf("%04d-%02d-%02dT%02d:%02d:%02d+09:00",
+            $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6]);
+}
+
+// ----------------------------------------------------------------------------
+// }}}
+// {{{ DB Access Objects
+
+/**
+ * ページデータを扱うクラス.
+ */
+class LC_PageLayout {
+
+    var $arrPageData;		// ページデータ格納用
+    var $arrPageList;		// ページデータ格納用
+
+    /**
+     * コンストラクタ.
+     */
+    function LC_PageLayout() {
+        $this->arrPageList = $this->getPageData();
+    }
+
+    /**
+     * ブロック情報を取得する.
+     *
+     * @param string $where WHERE句
+     * @param array  $arrVal WHERE句の値を格納した配列
+     * @return ブロック情報
+     */
+    function getPageData($where = '', $arrVal = ''){
+        $objDBConn = new SC_DbConn;		// DB操作オブジェクト
+        $sql = "";						// データ取得SQL生成用
+        $arrRet = array();				// データ取得用
+
+        // SQL生成(url と update_date 以外は不要？)
+        $sql .= " SELECT";
+        $sql .= " page_id";				// ページID
+        $sql .= " ,page_name";			// 名称
+        $sql .= " ,url";				// URL
+        $sql .= " ,php_dir";			// php保存先ディレクトリ
+        $sql .= " ,tpl_dir";			// tpl保存先ディdレクトリ
+        $sql .= " ,filename";			// ファイル名称
+        $sql .= " ,header_chk ";		// ヘッダー使用FLG
+        $sql .= " ,footer_chk ";		// フッター使用FLG
+        $sql .= " ,author";				// authorタグ
+        $sql .= " ,description";		// descriptionタグ
+        $sql .= " ,keyword";			// keywordタグ
+        $sql .= " ,update_url";			// 更新URL
+        $sql .= " ,create_date";		// データ作成日
+        $sql .= " ,update_date";		// データ更新日
+        $sql .= " FROM ";
+        $sql .= "     dtb_pagelayout";
+
+        // where句の指定があれば追加
+        if ($where != '') {
+            $sql .= " WHERE " . $where;
+        }
+
+        $sql .= " ORDER BY 	page_id";
+
+        $arrRet = $objDBConn->getAll($sql, $arrVal);
+
+        $this->arrPageData = $arrRet;
+
+        return $arrRet;
+    }
+}
+
+/**
+ * すべての商品一覧ページを取得する.
+ *
+ * @param boolean $isMobile モバイルページを取得する場合 true
+ * @return 検索エンジンからアクセス可能な商品一覧ページの情報
+ */
+function getAllProducts($isMobile = false) {
+    $conn = new SC_DBConn();
+    $sql = "SELECT category_id FROM dtb_category WHERE del_flg = 0";
+    $result = $conn->getAll($sql);
+
+    $mobile = "";
+    if ($isMobile) {
+        $mobile = "mobile/";
+    }
+
+    $arrRet = array();
+    for ($i = 0; $i < count($result); $i++) {
+        // :TODO: カテゴリの最終更新日を取得できるようにする
+        $page = array("url" => SITE_URL . sprintf("%sproducts/list.php?category_id=%d", $mobile, $result[$i]['category_id']));
+        $arrRet[$i] = $page;
+    }
+    return $arrRet;
+}
+
+/**
+ * すべての商品詳細ページを取得する.
+ *
+ * @param boolean $isMobile モバイルページを取得する場合 true
+ * @return 検索エンジンからアクセス可能な商品詳細ページの情報
+ */
+function getAllDetail($isMobile = false) {
+    $conn = new SC_DBConn();
+    $sql = "SELECT product_id, update_date FROM dtb_products WHERE del_flg = 0 AND status = 1";
+    $result = $conn->getAll($sql);
+
+    $mobile = "";
+    if ($isMobile) {
+        $mobile = "mobile/";
+    }
+
+    $arrRet = array();
+    for ($i = 0; $i < count($result); $i++) {
+        $page = array("url" => SITE_URL. sprintf("%sproducts/detail.php?product_id=%d", $mobile, $result[$i]['product_id']),
+                        "update_date" => $result[$i]['update_date']);
+        $arrRet[$i] = $page;
+    }
+    return $arrRet;
+}
+?>
Index: branches/comu-utf8/html/products/review.php
===================================================================
--- branches/comu-utf8/html/products/review.php	(revision 15099)
+++ branches/comu-utf8/html/products/review.php	(revision 16016)
@@ -85,5 +85,5 @@
 			lfRegistRecommendData($arrForm, $arrRegistColumn);
 			//レビュー書き込み完了ページへ
-			header("Location: ./review_complete.php");
+			header("Location: " . sfGetCurrentUri() . "/review_complete.php");
 			exit;
 		}
