60 lines
3.0 KiB
PHP
60 lines
3.0 KiB
PHP
<?php
|
||
/**
|
||
* func/ip.php —— IP 地址处理
|
||
* 提取输入文本中的全部 IPv4,按 /24 段聚合输出纯文本结果:
|
||
* IP段 发现数量(段内去重IP数) IP段性质
|
||
* 1.2.3.0/24 8 公网
|
||
* 1.2.3.4
|
||
*
|
||
* 段性质区分:内网(含保留)/ CDN / 公网;IPv6 暂不参与。
|
||
*/
|
||
$P = '../';
|
||
require_once dirname(__DIR__) . '/includes/layout.php';
|
||
require_once __DIR__ . '/_bar.php';
|
||
|
||
layout_head('IP 地址处理');
|
||
func_bar('IP 地址处理');
|
||
?>
|
||
<main class="page-main">
|
||
<div class="wrap page-body">
|
||
<div class="panel-card">
|
||
<h2>使用说明</h2>
|
||
<p class="tip">粘贴任意日志 / 文本,系统提取其中全部 <strong>IPv4</strong>(IPv6 暂不参与),
|
||
按 <strong>/24 段</strong>聚合为文本结果:每段一行 <code>IP段 / 发现数量 / IP段性质</code>,
|
||
其中「发现数量」为该段内<strong>去重后的 IP 个数</strong>;段行下方缩进列出该段具体 IP,段与段之间空一行分隔。
|
||
段性质按 <strong>内网(含保留)/ CDN / 公网</strong> 区分。
|
||
若在下方「重点匹配 IP」中填写了需要关注的 IP,命中其所在的 /24 段会<strong>优先置顶</strong>,并在预览结果中用<strong>红色</strong>标出该 IP(复制得到的纯文本不含颜色)。</p>
|
||
<label class="fl" for="ipInput">待分析文本</label>
|
||
<textarea id="ipInput" rows="12" placeholder="粘贴防火墙 / nginx / 安全设备日志等包含 IP 的内容…"></textarea>
|
||
<label class="fl" for="ipFocus" style="margin-top:12px">重点匹配 IP(可选,多个用空格 / 逗号 / 换行分隔)</label>
|
||
<input type="text" id="ipFocus" placeholder="如 8.8.8.8 104.16.1.18;命中该 IP 的 /24 段将优先置顶展示,并将对应 IP 标红">
|
||
<div class="field-row" style="margin-top:10px">
|
||
<button type="button" class="btn btn-primary" id="ipBtn">分析</button>
|
||
<button type="button" class="btn" id="ipClear">清空</button>
|
||
<span class="tip" style="align-self:center">支持 Ctrl / Cmd + Enter 快速分析</span>
|
||
</div>
|
||
<div id="ipMsg"></div>
|
||
</div>
|
||
|
||
<div id="ipResult" hidden>
|
||
<div class="panel-card">
|
||
<div class="field-row" style="align-items:center;justify-content:space-between">
|
||
<h2 style="margin:0">识别结果</h2>
|
||
<button type="button" class="btn btn-sm" id="ipCopy">复制结果</button>
|
||
</div>
|
||
<div id="ipPreview" class="ip-pre"></div>
|
||
<p class="tip" id="ipStat" style="margin:8px 0"></p>
|
||
<p class="tip">复制结果为纯文本(不含红色标记);含重点 IP 的段已优先置顶展示。若 /24 段内混有不同性质,按数量多者标注“xx为主(混合)”。</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
<?php layout_theme_fab(); ?>
|
||
<?php layout_footer(); ?>
|
||
<textarea id="ipCdnRaw" hidden><?= he(cdn_ranges_text()) ?></textarea>
|
||
<script src="../assets/js/common.js"></script>
|
||
<script src="../assets/js/ip.js"></script>
|
||
</body>
|
||
</html>
|