Example #1
0
 public function vxBankTransferConfirm($rt)
 {
     echo '<div id="main">';
     echo '<div class="blank">';
     _v_ico_map();
     echo ' <a href="/">' . Vocabulary::site_name . '</a> &gt; ' . $this->lang->send_money() . '</div>';
     echo '<div class="blank">';
     echo '<span class="text_large">';
     _v_ico_tango_32('actions/go-next');
     echo ' ' . $this->lang->send_money();
     echo '</span>';
     _v_hr();
     echo '<span class="tip">';
     if ($rt['errors'] > 0) {
         echo '你可以使用本功能向其他 ' . Vocabulary::site_name . ' 会员汇 ' . Vocabulary::site_name . ' 上的虚拟货币(单位为铜币)。<br /><br />根据你目前持有的铜币数量及注册时间,在汇款过程中可能需要收取一定手续费:';
         echo '<ul style="list-style: square;">';
         echo '<li><strong>0%</strong> 手续费 - 注册时间超过 200 天,铜币数量超过 10000</li>';
         echo '<li><strong>2%</strong> 手续费 - 注册时间超过 100 天,铜币数量超过 5000</li>';
         echo '<li><strong>5%</strong> 手续费 - 注册时间超过 30 天,铜币数量超过 2000</li>';
         echo '<li><strong>8%</strong> 手续费 - 注册时间不限,铜币数量超过 1800</li>';
         echo '</ul>';
         echo '如果你所持有的铜币数量小于 1800,则不能使用汇款服务。';
     } else {
         echo '请确认本次汇款的细节无误之后,点击“确认汇款”。';
     }
     echo '</span>';
     _v_hr();
     $duration = round((time() - $this->User->usr_created) / 86400);
     $rate = Validator::vxSendMoneyRate($this->User->usr_created, $this->User->usr_money);
     echo '<form action="/bank/transfer/confirm.vx" method="post" id="form_send_money">';
     if ($rt['errors'] == 0) {
         echo '<blockquote>';
         echo '收款人 <span class="tip_i">用户编号 #' . $rt['who_object']->usr_id . '</span><br />';
         _v_ico_silk('user');
         echo '&nbsp;<input readonly="readonly" class="sll" type="text" value="' . make_single_return($rt['who_value'], 0) . '" name="who" />';
         echo '<br /><br />';
         echo '数额 <br />';
         _v_ico_silk('coins');
         echo '&nbsp;<input readonly="readonly" class="sll" type="text" value="' . make_single_return($rt['amount_value'], 0) . '" name="amount" /><br /><br />';
         echo '服务费 <br />';
         _v_ico_silk('emoticon_smile');
         echo '&nbsp;' . make_single_return($rt['fee_value'], 0) . '';
         echo '</blockquote>';
         _v_btn_f('确认汇款', 'form_send_money');
         echo '<input type="hidden" value="1" name="confirm" />';
     } else {
         echo '<blockquote>';
         echo '收款人 ';
         if ($rt['who_error'] > 0) {
             echo '<small class="red">' . _vo_ico_silk('exclamation') . ' ' . $rt['who_error_msg'][$rt['who_error']] . '</small>';
         } else {
             echo '<span class="tip_i">请输入对方的 V2EX 会员账号的名字</span>';
         }
         echo '<br />';
         _v_ico_silk('user');
         echo '&nbsp;<input type="text" class="sll" name="who" value="' . make_single_return($rt['who_value'], 0) . '" /><br /><br />';
         echo '数额 ';
         if ($rt['amount_error'] > 0) {
             echo '<small class="red">' . _vo_ico_silk('exclamation') . ' ' . $rt['amount_error_msg'][$rt['amount_error']] . '</small>';
         } else {
             echo '<span class="tip_i">请输入以铜币为单位的汇款数额</span>';
         }
         echo '<br />';
         _v_ico_silk('coins');
         echo '&nbsp;<input type="text" class="sll" name="amount" value="' . make_single_return($rt['amount_value'], 0) . '" />';
         echo '</blockquote>';
         _v_btn_f('汇款', 'form_send_money');
     }
     echo '</form>';
     _v_hr();
     echo '<span class="tip_i">';
     _v_ico_silk('information');
     echo ' 我现在持有 ' . intval($this->User->usr_money) . ' 铜币,注册时间 ' . $duration . ' 天,我的汇款手续费率为 ' . $rate * 100 . '%</span>';
     echo '</div>';
     if ($rt['errors'] > 0) {
         echo '<div class="blank">';
         echo '<span class="text_large">';
         _v_ico_tango_32('apps/help-browser');
         echo ' 帮助';
         echo '</span>';
         _v_hr();
         echo 'Q: 请为我解释一下 ' . Vocabulary::site_name . ' 的货币系统?';
         echo '<blockquote><span class="tip">';
         echo 'A: ' . Vocabulary::site_name . ' 的虚拟货币系统的最小单位为铜币,每 100 个铜币等于 1 个银币,每 100 个银币等于 1 个金币。根据当前的货币政策,新会员在注册初始将获得 ' . BABEL_USR_INITIAL_MONEY . ' 个铜币。社区内的很多功能和设施的使用都将消耗或者获得铜币。';
         echo '</span></blockquote>';
         echo '</div>';
     }
     echo '</div>';
 }
 public function vxSendMoneyCheck()
 {
     $rt = array();
     $rt['errors'] = 0;
     $rt['who_value'] = '';
     $rt['who_object'] = null;
     $rt['who_error'] = 0;
     $rt['who_error_msg'] = array(1 => '你没有输入收款人的名字', 2 => '不能汇款给自己', 3 => '汇款人不存在');
     if (isset($_POST['who'])) {
         $rt['who_value'] = fetch_single($_POST['who']);
         if ($rt['who_value'] != '') {
             $sql = "SELECT usr_id, usr_nick, usr_email, usr_money FROM babel_user WHERE usr_nick = '" . mysql_real_escape_string($rt['who_value']) . "'";
             $rs = mysql_query($sql);
             if ($Object = mysql_fetch_object($rs)) {
                 if ($Object->usr_id != $this->User->usr_id) {
                     $rt['who_object'] = $Object;
                 } else {
                     $rt['errors']++;
                     $rt['who_error'] = 2;
                 }
             } else {
                 $rt['errors']++;
                 $rt['who_error'] = 3;
             }
             mysql_free_result($rs);
         } else {
             $rt['errors']++;
             $rt['who_error'] = 1;
         }
     } else {
         $rt['errors']++;
         $rt['who_error'] = 1;
     }
     $rt['amount_value'] = -1;
     $rt['amount_error'] = 0;
     $rt['amount_error_msg'] = array(1 => '你没有输入汇款数额', 2 => '每次汇款数额至少为 100 铜币', 3 => '汇款数额超出了你持有的铜币数量');
     if (isset($_POST['amount'])) {
         $rt['amount_value'] = abs(intval($_POST['amount']));
         if ($rt['amount_value'] != 0) {
             if ($rt['amount_value'] >= 100) {
                 $rate = Validator::vxSendMoneyRate($this->User->usr_created, $this->User->usr_money);
                 if ($rt['amount_value'] * (1 + $rate) > $this->User->usr_money) {
                     $rt['fee_value'] = 0;
                     $rt['errors']++;
                     $rt['amount_error'] = 3;
                 } else {
                     $rt['fee_value'] = $rt['amount_value'] * $rate;
                 }
             } else {
                 $rt['errors']++;
                 $rt['amount_error'] = 2;
             }
         } else {
             $rt['errors']++;
             $rt['amount_error'] = 1;
         }
     } else {
         $rt['errors']++;
         $rt['amount_error'] = 1;
     }
     $rt['confirm'] = 0;
     if (isset($_POST['confirm'])) {
         $confirm = intval($_POST['confirm']);
         if ($confirm == 1) {
             $rt['confirm'] = 1;
         }
     }
     return $rt;
 }