Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hunter-ht.cn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘莹莹
hunter-ht.cn
Commits
2d2a8539
Commit
2d2a8539
authored
May 14, 2020
by
Xu Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mange users.
parent
89410cb8
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
426 additions
and
32 deletions
+426
-32
urls.cpython-37.pyc
hunter/__pycache__/urls.cpython-37.pyc
+0
-0
views.cpython-37.pyc
hunter/__pycache__/views.cpython-37.pyc
+0
-0
admin.css
hunter/static/hunter/admin.css
+1
-1
md5.js
hunter/static/hunter/md5.js
+256
-0
admin.html
hunter/templates/hunter/admin.html
+22
-12
index.html
hunter/templates/hunter/index.html
+5
-4
profile.html
hunter/templates/hunter/profile.html
+3
-2
user.html
hunter/templates/hunter/user.html
+3
-1
urls.py
hunter/urls.py
+3
-0
utils.py
hunter/utils.py
+6
-0
views.py
hunter/views.py
+127
-12
No files found.
hunter/__pycache__/urls.cpython-37.pyc
deleted
100644 → 0
View file @
89410cb8
File deleted
hunter/__pycache__/views.cpython-37.pyc
deleted
100644 → 0
View file @
89410cb8
File deleted
hunter/static/hunter/admin.css
View file @
2d2a8539
...
...
@@ -69,7 +69,7 @@ a:hover{
}
.adduserbtn
,
.deluserbtn
,
.resetPwd
{
display
:
inline-block
;
width
:
1
00px
;
width
:
2
00px
;
height
:
40px
;
line-height
:
40px
;
font-family
:
"Helvetica Neue"
,
Helvetica
,
Arial
,
sans-serif
;
...
...
hunter/static/hunter/md5.js
0 → 100644
View file @
2d2a8539
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var
hexcase
=
0
;
/* hex output format. 0 - lowercase; 1 - uppercase */
var
b64pad
=
""
;
/* base-64 pad character. "=" for strict RFC compliance */
var
chrsz
=
8
;
/* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function
hex_md5
(
s
){
return
binl2hex
(
core_md5
(
str2binl
(
s
),
s
.
length
*
chrsz
));}
function
b64_md5
(
s
){
return
binl2b64
(
core_md5
(
str2binl
(
s
),
s
.
length
*
chrsz
));}
function
str_md5
(
s
){
return
binl2str
(
core_md5
(
str2binl
(
s
),
s
.
length
*
chrsz
));}
function
hex_hmac_md5
(
key
,
data
)
{
return
binl2hex
(
core_hmac_md5
(
key
,
data
));
}
function
b64_hmac_md5
(
key
,
data
)
{
return
binl2b64
(
core_hmac_md5
(
key
,
data
));
}
function
str_hmac_md5
(
key
,
data
)
{
return
binl2str
(
core_hmac_md5
(
key
,
data
));
}
/*
* Perform a simple self-test to see if the VM is working
*/
function
md5_vm_test
()
{
return
hex_md5
(
"abc"
)
==
"900150983cd24fb0d6963f7d28e17f72"
;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function
core_md5
(
x
,
len
)
{
/* append padding */
x
[
len
>>
5
]
|=
0x80
<<
((
len
)
%
32
);
x
[(((
len
+
64
)
>>>
9
)
<<
4
)
+
14
]
=
len
;
var
a
=
1732584193
;
var
b
=
-
271733879
;
var
c
=
-
1732584194
;
var
d
=
271733878
;
for
(
var
i
=
0
;
i
<
x
.
length
;
i
+=
16
)
{
var
olda
=
a
;
var
oldb
=
b
;
var
oldc
=
c
;
var
oldd
=
d
;
a
=
md5_ff
(
a
,
b
,
c
,
d
,
x
[
i
+
0
],
7
,
-
680876936
);
d
=
md5_ff
(
d
,
a
,
b
,
c
,
x
[
i
+
1
],
12
,
-
389564586
);
c
=
md5_ff
(
c
,
d
,
a
,
b
,
x
[
i
+
2
],
17
,
606105819
);
b
=
md5_ff
(
b
,
c
,
d
,
a
,
x
[
i
+
3
],
22
,
-
1044525330
);
a
=
md5_ff
(
a
,
b
,
c
,
d
,
x
[
i
+
4
],
7
,
-
176418897
);
d
=
md5_ff
(
d
,
a
,
b
,
c
,
x
[
i
+
5
],
12
,
1200080426
);
c
=
md5_ff
(
c
,
d
,
a
,
b
,
x
[
i
+
6
],
17
,
-
1473231341
);
b
=
md5_ff
(
b
,
c
,
d
,
a
,
x
[
i
+
7
],
22
,
-
45705983
);
a
=
md5_ff
(
a
,
b
,
c
,
d
,
x
[
i
+
8
],
7
,
1770035416
);
d
=
md5_ff
(
d
,
a
,
b
,
c
,
x
[
i
+
9
],
12
,
-
1958414417
);
c
=
md5_ff
(
c
,
d
,
a
,
b
,
x
[
i
+
10
],
17
,
-
42063
);
b
=
md5_ff
(
b
,
c
,
d
,
a
,
x
[
i
+
11
],
22
,
-
1990404162
);
a
=
md5_ff
(
a
,
b
,
c
,
d
,
x
[
i
+
12
],
7
,
1804603682
);
d
=
md5_ff
(
d
,
a
,
b
,
c
,
x
[
i
+
13
],
12
,
-
40341101
);
c
=
md5_ff
(
c
,
d
,
a
,
b
,
x
[
i
+
14
],
17
,
-
1502002290
);
b
=
md5_ff
(
b
,
c
,
d
,
a
,
x
[
i
+
15
],
22
,
1236535329
);
a
=
md5_gg
(
a
,
b
,
c
,
d
,
x
[
i
+
1
],
5
,
-
165796510
);
d
=
md5_gg
(
d
,
a
,
b
,
c
,
x
[
i
+
6
],
9
,
-
1069501632
);
c
=
md5_gg
(
c
,
d
,
a
,
b
,
x
[
i
+
11
],
14
,
643717713
);
b
=
md5_gg
(
b
,
c
,
d
,
a
,
x
[
i
+
0
],
20
,
-
373897302
);
a
=
md5_gg
(
a
,
b
,
c
,
d
,
x
[
i
+
5
],
5
,
-
701558691
);
d
=
md5_gg
(
d
,
a
,
b
,
c
,
x
[
i
+
10
],
9
,
38016083
);
c
=
md5_gg
(
c
,
d
,
a
,
b
,
x
[
i
+
15
],
14
,
-
660478335
);
b
=
md5_gg
(
b
,
c
,
d
,
a
,
x
[
i
+
4
],
20
,
-
405537848
);
a
=
md5_gg
(
a
,
b
,
c
,
d
,
x
[
i
+
9
],
5
,
568446438
);
d
=
md5_gg
(
d
,
a
,
b
,
c
,
x
[
i
+
14
],
9
,
-
1019803690
);
c
=
md5_gg
(
c
,
d
,
a
,
b
,
x
[
i
+
3
],
14
,
-
187363961
);
b
=
md5_gg
(
b
,
c
,
d
,
a
,
x
[
i
+
8
],
20
,
1163531501
);
a
=
md5_gg
(
a
,
b
,
c
,
d
,
x
[
i
+
13
],
5
,
-
1444681467
);
d
=
md5_gg
(
d
,
a
,
b
,
c
,
x
[
i
+
2
],
9
,
-
51403784
);
c
=
md5_gg
(
c
,
d
,
a
,
b
,
x
[
i
+
7
],
14
,
1735328473
);
b
=
md5_gg
(
b
,
c
,
d
,
a
,
x
[
i
+
12
],
20
,
-
1926607734
);
a
=
md5_hh
(
a
,
b
,
c
,
d
,
x
[
i
+
5
],
4
,
-
378558
);
d
=
md5_hh
(
d
,
a
,
b
,
c
,
x
[
i
+
8
],
11
,
-
2022574463
);
c
=
md5_hh
(
c
,
d
,
a
,
b
,
x
[
i
+
11
],
16
,
1839030562
);
b
=
md5_hh
(
b
,
c
,
d
,
a
,
x
[
i
+
14
],
23
,
-
35309556
);
a
=
md5_hh
(
a
,
b
,
c
,
d
,
x
[
i
+
1
],
4
,
-
1530992060
);
d
=
md5_hh
(
d
,
a
,
b
,
c
,
x
[
i
+
4
],
11
,
1272893353
);
c
=
md5_hh
(
c
,
d
,
a
,
b
,
x
[
i
+
7
],
16
,
-
155497632
);
b
=
md5_hh
(
b
,
c
,
d
,
a
,
x
[
i
+
10
],
23
,
-
1094730640
);
a
=
md5_hh
(
a
,
b
,
c
,
d
,
x
[
i
+
13
],
4
,
681279174
);
d
=
md5_hh
(
d
,
a
,
b
,
c
,
x
[
i
+
0
],
11
,
-
358537222
);
c
=
md5_hh
(
c
,
d
,
a
,
b
,
x
[
i
+
3
],
16
,
-
722521979
);
b
=
md5_hh
(
b
,
c
,
d
,
a
,
x
[
i
+
6
],
23
,
76029189
);
a
=
md5_hh
(
a
,
b
,
c
,
d
,
x
[
i
+
9
],
4
,
-
640364487
);
d
=
md5_hh
(
d
,
a
,
b
,
c
,
x
[
i
+
12
],
11
,
-
421815835
);
c
=
md5_hh
(
c
,
d
,
a
,
b
,
x
[
i
+
15
],
16
,
530742520
);
b
=
md5_hh
(
b
,
c
,
d
,
a
,
x
[
i
+
2
],
23
,
-
995338651
);
a
=
md5_ii
(
a
,
b
,
c
,
d
,
x
[
i
+
0
],
6
,
-
198630844
);
d
=
md5_ii
(
d
,
a
,
b
,
c
,
x
[
i
+
7
],
10
,
1126891415
);
c
=
md5_ii
(
c
,
d
,
a
,
b
,
x
[
i
+
14
],
15
,
-
1416354905
);
b
=
md5_ii
(
b
,
c
,
d
,
a
,
x
[
i
+
5
],
21
,
-
57434055
);
a
=
md5_ii
(
a
,
b
,
c
,
d
,
x
[
i
+
12
],
6
,
1700485571
);
d
=
md5_ii
(
d
,
a
,
b
,
c
,
x
[
i
+
3
],
10
,
-
1894986606
);
c
=
md5_ii
(
c
,
d
,
a
,
b
,
x
[
i
+
10
],
15
,
-
1051523
);
b
=
md5_ii
(
b
,
c
,
d
,
a
,
x
[
i
+
1
],
21
,
-
2054922799
);
a
=
md5_ii
(
a
,
b
,
c
,
d
,
x
[
i
+
8
],
6
,
1873313359
);
d
=
md5_ii
(
d
,
a
,
b
,
c
,
x
[
i
+
15
],
10
,
-
30611744
);
c
=
md5_ii
(
c
,
d
,
a
,
b
,
x
[
i
+
6
],
15
,
-
1560198380
);
b
=
md5_ii
(
b
,
c
,
d
,
a
,
x
[
i
+
13
],
21
,
1309151649
);
a
=
md5_ii
(
a
,
b
,
c
,
d
,
x
[
i
+
4
],
6
,
-
145523070
);
d
=
md5_ii
(
d
,
a
,
b
,
c
,
x
[
i
+
11
],
10
,
-
1120210379
);
c
=
md5_ii
(
c
,
d
,
a
,
b
,
x
[
i
+
2
],
15
,
718787259
);
b
=
md5_ii
(
b
,
c
,
d
,
a
,
x
[
i
+
9
],
21
,
-
343485551
);
a
=
safe_add
(
a
,
olda
);
b
=
safe_add
(
b
,
oldb
);
c
=
safe_add
(
c
,
oldc
);
d
=
safe_add
(
d
,
oldd
);
}
return
Array
(
a
,
b
,
c
,
d
);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function
md5_cmn
(
q
,
a
,
b
,
x
,
s
,
t
)
{
return
safe_add
(
bit_rol
(
safe_add
(
safe_add
(
a
,
q
),
safe_add
(
x
,
t
)),
s
),
b
);
}
function
md5_ff
(
a
,
b
,
c
,
d
,
x
,
s
,
t
)
{
return
md5_cmn
((
b
&
c
)
|
((
~
b
)
&
d
),
a
,
b
,
x
,
s
,
t
);
}
function
md5_gg
(
a
,
b
,
c
,
d
,
x
,
s
,
t
)
{
return
md5_cmn
((
b
&
d
)
|
(
c
&
(
~
d
)),
a
,
b
,
x
,
s
,
t
);
}
function
md5_hh
(
a
,
b
,
c
,
d
,
x
,
s
,
t
)
{
return
md5_cmn
(
b
^
c
^
d
,
a
,
b
,
x
,
s
,
t
);
}
function
md5_ii
(
a
,
b
,
c
,
d
,
x
,
s
,
t
)
{
return
md5_cmn
(
c
^
(
b
|
(
~
d
)),
a
,
b
,
x
,
s
,
t
);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function
core_hmac_md5
(
key
,
data
)
{
var
bkey
=
str2binl
(
key
);
if
(
bkey
.
length
>
16
)
bkey
=
core_md5
(
bkey
,
key
.
length
*
chrsz
);
var
ipad
=
Array
(
16
),
opad
=
Array
(
16
);
for
(
var
i
=
0
;
i
<
16
;
i
++
)
{
ipad
[
i
]
=
bkey
[
i
]
^
0x36363636
;
opad
[
i
]
=
bkey
[
i
]
^
0x5C5C5C5C
;
}
var
hash
=
core_md5
(
ipad
.
concat
(
str2binl
(
data
)),
512
+
data
.
length
*
chrsz
);
return
core_md5
(
opad
.
concat
(
hash
),
512
+
128
);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function
safe_add
(
x
,
y
)
{
var
lsw
=
(
x
&
0xFFFF
)
+
(
y
&
0xFFFF
);
var
msw
=
(
x
>>
16
)
+
(
y
>>
16
)
+
(
lsw
>>
16
);
return
(
msw
<<
16
)
|
(
lsw
&
0xFFFF
);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function
bit_rol
(
num
,
cnt
)
{
return
(
num
<<
cnt
)
|
(
num
>>>
(
32
-
cnt
));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function
str2binl
(
str
)
{
var
bin
=
Array
();
var
mask
=
(
1
<<
chrsz
)
-
1
;
for
(
var
i
=
0
;
i
<
str
.
length
*
chrsz
;
i
+=
chrsz
)
bin
[
i
>>
5
]
|=
(
str
.
charCodeAt
(
i
/
chrsz
)
&
mask
)
<<
(
i
%
32
);
return
bin
;
}
/*
* Convert an array of little-endian words to a string
*/
function
binl2str
(
bin
)
{
var
str
=
""
;
var
mask
=
(
1
<<
chrsz
)
-
1
;
for
(
var
i
=
0
;
i
<
bin
.
length
*
32
;
i
+=
chrsz
)
str
+=
String
.
fromCharCode
((
bin
[
i
>>
5
]
>>>
(
i
%
32
))
&
mask
);
return
str
;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function
binl2hex
(
binarray
)
{
var
hex_tab
=
hexcase
?
"0123456789ABCDEF"
:
"0123456789abcdef"
;
var
str
=
""
;
for
(
var
i
=
0
;
i
<
binarray
.
length
*
4
;
i
++
)
{
str
+=
hex_tab
.
charAt
((
binarray
[
i
>>
2
]
>>
((
i
%
4
)
*
8
+
4
))
&
0xF
)
+
hex_tab
.
charAt
((
binarray
[
i
>>
2
]
>>
((
i
%
4
)
*
8
))
&
0xF
);
}
return
str
;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function
binl2b64
(
binarray
)
{
var
tab
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
var
str
=
""
;
for
(
var
i
=
0
;
i
<
binarray
.
length
*
4
;
i
+=
3
)
{
var
triplet
=
(((
binarray
[
i
>>
2
]
>>
8
*
(
i
%
4
))
&
0xFF
)
<<
16
)
|
(((
binarray
[
i
+
1
>>
2
]
>>
8
*
((
i
+
1
)
%
4
))
&
0xFF
)
<<
8
)
|
((
binarray
[
i
+
2
>>
2
]
>>
8
*
((
i
+
2
)
%
4
))
&
0xFF
);
for
(
var
j
=
0
;
j
<
4
;
j
++
)
{
if
(
i
*
8
+
j
*
6
>
binarray
.
length
*
32
)
str
+=
b64pad
;
else
str
+=
tab
.
charAt
((
triplet
>>
6
*
(
3
-
j
))
&
0x3F
);
}
}
return
str
;
}
hunter/templates/hunter/admin.html
View file @
2d2a8539
...
...
@@ -3,12 +3,14 @@
<head>
{% load static %}
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
<title>
管理员面板
</title>
<link
rel=
"icon"
href=
"{% static 'hunter/images/logo.ico' %}"
type=
"text/icon"
>
<link
rel=
"stylesheet"
href=
"{% static 'hunter/admin.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'hunter/bootstrap.css' %}"
>
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<script
src=
"{% static 'hunter/jquery.form.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md/showdown.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md5.js' %}"
></script>
</head>
<body>
...
...
@@ -30,7 +32,7 @@
<div
id=
"paperadmin"
class=
"userlist"
>
<table
class=
"table tableList"
>
<thead>
</thead>
<tbody>
{% for publication in publications %}
...
...
@@ -53,7 +55,10 @@
</tbody>
</table>
</div>
<div
id=
"useradmin"
class=
"userlist"
>
<!--用户列表-->
<div
id=
"useradmin"
class=
"userlist"
style=
"border:1px solid #000;"
>
<span
id=
"user_score_List"
style=
"color:#ff9800"
>
用户列表
</span>
<div
class=
"adminForm"
>
<div
id=
"adduserform"
class=
"form-horizontal"
>
<div
class=
"form-group"
>
...
...
@@ -77,18 +82,20 @@
</div>
<table
class=
"table tableList"
>
<thead>
<tr>
<th>
用户名
</th>
<th>
姓名
</th>
<th>
角色
</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td
class=
"col-xm-4 col-md-4"
>
{{ user.name }}
</td>
<td
class=
"col-xm-4 col-md-4 col-md-offset-2"
>
<p>
{{ user.nake_name }}
</p>
</td>
<td
class=
"col-xm-4 col-md-4 col-md-offset-2"
><p>
{{ user.name_hanzi }}
</p></td>
<td
class=
"col-xm-4 col-md-4 col-md-offset-2"
>
{{ user.identity }}
</td>
<td><button
class=
"
col-xm-2 col-md-2
resetPwd"
onclick=
"changeIdentity(this)"
>
更改权限
</button></td>
<td><button
class=
"
col-xm-2 col-md-2
resetPwd"
onclick=
"resetPWD(this)"
>
重置密码
</button></td>
<td><button
class=
"resetPwd"
onclick=
"changeIdentity(this)"
>
更改权限
</button></td>
<td><button
class=
"resetPwd"
onclick=
"resetPWD(this)"
>
重置密码
</button></td>
<td
class=
"col-xm-2 col-md-2"
><button
class=
"deluserbtn"
onclick=
"delUser(this)"
>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1539054739914"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2718"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M861.012317 164.091494C765.809507 68.885661 639.229448 16.455901 504.590713 16.455901S243.372927 68.885661 148.170117 164.091494C52.965291 259.293296 0.534525 385.874363 0.534525 520.51209c0 134.639743 52.430767 261.217786 147.635592 356.422612 95.20281 95.20281 221.782869 147.633577 356.420596 147.633577s261.217786-52.430767 356.420596-147.633577c95.204825-95.204825 147.635592-221.783877 147.635592-356.422612C1008.646902 385.874363 956.217143 259.293296 861.012317 164.091494zM791.219829 810.54584c-4.394084 4.393077-10.152441 6.590623-15.910797 6.590623-5.759364 0-11.518728-2.197546-15.911805-6.590623L504.590713 555.740334 249.785207 810.54584c-4.394084 4.393077-10.152441 6.590623-15.911805 6.590623-5.758356 0-11.516713-2.197546-15.910797-6.590623-8.788169-8.788169-8.788169-23.036448 0-31.824617L472.767104 523.916725 219.336953 270.485566c-8.788169-8.788169-8.788169-23.036448 0-31.824617 8.788169-8.785146 23.035441-8.785146 31.823609 0l253.431158 253.431158 253.431158-253.431158c8.788169-8.785146 23.035441-8.785146 31.823609 0 8.788169 8.788169 8.788169 23.036448 0 31.824617L536.41533 523.916725l254.804499 254.805506C800.007998 787.509392 800.007998 801.757672 791.219829 810.54584z"
p-id=
"2719"
fill=
"#ff9800"
></path></svg></button>
</td>
</tr>
...
...
@@ -96,6 +103,7 @@
</tbody>
</table>
</div>
<div
id=
"privateArtadmin"
class=
"userlist"
>
<ul
id=
"articleList"
class=
"node-list"
>
{% for article in articles %}
...
...
@@ -207,12 +215,13 @@
data
[
'password'
]
=
$
(
'input'
)[
1
].
value
;
data
[
'actiontype'
]
=
'0'
;
//0 添加用户 1 删除用户
encryptSend
(
'/operator/'
,
data
);
// Jsencrypt.do对应服务端处理地址
console
.
log
(
"add user: username = "
+
username
);
});
var
storage
=
window
.
sessionStorage
;
var
username
=
storage
.
username
;
var
identity
=
storage
.
identity
;
if
(
username
!=
null
&&
username
.
toString
().
length
>
0
){
if
(
identity
==
'0'
){
if
(
username
!=
null
&&
username
.
toString
().
length
>
0
){
if
(
identity
==
'0'
){
alert
(
"请以管理员身份登录"
);
{
#
window
.
location
.
href
=
"/signin/"
;
#
}
}
else
{
...
...
@@ -432,7 +441,8 @@
}
function
resetPWD
(
thisbtn
)
{
var
resetname
=
thisbtn
.
parentElement
.
parentElement
.
firstElementChild
.
innerHTML
;
var
resetname
=
prompt
(
"Enter your password?"
);
if
(
resetname
==
null
)
return
;
var
resetPwd
=
hex_md5
(
resetname
);
$
.
ajax
({
url
:
'/operator/'
,
...
...
hunter/templates/hunter/index.html
View file @
2d2a8539
...
...
@@ -2,11 +2,12 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
野旷天低树
天
清月近人
</title>
<title>
野旷天低树
江
清月近人
</title>
{% load static %}
<link
rel=
"icon"
href=
"{% static 'hunter/images/logo.ico' %}"
type=
"text/icon"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'hunter/style.css' %}"
>
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md5.js' %}"
></script>
</head>
<body>
<div
id=
"login_div"
class=
""
>
...
...
@@ -363,7 +364,7 @@
function
login
(){
let
username
=
$
(
"input"
)[
0
].
value
;
let
password
=
$
(
"input"
)[
1
].
value
;
if
(
username
===
""
||
password
===
""
){
if
(
username
===
""
||
password
===
""
){
login_fail
(
'用户名密码不能为空'
);
}
else
{
$
.
ajax
({
...
...
@@ -371,8 +372,8 @@
type
:
'post'
,
dataType
:
'json'
,
data
:{
"username"
:
username
,
"password"
:
password
,
"username"
:
username
,
"password"
:
hex_md5
(
password
)
,
},
success
:
function
(
response
){
console
.
log
(
response
);
...
...
hunter/templates/hunter/profile.html
View file @
2d2a8539
...
...
@@ -5,6 +5,7 @@
<title>
修改个人信息
</title>
{% load static %}
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md5.js' %}"
></script>
</head>
<style
type=
"text/css"
>
*
{
...
...
@@ -352,7 +353,7 @@
}
}
console
.
log
(
edu_arr
);
if
(
pwd
!==
$
(
"#confirm_pwd"
).
val
()){
if
(
pwd
!==
$
(
"#confirm_pwd"
).
val
()){
$
(
"#error_log"
).
innerHTML
=
"密码不一致"
;
}
else
if
(
!
name_eng
&&!
name_hanzi
)
{
...
...
@@ -367,7 +368,7 @@
"userID"
:
userID
,
"name_hanzi"
:
name_hanzi
,
"name_eng"
:
name_eng
,
"pwd"
:
pwd
,
"pwd"
:
hex_md5
(
pwd
)
,
"mail"
:
mail
,
"website"
:
website
,
"profile"
:
profile
,
...
...
hunter/templates/hunter/user.html
View file @
2d2a8539
...
...
@@ -48,7 +48,9 @@
<a
href=
"{% url 'hunter:profile_edit' user.userID %}"
target=
"_blank"
class=
"main_bar userID"
id=
""
>
修改个人信息
</a>
<a
href=
"{% url 'hunter:detail' user.userID %}"
class=
"main_bar"
target=
"_blank"
>
查看个人详情页
</a>
{% if user.identity == '1' %}
<a
href=
"../../ht/admin"
class=
"main_bar"
target=
"_blank"
>
管理员
</a>
{% endif %}
<a
href=
"{% url 'hunter:detail' user.userID %}"
id=
"username"
class=
"main_bar"
target=
"_blank"
>
{{ usr.name }}
</a>
</div>
</div>
...
...
hunter/urls.py
View file @
2d2a8539
...
...
@@ -31,4 +31,6 @@ urlpatterns = [
path
(
'add/article/'
,
views
.
add_article
,
name
=
'add_article'
),
path
(
'ht/admin/'
,
views
.
admin
,
name
=
'admin'
),
path
(
'operator/'
,
views
.
operator
,
name
=
'operator'
),
path
(
'add_user/'
,
views
.
add_user
,
name
=
'add_user'
),
]
\ No newline at end of file
hunter/utils.py
0 → 100644
View file @
2d2a8539
import
hashlib
def
hex_md5
(
str
):
md5
=
hashlib
.
md5
()
md5
.
update
(
str
.
encode
(
'utf-8'
))
return
md5
.
hexdigest
()
\ No newline at end of file
hunter/views.py
View file @
2d2a8539
...
...
@@ -4,6 +4,7 @@ from .models import *
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.http
import
JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
django.template.context_processors
import
csrf
import
os
from
django.db.utils
import
ProgrammingError
import
datetime
...
...
@@ -14,23 +15,23 @@ import json
from
django.views
import
generic
from
django.db.models.aggregates
import
Count
from
django.db.models
import
Count
from
django.views.decorators.csrf
import
ensure_csrf_cookie
# Create your views here.
def
index
(
request
):
user_list
=
User
.
objects
.
filter
(
isCurrent
=
1
,
identity
=
'0'
)
.
all
()
user_list
=
User
.
objects
.
filter
(
isCurrent
=
1
)
.
all
()
user_type_list
=
{
"Academic STAFF"
:
[],
"Phd"
:
[],
"Master"
:
[],
"Engineer STAFF"
:
[]}
for
u
in
user_list
:
if
u
.
member_type
==
0
:
u
.
member_type
=
"Academic STAFF"
elif
u
.
member_type
==
1
:
u
.
member_type
=
"Engineer STAFF"
elif
u
.
member_type
==
2
:
u
.
member_type
=
"Master"
else
:
if
u
.
member_type
==
1
:
u
.
member_type
=
"Engineer STAFF"
else
:
if
u
.
member_type
==
2
:
u
.
member_type
=
"Master"
else
:
u
.
member_type
=
"Phd"
u
.
member_type
=
"Phd"
member_type
=
u
.
member_type
user_type_list
[
member_type
]
.
append
(
u
)
...
...
@@ -192,6 +193,7 @@ def user(request, user_id):
'cve_list'
:
my_bug_list
,
'article_year_list'
:
my_article_year_list
,
}
print
(
"display user: "
,
usr
)
return
render
(
request
,
'hunter/user.html'
,
context
)
...
...
@@ -711,8 +713,7 @@ def edit_art(request, article_id):
# 管理员
@ensure_csrf_cookie
def
admin
(
request
):
if
User
.
objects
.
last
():
if
User
.
objects
.
last
()
.
userID
>
0
:
...
...
@@ -730,7 +731,121 @@ def admin(request):
else
:
user
.
identity
=
'管理员'
if
ScoreRecords
.
objects
.
last
()
is
None
:
records
=
0
records
=
[]
else
:
records
=
ScoreRecords
.
objects
.
all
()
return
render
(
request
,
"hunter/admin.html"
,
locals
())
print
(
users
)
return
render
(
request
,
"hunter/admin.html"
,
locals
())
@csrf_exempt
def
operator
(
request
):
message
=
{}
print
(
"cal api operator."
)
if
request
.
is_ajax
():
actiontype
=
request
.
POST
.
get
(
'actiontype'
)
if
actiontype
==
'0'
:
username
=
request
.
POST
.
get
(
'username'
)
password
=
request
.
POST
.
get
(
'password'
)
if
username
==
''
or
password
==
''
:
message
[
"warning"
]
=
"用户名或密码不能为空"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
result
=
User
.
objects
.
filter
(
name
=
username
)
if
result
:
message
[
"warning"
]
=
"用户名已存在"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
if
User
.
objects
.
last
()
is
None
:
userID
=
1
else
:
userID
=
User
.
objects
.
last
()
.
userID
+
1
try
:
userAdd
=
User
.
objects
.
create
(
userID
=
userID
,
name
=
username
,
pwd
=
password
)
message
[
"warning"
]
=
"添加成功"
users
=
User
.
objects
.
all
()
userList
=
[]
for
user
in
users
:
userList
.
append
(
user
.
name
)
message
[
"users"
]
=
userList
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
except
ValidationError
as
e
:
message
[
"warning"
]
=
e
;
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
if
actiontype
==
'1'
:
delname
=
request
.
POST
.
get
(
'delname'
)
try
:
delrestlt
=
User
.
objects
.
filter
(
name
=
delname
)
.
delete
()
message
[
"warning"
]
=
"删除成功"
users
=
User
.
objects
.
all
()
userList
=
[]
for
user
in
users
:
userList
.
append
(
user
.
name
)
message
[
"users"
]
=
userList
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
# return render_to_response('admin.html',locals())
except
:
message
[
"warning"
]
=
"删除出错"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
if
actiontype
==
'2'
:
resetPwd
=
request
.
POST
.
get
(
'resetPwd'
)
resetname
=
request
.
POST
.
get
(
'resetname'
)
try
:
User
.
objects
.
filter
(
name
=
resetname
)
.
update
(
pwd
=
resetPwd
)
message
[
"warning"
]
=
"密码更新成功"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
except
:
message
[
"warning"
]
=
"密码更新错误"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
if
actiontype
==
'3'
:
identity
=
request
.
POST
.
get
(
'identity'
)
username
=
request
.
POST
.
get
(
'username'
)
try
:
User
.
objects
.
filter
(
name
=
username
)
.
update
(
identity
=
identity
)
message
[
"flag"
]
=
"1"
;
message
[
"warning"
]
=
"权限更改成功"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
except
:
message
[
"warning"
]
=
"权限更改错误"
message
[
"flag"
]
=
"1"
;
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
if
actiontype
==
'4'
:
pubtitle
=
request
.
POST
.
get
(
'delpub'
)
pubFileName
=
request
.
POST
.
get
(
'pubFileName'
)
print
(
pubtitle
)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
destination
=
os
.
path
.
join
(
BASE_DIR
,
'hunter'
,
'static'
,
'publications'
,
pubFileName
)
try
:
pubIDs
=
Publications
.
objects
.
filter
(
title
=
pubtitle
)
.
all
()
.
values
(
"pubID"
)
print
(
pubIDs
)
for
pubID
in
pubIDs
:
print
(
pubID
[
'pubID'
])
PubToUser
.
objects
.
filter
(
pubID
=
pubID
[
'pubID'
])
.
delete
()
Publications
.
objects
.
filter
(
title
=
pubtitle
)
.
delete
()
if
os
.
path
.
exists
(
destination
):
os
.
remove
(
destination
)
message
[
"warning"
]
=
"1"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
except
:
message
[
"warning"
]
=
"2"
return
HttpResponse
(
json
.
dumps
(
message
),
content_type
=
'application/json'
)
return
render_to_response
(
'admin.html'
,
locals
())
def
add_user
(
request
):
print
(
'call api add_user'
)
if
request
.
is_ajax
():
username
=
request
.
POST
.
get
(
'username'
)
password
=
request
.
POST
.
get
(
'password'
)
message
=
{}
if
username
==
''
or
password
==
''
:
return
render
(
request
,
'admin.html'
,
{
'message'
:
'用户名或密码不能为空'
})
result
=
User
.
objects
.
filter
(
name
=
username
)
if
result
:
return
render
(
request
,
'admin.html'
,{
'message'
:
'用户名已存在'
})
if
User
.
objects
.
last
()
is
None
:
userID
=
1
else
:
userID
=
User
.
objects
.
last
()
.
userID
+
1
userAdd
=
User
.
objects
.
create
(
userID
=
userID
,
name
=
username
,
pwd
=
password
)
if
userAdd
:
return
render
(
request
,
'admin.html'
,{
'message'
:
'添加成功'
})
else
:
return
render
(
request
,
'admin.html'
,{
'message'
:
'添加失败'
})
return
render
(
request
,
'admin.html'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment