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

/* 取：我收到的回复 */
/* 162100源码 - 162100.com */



$article_url_base = $web['url_html_article'] == 1 ? '"article.".$area_mode[get_arearoot($row["area_id"])].".".$row["r_id"].".1.html' : '"article.php?mode=".$area_mode[get_arearoot($row["area_id"])]."&id=".$row["r_id"]."';

$mess = 0;
$text=$err = '';
if (!isset($sql['db_err'])) {
  db_conn();
}

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

  $result = @mysql_query('SELECT mess_num,check_reg FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE username="'.$session[0].'" LIMIT 1', $db);
	if ($row = @mysql_fetch_assoc($result)) {
    if ($row['check_reg'] == '1') {
      $err = '帐号注册审核中！';
    } elseif ($row['check_reg'] == '2') {
      $err = '帐号已被移除至<a href="list_member.php?act=punished" target="_blank">黑名单</a>！';
    } else {
      $mess = '<span class="grayword">'.preg_replace('/^\d+/', '<span>$0</span>', $row['mess_num']).'</span>';
    }
    unset($row);
  } else {
    $err = '帐号不存在！';
  }
  @mysql_free_result($result);

  if (empty($err)) {
    $result = @mysql_query('SELECT area_id,area_check_reply,area_index FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id REGEXP "^[0-9]+\-[0-9]+$"', $db);
    while ($row = @mysql_fetch_assoc($result)) {
      $area_mode[$row['area_id']] = get_li_mode($row['area_index']);
      unset($row);
    }
    @mysql_free_result($result);

    $result = @mysql_query('SELECT COUNT(A.id) AS total FROM `'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS A LEFT JOIN `'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS B ON B.id=A.quote WHERE B.author_ip="'.$session[0].'"', $db);
    $row = @mysql_fetch_assoc($result);
    $n = abs($row['total']);
    unset($row);
    @mysql_free_result($result);

    require ('inc/function/get_page.php');
@ require ('inc/function/get_date.php'); //时间
    require ('inc/function/cutstr.php');
    if ($n > 0) {
      $p = get_page($n); //页数
      $seek = $web['pagesize'] * ($p-1);
      //$result = @mysql_query('SELECT A.*,B.id AS quote_id FROM `'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS A LEFT JOIN `'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS B ON B.id=A.quote WHERE B.author_ip="'.$session[0].'" ORDER BY id DESC', $db);

//id,author_ip,date,text,area_check_reply,floor
      $result = @mysql_query('SELECT A.id,A.r_id,A.text,A.date,A.author_ip,
                                     B.id AS quote_id,B.date AS quote_date,B.text AS quote_text,B.floor AS quote_floor,
                                     C.area_id,C.title FROM `'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS A LEFT JOIN (`'.$sql['pref'].''.$sql['data']['承载回复评论的表名'].'` AS B, `'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].'` AS C)
									ON B.id=A.quote WHERE B.author_ip="'.$session[0].'" AND C.id=A.r_id ORDER BY id DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);


      //$result = @mysql_query('SELECT A.id,A.r_id,A.text,A.date,A.area_check_reply,A.author_ip,B.area_id,B.author_ip AS author,B.title,B.date AS d FROM '.$sql['pref'].''.$sql['data']['承载回复评论的表名'].' AS A,'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE A.`text` LIKE "%<fieldset><legend><b>回复'.$session[0].'发表于#%" AND B.id=A.r_id ORDER BY A.id DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);
      while ($row = @mysql_fetch_assoc($result)) {

        $short_str=cutstr($row['quote_text'], 450);
        if (preg_match('/<img [^>]*src[\s\r\n]*=(?![\s\r\n]*\"?('.preg_quote($web['path'], '/').')?inc\/images\/)[^>]*>/i', $row['quote_text'], $mi)) {
          $first_img='<br /><span class="iface_s">'.$mi[0].'</span>';
        }
        $content_quote = '<div class="text"><fieldset><legend><b>'.$session[0].' 发表在 <a href="'.eval('return '.$article_url_base.'&reply_id='.$row['quote_id'].'#reply_'.$row['quote_id'].'";').'" target="_blank">'.$row['quote_floor'].' 楼</a>：</b></legend>'.$short_str.@$first_img.'</fieldset></div>';
        unset($short_str, $first_img);

        $text .= '
<table width="100%" class="li" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <div><span class="column_">在主题文章<a href="'.eval('return '.$article_url_base.'";').'" target="_blank"><b>《'.$row['title'].'》</b></a>中</span></div>
      '.$content_quote.'<div class="text">'.cutstr($row['text'], 450).'</div>
  <div class="li_">
    被回复时间（'.get_date_c($row['date']).'） <a href="'.eval('return '.$article_url_base.'&reply_id='.$row['id'].'#reply_'.$row['id'].'";').'" target="_blank">查看回复详情&raquo;</a>
  </div>

    </td>
  </tr>
</table>
';
        unset($row);
      }
      @mysql_free_result($result);

      $text .= @get_page_foot($n, $web['pagesize'], $p, '?get=replyme&act='.$_GET['act'].'&p=');
    } else {
      $err = '暂无记录';
    }

  }

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

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

?>
<style type="text/css">
<!--
.li .column_ { border-bottom:1px #999966 solid; }
-->
</style>
<div class="list_title"><a class="list_title_in">我收到的回复<span>（<?php echo $n; ?>）</span></a></div>
<?php echo $text, $err; ?>
