宝塔面板中-安全-系统防火墙 功能非常丰富,特别是“地区规则”用来屏蔽来自国外的请求非常有用,那些通过 URL 来找网站漏洞的恶意请求大多来自国外。但是添加规则经常无反应
于是找到这个功能对应的配置文件:/etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<port protocol="tcp" port="80"/>
<port protocol="tcp" port="443"/>
<masquerade/>
<rule family="ipv4">
<source address="43.131.232.135"/>
<drop/>
</rule>
<rule family="ipv4">
<source address="103.150.11.45"/>
<drop/>
</rule>
<rule>
<source ipset="US"/>
<drop/>
</rule>
<rule>
<source ipset="GB"/>
<drop/>
</rule>
</zone>
修改完成后重启防火墙。
但是看到的效果好像并不一致,甚至有时候服务器重启后防火墙是关闭的,但是有时候又是生效的。
关键的问题是CPU占用异常高。
反正宝塔的系统防火墙功能挺好挺强大,但是用起来不稳定不顺手,有些暴殄天物了。
相关阅读:
2024年8月30日补充 :宝塔面板中配置禁用IP等规则时,提示保存成功或未提醒是否成功,但效果是未成功。其实在宝塔自己的配置里已经记录了(包含备注),但在系统防火墙配置文件中未更改成功,手动修改系统防火墙配置文件就能完全修改成功。(系统防火墙配置文件中没有备注信息,根据IP地址等规则与宝塔自己的配置文件里的记录关联后,在宝塔面板安全模块中展示出来就有备注了。)
2024年8月30日下午补充:在宝塔的软件商店找到这个应用,看到红色的说明,啥都明白了:
于是果断关闭了系统防火墙,开始研究其它替代方案。
引用
jQuery、moment.js、daterangepicker
例子
$('.x_dates').daterangepicker({
"timePicker": false, // 是否显示时间
//"dateLimit": {
// "days": 7 // 可选中的最大区间(天)
//},
"ranges": { // 快捷栏
"今天": [moment(), moment()],
"昨天": [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
"最近 7 天": [moment().subtract(6, 'days'), moment()],
"最近 30 天": [moment().subtract(29, 'days'), moment()],
"本月": [moment().startOf('month'), moment().endOf('month')],
"上个月": [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: daterangepicker_startDate, // moment(),
endDate: daterangepicker_endDate, // moment(),
autoUpdateInput: true,
"locale": {
"direction": "ltr",
"format": "YYYY-MM-DD", // YYYY-MM-DD HH:mm
"separator": " 至 ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "From",
"toLabel": "To",
"customRangeLabel": "自定义",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
}
}, function (start, end, label) {
//console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
fn_daterangepicker_changed(start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'))
});
官网(含配置工具)
http://www.daterangepicker.com/
GitHub
https://github.com/dangrossman/daterangepicker
配置工具
下载的包中的 demo.html
Demo
https://awio.iljmp.com/5/drpdemo
<input name="aaa" id="theinput" type="checkbox" />
// 选中它
$('input[name="aaa"]').prop("checked", true);
// 取消它
$('input[name="aaa"]').prop("checked", false);
// 顺便提一下将 select 选中首项
$("#ddl_types option:first").prop('selected', true);
// 获取选中的项
$('input[name="aaa"]:checked').each(function(){ });
// 获取项是否选中
$('#theinput').is(':checked')
或
$('#theinput').prop('checked')
或
theinput.checked
// 获取 radio 选中项的值
$('input[name="aaa"]:checked').val()
CatalogEdit.aspx
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="catalog" DataValueField="ID" Rows="10"></asp:ListBox> <asp:LinkButton ID="LinkButton_up" runat="server" OnClick="LinkButton_up_Click">上移</asp:LinkButton> <asp:LinkButton ID="LinkButton_down" runat="server" OnClick="LinkButton_down_Click">下移</asp:LinkButton> <asp:LinkButton ID="LinkButton_del" runat="server" OnClick="LinkButton_del_Click">删除</asp:LinkButton> <asp:Label ID="Label_alert" runat="server" ForeColor="Red" Text="Label"></asp:Label><br /> <asp:TextBox ID="TextBox_newCatalog" runat="server"></asp:TextBox> <asp:LinkButton ID="LinkButton_add" runat="server" OnClick="LinkButton_add_Click">新增</asp:LinkButton> <asp:LinkButton ID="LinkButton_edit" runat="server" OnClick="LinkButton_edit_Click">修改</asp:LinkButton> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringLink %>" DeleteCommand="DELETE FROM [xLinkCategory] WHERE [ID] = ?" InsertCommand="INSERT INTO [xLinkCategory] ([username],[catalog],[order]) VALUES (?,?,0)" ProviderName="<%$ ConnectionStrings:ConnectionStringLink.ProviderName %>" SelectCommand="SELECT [ID], [catalog] FROM [xLinkCategory] WHERE ([username] = ?) ORDER BY [order],[ID] desc" UpdateCommand="UPDATE [xLinkCategory] SET [catalog] = ? WHERE [ID] = ?"> <DeleteParameters> <asp:Parameter Name="ID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="catalog" Type="String" /> <asp:Parameter Name="ID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:SessionParameter Name="username" SessionField="username" Type="String" /> </SelectParameters> <InsertParameters> <asp:SessionParameter Name="username" SessionField="username" Type="String" /> <asp:Parameter Name="catalog" Type="String" /> </InsertParameters> </asp:SqlDataSource>
CatalogEdit.aspx.cs
/**//// <summary> /// 上移 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_up_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex > 0) { string tempValue = ListBox1.SelectedValue; string tempText = ListBox1.SelectedItem.Text; int index = ListBox1.SelectedIndex; ListBox1.SelectedItem.Value = ListBox1.Items[index - 1].Value; ListBox1.SelectedItem.Text = ListBox1.Items[index - 1].Text; ListBox1.Items[index - 1].Value = tempValue; ListBox1.Items[index - 1].Text = tempText; ListBox1.SelectedIndex--; operateDB_move(); } } /**//// <summary> /// 下移 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_down_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex < ListBox1.Items.Count - 1) { string tempValue = ListBox1.SelectedValue; string tempText = ListBox1.SelectedItem.Text; int index = ListBox1.SelectedIndex; ListBox1.SelectedItem.Value = ListBox1.Items[index + 1].Value; ListBox1.SelectedItem.Text = ListBox1.Items[index + 1].Text; ListBox1.Items[index + 1].Value = tempValue; ListBox1.Items[index + 1].Text = tempText; ListBox1.SelectedIndex++; operateDB_move(); } } /**//// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_add_Click(object sender, EventArgs e) { if (TextBox_newCatalog.Text != "") { //检查同名 bool goon = true; foreach (ListItem li in ListBox1.Items) { if (li.Text == TextBox_newCatalog.Text) { goon = false; } } if (goon) { //操作 SqlDataSource1.InsertParameters["catalog"].DefaultValue = TextBox_newCatalog.Text; SqlDataSource1.Insert(); //设置selected if (ListBox1.Items.Count > 0) { ListBox1.SelectedIndex = 0; } } else { Label_alert.Text = "已存在"; } } } /**//// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_edit_Click(object sender, EventArgs e) { if (TextBox_newCatalog.Text != "" && ListBox1.SelectedItem != null) { int index = ListBox1.SelectedIndex; //检查同名 bool goon = true; foreach (ListItem li in ListBox1.Items) { if (li.Text == TextBox_newCatalog.Text) { goon = false; } } if (goon) { //操作 SqlDataSource1.UpdateParameters["catalog"].DefaultValue = TextBox_newCatalog.Text; SqlDataSource1.UpdateParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value; SqlDataSource1.Update(); //设置selected ListBox1.SelectedIndex = index; } else { Label_alert.Text = "已存在"; } } } /**//// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_del_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null) { int index = ListBox1.SelectedIndex; int count = ListBox1.Items.Count; //检查该 Catalog 下是否有 Link bool goon = true; goon = !checkSubLink(ListBox1.SelectedValue); //下有 Link 则返回真,注意前面有个"!",有则不继续 if (goon) { //操作 SqlDataSource1.DeleteParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value; SqlDataSource1.Delete(); //设置selected if (index < count - 1) //删的不是最末项 { ListBox1.SelectedIndex = index; } if (index == count - 1 && index != 0) //删的是最末项,并且不是最首项 { ListBox1.SelectedIndex = index - 1; } if (index == count - 1 && index == 0) //删的是最末项,并且是最首项 { //不设索引 } } else { Label_alert.Text = "该节点下面存在Link(s),请删除后再删除该节点!"; } } }