123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- myApp.controller("file", ["$scope", "$http", function ($scope, $http) {
- }]);
- myApp.controller("task", ["$scope", "$http", function ($scope, $http) {
- }]);
- myApp.controller("dashboard", ["$scope", function ($scope) {
- }]);
- myApp.controller("system", ["$scope", "$http", function($scope, $http) {
- $scope.request("/system/getsettings", null, function(data) {
- var settings = {};
- Enumerable.From(data.Data).Select(e => {
- return {
- name: e.Name,
- value: e.Value
- }
- }).Distinct().ToArray().map(function(item, index, array) {
- settings[item.name] = item.value;
- });
- $scope.Settings = settings;
- });
- $scope.uploadImage = function() {
-
- $("#setImageForm").ajaxSubmit({
- url: "/Upload",
- type: "post",
- success: function(data) {
-
- document.getElementById("setImageForm").reset();
- $scope.$apply(function () {
- $scope.Settings[$scope.property] = data.Data;
- });
- layer.closeAll();
- }
- });
- };
- $scope.setImage = function(property) {
- layer.open({
- type: 1,
- zIndex: 20,
- title: '请选择一张图片',
- area: '420px', //宽高
- content: $("#setImageForm"),
- cancel: function(index, layero) {
- return true;
- }
- });
- $scope.property=property;
- }
- $scope.save = function() {
- swal({
- title: '确认保存吗?',
- type: 'warning',
- showCloseButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- showLoaderOnConfirm: true,
- animation: true,
- allowOutsideClick: false,
- preConfirm: function() {
- return new Promise(function(resolve, reject) {
- var result = [];
- for (var key in $scope.Settings) {
- if ($scope.Settings.hasOwnProperty(key)) {
- result.push({
- Name: key,
- Value: $scope.Settings[key]
- });
- }
- }
- $http.post("/system/save", {
- sets: JSON.stringify(result)
- }, {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }).then(function(res) {
- resolve(res.data);
- }, function() {
- reject("请求服务器失败!");
- });
- });
- }
- }).then(function(data) {
- swal({
- type: data.Success ? "success" : "error",
- text: data.Message
- });
- }).catch(swal.noop);
- }
- $scope.mailtest= function() {
- $http.post("/system/mailtest", {
- smtp: $scope.Settings.SMTP,
- user: $scope.Settings.EmailFrom,
- pwd: $scope.Settings.EmailPwd,
- port: $scope.Settings.SmtpPort,
- to: $scope.Settings.ReceiveEmail,
- ssl:$scope.Settings.EnableSsl
- }).then(function(res) {
- if (res.data.Success) {
- swal(res.data.Message,'','success');
- } else {
- swal({
- input: 'textarea',
- showCloseButton: true,
- width: 800,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- inputValue: res.data.Message,
- inputClass: "height700"
- });
- }
- }, function() {
- swal('服务请求失败','','error');
- }).catch(swal.noop);
- }
- $scope.pathtest = function() {
- $http.post("/system/pathtest", {
- path: $scope.Settings.PathRoot
- }).then(function(res) {
- if (res.data.Success) {
- swal(res.data.Message,'','success');
- } else {
- swal({
- input: 'textarea',
- showCloseButton: true,
- width: 800,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- inputValue: res.data.Message,
- inputClass: "height700"
- });
- }
- }, function() {
- swal('服务请求失败','','error');
- }).catch(swal.noop);
- }
- $scope.EmailEnableSsl= function() {
- if($scope.Settings.EnableSsl=="true") {
- $scope.Settings.EnableSsl="false";
- } else {
- $scope.Settings.EnableSsl="true";
- }
- }
- $scope.EnableDonate= function() {
- if($scope.Settings.EnableDonate=="true") {
- $scope.Settings.EnableDonate="false";
- } else {
- $scope.Settings.EnableDonate="true";
- }
- }
- $scope.CloseSite= function() {
- if($scope.Settings.CloseSite=="true") {
- $scope.Settings.CloseSite="false";
- } else {
- swal({
- title: '确定要关闭站点么?',
- text: "一旦关闭,所有前台功能将不再可用!所有前台访问将会被重定向到:/ComingSoon",
- type: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- }).then(function(isConfirm) {
- if (isConfirm) {
- $scope.Settings.CloseSite = "true";
- $scope.$apply();
- }
- });
- }
- }
- $scope.DataReadonly= function() {
- if($scope.Settings.DataReadonly=="true") {
- $scope.Settings.DataReadonly="false";
- } else {
- swal({
- title: '确定要开启站点写保护么?',
- text: "一旦开启,前台所有表单数据将无法被提交!",
- type: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- }).then(function(isConfirm) {
- if (isConfirm) {
- $scope.Settings.DataReadonly = "true";
- $scope.$apply();
- }
- });
- }
- }
- }]);
- myApp.controller("log", ["$scope", function ($scope) {
- $scope.getfiles= function() {
- $scope.request("/dashboard/GetLogfiles", null, function(data) {
- $scope.files = data.Data;
- });
- }
- $scope.getfiles();
- $scope.view= function(file) {
- $scope.request("/dashboard/catlog", { filename: file }, function (data) {
- swal({
- input: 'textarea',
- showCloseButton: true,
- width: 1000,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- inputValue: data.Data,
- inputClass:"height700"
- });
- });
- }
- $scope.delete= function(file) {
- swal({
- title: '确定删除吗?',
- type: 'warning',
- showCancelButton: true,
- showCloseButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- preConfirm: function() {
- return new Promise(function (resolve) {
- $scope.request("/dashboard/deletefile", { filename: file }, function (res) {
- $scope.getfiles();
- resolve(res.Message);
- });
- });
- }
- }).then(function (msg) {
- swal(
- msg,
- '',
- 'success'
- );
- }).catch(swal.noop);
- }
- }]);
- myApp.controller("email", ["$scope", "$http", function ($scope) {
- $scope.getfiles = function () {
- $scope.request("/file/Getfiles", {path:"/template"}, function (data) {
- $scope.files = data.Data;
- });
- }
- $scope.getfiles();
- $scope.view = function (file) {
- $scope.request("/file/read", { filename: file }, function (data) {
- swal({
- input: 'textarea',
- showCloseButton: true,
- width: 1000,
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputValue: data.Data,
- inputClass: "height700",
- preConfirm: function (value) {
- return new Promise(function (resolve, reject) {
- if (value) {
- $scope.request("/file/save", { filename: file, content: value }, function (res) {
- if (res.Success) {
- resolve(res.Message);
- } else {
- reject(res.Message);
- }
- });
- } else {
- reject('请输入内容');
- }
- });
- }
- }).then(function (msg) {
- swal(
- msg,
- '',
- 'success'
- );
- }).catch(swal.noop);
- });
- }
- }]);
- myApp.controller("firewall", ["$scope", "$http","NgTableParams","$timeout", function ($scope, $http,NgTableParams,$timeout) {
- var self = this;
- var data = [];
- self.data = {};
- $scope.request("/system/getsettings", null, function(data) {
- var settings = {};
- Enumerable.From(data.Data).Select(e => {
- return {
- name: e.Name,
- value: e.Value
- }
- }).Distinct().ToArray().map(function(item, index, array) {
- settings[item.name] = item.value;
- });
- $scope.Settings = settings;
- });
- this.load = function() {
- $scope.request("/system/InterceptLog", null, function(res) {
- self.tableParams = new NgTableParams({}, {
- filterDelay: 0,
- dataset: res.Data.list
- });
- data = res.Data.list;
- $scope.interceptCount=res.Data.interceptCount;
- $scope.ranking=res.Data.ranking;
- });
- }
- self.load();
- this.clear= function() {
- swal({
- title: '确定清空拦截日志吗?',
- type: 'warning',
- showCancelButton: true,
- showCloseButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- preConfirm: function() {
- return new Promise(function (resolve) {
- $scope.request("/system/ClearInterceptLog", null, function (res) {
- resolve(res.Message);
- });
- });
- }
- }).then(function (msg) {
- swal(msg,'','success');
- self.load();
- }).catch(swal.noop);
- }
- $scope.EnableFirewall= function() {
- if($scope.Settings.FirewallEnabled=="true") {
- swal({
- title: '确定要关闭网站防火墙么?',
- text: "一旦关闭,网站将面临可能会被流量攻击的风险!",
- type: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- }).then(function(isConfirm) {
- if (isConfirm) {
- $scope.Settings.FirewallEnabled="false";
- $scope.$apply();
- }
- });
- } else {
- $scope.Settings.FirewallEnabled="true";
- }
- }
- $scope.getIPBlackList= function() {
- $scope.request("/system/IpBlackList",null, function (data) {
- swal({
- title:"编辑全局IP黑名单",
- text:"多个IP之间用英文逗号分隔",
- input: 'textarea',
- showCloseButton: true,
- width: 1000,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- inputValue: data.Data,
- inputClass:"height700",
- showLoaderOnConfirm: true,
- preConfirm: function(value) {
- return new Promise(function (resolve) {
- $scope.request("/system/SetIpBlackList", { content: value }, function (res) {
- resolve(res.Message);
- });
- });
- }
- }).then(function (msg) {
- swal("更新成功",'','success');
- }).catch(swal.noop);
- });
- }
- $scope.getIPWhiteList= function() {
- $scope.request("/system/IpWhiteList",null, function (data) {
- swal({
- title:"编辑全局IP白名单",
- text:"多个IP之间用英文逗号分隔",
- input: 'textarea',
- showCloseButton: true,
- width: 1000,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- inputValue: data.Data,
- inputClass:"height700",
- showLoaderOnConfirm: true,
- preConfirm: function(value) {
- return new Promise(function (resolve) {
- $scope.request("/system/SetIpWhiteList", { content: value }, function (res) {
- resolve(res.Message);
- });
- });
- }
- }).then(function (msg) {
- swal("更新成功",'','success');
- }).catch(swal.noop);
- });
- }
- $scope.getIPRangeBlackList= function() {
- $scope.request("/system/GetIPRangeBlackList",null, function (data) {
- swal({
- title:"编辑IP地址段黑名单",
- text:"每行一条地址段,起始地址和结束地址用空格分隔开,其余信息也用空格分隔开",
- input: 'textarea',
- showCloseButton: true,
- width: 1000,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- inputValue: data.Data,
- inputClass:"height700",
- showLoaderOnConfirm: true,
- preConfirm: function(value) {
- return new Promise(function (resolve) {
- $scope.request("/system/SetIPRangeBlackList", { content: value }, function (res) {
- resolve(res.Message);
- });
- });
- }
- }).then(function (msg) {
- swal("更新成功",'','success');
- }).catch(swal.noop);
- });
- }
- $scope.save = function() {
- swal({
- title: '确认保存吗?',
- type: 'warning',
- showCloseButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- showLoaderOnConfirm: true,
- animation: true,
- allowOutsideClick: false,
- preConfirm: function() {
- return new Promise(function(resolve, reject) {
- var result = [];
- for (var key in $scope.Settings) {
- if ($scope.Settings.hasOwnProperty(key)) {
- result.push({
- Name: key,
- Value: $scope.Settings[key]
- });
- }
- }
- $http.post("/system/save", {
- sets: JSON.stringify(result)
- }, {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }).then(function(res) {
- resolve(res.data);
- }, function() {
- reject("请求服务器失败!");
- });
- });
- }
- }).then(function(data) {
- swal({
- type: data.Success ? "success" : "error",
- text: data.Message
- });
- }).catch(swal.noop);
- }
- $scope.addToWhiteList= 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/AddToWhiteList", {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);
- }
- $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);
- }
- }]);
- myApp.controller("sendbox", ["$scope", "$http", function ($scope, $http) {
- $http.post("/system/sendbox").then(function (res) {
- $scope.Mails = res.data;
- });
- $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);
- }
- }]);
|