version();
if($mysql_ver > '3.2.3')
{
$sql .= "SELECT 'feedback' AS tablename, msg_id AS ID, msg_content AS msg_content, msg_title AS msg_title, msg_time AS msg_time, null AS id_value, null AS comment_rank, message_img AS message_img, user_name AS user_name, msg_type AS msg_type ";
$sql .= " FROM " .$GLOBALS['ecs']->table('feedback');
$sql .= " WHERE `msg_type`='1' AND `msg_area`='1' AND `msg_status` = '1' ";
$sql .= " ORDER BY msg_time DESC ";
}
else
{
$con_sql = "SELECT 'comment' AS tablename, comment_id AS ID, content AS msg_content, null AS msg_title, add_time AS msg_time, id_value AS id_value, comment_rank AS comment_rank, null AS message_img, user_name AS user_name, '6' AS msg_type ";
$con_sql .= " FROM " .$GLOBALS['ecs']->table('comment');
$con_sql .= "WHERE STATUS =1 AND comment_type =0 ";
$fee_sql = "SELECT 'feedback' AS tablename, msg_id AS ID, msg_content AS msg_content, msg_title AS msg_title, msg_time AS msg_time, null AS id_value, null AS comment_rank, message_img AS message_img, user_name AS user_name, msg_type AS msg_type ";
$fee_sql .= " FROM " .$GLOBALS['ecs']->table('feedback');
$fee_sql .= " WHERE `msg_type`='1' AND `msg_area`='1' AND `msg_status` = '1' ";
$cre_con = "CREATE TEMPORARY TABLE tmp_table ".$con_sql;
$GLOBALS['db']->query($cre_con);
$cre_con = "INSERT INTO tmp_table ".$fee_sql;
$GLOBALS['db']->query($cre_con);
$sql = "SELECT * FROM " .$GLOBALS['ecs']->table('tmp_table') . " ORDER BY msg_time DESC ";
}
$res = $GLOBALS['db']->SelectLimit($sql, $num, $start);
while ($rows = $GLOBALS['db']->fetchRow($res))
{
for($i = 0; $i < count($rows); $i++)
{
$msg[$rows['msg_time']]['user_name'] = htmlspecialchars($rows['user_name']);
$msg[$rows['msg_time']]['msg_content'] = str_replace('\r\n', '
', htmlspecialchars($rows['msg_content']));
$msg[$rows['msg_time']]['msg_content'] = str_replace('\n', '
', $msg[$rows['msg_time']]['msg_content']);
$msg[$rows['msg_time']]['msg_time'] = local_date($GLOBALS['_CFG']['time_format'], $rows['msg_time']);
$msg[$rows['msg_time']]['msg_type'] = $GLOBALS['_LANG']['message_type'][$rows['msg_type']];
$msg[$rows['msg_time']]['msg_title'] = nl2br(htmlspecialchars($rows['msg_title']));
$msg[$rows['msg_time']]['message_img'] = $rows['message_img'];
$msg[$rows['msg_time']]['tablename'] = $rows['tablename'];
if(isset($rows['order_id']))
{
$msg[$rows['msg_time']]['order_id'] = $rows['order_id'];
}
$msg[$rows['msg_time']]['comment_rank'] = $rows['comment_rank'];
$msg[$rows['msg_time']]['id_value'] = $rows['id_value'];
/*如果id_value为true为商品评论,根据商品id取出商品名称*/
if($rows['id_value'])
{
$sql_goods = "SELECT goods_name FROM ".$GLOBALS['ecs']->table('goods');
$sql_goods .= "WHERE goods_id= ".$rows['id_value'];
$goods_res = $GLOBALS['db']->getRow($sql_goods);
$msg[$rows['msg_time']]['goods_name'] = $goods_res['goods_name'];
$msg[$rows['msg_time']]['goods_url'] = build_uri('goods', array('gid' => $rows['id_value']), $goods_res['goods_name']);
}
}
$msg[$rows['msg_time']]['tablename'] = $rows['tablename'];
$id = $rows['ID'];
$reply = array();
if(isset($msg[$rows['msg_time']]['tablename']))
{
$table_name = $msg[$rows['msg_time']]['tablename'];
if ($table_name == 'feedback')
{
$sql = "SELECT user_name AS re_name, user_email AS re_email, msg_time AS re_time, msg_content AS re_content ,parent_id".
" FROM " .$GLOBALS['ecs']->table('feedback') .
" WHERE parent_id = '" . $id. "'";
}
else
{
$sql = 'SELECT user_name AS re_name, email AS re_email, add_time AS re_time, content AS re_content ,parent_id
FROM ' . $GLOBALS['ecs']->table('comment') .
" WHERE parent_id = $id ";
}
$reply = $GLOBALS['db']->getRow($sql);
if ($reply)
{
$msg[$rows['msg_time']]['re_name'] = $reply['re_name'];
$msg[$rows['msg_time']]['re_email'] = $reply['re_email'];
$msg[$rows['msg_time']]['re_time'] = local_date($GLOBALS['_CFG']['time_format'], $reply['re_time']);
$msg[$rows['msg_time']]['re_content'] = nl2br(htmlspecialchars($reply['re_content']));
}
}
}
return $msg;
}
?>
assign('zj_lists', $zj_lists); // 数据条数
?>