因为pbootcms模板框架种默认的系统日记记录有爬虫信息,但是爬虫头又没分类查询,为了方便查询添加了一个爬虫头分类选择下拉框。
1.在apps/admin/view/default/system/syslog.html中添加爬虫头分类选择下拉框功能:
<form action="{url./admin/Syslog/index}" method="get" class="layui-form">
<div class="layui-form-item nospace">
<div class="layui-input-inline">
{$pathinfo}
<select name="field" lay-verify="required">
<option value="0">全部</option>
<option value="Baidu" {if(get('field')=='Baidu')}selected="selected" {/if}>百度</option>
<option value="360sou" {if(get('field')=='360sou')}selected="selected" {/if}>360</option>
<option value="Yisou" {if(get('field')=='Yisou')}selected="selected" {/if}>易搜</option>
<option value="Byte" {if(get('field')=='Byte')}selected="selected" {/if}>Byte</option>
<option value="Bing" {if(get('field')=='Bing')}selected="selected" {/if}>微软必应</option>
<option value="Sougou" {if(get('field')=='Sougou')}selected="selected" {/if}>搜狗</option>
<option value="Google" {if(get('field')=='Google')}selected="selected" {/if}>谷歌</option>
<option value="other-bot" {if(get('field')=='other-bot')}selected="selected" {/if}>其他</option>
</select>
</div>
<div class="layui-input-inline">
<button class="layui-btn" lay-submit>搜索</button>
</div>
</div>
</form>
2.修改apps/admin/model/system/SyslogModel.php文件中的getList添加爬虫头like查询:
public function getList($where)
{
if($where == "0"){
return parent::table('ay_syslog')->order('id DESC')->page()->select();
}else{
return parent::table('ay_syslog')->like('event',$where)->order('id DESC')->page()->select();
}
}
3.apps/admin/controller/system/SyslogController.php中的index添加接受前端搜索表单提交过来的数据:
public function index()
{
if (isset($_GET['field'])) {
$type_str = $_GET['field'];
$this->assign('syslogs',$this->model->getList($type_str));
$this->display('system/syslog.html');
}
}
改后样式: