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

/* 取：用户信誉 */
/* 162100源码 - 162100.com */


$_GET['username'] = strtolower(trim($_GET['username']));
$_GET['username'] = str_replace('.', '&#46;', $_GET['username']);
$text=$err = '';
if (!preg_match('/^([^\x00-\x7f]|\w|&#46;){3,45}$/', $_GET['username'])) :
  $err = '用户名不合法！';
else :

  $n = $total = 0;

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

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

    $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE username="'.$_GET['username'].'" LIMIT 1', $db);
    if (!$row = @mysql_fetch_assoc($result)) {
      $err = '查不到用户'.$_GET['username'].'的信息！';
	} else {
      if ($row['check_reg'] == '1') {
        $err = '用户'.$_GET['username'].'尚在注册审核中！';
      }
      if ($row['check_reg'] == '2') {
        $err = '用户'.$_GET['username'].'已经被置入黑名单！';
      }
      unset($row);
    }
    @mysql_free_result($result);

    if (empty($err)) {

      //求和信誉值
      $result = @mysql_query('SELECT SUM(money) AS total FROM '.$sql['pref'].''.$sql['data']['承载财务数据的表名'].' WHERE username="'.$_GET['username'].'" AND type="1"', $db);
      if ($row = @mysql_fetch_assoc($result)) {
        $total = (float)$row['total'];
        unset($row);
      }
      @mysql_free_result($result);

      //求总数
      $result = @mysql_query('SELECT COUNT(id) AS total FROM '.$sql['pref'].''.$sql['data']['承载财务数据的表名'].' WHERE username="'.$_GET['username'].'" AND type="1" AND check_credit="0"', $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 username="'.$_GET['username'].'" AND type="1" AND check_credit="0" ORDER BY date DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);
        $step = 0;
        while ($row = @mysql_fetch_assoc($result)) {
          $money = $row['money'] > 0 ? '+'.$row['money'] : $row['money'];
          $text .= '
  <div class="li">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td style="text-align:left;">'.$row['description'].'</td>
        <td width="100" style="text-align:center;">'.$money.'</td>
        <td width="200" style="text-align:center;">'.$row['date'].'</td>
        <td width="200" style="text-align:center;">'.(strpos($row['other'], 'credit-')!==false ? ''.((string)substr($row['other'], 0, 1) != '1' ? '未公开' : '<a href="__temp__/temp/'.urlencode(substr($row['other'], 1)).'" target="_blank">浏览</a>').'' : $row['other']).'</td>
      </tr>
    </table>
  </div>
';
	      unset($row);

        }
        @mysql_free_result($result);
        $text .= get_page_foot($n, $web['pagesize'], $p, '?get=credit&username='.$_GET['username'].'&p=');

	  } else {
        $text = '暂无相应记录';
      }

    }


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

  require ('inc/function/add_online.php'); //在线
  @mysql_close();
  
endif;

if (empty($err)) {
  echo '
<div class="column aline">
'.$_GET['username'].'当前的信誉值为：<span class="redword">'.$total.''.($_GET['username'] == $web['manager'] ? '（管理员）' : '').'</span></div>
<div class="list_title" style="margin-top:10px;"><a class="list_title_in">信誉值记录<span>（'.$n.'）</span></a></div>
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th>信誉值明细</th>
      <th width="100">信誉值变化</th>
      <th width="200">日期</th>
      <th width="200">备注</th>
    </tr>
  </table>
</div>
'.$text;

} else {
  echo $err;
}
?>
