You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
394 lines
11 KiB
394 lines
11 KiB
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>文件更新控制台</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="./static/css/bootstrap.css">
|
|
<link rel="icon" type="image/x-icon" href="/favicon.ico?v=2">
|
|
<script type="text/javascript" src="./static/js/jquery.min.js"></script>
|
|
<script type="text/javascript" src="./static/js/bootstrap.min.js"></script>
|
|
<style>
|
|
.list-group>.list-group-item {
|
|
padding: 20px;
|
|
}
|
|
|
|
.optzone {
|
|
height: 60px;
|
|
}
|
|
|
|
.stabox {
|
|
height: 260px;
|
|
overflow: scroll;
|
|
}
|
|
|
|
.flist {
|
|
height: 360px;
|
|
overflow: auto;
|
|
}
|
|
|
|
.icon {
|
|
display: inline-block;
|
|
width: 24px;
|
|
height: 24px;
|
|
}
|
|
|
|
.icon:hover {
|
|
cursor: pointer;
|
|
background-color: #da1616;
|
|
}
|
|
|
|
.hsval {
|
|
font-size: 10px;
|
|
margin-left: 16px;
|
|
}
|
|
|
|
.folder-icon {
|
|
mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyAgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pZFlNaWQgbWVldCcgIHZpZXdCb3g9IjAgMCAyNCAyNCIgPjxwYXRoIGQ9Ik0xMCA0SDRDMi45IDQgMiA0LjkgMiA2VjE4QzIgMTkuMSAyLjkgMjAgNCAyMEgyMEMyMS4xIDIwIDIyIDE5LjEgMjIgMThWOEMyMiA2LjkgMjEuMSA2IDIwIDZIMTJMMTAgNFoiIC8+PC9zdmc+");
|
|
-webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDov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wIDIxLjEgMjAgMjBWOEwxNCAyTTEzIDlWMy41TDE4LjUgOUgxM1oiIC8+IDwvc3ZnPg==");
|
|
background-repeat: no-repeat;
|
|
background-color: #0e0b8b;
|
|
}
|
|
|
|
#rstatus {
|
|
height: 360px;
|
|
overflow-y: auto;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="jumbotron">
|
|
<div class="container">
|
|
<p>文件更新控制台</p>
|
|
<p>ver:3.04</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 输入服务器ip -->
|
|
<div class="container">
|
|
|
|
<div class="form-group col-md-6">
|
|
<div class="input-group">
|
|
<div class="input-group-addon">服务器ip</div>
|
|
<input type="text" class="form-control" name="sip" id="scip" placeholder="eg:192.168.66.99">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="input-group">
|
|
<div class="input-group-addon">监视目录</div>
|
|
<input type="text" class="form-control" name="sdir" placeholder="eg :/www/wwwroot/aa_com/" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<button type="button" id="entsip" class="btn btn-primary">查看信息</button>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 罗列文件的列表信息 -->
|
|
<div class="container">
|
|
<!-- 源服务器 -->
|
|
<div class="col-md-12">
|
|
<div class="panel panel-default">
|
|
<!-- Default panel contents -->
|
|
<div class="panel-heading">源站(192.168.66.100)</div>
|
|
<div class="panel-body">
|
|
<p>监听目录:/www</p>
|
|
<p>相对目录: /app/common </p>
|
|
</div>
|
|
|
|
<!-- List group -->
|
|
<ul class="list-group" id="scsc">
|
|
<li class="list-group-item optzone">
|
|
<div class="col-md-10">
|
|
<input type="checkbox" name="sfiles" />
|
|
<span class="icon folder-icon"></span>
|
|
<a href="#">涨涨</a>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<a href="#" class="btn btn-primary btn-sm">同步</a>
|
|
<a href="#" class="btn btn-success btn-sm">复制</a></a>
|
|
</div>
|
|
</li>
|
|
<li class="list-group-item optzone">
|
|
<div class="col-md-10">
|
|
<input type="checkbox" name="sfiles" />
|
|
<span class="icon file-icon"></span>
|
|
<a href="#">fa.php</a>
|
|
<span class="hsval">HASh:98986</span>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<a href="#" class="btn btn-primary btn-sm">同步</a>
|
|
<a href="#" class="btn btn-success btn-sm">复制</a></a>
|
|
</div>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<!-- 目标服务器 -->
|
|
<div class="container">
|
|
<!-- 目标的服务器信息 -->
|
|
<div class="form-group col-md-6">
|
|
<div class="input-group">
|
|
<div class="input-group-addon">服务器ip</div>
|
|
<input type="text" class="form-control" name="tsip" id="tcip" placeholder="eg:192.168.66.99">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="input-group">
|
|
<div class="input-group-addon">监视目录</div>
|
|
<input type="text" class="form-control" name="tsdir" id="" placeholder="eg :/www/wwwroot/aa_com/" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<button type="button" id="tentsip" class="btn btn-primary">查看信息</button>
|
|
</div>
|
|
<!-- 目标服务器 -->
|
|
<div class="col-md-12">
|
|
<div class="panel panel-default">
|
|
<!-- Default panel contents -->
|
|
<div class="panel-heading" id="mbip">目标服务器</div>
|
|
<div class="panel-body">
|
|
<p>监听目录:<span id="sc01"></span></p>
|
|
<p>相对目录: <span id="sc02"></span> </p>
|
|
</div>
|
|
|
|
<!-- List group -->
|
|
<ul class="list-group" id="tgsc">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 状态信息 -->
|
|
<div class="container">
|
|
<div class="col-md-12">
|
|
<p>1、获取远程服务器的文件信息,2、校验hash值3、枚举出所有hash不同的文件4、勾选文件更新即可5、根据勾选的文件制作更新zip文件,发送到目标服务器。文件的参考HASH值,如何同步到几个平台?</p>
|
|
</div>
|
|
<div class="panel">
|
|
<div class="panel-heading">运行状态</div>
|
|
<div class="panel-body">
|
|
<ul class="list-group" id="rstatus"></ul>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var chkall = true;
|
|
var chknum = 0;
|
|
var scip = ""; //目标服务器ip
|
|
var urlpath = ".";// 当前的操作目录
|
|
|
|
$(function () {
|
|
// read sessionStorage
|
|
var oscip = sessionStorage.getItem("scip");
|
|
if (oscip != "") {
|
|
$("#scip").val(oscip);
|
|
scip = oscip;
|
|
$("input[name='serverip']").val(oscip);
|
|
}
|
|
|
|
// click function SOURCE SERVER
|
|
$("#entsip").on("click", function () {
|
|
scfs();
|
|
})
|
|
|
|
|
|
// 目标服务器的文件信息
|
|
var scfs = function () {
|
|
//
|
|
scip = $("input[name='sip']").val();
|
|
// ip storage
|
|
sessionStorage.setItem("scip", scip);
|
|
//监视目录
|
|
var jsdir = $("input[name='sdir']").val();
|
|
if (jsdir != '') {
|
|
urlpath = encodeURIComponent(btoa(jsdir));
|
|
}
|
|
//
|
|
var html = "<li class=\"list-group-item\">输入目标服务器" + scip + "</li>";
|
|
$("#mbip").text("源站(" + scip + ")");
|
|
// 获取信息
|
|
gescinfo("#scsc",scip);
|
|
//
|
|
$("#rstatus").append(html);
|
|
}
|
|
|
|
// button click function for TARGET SERVER
|
|
$("#tentsip").on("click", function () {
|
|
tgfs();
|
|
})
|
|
|
|
// 目标服务器的文件信息
|
|
var tgfs = function () {
|
|
//
|
|
scip = $("input[name='tsip']").val();
|
|
// ip storage
|
|
sessionStorage.setItem("scip", scip);
|
|
//监视目录
|
|
var jsdir = $("input[name='tsdir']").val();
|
|
if (jsdir != '') {
|
|
urlpath = encodeURIComponent(btoa(jsdir));
|
|
}
|
|
//
|
|
var html = "<li class=\"list-group-item\">输入目标服务器" + scip + "</li>";
|
|
// 目标站
|
|
$("#mbip").text("目标站(" + scip + ")");
|
|
// 获取信息
|
|
gescinfo("#tgsc",scip);
|
|
//
|
|
$("#rstatus").append(html);
|
|
}
|
|
|
|
// 获取目标服务器的信息
|
|
var gescinfo = function (elemnt,scip) {
|
|
// 客户端的状态地址
|
|
var url = "http://" + scip + ":9099/sc?p=" + urlpath.replace("/\\/g", "\/");
|
|
//
|
|
var html = "";
|
|
$.getJSON(url, function (res) {
|
|
// res.curdir
|
|
$.each(res.data.list, function (k, v) {
|
|
html += "<li class=\"list-group-item optzone\"><div class=\"col-md-10\">";
|
|
if (v.dirflag) {
|
|
html += "<span class=\"icon folder-icon\"></span>" + v.fname + "</div>";
|
|
} else {
|
|
html += "<span class=\"icon file-icon\"></span>" + v.fname +
|
|
"<span class=\"hsval\">HASH:" + v.hash + "</span></div>";
|
|
}
|
|
|
|
if (v.isbackup == 1) {
|
|
html += "<div class=\"col-md-2\"><a href=\"#\" class=\"btn btn-warning btn-sm\">恢复</a></div>";
|
|
} else {
|
|
html += "<div class=\"col-md-2\"></div>";
|
|
}
|
|
|
|
html += "</li>";
|
|
})
|
|
// append to html
|
|
// $("#tgsc").html(html)
|
|
$(elemnt).html(html);
|
|
writelog(scip + "获取数据:" + res.data.list.length + "条数据")
|
|
// 客户端监控目录
|
|
$("#sc01").text(res.workdir);
|
|
|
|
$("#sc02").text(dbsresp(res.curdir));
|
|
});
|
|
}
|
|
|
|
// write log
|
|
var writelog = function (html) {
|
|
var hprex = "<li class=\"list-group-item\">" + html + "</li>";
|
|
$("#rstatus").append(hprex);
|
|
}
|
|
|
|
|
|
//同步文件
|
|
$(".gsbtn").on("click", function () {
|
|
var ff = $(this).attr("fid");
|
|
var fpa = $(this).attr("fpa");
|
|
// build post body
|
|
var param = { sip: scip, bfile: ff, bpath: fpa }
|
|
// do post
|
|
$.post("./sup", param, function (res) {
|
|
if (res.status == '200') {
|
|
alert("操作成功");
|
|
}
|
|
});
|
|
return false;
|
|
})
|
|
|
|
|
|
|
|
//全选按钮设置点击事件
|
|
$("#slall").click(function () {
|
|
//1、循环设置其它多选框选中状态,跟标识用的变量一样
|
|
$(".mfile").prop("checked", chkall);
|
|
// down button toggle
|
|
if (chkall || chknum > 2) {
|
|
$("#tropt").show()
|
|
chknum += 1
|
|
} else {
|
|
$("#tropt").hide()
|
|
chknum -= 1
|
|
}
|
|
//2、标识的变量取反
|
|
chkall = !chkall;
|
|
})
|
|
|
|
//同步操作
|
|
$("#sybtn").on("click", function () {
|
|
var ttsip = $("input[name='serverip']").val();
|
|
if (ttsip == "") {
|
|
alert("老天鹅,你还没填写目标服务器地址。");
|
|
} else {
|
|
$("#hscip").val(scip);
|
|
// 提交表单
|
|
$(".form-inline").submit();
|
|
}
|
|
|
|
});
|
|
|
|
// 勾选是否同步的选项
|
|
$("#sw_sybtn").on("click", function () {
|
|
let swval = $(this).has("checked").val();
|
|
// 设置相反的值
|
|
alert(swval);
|
|
});
|
|
|
|
//base64 编码防止请求错误
|
|
var bsrqst = function (path) {
|
|
return encodeURIComponent(btoa(path));
|
|
}
|
|
//解码base64
|
|
var dbsresp = function (bsStr) {
|
|
console.log("respone base64 string ",bsStr)
|
|
if(bsStr=="."){
|
|
return "."
|
|
}else{
|
|
return decodeURIComponent(atob(bsStr))
|
|
}
|
|
}
|
|
|
|
// 另外的base64的解码
|
|
function safeAtob(base64Str) {
|
|
// 检查输入字符串是否是有效的Base64编码
|
|
const base64Regex = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
if (!base64Regex.test(base64Str)) {
|
|
throw new Error('The string to be decoded is not correctly encoded.');
|
|
}
|
|
|
|
// 如果输入字符串长度不是4的倍数,添加等号'='
|
|
while (base64Str.length % 4 !== 0) {
|
|
base64Str += '=';
|
|
}
|
|
|
|
return atob(base64Str);
|
|
}
|
|
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|