<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id 3 2008-08-25 18:35 $
*/
!defined('IN_MUDDER') && exit('Access Denied');

if(!check_submit('mysubmit')) {

    $from = "{$dbpre}reviews a LEFT JOIN {$dbpre}shops b ON(a.shopid=b.sid)";
    $where = "a.uid='{$user->uid}' AND a.status=1";
    $row = $db->get_one("SELECT COUNT(*) as count FROM {$dbpre}reviews WHERE uid='{$user->uid}'");
    $total = $row['count'];
    if($total > 0) {
        $query = $db->query("SELECT a.rid,a.flower,a.respond,a.shopid,a.status,FROM_UNIXTIME(a.posttime,'%Y-%m-%d %H:%i:%s')as posttime,b.shopname,b.subname FROM $from WHERE $where GROUP BY a.shopid ORDER BY posttime DESC");
        while($review = $db->fetch_array($query)) {
            $review['shopname'] .= ($review['subname'] ? "({$review['subname']})" : "");
            $review['statusname'] = $review['status'] == 1 ? '正常' : ($review['status'] == 2 ? '未审核' : '隐藏');
            $reviews[] = $review;
        }
        $multipage = multi($total, $offset, $page, "index.php?ac=$ac");
    }

} else {

    if($reviewids && is_array($reviewids)) {
        require_once MUDDER_ROOT.'./include/addnew.func.php';
        foreach($reviewids as $id) {
            $responds = $db->get_all("SELECT rid as respondid FROM {$dbpre}responds WHERE reviewid='$id'");
            if($responds) foreach($responds as $respond) {
                delete_respond($respond['respondid'], false);
            }
            delete_review($id, true);
        }
        redirect('删除完毕！',"index.php?ac=$ac");
    } else {
        redirect('未选择，请返回修改，至少选择一项。');
    }

}
?>