From 28bfe9ea16c4efd541f8fc38a88f60bc02792d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B9i=20Nguy=E1=BB=85n=20T=E1=BA=A5n=20Sang?= Date: Thu, 8 Feb 2024 11:52:45 +0700 Subject: [PATCH] Update Better account system Added Admin panel Added Log system --- acc.bat | 1 + acc.sh | 1 + account/__pycache__/loader.cpython-312.pyc | Bin 418 -> 526 bytes .../__pycache__/reliability.cpython-312.pyc | Bin 857 -> 789 bytes account/__pycache__/userid.cpython-312.pyc | Bin 0 -> 555 bytes account/__pycache__/username.cpython-312.pyc | Bin 0 -> 559 bytes account/create.py | 37 ----- account/database.py | 2 +- account/loader.py | 2 + account/main.py | 111 +++++++++++++++ account/reliability.py | 2 - account/userid.py | 11 ++ account/username.py | 11 ++ adpn.bat | 1 + adpn.py | 129 ++++++++++++++++++ adpn.sh | 1 + .../__pycache__/database.cpython-312.pyc | Bin 2141 -> 2439 bytes .../__pycache__/loader.cpython-312.pyc | Bin 622 -> 783 bytes initializer/database.py | 5 +- initializer/loader.py | 3 + log.txt | 0 log/__pycache__/write.cpython-312.pyc | Bin 0 -> 1285 bytes log/write.py | 14 ++ main.py | 4 +- manager/__pycache__/manager.cpython-312.pyc | Bin 2855 -> 3705 bytes manager/manager.py | 19 ++- 26 files changed, 306 insertions(+), 48 deletions(-) create mode 100644 acc.bat create mode 100644 acc.sh create mode 100644 account/__pycache__/userid.cpython-312.pyc create mode 100644 account/__pycache__/username.cpython-312.pyc delete mode 100644 account/create.py create mode 100644 account/main.py create mode 100644 account/userid.py create mode 100644 account/username.py create mode 100644 adpn.bat create mode 100644 adpn.py create mode 100644 adpn.sh create mode 100644 log.txt create mode 100644 log/__pycache__/write.cpython-312.pyc create mode 100644 log/write.py diff --git a/acc.bat b/acc.bat new file mode 100644 index 0000000..6dc3da5 --- /dev/null +++ b/acc.bat @@ -0,0 +1 @@ +python -m streamlit run account/main.py \ No newline at end of file diff --git a/acc.sh b/acc.sh new file mode 100644 index 0000000..7716383 --- /dev/null +++ b/acc.sh @@ -0,0 +1 @@ +python -m streamlit run account/manager.py \ No newline at end of file diff --git a/account/__pycache__/loader.cpython-312.pyc b/account/__pycache__/loader.cpython-312.pyc index 6946cc3648d130ecacffc7c690239c03bb77a18d..b45d892f4ff7cfbf1888ea8af49f6461efc84fb0 100644 GIT binary patch delta 328 zcmZ3)+{eOunwOW00SJN&j-;NL$Sdh12jom=NMT4}%wdQE(M&mvxlB<^j0`EvEeui2 zm5iD!FF`u|G#PKP7grX?=j5j+g9KoJ1;}6q;?EuvqxI!VSYhHROexH(nIJqyh8l)o z22GZU6Xc9mzSDc zQUo%3;-Rv7kh4Kn6)OUX28KJ_LjCrg_7|irE^}KpxZGjk?(n!Erg4Qu^9DD6gZF2k zBA|UmY(VN3C(y}y19!{;B$SY|o1msL-NMT4}%wdRPNMUMWh+?c{)MS1MQstKn zB4L0T$N=Hb1`~_)*=iVq88n$D?w1qMWV*#(T$qztl4^X5Jvl!wFEzPjvH)Wl7Y9^B zvDoAZj3PcaxcM8rKZ8uuWGZ3-QbiyID;bJ7L2Py)@r%PIH$SB`C)KWq8^~n@;$mJP U@qw9t<8 diff --git a/account/__pycache__/reliability.cpython-312.pyc b/account/__pycache__/reliability.cpython-312.pyc index 9cb9dc038fd85b4efbf321026684e300bd6e2e8d..73141c0439c33770b7790e8fd397059307e53ce4 100644 GIT binary patch delta 139 zcmcb~HkHlnG%qg~0}vz{9!c$FVqka-;=lkSl<^s)WI96%LkmL`LnWgo)5at&My8hx zoAVeY7+Lv%l8lqPnQAQ=i$Ls^3`P7vs)!dz{Nk|5%}*)KNwq5y1StdJVvu1Um>C%v MKQjq3ih$Ju0J=~ZG5`Po delta 207 zcmbQrc9SjXG%qg~0}#AvI-I(niGkrUhyw#aJ{Wu!15(o&QW#Pga~N_NqZk<(QkYs8 zqL?a~HCbMQlxQ;E5>HG{&M(a?iBCx^NlZ#CPL0pWPfSTI+Gxhb$W+9%*@;ntk(D2) zmU(hKQ*9vgEk39QJ&3v@W}sXVNWn^mA^{Ma4@mstu*uC&Da}c>D-s5B8G*Q%7f5_y SW@Kc%%V6}GMUYVhtQ-K-U@i*) diff --git a/account/__pycache__/userid.cpython-312.pyc b/account/__pycache__/userid.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..742c4425833259a9dc8fa8fe47e9a8a5f6118374 GIT binary patch literal 555 zcmX@j%ge<81kXc{q`m~wk3k$5V1hC}3jrC^8B!Qh7;_k+7*d#87@`;}88w+fIvD(t zVd_9U79eH@;?F5SVmd<&Llz^Dfd*0-YZ%iQS3~tNf>eR@pn=s;el1fClM6#EI|D;4 za}9F}lO#~QmZgW2g`u7$m_d`-uSz}G)yLI2L?JUp!7a$&SD~~xwWwGj+`~1<70k{{ z%uQ9WRj@At*{I2Mi#@d>HMz7T^%h53YDscNVor`G>n*nA(xT%0qFWpw-5?#eSc>w? zi*GRl$y;n7!OWCmR-ge2An?@_$a1!d2?bddR}S`_1-m+DfKS(X|Tl6a;eQz0kw z@TxP5OJm$KOFT-GVtn)S@`F95|fkjOY=%%AcpD{RNmrFPc4ZDapN;nigV(z9A?w zA#kEtC))>RApZj!1CLOH?`NP1U>_G3=46(n8iUPV$xy@#6fWWh62CZXa`RJ4b5iY! b1b|#nWEF!XfrcyPq`m>tk3k$5V1hC}3jrC^8B!Qh7;_k+7*d#87@`;}88w+-f)w~A z!_Jk1gQe)K?AFy{92|OCKrZSb_Rx8 z<{IV{CP|=pElUq43qw6iFoPzuUzK{WtBMf46)RN?k#GD*W)>~}JrA5X0MYq^Nro?Ba++r!p zFE75u3?y%Hz)UV?1)87$0$;s>EN82jP@wAK7}va%)S?*wyi}K>%(B#&ki;_$nF=|X zhgY3hTpHt^S>jQe6yuwpmmi#(Sd^R*lbD>GUz%4E12a~ypz;<^dTL2LOrVGdXgVlN zitT_z1H%m#u6DmhzYD@PJIZ%tU19Njz%AHs-)VoDTc*L~0l)Ak21Zt?4(1!eViO7{ znsst~U= 4: + print('Logged in successfully.') +else: + print('You do not have sufficient rights to access the panel.') + exit() + +while(True): + command = input('>>> ') + + if command == "exit": + exit() + elif command == "check": + compare_databases() + elif command == "sync": + synchronization_databases() + elif command == "log": + with open('log.txt', 'r') as file: + for line in file: + print(line.strip()) + elif command == "users-list": + list_users_database() + elif command == "users-rel": + user_id = input('User ID: ') + print("Current reliability: " + str(get_reliability_from_id(user_id))) + new_reliability = input('Change reliability to: ') + change_reliability_by_user_id(user_id, new_reliability) + print('Changed reliability successfully.') + \ No newline at end of file diff --git a/adpn.sh b/adpn.sh new file mode 100644 index 0000000..747882a --- /dev/null +++ b/adpn.sh @@ -0,0 +1 @@ +python adpn.py \ No newline at end of file diff --git a/initializer/__pycache__/database.cpython-312.pyc b/initializer/__pycache__/database.cpython-312.pyc index 1a2e06ecb36188157647fd827dae40ef1ca13b77..0485d505490e2c81e8b6013a515c19e6fa9f7a67 100644 GIT binary patch delta 623 zcmZutziSjh6rS0g+ui$pCSpW$xCEO;?ns1K1(OgPn+Ot{MUcIn!7S{L@MbUOuDM1? zeVmZeQpGCdUr3cSSH$Kt*l1y;c-UC^W-odv9GExX_sx6r-hAh^{n^TCxm+N)-Ygx9 zU87&Q{&Wr50pWzxkhtp9LKcXM!IWIm z3%vMWy~N8?y+fSJCRj(0*(PEl^tNHpzJ`$n4iQk%p#HM_qGky!J>JiFo$GDsfU9tv)}u|io?>v@b>ZYl(WvJAo$tb!$vD|ys_8qDJp@(6 vzpa%h;q6c?-iMpWDQ-EB;fGEs{YWaG$-+6QeQa}HB3 za}+a>&CQ2Kq;`&$&=kVCJH~`=5O#W;s*+9 zvOz3io-D^H<_|I&VhKpYN(QhJu(`iDY;yBcN^?@}iX?zij6hrrVtim`WMsU}z;~BH U_9=tWCl(Gy+0SB9i~?Yt0RCM=+W-In diff --git a/initializer/__pycache__/loader.cpython-312.pyc b/initializer/__pycache__/loader.cpython-312.pyc index fa608ab6cee80be9089b918e99e0971416ecfa16..5fd5b117bab73ca1613a1e3fb9c3cc2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pOLFIrO>^rhj#$Jm$3kX&eURJKWuB&7}FEg*t(U~0w3Q%E*^ zUNP5MFE51IuF_4y?6SXm)jzR=zbGHV;?${`FJ3VX-7aObrftuaa=GQWmkHVw|Hg}$ z#$ZWI8G9Rcq{qX4nMBX-k17#)1XO&g0?_ZsD%M)p1R&gQuqhgr`- zw=3)od4T<+Mpl1P`tK>hPn7FQHGE=A8LThwmp0qoSU7qp?<73A2nqnAk z3jF*$SbNIL`Jz$EnXl3p;S=VC{S3gaL)`S{|oe#6$nSJkl-|S)Gb;kIp>zah) z`SyEfPwg66cBgx4C9iHttA-szj@TM9xz5b^4?0-set5#x#CI(#?z2y9PLz+`5a-ot zk(5uch$zYJycq)-PX^I?2fQ`_#}|kY6p`YSqQq~rgm}uI#V1jW;q+cg;&JSvfJjxm z)5gU0Xr66^IkuvoF~_n}6>0Sv#=ogvS_Y~Z;)s4GNRV)pCQ7e5!61wfk_gj)6s<=I zX+)rSuJ6=bTl`YTs#%hAgyV!TXr5LDgh!#KhXzcb6r`F~%ew18&9Pm-W?Q}mv#5vP zydqlyEoBN*sMV>&!Jvjvn-2CQ(Tt9ZL+x^84wKD@a{MaaC{tnJ+xE!?U|w+g^IO^r!-4%S;6^&j-h9He5d}A~39az1?Z~^NqG;I{>nHq30fu z{b1B>xxQ;P+zkf?+tiC7(Qo8DH4^9!17je$EzbcTsMsSBoMwB?fzUerNnziC%6}t; zg@qUNTU~6n?M}lfFT!cuV>mq%@l$4ueUmah>0D1L^`r|uX|^X7@!97omfJ5P4vHE} Hhq3+u&T6x^ diff --git a/manager/manager.py b/manager/manager.py index aa1fcf7..1242a77 100644 --- a/manager/manager.py +++ b/manager/manager.py @@ -1,4 +1,6 @@ import streamlit as st +from account.userid import get_user_id +from log.write import log from account.loader import account_database_loader from account.reliability import get_user_reliability from initializer.loader import censorship_database_loader @@ -17,11 +19,13 @@ def manager_insert_data(conn, username, password, link, title, text, description insert_data(censorship_conn, link, title, text, description, keywords, shorttext) st.success("Your add request has been sent to the administrator.") censorship_conn.close() - elif reliability == 1: + elif reliability >= 1: insert_data(conn, link, title, text, description, keywords, shorttext) else: st.error("The user's reliability cannot be determined.") + log(cursor, username, password, "Insert Data", "Link: " + link + " Title: " + title + " Text: " + text + " Description: " + description + " Keywords: " + keywords + " ShortText: " + shorttext) + cursor.close() account_conn.close() @@ -36,11 +40,13 @@ def manager_edit_data(conn, username, password, site_id, link, title, text, desc edit_data(censorship_conn, site_id, link, title, text, description, keywords, shorttext) st.success("Your edit request has been sent to the administrator.") censorship_conn.close() - elif reliability == 1: + elif reliability >= 2: edit_data(conn, site_id, link, title, text, description, keywords, shorttext) else: st.error("The user's reliability cannot be determined.") + log(cursor, username, password, "Edit Data", "Site ID: " + site_id + " Link: " + link + " Title: " + title + " Text: " + text + " Description: " + description + " Keywords: " + keywords + " ShortText: " + shorttext) + cursor.close() account_conn.close() @@ -50,10 +56,13 @@ def manager_remove_data(conn, username, password, site_id): reliability = get_user_reliability(cursor, username, password) - if reliability == 1: + if reliability >= 3: remove_data(conn, site_id) st.success("Data removed successfully.") - account_conn.close() - cursor.close() + else: + st.error("The user's reliability cannot be determined.") + log(cursor, username, password, "Remove Data", "Site ID: " + site_id) + account_conn.close() + cursor.close()