<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'ask_list';
switch ($act) {
	//#####################@ 留言回复 @#####################//
	case 'edit':
		$info = $db->pe_select('ask', array('ask_id'=>$_g_id));

		$seo = pe_seo($menutitle='回复留言', '', '', 'admin');
		$action = "admin.php?mod=ask&act=editsql&id={$_g_id}";
		include(pe_tpl('ask_add.html'));
	break;
	//#####################@ 留言回复sql @#####################//
	case 'editsql':
		if ($_p_info['ask_replytext']) {
			$_p_info['ask_replytime'] = time();
			$_p_info['ask_state'] = 1;
		}
		else {
			$_p_info['ask_replytime'] = $_p_info['ask_state'] = 0;		
		}
		if ($db->pe_update('ask', array('ask_id'=>$_g_id), pe_dbhold($_p_info))) {
			pe_success('留言回复成功!', 'admin.php?mod=ask&act=list&state=all');
		}
		else {
			pe_error('留言回复失败...');
		}
	break;
	//#####################@ 留言删除sql @#####################//
	case 'delsql':
		if ($db->pe_delete('ask', array('ask_id'=>is_array($_p_ask_id) ? $_p_ask_id : $_g_id))) {
			pe_success('留言删除成功!');
		}
		else {
			pe_error('留言删除失败...');
		}
	break;
	//#####################@ 留言列表 @#####################//
	default :
		$_g_state != 'all' && $sqlwhere .= " and `ask_state` = '{$_g_state}'";
		$_g_keyword && $sqlwhere .= " and `ask_text` like '%{$_g_keyword}%'";
		$sqlwhere .= " order by `ask_id` desc";
		$info_list = $db->pe_selectall('ask', $sqlwhere, '*', array(20, $_g_page));

		$seo = pe_seo($menutitle='留言列表', '', '', 'admin');
		include(pe_tpl('ask_list.html'));
	break;
}
?>