<?php
/**
* 评价回应
* @author moufer<moufer@163.com>
* @package modoer
* @copyright Moufer Studio(www.modoer.com)
* @version $Id: viewreview.php 10 2008-09-03 21:09 $
*/
define('SCRIPTNAV', 'viewreview');
require_once './include/inc_common.php';

if(!function_exists('getMember')) {
    require_once(MUDDER_ROOT.'./member/include/fun_member.php');
}

if(!is_numeric($reviewid) || $reviewid < 0) {
    redirect('无效的点评信息。', NULL);
}
$review = getReview($reviewid);
empty($review) && redirect('点评信息不存在或已被删除。');
$review['status'] == 2 && redirect('点评信息尚未审核，暂时无法查看。');
$shop = getItem($review['shopid']);
empty($shop) && redirect('点评的商铺不存在或已被删除，无法查看点评信息。');
$member = &$review['member'];

//回应列表
$where = "reviewid='$reviewid' AND a.status='1'";
$total = $db->get_value("SELECT COUNT(*) FROM {$dbpre}responds a WHERE $where");
if($total > 0) {
    $limit = get_limit($page, $_config['dpreview_respondnumber']);
    $query = $db->query("SELECT a.*,FROM_UNIXTIME(a.posttime,'%Y-%m-%d %H:%i') as posttime,b.username FROM {$dbpre}responds a LEFT JOIN {$dbpre}members b ON(a.uid=b.uid) WHERE $where ORDER BY posttime DESC LIMIT $limit");
    $flag = 1;
    while($row = $db->fetch_array($query)) {
        $row['flag'] = $flag;
        $row['content'] = strip_textarea($row['content']);
        $responds[] = $row;
        $flag = $flag == 1 ? 2 : 1;
    }
    $multipage = multi($total, $offset, $page, "viewreview.php?reviewid=$reviewid");
}

$flowercount = &$review['flower'];
$flowers = array();
if($review['flower'] > 0) {
    $query = $db->query("SELECT * FROM {$dbpre}flowers WHERE reviewid='$reviewid'");
    while($row = $db->fetch_array($query)) {
        $flowers[] = $row;
    }
    $db->free_result($query);
}

if(!$user->isLogin) {
    $forward = rawurlencode($_config['siteurl'].'viewreview.php?reviewid='.$reviewid);
}

$subtitle = $member['username'].'_点评_'.$shop['fullname'];
require_once MUDDER_ROOT.'header.php';
require_once template('shop_viewreview');
footer();
?>
