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 @@
+
+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();
+
+?>
+
+
+
現在のポイント寄付状況
+
ご協力ありがとうございます。
現在、皆様からお寄せ頂いた東北地方太平洋沖地震へのポイント寄付は以下の通りです。
+
+ - 件数:
+ - summary[0]); ?>件
+ - 合計:
+ - summary[1]); ?>pt
+
+
+
+
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を承りました。
寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。";
+ 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を承りました。
寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。";
+ //サマリー更新
+ 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 @@
+complete === true){ ?>
+
ご協力ありがとうございました
+
ポイントの東北地方太平洋沖地震の復旧活動への寄付ですが、皆様のご協力により目標ポイント数を達成する事が出来ました。
+
寄付して頂いたポイント分の金額を、当店がお客様に代わり東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。
多大なご協力ありがとうございました。
+
現金で赤十字に募金される場合はコチラをご参照ください。
+
東北地方太平洋沖地震へのポイント寄付のお願い
-tpl_login){?>
+ tpl_login){?>
現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付出来ます。
下記フォームに寄付するポイント数を入力の上、「寄付」ボタンをクリックしてください。
@@ -161,10 +200,12 @@
-
+
直接現金で赤十字に募金される場合はコチラをご参照ください。
+
会員のお客様は、現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付できます。ログインしてご協力をお願いします。
- ログイン -
運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。
+
直接現金で赤十字に募金される場合はコチラをご参照ください。
+
-
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 @@
現在のステータス
+
集まった義援金総額を, 義援金として日本赤十字社などにお贈り下さい