$Input=D('UserIndexInput');
if(!$Input->create($_REQUEST))
$this->error($Input->getError());class UserIndexInputModel extends Model{
protected $autoCheckFields=false;
protected $_auto=array(
array('keyword', 'autoKeyword', 3, 'callback'),
array('page', 'autoPage', 3, 'callback'),
array('pageRecords', 'autoPageRecords', 3, 'callback'),
);
protected function autoKeyword(){
if(!Think::validate('/^\w{0,16}$/'))
return "";
return $_REQUEST['keyword'];
}
protected function autoPage(){
if(empty($_REQUEST['page']) || $_REQUEST['page']<1)
return '1';
return $_REQUEST['page'];
}
protected function autoPageRecords(){
if($_REQUEST['pageRecords']>=1 && $_REQUEST['pageRecords']<=1024)
return $_REQUEST['pageRecords'];
if($_REQUEST['pageRecords']>1024)
return '1024';
return '20';
}
}
?> 最佳答案