abuse_protection.hbs 2.67 KB
<div class="pageheader">
    <div class="media">
        <div class="pageicon pull-left">
            <i class="fa fa-th-list"></i>
        </div>
        <div class="media-body">
            <ul class="breadcrumb">
                <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
                <li><a href="/abuse_protection">滥用防护</a></li>
            </ul>
            <h4>疑似爬虫监控</h4>
        </div>
    </div>
    <!-- media -->
</div>
<!-- pageheader -->

<div class="contentpanel servers-page">
    <form action="/abuse_protection/abuse_protection" class="form-inline" method="get">
        <div class="form-group">
            <select name="node" class="form-control" style="height: 40px">
                <option value="">Memcached节点</option>
                {{#hosts}}
                    <option value="{{host}}" {{#if isCurrent}}selected="selected"{{/if}}>{{host}}</option>
                {{/hosts}}
            </select>
        </div>

        <div class="form-group input-group">
            <input id="threshold" type="text" class="form-control" size="3" name="threshold" value="{{threshold}}"/>
            <div class="input-group-addon">/天</div>
        </div>

        <div class="form-group input-group">
            <div class="input-group-addon">显示</div>
            <input id="threshold" type="text" class="form-control" size="3" name="limit" value="{{limit}}"/>
            <div class="input-group-addon"></div>
        </div>
        <button class="btn btn-primary">应用</button>
    </form>

    <table class="table table-striped table-bordered building-table" style="margin-top: 2rem">
        <tr>
            <th>IP</th>
            <th>爬虫指数</th>
            <th>操作</th>
        </tr>

        {{#list}}
            <tr>
                <td>{{ip}}</td>
                <td>{{index}}</td>
                <td>
                    <button class="access-deny btn btn-primary btn-sm btn-danger" data-ip="{{ip}}">禁止访问</button>
                    <button class="access-allow btn btn-success btn-sm" data-ip="{{ip}}">允许访问</button>
                </td>
            </tr>
        {{/list}}

        {{#if noData}}
            <tr>
                <td colspan="4" class="text-center">无数据</td>
            </tr>
        {{/if}}
    </table>
</div>

<script>
    $(function() {
        $('.access-deny').click(function() {
            $.post('/abuse_protection/lock', {remoteIp: $(this).data('ip')}, function() {
            });
        });

        $('.access-allow').click(function() {
            $.post('/abuse_protection/unlock', {remoteIp: $(this).data('ip')}, function() {
            });
        });
    });
</script>