Browse Source

IP黑白名单快捷操作

懒得勤快 7 years ago
parent
commit
4915ddb561

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.WebApp/App_Data/ban.txt


+ 1 - 1
src/Masuit.MyBlogs.WebApp/App_Data/denyareaip.txt

@@ -1 +1 @@
-{"苏州市":["180.101.139.171","49.64.234.126","112.80.38.106","58.210.4.122","222.92.48.26","218.4.55.220","49.75.116.127","58.210.219.66","112.87.42.14","218.4.255.238","121.236.81.66","112.25.180.10","223.166.151.199","223.166.151.197","223.64.74.5","61.151.178.217","49.92.158.58","58.210.233.234","49.72.32.15","180.97.147.133","157.0.165.53","180.106.65.216","49.92.106.254","114.217.67.220","58.211.71.126","61.151.178.163","58.208.3.70","49.75.151.5","221.224.214.35","180.107.26.211","121.239.39.8","49.92.120.119","180.107.207.109","221.224.140.163","122.192.13.147","218.4.91.131","114.218.165.252","49.64.255.66","222.92.73.58","211.143.246.38","223.166.151.191","180.208.58.133","49.73.142.24","58.211.49.69","58.210.98.46","58.210.90.142","114.217.202.41","42.244.62.238","58.210.89.132","58.208.153.168","180.106.238.244","58.211.111.42","221.224.134.178","218.4.136.119","221.224.81.146","58.209.0.164","223.106.11.159","183.211.92.114","14.116.141.79","58.209.249.164","122.193.89.146","117.80.217.172"]}
+{"苏州市":["180.101.139.171","49.64.234.126","112.80.38.106","58.210.4.122","222.92.48.26","218.4.55.220","49.75.116.127","58.210.219.66","112.87.42.14","218.4.255.238","121.236.81.66","112.25.180.10","223.166.151.199","223.166.151.197","223.64.74.5","61.151.178.217","49.92.158.58","58.210.233.234","49.72.32.15","180.97.147.133","157.0.165.53","180.106.65.216","49.92.106.254","114.217.67.220","58.211.71.126","61.151.178.163","58.208.3.70","49.75.151.5","221.224.214.35","180.107.26.211","121.239.39.8","49.92.120.119","180.107.207.109","221.224.140.163","122.192.13.147","218.4.91.131","114.218.165.252","49.64.255.66","222.92.73.58","211.143.246.38","223.166.151.191","180.208.58.133","49.73.142.24","58.211.49.69","58.210.98.46","58.210.90.142","114.217.202.41","42.244.62.238","58.210.89.132","58.208.153.168","180.106.238.244","58.211.111.42","221.224.134.178","218.4.136.119","221.224.81.146","58.209.0.164","223.106.11.159","183.211.92.114","14.116.141.79","58.209.249.164","122.193.89.146","117.80.217.172"]}

+ 1 - 1
src/Masuit.MyBlogs.WebApp/App_Data/denyip.txt

@@ -1 +1 @@
-220.181.158.218,220.181.55.144,120.237.57.222,49.72.109.190
+220.181.158.218,220.181.55.144,120.237.57.222,49.72.109.190

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.WebApp/App_Data/mod.txt


+ 30 - 10
src/Masuit.MyBlogs.WebApp/Controllers/SystemController.cs

@@ -234,7 +234,7 @@ namespace Masuit.MyBlogs.WebApp.Controllers
                     var strs = line.Split(' ');
                     CommonHelper.DenyIPRange[strs[0]] = strs[1];
                 }
-                catch (IndexOutOfRangeException e)
+                catch (IndexOutOfRangeException)
                 {
                 }
             }
@@ -310,19 +310,39 @@ namespace Masuit.MyBlogs.WebApp.Controllers
         /// <returns></returns>
         public ActionResult AddToWhiteList(string ip)
         {
-            string ips = System.IO.File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"));
-            List<string> list = ips.Split(',').Where(s => !string.IsNullOrEmpty(s)).ToList();
-            list.Add(ip);
-            System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"), string.Join(",", list.Distinct()), Encoding.UTF8);
-            foreach (var kv in CommonHelper.DenyAreaIP)
+            if (ip.MatchInetAddress())
             {
-                foreach (string item in list)
+                string ips = System.IO.File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"));
+                List<string> list = ips.Split(',').Where(s => !string.IsNullOrEmpty(s)).ToList();
+                list.Add(ip);
+                System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"), string.Join(",", list.Distinct()), Encoding.UTF8);
+                foreach (var kv in CommonHelper.DenyAreaIP)
                 {
-                    CommonHelper.DenyAreaIP[kv.Key].Remove(item);
+                    foreach (string item in list)
+                    {
+                        CommonHelper.DenyAreaIP[kv.Key].Remove(item);
+                    }
                 }
+                System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString(), Encoding.UTF8);
+                return ResultData(null);
             }
