<?php
require ('authentication_manager.php');
?>
<?php

/* 管理货币值 */
/* 162100源码 - 162100.com */

$text = $err = '';
$_GET['username'] = @$_GET['username'];
if ($_GET['username']) {
  $_GET['username'] = strtolower(trim($_GET['username']));
  $_GET['username'] = str_replace('.', '&#46;', $_GET['username']);
  if (preg_match('/^([^\x00-\x7f]|\w|&#46;){3,45}$/', $_GET['username'])) {
    $where_eval = ' username="'.$_GET['username'].'" AND type="0"';
    $search_r = '搜索结果 - ';
  } else {
    $where_eval = ' type="0"';
    $search_r = '<span class=\"red\">用户名不合法</span> | ';
  }
} else {
  $where_eval = ' type="0"';
}
$_GET['act'] = @$_GET['act'];
if ($_GET['act'] == 'add') {
  $where_eval .= ' AND money>0';
  $list_title = '"<a href=\"?get=member_funds\">所有货币记录</a><a class=\"list_title_in\">增值记录<span>（".$n."）</span></a><a href=\"?get=member_funds&act=del\">支出记录</a><a href=\"?get=member_funds&act=recharge\">在线充值记录</a>"';

} elseif ($_GET['act'] == 'del') {
  $where_eval .= ' AND money<0';
  $list_title = '"<a href=\"?get=member_funds\">所有货币记录</a><a href=\"?get=member_funds&act=add\">增值记录</a><a class=\"list_title_in\">支出记录<span>（".$n."）</span></a><a href=\"?get=member_funds&act=recharge\">在线充值记录</a>"';

} elseif ($_GET['act'] == 'recharge') {
  $where_eval .= ' AND description="在线充值"';
  $list_title = '"<a href=\"?get=member_funds\">所有货币记录</a><a href=\"?get=member_funds&act=add\">增值记录</a><a href=\"?get=member_funds&act=del\">支出记录</a><a class=\"list_title_in\">在线充值记录<span>（".$n."）</span></a>"';

} else {
  $where_eval .= '';
  $list_title = '"<a class=\"list_title_in\">所有货币记录<span>（".$n."）</span></a><a href=\"?get=member_funds&act=add\">增值记录</a><a href=\"?get=member_funds&act=del\">支出记录</a><a href=\"?get=member_funds&act=recharge\">在线充值记录</a>"';
  $_GET['act'] = '';
}






if (!isset($sql['db_err'])) {
  db_conn();
}

if ($sql['db_err'] == '') {

  $result = @mysql_query('SELECT COUNT(id) AS total FROM '.$sql['pref'].''.$sql['data']['承载财务数据的表名'].' WHERE'.$where_eval.'', $db);
  $row = @mysql_fetch_assoc($result);
  $n = abs($row['total']);
  @mysql_free_result($result);
  unset($row);

  require ('inc/function/get_page.php');
  if ($n > 0) :
    $p = get_page($n); //页数
    $seek = $web['pagesize'] * ($p-1);
    $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载财务数据的表名'].' WHERE'.$where_eval.' ORDER BY id DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);

    $text .= '
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th width="200">用户名</th>
      <th width="200">货币值明细</th>
      <th>货币出入</th>
      <th width="200">日期</th>
    </tr>
  </table>
</div>
';
    while ($row = @mysql_fetch_assoc($result)) {
      $row['money'] = $row['money'] > 0 ? '+'.$row['money'] : $row['money'];
      $text .= '
<div class="li">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="200" style="text-align:left;"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['id'].'" /> '.$row['username'].'</td>
      <td width="200" style="text-align:center;">'.$row['description'].'</td>
      <td style="text-align:center;">'.$row['money'].'</td>
      <td width="200" style="text-align:center;">'.$row['date'].'</td>
    </tr>
  </table>
</div>
';
    }
    @mysql_free_result($result);

    $text .= get_page_foot($n, $web['pagesize'], $p, '?get=member_funds&act='.$_GET['act'].'&username='.$_GET['username'].'&p=');

  else :
    $err .= '没有记录！';
  endif;

} else {
  $err .= $sql['db_err'];
}

@mysql_close();

?>
<div class="column"><b>提示：</b>删除操作要极其谨慎！删除正值相当于扣钱，删除负值相当于给用户进款。</div>
<div class="list_title"><?php echo eval('return '.$list_title.';'); ?></div>
<form method="post" id="manageform" action="?post=unity_run&dataname=myaccount" onsubmit="if(get_checkbox('id[]')==0){alert ('请点选！');return false;}">
  <div class="manager_menu"> <a href="javascript:void(0)" onclick="allChoose(true,true);return false;">全选</a> - <a href="javascript:void(0)" onclick="allChoose(true,false);return false;">反选</a> - <a href="javascript:void(0)" onclick="allChoose(false,false);return false;">不选</a> &nbsp;&nbsp;
      <button type="button" name="act2" onclick="chk(this.form,this,'delfunds')"><b>删除</b></button>
    | 按用户名
    <input name="username" id="username" value="<?php echo $_GET['username']; ?>" type="text" size="20" />
      <button name="button" type="button" onclick="location.href='?get=member_funds&act=show&username='+encodeURIComponent($('username').value)+'&act=<?php echo $_GET['act']; ?>'"><b>搜索</b></button>
  </div>
  <?php
echo $text, $err;
?>
  <input type="hidden" name="limit" />
</form>
