index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!DOCTYPE html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>数字校园</title>
  5. <script type="text/javascript" src="/js/jquery.min.js"></script>
  6. <link rel="stylesheet" href="/css/bootstrap.min.css">
  7. <script type="text/javascript" src="/js/bootstrap.min.js"></script>
  8. <script type="text/javascript" src="/js/md5.js"></script>
  9. <link rel="preconnect" href="https://fonts.gstatic.com">
  10. <link href="https://fonts.loli.net/css2?family=Anonymous+Pro:ital,wght@0,400;0,700;1,400;1,700
  11. &family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  12. <link rel="stylesheet" href="/css/style.css">
  13. <script>
  14. var status, oid, user, pwd
  15. const rot = '43.143.233.184:81', root = 'https://43.143.233.184:81/'
  16. function getCookie(name) {
  17. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  18. if (arr != null) return arr[2];
  19. return null;
  20. }
  21. function delCookie(name, path = 'u') {
  22. var exp = new Date();
  23. exp.setTime(exp.getTime() - 1);
  24. var cval = getCookie(name);
  25. if (cval != null)
  26. document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ((path == 'u') ? '' : ';path=' + path)
  27. }
  28. function getUrl(e) {
  29. return e.replace('dd.sdsz.com.cn', rot).replace(/^http:/, 'https:').replace(rot.split(':')[0] + '/', rot + '/')
  30. }
  31. function setStatus(e, fast) {
  32. status = e
  33. if (e == 1) {
  34. $('#loginSt').text('登录成功')
  35. $('.login').hide(200)
  36. $('#loginSt').addClass('label-success')
  37. $('#loginSt').removeClass('label-danger')
  38. $('.reqLogin').show(300)
  39. } else if (e == 2) {
  40. $('#loginSt').text('登录失败')
  41. $('#loginSt').removeClass('label-success')
  42. $('#loginSt').addClass('label-danger')
  43. } else {
  44. $('.login').show()
  45. $('#loginSt').text('未登录')
  46. $('#loginSt').removeClass('label-success')
  47. $('#loginSt').removeClass('label-danger')
  48. $('.reqLogin').hide(300 * !fast)
  49. $('#avatar').attr('src', '')
  50. $('#user').text('-')
  51. }
  52. }
  53. function delCookies(force) {
  54. if (force) {
  55. delCookie('CASTGC', '/')
  56. delCookie('gosh', '/score/')
  57. delCookie('gosh', '/sso/')
  58. delCookie('gowd', '/sso/')
  59. }
  60. if (force == 2) {
  61. delCookie('JSESSIONID', '/bxn-portal/')
  62. delCookie('JSESSIONID', '/bxn-library/')
  63. delCookie('JSESSIONID', '/bxn-core-uic/')
  64. }
  65. delCookie('JSESSIONID', '/')
  66. delCookie('JSESSIONID', '/sso/')
  67. }
  68. function postRes() {
  69. }
  70. function postLogin() {
  71. if (status != 1) return;
  72. if (!user) user = getCookie('gosh'), pwd = getCookie('gowd')
  73. document.cookie = "gosh=" + user + ";path=/score/";
  74. document.cookie = "gosh=" + user + ";path=/sso/";
  75. document.cookie = "gowd=" + pwd + ";path=/sso/";
  76. $('#changePwd').val(pwd)
  77. // get('bxn-portal/portal/osforstudent/index', 0, e => {
  78. // let res = JSON.parse(e.match(/user_resources.*window\.admin/gs)[0].replace(/(?:user_resources =|window\.admin|([^)]);)/gs, '$1'))
  79. // console.log(res)
  80. // })
  81. get('bxn-library/library/jumpExamreport?jumpUrl=http://36.112.23.77/analysis/auto/%23/autoLogin', 0, e => {
  82. $('#scoreOld').attr('href', e)
  83. })
  84. get('bxn-portal/portal/api/proxy?username=true&userId=true&needvalidate=true&t=http%3A%2F%2F202.94.10.118%2Fbxn-library%2Fapi%2Flibrary%2FgetLatestBorrowBook%3Fcategory%3D1&resourceId=103519&cache=nocache&systime=0', 0, e => {
  85. e = JSON.parse(e)
  86. $('#user').text(e.requestParams[0].ownerName)
  87. oid = e.requestParams[0].ownerId
  88. console.log(oid)
  89. $('#avatar').attr('src', root + 'avatar/tiny/' + oid)
  90. })
  91. get('bxn-portal/portal/api/proxy?username=true&userId=true&needvalidate=true&t=http%3A%2F%2F202.94.10.164%3A18030%2Fbxn-office%2Fapi%2Fmsg%2FgetLatestActivities&resourceId=100022&cache=nocache&systime=0', 0, e => {
  92. e = JSON.parse(e)
  93. $('#mailList').empty()
  94. for (let i = 0; i < e.list.length; i++) {
  95. $('#mailList').append('<li>' + e.list[i].typeZh + ': ' + e.list[i].title + '<span class="pull-right" style="color:rgb(144,144,144);">' + e.list[i].time + '</span></li>')
  96. }
  97. })
  98. }
  99. function login() {
  100. if (status == 1) return;
  101. delCookies()
  102. user = $('#loginId').val(), pwd = $('#loginPwd').val()
  103. fetch(root + "sso/login", {
  104. "headers": {
  105. "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
  106. // "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
  107. },
  108. "method": "GET",
  109. "mode": "cors",
  110. "credentials": 'include'
  111. }).then(() => {
  112. return fetch('https://43.143.233.184/andlogin', {
  113. method: 'POST',
  114. headers: { 'Content-type': 'application/json' },
  115. body: JSON.stringify({
  116. user: user,
  117. pwd: pwd,
  118. cook: getCookie('JSESSIONID')
  119. }),
  120. credentials: 'include',
  121. })
  122. }).then(e => e.text()).then(e => {
  123. if (e == 'success') setStatus(1)
  124. else setStatus(2)
  125. }).then(postLogin)
  126. }
  127. function matches(e) {
  128. return e.match('(DOCTYPE|[/n]\\?username=|requestParams|\"newmessage\")')
  129. }
  130. async function next(e, call) {//异步递归嘿嘿嘿,再多 302 也不怕;再加上回调函数,真是妙
  131. if (e.length < 3000 && !matches(e)) {
  132. return fetch(getUrl(e), {
  133. method: 'GET',
  134. credentials: 'include'
  135. }).then(e => e.text()).then(res => { next(res, call) })
  136. }
  137. else return call(e), new Promise((resolve, reject) => { })
  138. }
  139. function get(url, name, call = () => { }) {
  140. if (status != 1) return
  141. next(root + url, call)
  142. if (name) $('#' + name).addClass('btn-success')
  143. }
  144. function change() {
  145. if (status != 1 || pwd == $('#changePwd').val()) return
  146. var fd = new URLSearchParams()
  147. fd.append('rating', '4')
  148. fd.append('ratingWord', '极佳')
  149. fd.append('oldPassword', pwd)
  150. fd.append('newPassword', $('#changePwd').val())
  151. fd.append('reNewPassword', $('#changePwd').val())
  152. fetch(root + 'bxn-core-uic/uic-public/personal/management/password/save', {
  153. "headers": {
  154. "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
  155. // "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
  156. },
  157. method: 'POST',
  158. body: fd,
  159. credentials: 'include',
  160. })
  161. $('#changeBtn').addClass('btn-success')
  162. }
  163. $().ready(() => {
  164. $('.e').addClass('reqLogin')
  165. $('.e').removeClass('e')
  166. if (getCookie('CASTGC')) {
  167. setStatus(1), postLogin()
  168. } else setStatus(0, 1)
  169. $("[data-toggle='tooltip']").tooltip();
  170. })
  171. </script>
  172. <style>
  173. .form-control {
  174. font-weight: bold;
  175. font-family: 'Courier New', Courier, monospace;
  176. }
  177. li {
  178. border-bottom: 3px solid #eee;
  179. }
  180. li:hover {
  181. background-color: #eee;
  182. }
  183. .box::before {
  184. content: '';
  185. display: block;
  186. width: 100%;
  187. height: 3px;
  188. margin-top: 10px;
  189. border-bottom: 1px solid;
  190. border-image: linear-gradient(to right, transparent, #6aaad8, #75ddb6, transparent) 1;
  191. }
  192. .box:hover::before {
  193. border-bottom: 3px solid;
  194. border-image: linear-gradient(to right, transparent, #6aaad8, #75ddb6, transparent) 1;
  195. }
  196. .box:hover {
  197. background-image: linear-gradient(#f8ffef, transparent);
  198. }
  199. .page-header.nohr {
  200. margin-bottom: 0;
  201. border-bottom: none;
  202. }
  203. </style>
  204. </head>
  205. <body>
  206. <div class="page-header nohr">
  207. <h2>数字校园
  208. <button class="btn btn-default btn-xs">
  209. <span class="glyphicon glyphicon-question-sign"></span>
  210. </button>
  211. </h2>
  212. <span id="loginSt" class="label label-default">未登录</span>
  213. <span id="user" class="label label-default">-</span>
  214. <button class="btn btn-danger btn-xs e" onclick="postLogin()">
  215. <span class="glyphicon glyphicon-refresh"></span>
  216. </button>
  217. <button class="btn btn-danger btn-xs e" onclick="delCookies(1);setStatus(0)" onmouseenter="$('#double-off').css('scale','100%')" onmouseleave="$('#double-off').css('scale','0')">
  218. <span class="glyphicon glyphicon-log-out"></span>
  219. </button>
  220. <button id="double-off" class="btn btn-danger btn-xs e" onclick="delCookies(2);location.reload()" onmouseenter="$('#double-off').css('scale','100%')" onmouseleave="$('#double-off').css('scale','0')" style="scale:0;transition-duration: 1000ms;" data-toggle="tooltip" data-placement="right" title="全部重置">
  221. <span class="glyphicon glyphicon-off"></span>
  222. </button>
  223. <button class="btn btn-danger btn-xs login" onclick="delCookies(2);location.reload()" data-toggle="tooltip" data-placement="right" title="全部重置">
  224. <span class="glyphicon glyphicon-off"></span>
  225. </button>
  226. <img id="avatar" style="position:absolute;right:10px;top:10px;">
  227. </div>
  228. <div class="col-md-4 col-sm-6 box">
  229. <div class="page-header">
  230. <h3><span class="glyphicon glyphicon-stats"></span> 成绩</h3>
  231. </div>
  232. <div class="btn-group">
  233. <a id="scoreOld" class="btn btn-default e" target="_blank">原版</a>
  234. <a class="btn btn-default e" href="/score" target="_blank">新版</a>
  235. </div>
  236. </div>
  237. <div class="col-md-4 col-sm-6 box">
  238. <div class="page-header">
  239. <h3><span class="glyphicon glyphicon-user"></span> 账号
  240. <div id="cookie" class="btn-group" style="display: none;">
  241. <button id="bxn-portal" class="btn btn-default btn-xs" onclick="get('bxn-portal/portal/osforstudent/index','bxn-portal')">bxn-portal</button>
  242. <button id="bxn-core-uic" class="btn btn-default btn-xs" onclick="get('bxn-core-uic/uic/index','bxn-core-uic')">bxn-core-uic</button>
  243. <button id="bxn-library" class="btn btn-default btn-xs" onclick="get('bxn-library/library/jumpExamreport?jumpUrl=','bxn-library')">bxn-library</button>
  244. </div>
  245. </h3>
  246. </div>
  247. <button class="btn btn-default e" onclick="$('#change').toggle(200)">修改密码</button>
  248. <!-- <button class="btn btn-default e" onclick="$('#cookie').toggle(200)">cookie</button> -->
  249. <div class="login">
  250. <br>
  251. <div class="input-group">
  252. <span class="input-group-addon">账号</span>
  253. <input id="loginId" type="id" class="form-control" placeholder="20222222">
  254. </div>
  255. <br>
  256. <div class="input-group">
  257. <span class="input-group-addon">密码</span>
  258. <input id="loginPwd" type="password" class="form-control" placeholder="password">
  259. <span class="input-group-btn"><button class="btn btn-default" type="button" onclick="login()">登录</button></span>
  260. </div>
  261. </div>
  262. <div id="change" style="display: none;">
  263. <br>
  264. <div class="input-group">
  265. <span class="input-group-addon">新密码</span>
  266. <input id="changePwd" type="password" class="form-control" placeholder="password" onmouseenter="this.type='id'" onmouseleave="this.type='password'">
  267. <span class="input-group-btn"><button id="changeBtn" class="btn btn-default" type="button" onclick="change()">修改</button></span>
  268. </div>
  269. </div>
  270. </div>
  271. <div class="col-md-4 col-sm-6 box">
  272. <div class="page-header">
  273. <h3><span class="glyphicon glyphicon-envelope"></span> 通知</h3>
  274. </div>
  275. <ul id="mailList" class="list-unstyled e"></ul>
  276. </div>
  277. <div style="position:absolute;bottom:10px;left:10px;color:#ccc">
  278. 北师大实验中学
  279. </div>
  280. </body>