<?php
/**
 * 前台留言控制器
 *
 * @package Action
 * @subpackage Home
 * @stage 1.0
 * @author billow.wang <admin@ivears.com>
 * @date 2013-05-28
 */
class GuestbookAction extends HomeAction{
    
    public function _initialize() {
        parent::_initialize();
    }
    
	public function post(){
		$ary_post = $this->_post();
		/*
        $verify = session("code");
        if ($verify != md5($ary_post['vcode'])) {
                $this->error('验证码错误');
				exit;
        }
		*/
	
		
				$ip = get_client_ip();
                $ary_data = array(
                    'title'        =>  $ary_post['para41'],
                    'tel'       =>  trim($ary_post['para42']),
					'address'=>trim($ary_post['para43']),
					'content'=>trim($ary_post['para44']),
                    'addtime'    =>  date("Y-m-d H:i:s"),
                    'ip'      =>  $ip,
                    'visible'         => 0
                );
				//print_r($ary_data);
                $ary_result = D('Message')->add($ary_data);
				//print_r($ary_result);
				//exit;
                if(FALSE !== $ary_result){
                    $this->success("留言成功",'/',2);
                }else{
                    $this->error("申请失败");
                }		
	}
    public function index(){
		if($_POST){
			$this->post();
			exit;
		}else{
       		 $this->display();
		}
    }
}