-            System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString(), Encoding.UTF8);
-            return ResultData(null);
+            return ResultData(null, false);
+        }
+
+        /// <summary>
+        /// 将IP添加到白名单
+        /// </summary>
+        /// <param name="ip"></param>
+        /// <returns></returns>
+        public ActionResult AddToBlackList(string ip)
+        {
+            if (ip.MatchInetAddress())
+            {
+                CommonHelper.DenyIP += "," + ip;
+                System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyip.txt"), CommonHelper.DenyIP, Encoding.UTF8);
+                return ResultData(null);
+            }
+            return ResultData(null, false);
         }
         #endregion
     }

+ 418 - 343
src/Masuit.MyBlogs.WebApp/ng-views/controllers/analysis.js

@@ -8,60 +8,63 @@
 		$scope.currentPage = 1;
 		var _timeout;
 
-
-		$scope.start=$.nowDate({DD: 0}).substring(0,10);
-		$scope.end=$.nowDate({DD: 1});
+		$scope.start = $.nowDate({
+			DD:0
+		}).substring(0, 10);
+		$scope.end = $.nowDate({
+			DD:1
+		});
 		$("#start").val($scope.start);
 		$("#end").val($scope.end);
 		var start = {
-			format: 'YYYY-MM-DD hh:mm:ss',
-			minDate: '2014-06-16 23:59:59', //设定最小日期为当前日期
-			isinitVal: true,
-			maxDate: $.nowDate({
-				DD: 0
+			format:'YYYY-MM-DD hh:mm:ss',
+			minDate:'2014-06-16 23:59:59', //设定最小日期为当前日期
+			isinitVal:true,
+			maxDate:$.nowDate({
+				DD:0
 			}), //最大日期
-			choosefun: function(elem, datas) {
+			choosefun:function(elem, datas) {
 				end.minDate = datas; //开始日选好后,重置结束日的最小日期
 				end.trigger = false;
 				$("#end").jeDate(end);
-				$scope.start=datas;
+				$scope.start = datas;
 				$("#start").val(datas);
 			},
-			okfun: function(elem, datas) {
+			okfun:function(elem, datas) {
 				end.minDate = datas; //开始日选好后,重置结束日的最小日期
 				end.trigger = false;
 				$("#end").jeDate(end);
-				$scope.start=datas;
+				$scope.start = datas;
 				$("#start").val(datas);
 			}
 		};
 		var end = {
-			format: 'YYYY-MM-DD hh:mm:ss',
-			minDate: $.nowDate({
-				DD: 0
+			format:'YYYY-MM-DD hh:mm:ss',
+			minDate:$.nowDate({
+				DD:0
 			}), //设定最小日期为当前日期
-			isinitVal: true,
-			maxDate: $.nowDate({
-				DD: 1
+			isinitVal:true,
+			maxDate:$.nowDate({
+				DD:1
 			}), //最大日期
-			choosefun: function(elem, datas) {
+			choosefun:function(elem, datas) {
 				start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
-				$scope.end=datas;
+				$scope.end = datas;
 				$("#end").val(datas);
 			},
-			okfun: function(elem, datas) {
+			okfun:function(elem, datas) {
 				start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
-				$scope.end=datas;
+				$scope.end = datas;
 				$("#end").val(datas);
 				self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
 			}
 		}
 		$('#start').jeDate(start);
 		$('#end').jeDate(end);
-		
+
 		$('.field').dropdown({
-			allowAdditions: false,
-			onChange: function(value) {
+			allowAdditions:false,
+			onChange:function(value) {
 				var state = ["OperatingSystem", "UserAgent", "BrowserType", "ISP", "HttpMethod"];
 				state.map(function(item, index, array) {
 					$scope[item] = false;
@@ -73,13 +76,13 @@
 			}
 		});
 		$scope.paginationConf = {
-			currentPage: 1,
-			itemsPerPage: 10,
-			pagesLength: 25,
-			perPageOptions: [1, 5, 10, 15, 20, 30, 40, 50],
-			rememberPerPage: 'perPageItems',
-			onChange: function() {
-				if (_timeout) {
+			currentPage:1,
+			itemsPerPage:10,
+			pagesLength:25,
+			perPageOptions:[1, 5, 10, 15, 20, 30, 40, 50],
+			rememberPerPage:'perPageItems',
+			onChange:function() {
+				if(_timeout) {
 					$timeout.cancel(_timeout);
 				}
 				_timeout = $timeout(function() {
@@ -89,7 +92,7 @@
 			}
 		};
 		$scope.search = function() {
-			if (_timeout) {
+			if(_timeout) {
 				$timeout.cancel(_timeout);
 			}
 			_timeout = $timeout(function() {
@@ -104,25 +107,25 @@
 				end:$scope.end,
 				page,
 				size,
-				distinct: $scope.distinct,
-				search: $scope.query
+				distinct:$scope.distinct,
+				search:$scope.query
 			}).then(function(res) {
-				if (res.data.Data) {
+				if(res.data.Data) {
 					$scope.paginationConf.currentPage = page;
 					$scope.paginationConf.totalItems = res.data.TotalCount;
 					//$("div[ng-table-pagination]").remove();
 					$("#interview").next("div[ng-table-pagination]").remove();
 					self.tableParams = new NgTableParams({
-						count: 50000
+						count:50000
 					}, {
-						filterDelay: 0,
-						dataset: res.data.Data
+						filterDelay:0,
+						dataset:res.data.Data
 					});
 				} else {
 					window.notie.alert({
-						type: 3,
-						text: res.data.Message,
-						time: 4
+						type:3,
+						text:res.data.Message,
+						time:4
 					});
 				}
 				$scope.loadingDone();
@@ -132,7 +135,7 @@
 		$scope.loadingDone();
 		$scope.doDistinct = function() {
 			$scope.distinct = !$scope.distinct;
-			if (_timeout) {
+			if(_timeout) {
 				$timeout.cancel(_timeout);
 			}
 			_timeout = $timeout(function() {
@@ -143,62 +146,64 @@
 		}
 		$scope.analysis = function() {
 			$http.post("/interview/analysis", {
-				uniq: $scope.distinct
+				uniq:$scope.distinct
 			}).then(function(res) {
 				var data = res.data.Data;
-				if (!res.data.Success) {
+				if(!res.data.Success) {
 					window.notie.alert({
-						type: 3,
-						text: res.data.Message,
-						time: 4
+						type:3,
+						text:res.data.Message,
+						time:4
 					});
 					return;
 				}
 				$scope.interview = data;
 				window.echarts.init(document.getElementById('map')).setOption({
-					tooltip: {
-						trigger: 'item'
+					tooltip:{
+						trigger:'item'
 					},
-					visualMap: {
-						min: 0,
-						max: Enumerable.From(data.client).Where(e=>e.name!="XX").Max(e => e.value),
-						left: 'left',
-						top: 'bottom',
-						text: ['高', '低'], // 文本,默认为数值文本
-						calculable: true
+					visualMap:{
+						min:0,
+						max:Enumerable.From(data.client).Where(e => e.name != "XX").Max(e => e.value),
+						left:'left',
+						top:'bottom',
+						text:['高', '低'], // 文本,默认为数值文本
+						calculable:true
 					},
-					series: [
+					series:[
 						{
-							name: '访问量',
-							type: 'map',
-							mapType: 'china',
-							roam: false,
-							label: {
-								normal: {
-									show: true
+							name:'访问量',
+							type:'map',
+							mapType:'china',
+							roam:false,
+							label:{
+								normal:{
+									show:true
 								},
-								emphasis: {
-									show: true
+								emphasis:{
+									show:true
 								}
 							},
-							data: data.client
+							data:data.client
 						}
 					]
 				});
-				var china = ["北京", "天津", "上海", "重庆", "河北", "山西", "辽宁", "吉林", "黑龙江", "江苏", "浙江", "安徽", "福建", "江西", "山东", "河南", "湖北", "湖南", "广东", "海南", "四川", "贵州", "云南", "陕西", "甘肃", "青海", "台湾", "内蒙古", "广西", "西藏", "宁夏", "新疆", "香港", "澳门"];
+				var china = ["北京", "天津", "上海", "重庆", "河北", "山西", "辽宁", "吉林", "黑龙江", "江苏", "浙江", "安徽", "福建", "江西", "山东",
+					"河南", "湖北", "湖南", "广东", "海南", "四川", "贵州", "云南", "陕西", "甘肃", "青海", "台湾", "内蒙古", "广西", "西藏", "宁夏",
+					"新疆", "香港", "澳门"];
 				var sum1 = 0, sum2 = 0;
 				var dril1 = {
-					"name": '中国',
-					"id": '中国',
-					"data": []
+					"name":'中国',
+					"id":'中国',
+					"data":[]
 				};
 				var dril2 = {
-					"name": '海外',
-					"id": '海外',
-					"data": []
+					"name":'海外',
+					"id":'海外',
+					"data":[]
 				};
-				for (var i = 0; i < data.client.length; i++) {
-					if (china.indexOf(data.client[i].name) >= 0) {
+				for(var i = 0; i < data.client.length; i++) {
+					if(china.indexOf(data.client[i].name) >= 0) {
 						sum1 += data.client[i].value;
 						dril1.data.push([data.client[i].name, data.client[i].value]);
 					} else {
@@ -207,60 +212,60 @@
 					}
 				}
 				$('#client').highcharts({
-					chart: {
-						type: 'pie',
-						plotBackgroundColor: null,
-						plotBorderWidth: null,
-						backgroundColor: 'transparent',
-						plotShadow: false
+					chart:{
+						type:'pie',
+						plotBackgroundColor:null,
+						plotBorderWidth:null,
+						backgroundColor:'transparent',
+						plotShadow:false
 					},
-					title: {
-						text: '访问地区统计'
+					title:{
+						text:'访问地区统计'
 					},
-					boost: {
-						useGPUTranslations: true
+					boost:{
+						useGPUTranslations:true
 					},
-					credits: {
-						enabled: false
+					credits:{
+						enabled:false
 					},
-					plotOptions: {
-						series: {
-							dataLabels: {
-								enabled: true,
-								format: '<b>{point.name}</b>: {point.percentage:.2f} % - {point.y}人/次'
+					plotOptions:{
+						series:{
+							dataLabels:{
+								enabled:true,
+								format:'<b>{point.name}</b>: {point.percentage:.2f} % - {point.y}人/次'
 							}
 						}
 					},
-					tooltip: {
-						headerFormat: '<span>{series.name}</span><br>',
+					tooltip:{
+						headerFormat:'<span>{series.name}</span><br>',
 						pointFormat:
 							'<span style="color:{point.color}">{point.name}</span>: <b>{point.percentage:.2f}%</b> - {point.y}</b>人/次<br/>'
 					},
-					series: [{
-						name: '访问地区统计',
-						colorByPoint: true,
-						data: [{
-							name: '中国',
-							y: sum1,
-							drilldown: "中国"
+					series:[{
+						name:'访问地区统计',
+						colorByPoint:true,
+						data:[{
+							name:'中国',
+							y:sum1,
+							drilldown:"中国"
 						}, {
-							name: '海外',
-							y: sum2,
-							drilldown: "海外"
+							name:'海外',
+							y:sum2,
+							drilldown:"海外"
 						}]
 					}],
-					drilldown: {
-						series: [dril1, dril2]
+					drilldown:{
+						series:[dril1, dril2]
 					}
 				});
 				var groups = _.groupBy(data.browser, e => e[0].split(/\d+/)[0]);
 				var series = [], drilldown = [];
-				for (var key in groups) {
+				for(var key in groups) {
 					var sum = 0;
 					var dril = {
-						"name": key,
-						"id": key,
-						"data": []
+						"name":key,
+						"id":key,
+						"data":[]
 					};
 					groups[key].map((item, index) => {
 						sum += item[1];
@@ -268,233 +273,240 @@
 						dril.data.push([item[0], item[1]])
 					});
 					series.push({
-						name: key,
-						y: sum,
-						drilldown: key
+						name:key,
+						y:sum,
+						drilldown:key
 					});
 					drilldown.push(dril);
 				}
 				$('#browser').highcharts({
-					chart: {
-						type: 'pie',
-						plotBackgroundColor: null,
-						plotBorderWidth: null,
-						backgroundColor: 'transparent',
-						plotShadow: false
+					chart:{
+						type:'pie',
+						plotBackgroundColor:null,
+						plotBorderWidth:null,
+						backgroundColor:'transparent',
+						plotShadow:false
 					},
-					title: {
-						text: '浏览器统计'
+					title:{
+						text:'浏览器统计'
 					},
-					boost: {
-						useGPUTranslations: true
+					boost:{
+						useGPUTranslations:true
 					},
-					credits: {
-						enabled: false
+					credits:{
+						enabled:false
 					},
-					plotOptions: {
-						series: {
-							dataLabels: {
-								enabled: true,
-								format: '<b>{point.name}</b>: {point.percentage:.2f} % - {point.y}人/次'
+					plotOptions:{
+						series:{
+							dataLabels:{
+								enabled:true,
+								format:'<b>{point.name}</b>: {point.percentage:.2f} % - {point.y}人/次'
 							}
 						}
 					},
-					tooltip: {
-						headerFormat: '<span>{series.name}</span><br>',
+					tooltip:{
+						headerFormat:'<span>{series.name}</span><br>',
 						pointFormat:
 							'<span style="color:{point.color}">{point.name}</span>: <b>{point.percentage:.2f}%</b> - {point.y}</b>人/次<br/>'
 					},
-					series: [{
-						name: '浏览器类型',
-						colorByPoint: true,
-						data: series
+					series:[{
+						name:'浏览器类型',
+						colorByPoint:true,
+						data:series
 					}],
-					drilldown: {
-						series: drilldown
+					drilldown:{
+						series:drilldown
 					}
 				});
 				$('#alldata').highcharts('StockChart', {
-					credits: {
-						enabled: false
+					credits:{
+						enabled:false
 					},
-					boost: {
-						useGPUTranslations: true
+					boost:{
+						useGPUTranslations:true
 					},
-					rangeSelector: {
-						buttons: [{
-							type: 'day',
-							count: 7,
-							text: '1周'
+					rangeSelector:{
+						buttons:[{
+							type:'day',
+							count:7,
+							text:'1周'
 						}, {
-							type: 'day',
-							count: 15,
-							text: '半个月'
+							type:'day',
+							count:15,
+							text:'半个月'
 						}, {
-							type: 'month',
-							count: 1,
-							text: '1个月'
+							type:'month',
+							count:1,
+							text:'1个月'
 						}, {
-							type: 'month',
-							count: 3,
-							text: '3个月'
+							type:'month',
+							count:3,
+							text:'3个月'
 						}, {
-							type: 'month',
-							count: 6,
-							text: '6个月'
+							type:'month',
+							count:6,
+							text:'6个月'
 						}, {
-							type: 'ytd',
-							text: 'YTD'
+							type:'ytd',
+							text:'YTD'
 						}, {
-							type: 'year',
-							count: 1,
-							text: '1年'
+							type:'year',
+							count:1,
+							text:'1年'
 						}, {
-							type: 'all',
-							count: 1,
-							text: "所有"
+							type:'all',
+							count:1,
+							text:"所有"
 						}],
-						selected: 2,
-						inputEnabled: false
+						selected:2,
+						inputEnabled:false
 					},
-					tooltip: {
-						dateTimeLabelFormats: {
-							millisecond: '%H:%M:%S.%L',
-							second: '%H:%M:%S',
-							minute: '%H:%M',
-							hour: '%H:%M',
-							day: '%Y-%m-%d',
-							week: '%m-%d',
-							month: '%Y-%m',
-							year: '%Y'
+					tooltip:{
+						dateTimeLabelFormats:{
+							millisecond:'%H:%M:%S.%L',
+							second:'%H:%M:%S',
+							minute:'%H:%M',
+							hour:'%H:%M',
+							day:'%Y-%m-%d',
+							week:'%m-%d',
+							month:'%Y-%m',
+							year:'%Y'
 						},
-						formatter: function() {
+						formatter:function() {
 							try {
 								return '时间点:<b>' + Highcharts.dateFormat("%Y-%m-%d", this.points[0].x) + '</b><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[0] + '">直接访问量:<b>' + this.points[0].y +
-								'人/天</b></span><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[39] + '">独立访客量:<b>' + this.points[1].y +
-								'人/天</b></span><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[35] + '">新增独立访客:<b>' + this.points[2].y +
-								'人/天</b></span><br/>'+
-								'<span style="color:' + Highcharts.getOptions().colors[26] + '">跳出率:<b>' + Highcharts.numberFormat(this.points[3].y, 2) +
-								'%</b></span><br/>';
-							} catch (e) {
+									'<span style="color:' + Highcharts.getOptions().colors[0] + '">直接访问量:<b>' +
+									this.points[0].y +
+									'人/天</b></span><br/>' +
+									'<span style="color:' + Highcharts.getOptions().colors[39] + '">独立访客量:<b>' +
+									this.points[1].y +
+									'人/天</b></span><br/>' +
+									'<span style="color:' + Highcharts.getOptions().colors[35] + '">新增独立访客:<b>' +
+									this.points[2].y +
+									'人/天</b></span><br/>' +
+									'<span style="color:' + Highcharts.getOptions().colors[26] + '">跳出率:<b>' +
+									Highcharts.numberFormat(this.points[3].y, 2) +
+									'%</b></span><br/>';
+							} catch(e) {
 								return '时间点:<b>' + Highcharts.dateFormat("%Y-%m-%d", this.points[0].x) + '</b><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[0] + '">直接访问量:<b>' + this.points[0].y +
-								'人/天</b></span><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[39] + '">独立访客量:<b>' + this.points[1].y +
-								'人/天</b></span><br/>' +
-								'<span style="color:' + Highcharts.getOptions().colors[35] + '">新增独立访客:<b>' + this.points[2].y +
-								'人/天</b></span><br/>';
-							} 
+									'<span style="color:' + Highcharts.getOptions().colors[0] + '">直接访问量:<b>' +
+									this.points[0].y +
+									'人/天</b></span><br/>' +
+									'<span style="color:' + Highcharts.getOptions().colors[39] + '">独立访客量:<b>' +
+									this.points[1].y +
+									'人/天</b></span><br/>' +
+									'<span style="color:' + Highcharts.getOptions().colors[35] + '">新增独立访客:<b>' +
+									this.points[2].y +
+									'人/天</b></span><br/>';
+							}
 						},
-						crosshairs: true,
-						shared: true
+						crosshairs:true,
+						shared:true
 					},
-					scrollbar: {
-						enabled: false
+					scrollbar:{
+						enabled:false
 					},
-					title: {
-						text: '历史访客记录走势图'
+					title:{
+						text:'历史访客记录走势图'
 					},
-					xAxis: {
-						type: 'datetime',
-						dateTimeLabelFormats: {
-							millisecond: '%H:%M:%S.%L',
-							second: '%H:%M:%S',
-							minute: '%H:%M',
-							hour: '%H:%M',
-							day: '%m-%d',
-							week: '%m-%d',
-							month: '%Y-%m',
-							year: '%Y'
+					xAxis:{
+						type:'datetime',
+						dateTimeLabelFormats:{
+							millisecond:'%H:%M:%S.%L',
+							second:'%H:%M:%S',
+							minute:'%H:%M',
+							hour:'%H:%M',
+							day:'%m-%d',
+							week:'%m-%d',
+							month:'%Y-%m',
+							year:'%Y'
 						}
 					},
-					yAxis: [
+					yAxis:[
 						{
-							title: {
-								text: '访问量'
+							title:{
+								text:'访问量'
 							},
-							min: 0,
-							opposite: false
+							min:0,
+							opposite:false
 						}, {
-							title: {
-								text: '跳出率(%)'
+							title:{
+								text:'跳出率(%)'
 							},
-							min: 0,
-							max: 100,
-							opposite: true
+							min:0,
+							max:100,
+							opposite:true
 						}
 					],
-					plotOptions: {
-						series: {
-							showInNavigator: true,
-							marker: {
-								enabled: false
+					plotOptions:{
+						series:{
+							showInNavigator:true,
+							marker:{
+								enabled:false
 							}
 						}
 					},
-					series: [{
-						name: '直接访问量',
-						data: data.pv,
-						type: 'areaspline',
-						fillColor: {
-							linearGradient: {
-								x1: 0,
-								y1: 0,
-								x2: 0,
-								y2: 1
+					series:[{
+						name:'直接访问量',
+						data:data.pv,
+						type:'areaspline',
+						fillColor:{
+							linearGradient:{
+								x1:0,
+								y1:0,
+								x2:0,
+								y2:1
 							},
-							stops: [
+							stops:[
 								[0, Highcharts.getOptions().colors[0]],
 								[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
 							]
 						}
 					}, {
-						name: '独立访客量',
-						data: data.uv,
-						type: 'areaspline',
-						fillColor: {
-							linearGradient: {
-								x1: 0,
-								y1: 0,
-								x2: 0,
-								y2: 1
+						name:'独立访客量',
+						data:data.uv,
+						type:'areaspline',
+						fillColor:{
+							linearGradient:{
+								x1:0,
+								y1:0,
+								x2:0,
+								y2:1
 							},
-							stops: [
+							stops:[
 								[0, Highcharts.getOptions().colors[39]],
 								[1, Highcharts.Color(Highcharts.getOptions().colors[39]).setOpacity(0).get('rgba')]
 							]
 						}
 					}, {
-						name: '独立访客',
-						data: data.iv,
-						type: 'areaspline',
-						fillColor: {
-							linearGradient: {
-								x1: 0,
-								y1: 0,
-								x2: 0,
-								y2: 1
+						name:'独立访客',
+						data:data.iv,
+						type:'areaspline',
+						fillColor:{
+							linearGradient:{
+								x1:0,
+								y1:0,
+								x2:0,
+								y2:1
 							},
-							stops: [
+							stops:[
 								[0, Highcharts.getOptions().colors[35]],
 								[1, Highcharts.Color(Highcharts.getOptions().colors[35]).setOpacity(0).get('rgba')]
 							]
 						}
 					}, {
-						name: '跳出率',
-						data: data.BounceRateAggregate,
-						type: 'areaspline',
-						yAxis: 1,
-						fillColor: {
-							linearGradient: {
-								x1: 0,
-								y1: 0,
-								x2: 0,
-								y2: 1
+						name:'跳出率',
+						data:data.BounceRateAggregate,
+						type:'areaspline',
+						yAxis:1,
+						fillColor:{
+							linearGradient:{
+								x1:0,
+								y1:0,
+								x2:0,
+								y2:1
 							},
-							stops: [
+							stops:[
 								[0, Highcharts.getOptions().colors[26]],
 								[1, Highcharts.Color(Highcharts.getOptions().colors[26]).setOpacity(0).get('rgba')]
 							]
@@ -504,35 +516,68 @@
 			});
 		}
 		$scope.analysis();
-		$scope.details= function(id) {
+		$scope.details = function(id) {
 			layer.open({
-			type: 1,
-			zIndex: 20,
-			title: '访客浏览路径',
-			offset: window.screen.height*0.02+"px",
-			area: document.body.clientWidth*0.8+"px",
-			content: $("#modal"),
-			success: function(layero, index) {
-				$scope.request("/interview/InterviewDetails", {id}, function(data) {
-					if (data.Success) {
-						$scope.viewer=data.Data.interview;
-						$scope.viewdetails=data.Data.details;
-						self.ViewDetails = new NgTableParams({
-							count: 10
-						}, {
-							filterDelay: 0,
-							dataset: data.Data.details
+				type:1,
+				zIndex:20,
+				title:'访客浏览路径',
+				offset:window.screen.height * 0.02 + "px",
+				area:document.body.clientWidth * 0.8 + "px",
+				content:$("#modal"),
+				success:function(layero, index) {
+					$scope.request("/interview/InterviewDetails", {
+						id
+					}, function(data) {
+						if(data.Success) {
+							$scope.viewer = data.Data.interview;
+							$scope.viewdetails = data.Data.details;
+							self.ViewDetails = new NgTableParams({
+								count:10
+							}, {
+								filterDelay:0,
+								dataset:data.Data.details
+							});
+						}
+					});
+				},
+				end:function() {
+					$("#modal").css("display", "none");
+				}
+			});
+		}
+		$scope.addToBlackList = function(ip) {
+			swal({
+				title: "确认添加黑名单吗?",
+				text: "将"+ip+"添加到黑名单",
+				showCancelButton: true,
+				confirmButtonColor: "#DD6B55",
+				confirmButtonText: "确定",
+				cancelButtonText: "取消",
+				animation: true,
+				allowOutsideClick: false,
+				showLoaderOnConfirm: true,
+				preConfirm: function () {
+					return new Promise(function (resolve, reject) {
+						$http.post("/system/AddToBlackList", {ip}, {
+							'Content-Type': 'application/x-www-form-urlencoded'
+						}).then(function(res) {
+							resolve(res.data);
+						}, function() {
+							reject("请求服务器失败!");
 						});
-					}
-				});
-			},
-			end: function() {
-				$("#modal").css("display", "none");
-			}
-		});
+					});
+				}
+			}).then(function (data) {
+				if (data.Success) {
+					swal("添加成功",'','success');
+				} else {
+					swal("添加失败",'','error');
+				}
+			}).catch(swal.noop);
 		}
 	}]);
-myApp.controller("searchAnalysis", ["$scope", "$http", "NgTableParams", "$timeout",function($scope, $http, NgTableParams, $timeout) {
+myApp.controller("searchAnalysis", ["$scope", "$http", "NgTableParams", "$timeout",
+	function($scope, $http, NgTableParams, $timeout) {
 		window.hub.disconnect();
 		var self = this;
 		$scope.loading();
@@ -540,25 +585,25 @@ myApp.controller("searchAnalysis", ["$scope", "$http", "NgTableParams", "$timeou
 		$scope.currentPage = 1;
 		var _timeout;
 		$http.post("/search/HotKey").then(function(res) {
-			if (res.data.Success) {
-				$scope.agg=res.data.Data;
+			if(res.data.Success) {
+				$scope.agg = res.data.Data;
 			} else {
 				window.notie.alert({
-					type: 3,
-					text: res.data.Message,
-					time: 4
+					type:3,
+					text:res.data.Message,
+					time:4
 				});
 			}
 		});
 
 		$scope.paginationConf = {
-			currentPage: 1,
-			itemsPerPage: 10,
-			pagesLength: 25,
-			perPageOptions: [1, 5, 10, 15, 20, 30, 40, 50],
-			rememberPerPage: 'perPageItems',
-			onChange: function() {
-				if (_timeout) {
+			currentPage:1,
+			itemsPerPage:10,
+			pagesLength:25,
+			perPageOptions:[1, 5, 10, 15, 20, 30, 40, 50],
+			rememberPerPage:'perPageItems',
+			onChange:function() {
+				if(_timeout) {
 					$timeout.cancel(_timeout);
 				}
 				_timeout = $timeout(function() {
@@ -568,7 +613,7 @@ myApp.controller("searchAnalysis", ["$scope", "$http", "NgTableParams", "$timeou
 			}
 		};
 		$scope.search = function() {
-			if (_timeout) {
+			if(_timeout) {
 				$timeout.cancel(_timeout);
 			}
 			_timeout = $timeout(function() {
@@ -581,52 +626,82 @@ myApp.controller("searchAnalysis", ["$scope", "$http", "NgTableParams", "$timeou
 			$http.post("/search/SearchList", {
 				page,
 				size,
-				search: $scope.query
+				search:$scope.query
 			}).then(function(res) {
-				if (res.data.TotalCount>0) {
+				if(res.data.TotalCount > 0) {
 					$scope.paginationConf.currentPage = page;
 					$scope.paginationConf.totalItems = res.data.TotalCount;
 					//$("div[ng-table-pagination]").remove();
 					$("#interview").next("div[ng-table-pagination]").remove();
 					self.tableParams = new NgTableParams({
-						count: 50000
+						count:50000
 					}, {
-						filterDelay: 0,
-						dataset: res.data.Data
+						filterDelay:0,
+						dataset:res.data.Data
 					});
 				} else {
 					window.notie.alert({
-						type: 3,
-						text: res.data.Message,
-						time: 4
+						type:3,
+						text:res.data.Message,
+						time:4
 					});
 				}
 				$scope.loadingDone();
 			});
 		};
-	self.del = function(row) {
-		swal({
-			title: "确认删除这条记录吗?",
-			text: row.Title,
-			showCancelButton: true,
-			confirmButtonColor: "#DD6B55",
-			confirmButtonText: "确定",
-			cancelButtonText: "取消",
-			showLoaderOnConfirm: true,
-			animation: true,
-			allowOutsideClick: false
-		}).then(function() {
-			$scope.request("/search/delete", {
-				id: row.Id
-			}, function(data) {
-				window.notie.alert({
-					type: 1,
-					text: data.Message,
-					time: 4
+		self.del = function(row) {
+			swal({
+				title:"确认删除这条记录吗?",
+				text:row.Title,
+				showCancelButton:true,
+				confirmButtonColor:"#DD6B55",
+				confirmButtonText:"确定",
+				cancelButtonText:"取消",
+				showLoaderOnConfirm:true,
+				animation:true,
+				allowOutsideClick:false
+			}).then(function() {
+				$scope.request("/search/delete", {
+					id:row.Id
+				}, function(data) {
+					window.notie.alert({
+						type:1,
+						text:data.Message,
+						time:4
+					});
 				});
-			});
-			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-		}, function() {
-		}).catch(swal.noop);
-	}
-}]);
+				self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			}, function() {
+			}).catch(swal.noop);
+		}
+		$scope.addToBlackList = function(ip) {
+			swal({
+				title: "确认添加黑名单吗?",
+				text: "将"+ip+"添加到黑名单",
+				showCancelButton: true,
+				confirmButtonColor: "#DD6B55",
+				confirmButtonText: "确定",
+				cancelButtonText: "取消",
+				animation: true,
+				allowOutsideClick: false,
+				showLoaderOnConfirm: true,
+				preConfirm: function () {
+					return new Promise(function (resolve, reject) {
+						$http.post("/system/AddToBlackList", {ip}, {
+							'Content-Type': 'application/x-www-form-urlencoded'
+						}).then(function(res) {
+							resolve(res.data);
+						}, function() {
+							reject("请求服务器失败!");
+						});
+					});
+				}
+			}).then(function (data) {
+				if (data.Success) {
+					swal("添加成功",'','success');
+				} else {
+					swal("添加失败",'','error');
+				}
+			}).catch(swal.noop);
+		}
+	}]);

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.WebApp/ng-views/controllers/analysis.min.js


+ 27 - 3
src/Masuit.MyBlogs.WebApp/ng-views/controllers/system.js

@@ -458,11 +458,35 @@ myApp.controller("firewall", ["$scope", "$http","NgTableParams","$timeout", func
 		}).catch(swal.noop);
 	}
 	$scope.addToWhiteList= function(ip) {
-		$scope.request("/system/AddToWhiteList", {ip}, function (data) {
-			if(data.Success) {
+		swal({
+			title: "确认添加白名单吗?",
+			text: "将"+ip+"添加到白名单",
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			animation: true,
+			allowOutsideClick: false,
+			showLoaderOnConfirm: true,
+			preConfirm: function () {
+				return new Promise(function (resolve, reject) {
+					$http.post("/system/AddToWhiteList", {ip}, {
+						'Content-Type': 'application/x-www-form-urlencoded'
+					}).then(function(res) {
+						resolve(res.data);
+					}, function() {
+						reject("请求服务器失败!");
+					});
+				});
+			}
+		}).then(function (data) {
+			if (data.Success) {
 				$scope.AreaIPs.remove(ip);
+				swal("添加成功",'','success');
+			} else {
+				swal("添加失败",'','error');
 			}
-		});
+		}).catch(swal.noop);
 	}
 	$scope.searchIP= function(ip) {
 		if (ip) {

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.WebApp/ng-views/controllers/system.min.js


+ 2 - 1
src/Masuit.MyBlogs.WebApp/ng-views/views/analysis/interview.html

@@ -71,8 +71,9 @@
     </div>
     <table ng-table="list.tableParams" id="interview" class="table table-bordered table-hover table-condensed" ng-form="list.tableForm" disable-filter="list.isAdding" tracked-table="list.tableTracker">
         <tr ng-repeat="row in $data" ng-form="rowForm" tracked-table-row="row">
-            <td title="'IP'" filter="{IP: 'text'}" sortable="'IP'">
+            <td title="'IP'" filter="{IP: 'text'}" sortable="'IP'" style="width: 250px">
                 <a ng-href="/tools/ip?ip={{row.IP}}" target="_blank" style="font-size: 20px;" data-microtip="查看{{row.IP}}的详细信息" data-microtip-position="bottom">{{row.IP}}</a>
+                <button class="badge btn btn-primary pull-right" ng-click="addToBlackList(row.IP)">黑名单</button>
             </td>
             <td title="'用户代理'" filter="{UserAgent: 'text'}" sortable="'UserAgent'" ng-if="UserAgent">
                 {{row.UserAgent}}

+ 1 - 0
src/Masuit.MyBlogs.WebApp/ng-views/views/analysis/search.html

@@ -35,6 +35,7 @@
             </td>
             <td title="'客户端IP'" filter="{IP: 'text'}" sortable="'IP'">
                 <a ng-href="/tools/ip?ip={{row.IP}}" target="_blank" style="font-size: 20px;" data-microtip="查看{{row.IP}}的详细信息" data-microtip-position="bottom">{{row.IP}}</a>
+                <button class="badge btn btn-primary pull-right" ng-click="addToBlackList(row.IP)">黑名单</button>
             </td>
             <td title="'操作'" style="width: 185px;">
                 <button class="btn btn-danger btn-sm waves-effect" ng-click="list.del(row)">

+ 1 - 0
src/Masuit.MyBlogs.WebApp/ng-views/views/system/firewall.html

@@ -61,6 +61,7 @@
         <tr ng-form="rowForm" ng-repeat="row in $data" tracked-table-row="row">
             <td filter="{IP: 'text'}" sortable="'IP'" title="'IP'">
                 <a data-microtip="查看{{row.IP}}的详细信息" data-microtip-position="bottom" ng-href="/tools/ip?ip={{row.IP}}" style="font-size: 20px;" target="_blank">{{row.IP}}</a>
+                <button class="badge btn btn-primary pull-right" ng-click="addToWhiteList(row.IP)">添加到白名单</button>
             </td>
             <td filter="{RequestUrl: 'text'}" sortable="'RequestUrl'" title="'请求URL'">
                 <a ng-href="{{row.RequestUrl}}" target="_blank">{{row.RequestUrl}}</a>

Some files were not shown because too many files changed in this diff