<?php 
class Member_note_Controller extends Front_Controller {
	function __construct(){
		parent::__construct();
		$this->notes	=	new Note_Model();

	}
	function index($page=1,$showlines=20){
		$notes					=	$this->notes->get(false,$page,$showlines)->result_array();
		$GLOBALS['sum']			=	$this->notes->get(false,false,false)->count();
		$GLOBALS['page']		=	1;
		$GLOBALS['pagesize']	=	$showlines;
		$GLOBALS['dir']			=	"member_note/index";

		$this->lmtpl->title				=	"留言板";
		$this->lmtpl->keywords			=	'';
		$this->lmtpl->description		=	'';
		$this->lmtpl->note				=	$notes;
		@$this->lmtpl->user				=	$_SESSION['user'];
		$this->lmtpl->render(self::tplpath('member_note'));
	}
	function add(){
		if($this->input->post()){
			$note			=	$this->input->post("note");
			if(IS_VALID_NUMBER){
				if(strtoupper($_SESSION["valid_number"])!=strtoupper($note['valid_number'])){
					$this->Report("验证码错误","member_note");
				}
			}
			$strs			=	file("data/keywords.dat");
			unset($note['valid_number']);
			foreach ($note	as $key=>$n){
				$strs		=	str_replace("\r","",$strs);
				$strs		=	str_replace("\n","",$strs);
				$note[$key]	=		str_replace($strs,"",$n);
			}
			$note['ip']		=	$this->input->ip_address();
			$note['times']	=	time();
			$this->notes->insert($note);
			$this->index();
		}
	}
}