<?php
/*
秀影EasyFramework框架
qq:24498936
msn:jdzcn_net@hotmail.com
website:http://www.vodcms.com
*/
class DenyController extends Easy_Controller_Action {
	public function init(){
		$this->_deny = new DenyModel();
	}
	public function IndexAction(){
		if ($this->_Request->getParams('keyword')){
			$this->_View->deny = $this->_deny->search($this->_Request->getParams('keyword'));
		}else{
			$this->_View->deny = $this->_deny->getAll();
		}
	}
	public function deleteAction(){
		$id = $this->_Request->getParam('id');
		$this->_deny->delete(array('id'=>$id));
		$this->_View->redirect('deny/index');
	}
	public function addAction(){
		if ($this->_Request->isPost()){
			$array = array();
			$array['title'] = $this->_Request->getPost('title');
			$array['sip'] = $this->_Request->getPost('sip');
			$array['eip'] = $this->_Request->getPost('eip');
			$array['etime'] =  strtotime($this->_Request->getPost('etime'));
			if ($this->_deny->Deny($array['title'], $array['sip'], $array['eip'], $array['etime'])===false){
				$this->_View->message = $this->_deny->error;
			}else{
				$this->_View->message = _('添加成功!');
			}
			exit($this->_View->render('message'));
		}
	}
	public function modifyAction(){
		if ($this->_Request->getParam('do') == 'locked'){
			$this->_deny->locked((int)$this->_Request->getParam('id'));
		}
		$this->_View->redirect('deny/index');
	}
}