mirror of https://github.com/IoTcat/ushio-user.git
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.
250 lines
13 KiB
250 lines
13 KiB
<!DOCTYPE HTML> |
|
<!-- |
|
Eventually by HTML5 UP |
|
html5up.net | @ajlkn |
|
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) |
|
--> |
|
<html> |
|
<head> |
|
<title>Ushio User</title> |
|
<meta charset="utf-8" /> |
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> |
|
<link rel="stylesheet" href="https://cdn.yimian.xyz/ushio-user/assets/css/main.css" /> |
|
<script type="text/javascript">block_aplayer = true;lang = ['en', 'zh'];</script> |
|
<script src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script> |
|
<script type="text/javascript">page.auth = ['nickname']; page.proj = 'iotcat/ushio-user';</script> |
|
</head> |
|
<body class="is-preload"> |
|
|
|
<!-- Header --> |
|
<header id="header"> |
|
|
|
<h1 id="nickname"><span class=".zh">加载中..</span><span class=".en">Loading...</span></h1> |
|
<p><strong><span class=".zh">账户id</span><span class=".en">Uid</span>: </strong><span id="uid"></span></p> |
|
<p><strong><span class=".zh">邮箱</span><span class=".en">Email</span>: </strong><span id="email"></span></p> |
|
<p><strong><span class=".zh">手机号</span><span class=".en">Tel</span>: </strong><span id="tel"></span></p> |
|
<p><strong><span class=".zh">分组</span><span class=".en">Group</span>: </strong><span id="group"></span></p> |
|
<p><strong><span class=".zh">语言</span><span class=".en">Language</span>: </strong><span id="lang"></span></p> |
|
<p><strong><span class=".zh">本设备fp指纹</span><span class=".en">fp of this device</span>: </strong><span id="fp"></span></p> |
|
<p><strong><span class=".zh">设备</span><span class=".en">Devices</span>: </strong><span id="devices"></span></p> |
|
|
|
</header> |
|
|
|
|
|
|
|
<!-- Signup Form --> |
|
<form id="signup-form" method="post" action="#"> |
|
|
|
<button id="update" style="display: none"><span class=".zh">更新信息</span><span class=".en">Update</span></button> <button id="logout" style="display: none" onClick="window.location.href='https://login.yimian.xyz/logout.html'"><span class=".zh">退出登录</span><span class=".en">Logout</span></button> |
|
</form> |
|
|
|
|
|
<!-- Footer --> |
|
<footer id="footer"> |
|
|
|
<ul class="copyright"> |
|
<li>© 2018-<script type="text/javascript">document.write(new Date().getFullYear())</script> <a href="https://iotcat.me">iotcat</a></li><li>Powered by <a href="https://ushio.yimian.xyz">Ushio</a></li><li>Credits: <a href="http://html5up.net">HTML5 UP</a></li> |
|
</ul> |
|
</footer> |
|
|
|
<!-- Scripts --> |
|
<script src="https://cdn.yimian.xyz/ushio-user/assets/js/main.js"></script> |
|
<script type="text/javascript" src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script> |
|
<script type="text/javascript"> |
|
function findMost (arr) { |
|
if (!arr.length) return []; |
|
//if (arr.length === 1) return 1; |
|
let res = {}; |
|
let arrr = []; |
|
// 遍历数组 |
|
arr.forEach((item) => { |
|
res[item] ? res[item] += 1 : res[item] = 1; |
|
}) |
|
Object.keys(res).forEach(ii=>{ |
|
let ob = {}; |
|
ob.name = ii; |
|
ob.num = res[ii]; |
|
arrr.push(ob); |
|
}); |
|
let o = arrr.sort(function(a, b){ |
|
return b.num - a.num; |
|
}); |
|
return o; |
|
} |
|
|
|
session.onload(async function(){ |
|
$('#nickname').html(session.get('nickname')); |
|
$('#uid').html(session.get('uid')); |
|
$('#tel').html(session.get('tel')); |
|
$('#email').html(session.get('email')); |
|
$('#group').html(session.get('group')); |
|
$('#fp').html(await fp); |
|
$('#lang').html(((session.get('lang'))?atob(session.get('lang')):'')); |
|
$('#update').show(); |
|
$('#logout').show(); |
|
$.get('https://auth.yimian.xyz/getOnlineDevices.php?hash='+session.get('hash'), function(res){ |
|
var devicess = ''; |
|
var events = []; |
|
var f; |
|
for(var item of res){ |
|
if(page.tran.getLang() == 'zh'){ |
|
devicess += ' <button id="DEV'+item.fp+'">'+item.fp+'</button>'; |
|
events.push(item); |
|
f = function(item){$('#DEV'+item.fp).click(function(){ |
|
var totalSession = 0; |
|
var domains = []; |
|
for(var l of item.log){ |
|
if(l.sessiontime){ |
|
totalSession += Number(l.sessiontime); |
|
} |
|
domains.push(l.domain); |
|
} |
|
var domainss = ''; |
|
domains = findMost(domains); |
|
for(var i of domains){ |
|
domainss += i.name+'('+i.num+') '; |
|
}; |
|
tips.question({ |
|
timeout: 20000, |
|
close: false, |
|
overlay: true, |
|
displayMode: 'once', |
|
//id: 'question', |
|
zindex: 999, |
|
title: '设备管理', |
|
message: '<b>fp: </b>'+item.fp+'<br><b>ip: </b>'+item.ip+'<br><b>初次登录: </b>'+new Date(item.created_at+' UTC').toLocaleString()+'<br><b>最近登录: </b>'+new Date(item.updated_at+' UTC').toLocaleString()+'<br><b>最近访问: </b>'+new Date(item.log[item.log.length-1].timestamp+' UTC').toLocaleString()+'<br><b>设备类型: </b>'+item.log[item.log.length-1].platform+'<br><b>时区: </b>'+item.log[item.log.length-1].timezone+'<br><b>总访问次数: </b>'+item.log.length+'<br><b>总访问时长: </b>'+Math.ceil(+totalSession/60)+'分钟<br><b>访问站点: </b>'+domainss, |
|
position: 'center', |
|
buttons: [ |
|
['<button><b>登出这台设备</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
$.get('https://auth.yimian.xyz/logoutDevices.php?hash='+session.get('hash')+'&token='+item.token, function(res){ |
|
if(res.status){ |
|
alert('设备解绑成功!'); |
|
window.location.reload(); |
|
} |
|
}); |
|
}, true], |
|
['<button><b>关闭</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
}, true], |
|
] |
|
}); |
|
}); |
|
} |
|
}else{ |
|
devicess += ' <button id="DEV'+item.fp+'">'+item.fp+'</button>'; |
|
events.push(item); |
|
f = function(item){$('#DEV'+item.fp).click(function(){ |
|
var totalSession = 0; |
|
var domains = []; |
|
for(var l of item.log){ |
|
if(l.sessiontime){ |
|
totalSession += Number(l.sessiontime); |
|
} |
|
domains.push(l.domain); |
|
} |
|
var domainss = ''; |
|
domains = findMost(domains); |
|
for(var i of domains){ |
|
domainss += i.name+'('+i.num+') '; |
|
}; |
|
tips.question({ |
|
timeout: 20000, |
|
close: false, |
|
overlay: true, |
|
displayMode: 'once', |
|
//id: 'question', |
|
zindex: 999, |
|
title: 'Device Mangement', |
|
message: '<b>fp: </b>'+item.fp+'<br><b>ip: </b>'+item.ip+'<br><b>Created_at: </b>'+new Date(item.created_at+' UTC').toLocaleString()+'<br><b>Last_Login: </b>'+new Date(item.updated_at+' UTC').toLocaleString()+'<br><b>Last_Visit: </b>'+new Date(item.log[item.log.length-1].timestamp+' UTC').toLocaleString()+'<br><b>Platform: </b>'+item.log[item.log.length-1].platform+'<br><b>Timezome: </b>'+item.log[item.log.length-1].timezone+'<br><b>Visit Times: </b>'+item.log.length+'<br><b>Total Session: </b>'+Math.ceil(+totalSession/60)+'mins<br><b>Visit History: </b>'+domainss, |
|
position: 'center', |
|
buttons: [ |
|
['<button><b>Unregister</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
$.get('https://auth.yimian.xyz/logoutDevices.php?hash='+session.get('hash')+'&token='+item.token, function(res){ |
|
if(res.status){ |
|
alert('Unregister successfully!'); |
|
window.location.reload(); |
|
} |
|
}); |
|
}, true], |
|
['<button><b>Close</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
}, true], |
|
] |
|
}); |
|
}); |
|
} |
|
|
|
} |
|
}; |
|
|
|
$('#devices').html(devicess); |
|
events.forEach(i=>f(i)); |
|
}); |
|
}); |
|
|
|
|
|
$("#update").click(function(){ |
|
if(page.tran.getLang() == 'zh'){ |
|
var title = '更新信息'; |
|
var nickname = '昵称'; |
|
var tel = '手机号'; |
|
var email = '邮箱'; |
|
var lan = '重置语言偏好'; |
|
var close = '关闭'; |
|
}else{ |
|
var title = 'Update Info'; |
|
var nickname = 'Nickname'; |
|
var tel = 'Tel'; |
|
var email = 'Email'; |
|
var lan = 'Reset Language Preference'; |
|
var close = 'close'; |
|
} |
|
tips.question({ |
|
timeout: 20000, |
|
close: false, |
|
overlay: true, |
|
displayMode: 'once', |
|
//id: 'question', |
|
zindex: 999, |
|
title: title, |
|
message: '', |
|
position: 'center', |
|
buttons: [ |
|
['<button><b>'+nickname+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
window.location.href = 'https://login.yimian.xyz/?require=nickname&from=https://user.yimian.xyz/'; |
|
}, true], |
|
['<button><b>'+tel+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
window.location.href = 'https://login.yimian.xyz/?require=tel&from=https://user.yimian.xyz/'; |
|
}, true], |
|
['<button><b>'+email+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
window.location.href = 'https://login.yimian.xyz/?require=email&from=https://user.yimian.xyz/'; |
|
}, true], |
|
['<button><b>'+lan+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
session.del('lang'); |
|
session.del('nolang'); |
|
$('#lang').html(''); |
|
}, true], |
|
['<button><b>'+close+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
}, true], |
|
] |
|
}); |
|
}); |
|
|
|
session.onload(function(){ |
|
$('#nickname').html(session.get('nickname')); |
|
$('#uid').html(session.get('uid')); |
|
$('#tel').html(session.get('tel')); |
|
$('#email').html(session.get('email')); |
|
$('#group').html(session.get('group')); |
|
$('#lang').html(((session.get('lang'))?atob(session.get('lang')):'')); |
|
}, false, true); |
|
</script> |
|
</body> |
|
</html>
|
|
|