[20622] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | * |
---|
| 23 | * 2011-03-12 Tao Sasaki (tao@xross-cube.com) |
---|
| 24 | * |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | // {{{ requires |
---|
| 28 | if( !defined("CLASS_PATH") ){ |
---|
| 29 | require_once("../../require.php"); |
---|
| 30 | } |
---|
| 31 | require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php"); |
---|
| 32 | |
---|
| 33 | // }}} |
---|
| 34 | // {{{ generate page |
---|
| 35 | class LC_Page_FrontParts_Bloc_SendPoint extends LC_Page_FrontParts_Bloc { |
---|
| 36 | |
---|
| 37 | // }}} |
---|
| 38 | // {{{ functions |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * Page を初期化する. |
---|
| 42 | * |
---|
| 43 | * @return void |
---|
| 44 | */ |
---|
| 45 | function init() { |
---|
| 46 | parent::init(); |
---|
| 47 | $this->tpl_login = false; |
---|
| 48 | $this->tpl_disable_logout = false; |
---|
| 49 | $this->tpl_error = ""; |
---|
[20675] | 50 | $this->complete = false; |
---|
[20622] | 51 | } |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * Page のプロセス. |
---|
| 55 | * |
---|
| 56 | * @return void |
---|
| 57 | */ |
---|
| 58 | function process() { |
---|
[20675] | 59 | if(!file_exists(DATA_PATH.'downloads/donation.csv')){ |
---|
| 60 | $objQuery = new SC_Query; |
---|
| 61 | $ret = $objQuery->getOne("SELECT php_path FROM dtb_bloc WHERE php_path = 'frontparts/bloc/send_point.php'"); |
---|
| 62 | if(!$ret){ |
---|
| 63 | $objQuery->query("INSERT INTO dtb_bloc (bloc_name,tpl_path,filename,create_date,update_date,php_path,del_flg) |
---|
| 64 | VALUES('東北地方太平洋沖地震ポイント寄付','','send_point',NOW(),NOW(),'frontparts/bloc/send_point.php',0)"); |
---|
| 65 | if(!file_exists(DATA_PATH.'downloads/donation_summary.csv') AND $fp = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){ |
---|
| 66 | fwrite($fp,'0,0,0'); |
---|
| 67 | fclose($fp); |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
[20622] | 73 | |
---|
| 74 | $objCustomer = new SC_Customer(); |
---|
| 75 | $objCustomer->updateSession(); |
---|
| 76 | // クッキー管理クラス |
---|
| 77 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
[20675] | 78 | |
---|
| 79 | $limit = 0; |
---|
| 80 | if($fp2 = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){ |
---|
| 81 | flock($fp2,LOCK_EX); |
---|
| 82 | $summary = file_get_contents(DATA_PATH.'downloads/donation_summary.csv'); |
---|
| 83 | $summary = explode(",",$summary); |
---|
| 84 | $total = intval($summary[1]); |
---|
[20701] | 85 | if(intval($summary[2]) > 0){ |
---|
| 86 | $limit = intval($summary[2]); |
---|
| 87 | } |
---|
[20675] | 88 | if($limit != 0 and $total == $limit){ |
---|
| 89 | $this->complete = true; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
[20622] | 93 | // ログイン判定 |
---|
[20675] | 94 | if($objCustomer->isLoginSuccess() and $this->complete == false ) { |
---|
[20622] | 95 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
| 96 | if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0; |
---|
| 97 | if(isset($_POST["sendpoint"]) and $this->isValidToken()){ |
---|
| 98 | //ポイント寄付処理 |
---|
| 99 | $point = intval(mb_convert_kana($_POST["sendpoint"],"n")); |
---|
| 100 | if(!$point or $this->tpl_user_point < $point){ |
---|
| 101 | $this->tpl_error = "1以上のポイントを保有ポイント内で半角数字で入力してください。"; |
---|
| 102 | }else{ |
---|
[20701] | 103 | if($limit > 0 and $this->complete == false){ |
---|
[20675] | 104 | if(($limit - $total) < $point){ |
---|
| 105 | $point = $limit - $total; |
---|
| 106 | $this->complete = true; |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | if($fp = fopen(DATA_PATH.'downloads/donation.csv','a+') and $point > 0){ |
---|
| 110 | $objQuery = new SC_Query; |
---|
| 111 | $sqlval = array('point' => ($this->tpl_user_point - $point)); |
---|
| 112 | $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; |
---|
| 113 | $rs = $objQuery->update('dtb_customer', $sqlval, $where, array($objCustomer->getValue('customer_id'))); |
---|
| 114 | if($rs){ |
---|
| 115 | flock($fp,LOCK_EX); |
---|
| 116 | fwrite($fp,date("Y-m-d G:i:s").",".$objCustomer->getValue('customer_id').",".$point."\n"); |
---|
| 117 | $objCustomer->setValue("point", ($this->tpl_user_point - $point)); |
---|
| 118 | $this->tpl_error = "ご協力ありがとうございます。".$point."ptを承りました。<br />寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。"; |
---|
| 119 | //サマリー更新 |
---|
| 120 | if(isset($summary)){ |
---|
| 121 | $num = intval($summary[0]) + 1; |
---|
| 122 | $total = $total+$point; |
---|
| 123 | ftruncate($fp2,0); |
---|
[20700] | 124 | fseek($fp2,0); |
---|
[20675] | 125 | fwrite($fp2,$num.','.$total.','.$limit); |
---|
| 126 | }else{ |
---|
| 127 | $this->tpl_error = "正常に寄付ポイントを集計出来ませんでした。サイト管理者へご連絡願います。"; |
---|
| 128 | } |
---|
| 129 | }else{ |
---|
| 130 | $this->tpl_error = "正常に寄付ポイントを記録出来ませんでした。もう一度お願いします。"; |
---|
| 131 | } |
---|
| 132 | fclose($fp); |
---|
[20622] | 133 | } else { |
---|
| 134 | $this->tpl_error = "システムエラー"; |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | $this->tpl_login = true; |
---|
| 139 | $objCustomer->updateSession(); |
---|
| 140 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
| 141 | if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0; |
---|
| 142 | $this->tpl_name1 = $objCustomer->getValue('name01'); |
---|
| 143 | $this->tpl_name2 = $objCustomer->getValue('name02'); |
---|
| 144 | } |
---|
[20675] | 145 | |
---|
| 146 | if($fp2){ |
---|
| 147 | fclose($fp2); |
---|
| 148 | } |
---|
| 149 | |
---|
[20622] | 150 | $this->transactionid = $this->getToken(); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | /** |
---|
| 154 | * デストラクタ. |
---|
| 155 | * |
---|
| 156 | * @return void |
---|
| 157 | */ |
---|
| 158 | function destroy() { |
---|
| 159 | parent::destroy(); |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | $objPage = new LC_Page_FrontParts_Bloc_SendPoint(); |
---|
| 164 | register_shutdown_function(array($objPage, "destroy")); |
---|
| 165 | $objPage->init(); |
---|
| 166 | $objPage->process(); |
---|
| 167 | |
---|
| 168 | ?> |
---|
| 169 | <a name="sendPoint"></a> |
---|
| 170 | <div id="sendPoint" style="border: none;background: #FFF6CF;text-align: center;overflow: auto;"> |
---|
| 171 | <div id="innner" style="border: 3px solid red;margin:8px;"> |
---|
[20675] | 172 | <?php if($objPage->complete === true){ ?> |
---|
| 173 | <h2><font color="red" size="3">ご協力ありがとうございました</font></h2> |
---|
| 174 | <p><font size="-2" color="#333">ポイントの東北地方太平洋沖地震の復旧活動への寄付ですが、皆様のご協力により目標ポイント数を達成する事が出来ました。</font></p> |
---|
| 175 | <p><font size="-2" color="#333">寄付して頂いたポイント分の金額を、当店がお客様に代わり東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。<br />多大なご協力ありがとうございました。<br /></font></p> |
---|
| 176 | <p><font size="-2" color="#333">現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</font></p> |
---|
| 177 | <?php }else{ ?> |
---|
| 178 | <h2><font color="red" size="3">東北地方太平洋沖地震へのポイント寄付のお願い</font></h2> |
---|
| 179 | <?php if($objPage->tpl_login){?> |
---|
| 180 | <p><font size="-2" color="#333">現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付出来ます。</font></p> |
---|
| 181 | <p><font size="-2" color="#333">下記フォームに寄付するポイント数を入力の上、「寄付」ボタンをクリックしてください。</font></p> |
---|
| 182 | <p><font size="-2" color="#333">運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動に寄付させて頂きます。</font></p> |
---|
[20622] | 183 | <div id="sendForm"> |
---|
| 184 | <p><font color="#FF0000"><?php echo $objPage->tpl_error; ?></font></p> |
---|
| 185 | <form method="post" action="#sendPoint" name="sendPoint"> |
---|
| 186 | <input type="hidden" name="transactionid" value="<?php echo $objPage->transactionid ?>" /> |
---|
| 187 | <p><font size="-2" color="#333">現在お客様が保有しているポイント:<?php echo $objPage->tpl_user_point ?>pt</font></p> |
---|
| 188 | <p> |
---|
[20675] | 189 | <font size="-2" color="#333"><input type="text" maxlength="10" name="sendpoint" id="sendpointValue" value="" size="5" />ptを寄付<br /></font> |
---|
[20622] | 190 | <input type="submit" value="寄付" /> |
---|
| 191 | </p> |
---|
| 192 | </form> |
---|
| 193 | </div> |
---|
[20675] | 194 | <p><font size="-2" color="#333">直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</font></p> |
---|
| 195 | <?php }else{ ?> |
---|
| 196 | <p><font size="-2" color="#333">会員のお客様は、現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付できます。ログインしてご協力をお願いします。</font></p> |
---|
| 197 | <p><font size="3">- <a href="<?php echo URL_MYPAGE_TOP ?>">ログイン</a> -</font></p> |
---|
| 198 | <p><font size="-2" color="#333">運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。</font></p> |
---|
| 199 | <p><font size="-2" color="#333">直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</font></p> |
---|
| 200 | <?php } ?> |
---|
[20622] | 201 | <?php } ?> |
---|
| 202 | </div> |
---|
[20675] | 203 | </div> |
---|