Index: branches/eccube-donation/html/frontparts/bloc/thank_you.php
===================================================================
--- branches/eccube-donation/html/frontparts/bloc/thank_you.php	(revision 20674)
+++ branches/eccube-donation/html/frontparts/bloc/thank_you.php	(revision 20674)
@@ -0,0 +1,113 @@
+<style type="text/css">
+div#thankyou{border: none;background: #E0ECEF;text-align: center;overflow: auto;margin:12px auto;}
+div#thankyou div#innner{margin:8px;}
+div#thankyou div#innner h2{margin:12px;font-size:18px;text-shadow: -1px -1px 0px #FFF;font-weight: bold;}
+div#thankyou div#innner p{margin:2px 4px;font-size:90%;}
+div#thankyou div#innner dl{margin:12px auto;padding:0;line-height: 1.4em;width:14em;}
+div#thankyou div#innner dl dt{width: 3em;font-weight: bold;color:#666;}
+div#thankyou div#innner dl dd{margin-left: 4em; margin-top:-1.4em;font-weight: bold;}
+</style>
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * 
+ * 2011-03-17 Tao Sasaki (tao@xross-cube.com)
+ *
+ */
+
+// {{{ requires
+if( !defined("CLASS_PATH") ){
+    require_once("../../require.php");
+}
+require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php");
+
+// }}}
+// {{{ generate page
+class LC_Page_FrontParts_Bloc_ThankYou extends LC_Page_FrontParts_Bloc {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_login = false;
+        $this->tpl_disable_logout = false;
+        $this->tpl_error = "";
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        if(!file_exists(DATA_PATH.'downloads/donation_summary.csv')){
+            $objQuery = new SC_Query;
+            $ret = $objQuery->getOne("SELECT php_path FROM dtb_bloc WHERE php_path = 'frontparts/bloc/thank_you.php'");
+            if(!$ret){
+                $objQuery->query("INSERT INTO dtb_bloc (bloc_name,tpl_path,filename,create_date,update_date,php_path,del_flg)
+                 VALUES('東北地方太平洋沖地震ポイント寄付状況','','thank_you',NOW(),NOW(),'frontparts/bloc/thank_you.php',0)");
+                 if($fp = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){
+                    fwrite($fp,'0,0,0');
+                    fclose($fp);
+                 }
+            }
+        }
+        
+        //現在の寄付データ取得
+        $summary = file_get_contents(DATA_PATH.'downloads/donation_summary.csv');
+        $this->summary = explode(",",$summary);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+}
+
+$objPage = new LC_Page_FrontParts_Bloc_ThankYou();
+register_shutdown_function(array($objPage, "destroy"));
+$objPage->init();
+$objPage->process();
+
+?>
+<div id="thankyou">
+    <div id="innner">
+        <h2>現在のポイント寄付状況</h2>
+        <p>ご協力ありがとうございます。<br />現在、皆様からお寄せ頂いた東北地方太平洋沖地震へのポイント寄付は以下の通りです。</p>
+        <dl>
+            <dt>件数：</dt>
+            <dd><?php echo number_format($objPage->summary[0]); ?>件</dd>
+            <dt>合計：</dt>
+            <dd><?php echo number_format($objPage->summary[1]); ?>pt</dd>
+        </dl>
+    </div>
+</div>
+
Index: branches/eccube-donation/html/frontparts/bloc/send_point.php
===================================================================
--- branches/eccube-donation/html/frontparts/bloc/send_point.php	(revision 20622)
+++ branches/eccube-donation/html/frontparts/bloc/send_point.php	(revision 20674)
@@ -59,4 +59,5 @@
         $this->tpl_disable_logout = false;
         $this->tpl_error = "";
+        $this->complete = false;
     }
 
@@ -73,6 +74,12 @@
                 $objQuery->query("INSERT INTO dtb_bloc (bloc_name,tpl_path,filename,create_date,update_date,php_path,del_flg)
                  VALUES('東北地方太平洋沖地震ポイント寄付','','send_point',NOW(),NOW(),'frontparts/bloc/send_point.php',0)");
+                 if(!file_exists(DATA_PATH.'downloads/donation_summary.csv') AND $fp = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){
+                    fwrite($fp,'0,0,0');
+                    fclose($fp);
+                 }
             }
         }
+        
+        
 
         $objCustomer = new SC_Customer();
@@ -80,7 +87,19 @@
         // クッキー管理クラス
         $objCookie = new SC_Cookie(COOKIE_EXPIRE);
-
+        
+        $limit = 0;
+        if($fp2 = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){
+            flock($fp2,LOCK_EX);
+            $summary = file_get_contents(DATA_PATH.'downloads/donation_summary.csv');
+            $summary = explode(",",$summary);
+            $total = intval($summary[1]);
+            $limit = intval($summary[2]);
+            if($limit != 0 and $total == $limit){
+                $this->complete = true;
+            }
+        }
+        
         // ログイン判定
-        if($objCustomer->isLoginSuccess()) {
+        if($objCustomer->isLoginSuccess() and $this->complete == false ) {
             $this->tpl_user_point = $objCustomer->getValue('point');
             if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0;
@@ -91,13 +110,33 @@
                     $this->tpl_error = "1以上のポイントを保有ポイント内で半角数字で入力してください。";
                 }else{
-                    $objQuery = new SC_Query;
-                    $sqlval = array('point' => ($this->tpl_user_point - $point));
-                    $where = 'customer_id = ? AND del_flg = 0 AND status = 2';
-                    $rs = $objQuery->update('dtb_customer', $sqlval, $where, array($objCustomer->getValue('customer_id')));
-                    if($rs){
-                        $fp = fopen(DATA_PATH.'downloads/donation.csv','a+');
-                        fwrite($fp,date("Y-m-d G:i:s").",".$objCustomer->getValue('customer_id').",".$point."\n");
-                        $objCustomer->setValue("point", ($this->tpl_user_point - $point));
-                        $this->tpl_error = "ご協力ありがとうございます。".$point."ptを承りました。<br />寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。"; 
+                    if(isset($summary) and $this->complete == false){
+                        if(($limit - $total) < $point){
+                            $point = $limit - $total;
+                            $this->complete = true;
+                        }
+                    }
+                    if($fp = fopen(DATA_PATH.'downloads/donation.csv','a+') and $point > 0){
+                        $objQuery = new SC_Query;
+                        $sqlval = array('point' => ($this->tpl_user_point - $point));
+                        $where = 'customer_id = ? AND del_flg = 0 AND status = 2';
+                        $rs = $objQuery->update('dtb_customer', $sqlval, $where, array($objCustomer->getValue('customer_id')));
+                        if($rs){
+                            flock($fp,LOCK_EX);
+                            fwrite($fp,date("Y-m-d G:i:s").",".$objCustomer->getValue('customer_id').",".$point."\n");
+                            $objCustomer->setValue("point", ($this->tpl_user_point - $point));
+                            $this->tpl_error = "ご協力ありがとうございます。".$point."ptを承りました。<br />寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。";
+                            //サマリー更新
+                            if(isset($summary)){
+                                $num = intval($summary[0]) + 1;
+                                $total = $total+$point;
+                                ftruncate($fp2,0);
+                                fwrite($fp2,$num.','.$total.','.$limit);
+                            }else{
+                                $this->tpl_error = "正常に寄付ポイントを集計出来ませんでした。サイト管理者へご連絡願います。";
+                            }
+                        }else{
+                            $this->tpl_error = "正常に寄付ポイントを記録出来ませんでした。もう一度お願いします。";
+                        }
+                        fclose($fp);
                     } else {
                         $this->tpl_error = "システムエラー";  
@@ -111,16 +150,10 @@
             $this->tpl_name1 = $objCustomer->getValue('name01');
             $this->tpl_name2 = $objCustomer->getValue('name02');
-        } else {
-            // クッキー判定
-            $this->tpl_login_email = $objCookie->getCookie('login_email');
-            if($this->tpl_login_email != "") {
-                $this->tpl_login_memory = "1";
-            }
-
-            // POSTされてきたIDがある場合は優先する。
-            if($_POST['login_email'] != "") {
-                $this->tpl_login_email = $_POST['login_email'];
-            }
-        }
+        }
+        
+        if($fp2){
+            fclose($fp2);
+        }
+        
         $this->transactionid = $this->getToken();
     }
@@ -145,6 +178,12 @@
 <div id="sendPoint">
 <div id="innner">
+<?php if($objPage->complete === true){ ?>
+<h2>ご協力ありがとうございました</h2>
+<p>ポイントの東北地方太平洋沖地震の復旧活動への寄付ですが、皆様のご協力により目標ポイント数を達成する事が出来ました。</p>
+<p>寄付して頂いたポイント分の金額を、当店がお客様に代わり東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。<br />多大なご協力ありがとうございました。<br /></p>
+<p>現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p>
+<?php }else{ ?>
 <h2>東北地方太平洋沖地震へのポイント寄付のお願い</h2>
-<?php if($objPage->tpl_login){?>
+    <?php if($objPage->tpl_login){?>
 <p>現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付出来ます。</p>
 <p>下記フォームに寄付するポイント数を入力の上、「寄付」ボタンをクリックしてください。</p>
@@ -161,10 +200,12 @@
     </form>
 </div>
-<?php }else{ ?>
+<p>直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p>
+    <?php }else{ ?>
 <p>会員のお客様は、現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付できます。ログインしてご協力をお願いします。</p>
 <p>- <a href="<?php echo URL_MYPAGE_TOP ?>">ログイン</a> -</p>
 <p>運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。</p>
+<p>直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p>
+    <?php } ?>
 <?php } ?>
 </div>
 </div>
-
Index: branches/eccube-donation/html/frontparts/bloc/index.php
===================================================================
--- branches/eccube-donation/html/frontparts/bloc/index.php	(revision 20639)
+++ branches/eccube-donation/html/frontparts/bloc/index.php	(revision 20674)
@@ -36,4 +36,6 @@
 define('DONATION_VERSION', '0.0.1');
 
+
+
 $objQuery = new SC_Query();
 // 全顧客取得
@@ -63,4 +65,55 @@
     $correct_point += $arrDn[2];
 }
+$limit = 0;
+if($fp = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){
+    flock($fp2,LOCK_EX);
+    $summary = file_get_contents(DATA_PATH.'downloads/donation_summary.csv');
+    $summary = explode(",",$summary);
+    $num   = intval($summary[0]);
+    $total = intval($summary[1]);
+    $limit = intval($summary[2]);
+    
+    if(isset($_POST["limit"]) and isValidToken()){
+        $limit = mb_convert_kana(trim($_POST["limit"]),"n");
+        $limit = intval($limit);
+        ftruncate($fp,0);
+        fwrite($fp,$num.','.$total.','.$limit);
+    }
+    fclose($fp);
+}
+$token = getToken();
+
+function getToken() {
+    if (empty($_SESSION[TRANSACTION_ID_NAME])) {
+        $_SESSION[TRANSACTION_ID_NAME] = sha1(uniqid(rand(), true));
+    }
+    return $_SESSION[TRANSACTION_ID_NAME];
+}
+
+
+function isValidToken() {
+
+    $checkToken = "";
+
+    // $_POST の値を優先する
+    if (isset($_POST[TRANSACTION_ID_NAME])) {
+
+        $checkToken = $_POST[TRANSACTION_ID_NAME];
+    } elseif (isset($_GET[TRANSACTION_ID_NAME])) {
+
+        $checkToken = $_GET[TRANSACTION_ID_NAME];
+    }
+
+    $ret = false;
+    // token の妥当性チェック
+    if ($checkToken === $_SESSION[TRANSACTION_ID_NAME]) {
+
+        $ret = true;
+    }
+
+    unset($_SESSION[TRANSACTION_ID_NAME]);
+    return $ret;
+}
+
 
 ?>
@@ -79,4 +132,6 @@
 <h1><?php echo DONATION_TITLE; ?></h1>
 <h2>現在のステータス</h2>
+<form method="post">
+<input type="hidden" name="<?php echo TRANSACTION_ID_NAME ;?>" value="<?php echo $token; ?>" />
 <table>
   <tr>
@@ -89,5 +144,9 @@
     <th>顧客の保持ポイント合計</th><td><?php printf('%d', $total_point); ?>pt</td>
   </tr>
+  <tr>
+    <th>寄付ポイント上限設定</th><td><input type="text" value="<?php echo $limit; ?>" name="limit" /><input type="submit" value="設定" /><br />「0」は無制限</td>
+  </tr>
 </table>
+</form>
 
 <p>集まった義援金総額を, 義援金として日本赤十字社などにお贈り下さい</p>
