From 689ff0a77c4f4a492ab25af867d3feb31bb97aab Mon Sep 17 00:00:00 2001 From: zifan <1461978311@qq.com> Date: Wed, 20 Sep 2023 16:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/cgi-bin/c_mysql_user_pwd.c | 28 ++++++--- www/cgi-bin/creat_table.sql | 0 www/cgi-bin/login.c | Bin 0 -> 14112 bytes www/cgi-bin/tmp.txt | 1 + www/index.html | 111 +++++++++++++++++++++++++++++++++ www/login.html | 8 ++- 6 files changed, 137 insertions(+), 11 deletions(-) mode change 100644 => 100755 www/cgi-bin/c_mysql_user_pwd.c mode change 100644 => 100755 www/cgi-bin/creat_table.sql create mode 100755 www/cgi-bin/login.c create mode 100755 www/cgi-bin/tmp.txt create mode 100755 www/index.html diff --git a/www/cgi-bin/c_mysql_user_pwd.c b/www/cgi-bin/c_mysql_user_pwd.c old mode 100644 new mode 100755 index d4d9f68..1a2e5a6 --- a/www/cgi-bin/c_mysql_user_pwd.c +++ b/www/cgi-bin/c_mysql_user_pwd.c @@ -8,20 +8,23 @@ #include #include -int main() { +int main() +{ // 连接到 MySQL 数据库 MYSQL *conn; MYSQL_RES *res; MYSQL_ROW row; conn = mysql_init(NULL); - if (conn == NULL) { + if (conn == NULL) + { fprintf(stderr, "mysql_init() failed\n"); exit(1); } if (mysql_real_connect(conn, "localhost", "root", "root", "router", 3306, - NULL, 0) == NULL) { + NULL, 0) == NULL) + { fprintf(stderr, "mysql_real_connect() failed\n"); mysql_close(conn); exit(1); @@ -33,7 +36,8 @@ int main() { // 解析 JSON 数据 cJSON *p = cJSON_Parse(request_data); - if (p == NULL) { + if (p == NULL) + { fprintf(stderr, "Error parsing JSON data\n"); mysql_close(conn); return 1; @@ -44,7 +48,8 @@ int main() { cJSON *pwd = cJSON_GetObjectItemCaseSensitive(p, "pwd"); if (user == NULL || pwd == NULL || !cJSON_IsString(user) || - !cJSON_IsString(pwd)) { + !cJSON_IsString(pwd)) + { fprintf(stderr, "Error getting username and/or password from JSON data\n"); cJSON_Delete(p); @@ -60,7 +65,8 @@ int main() { sprintf(query, "SELECT * FROM users WHERE username='%s' AND password='%s'", username_from_frontend, password_from_frontend); - if (mysql_query(conn, query)) { + if (mysql_query(conn, query)) + { fprintf(stderr, "SELECT query failed. Error: %s\n", mysql_error(conn)); cJSON_Delete(p); mysql_close(conn); @@ -68,7 +74,8 @@ int main() { } res = mysql_store_result(conn); - if (res == NULL) { + if (res == NULL) + { fprintf(stderr, "mysql_store_result() failed\n"); cJSON_Delete(p); mysql_close(conn); @@ -77,10 +84,13 @@ int main() { cJSON *result_json = cJSON_CreateObject(); - if ((row = mysql_fetch_row(res))) { + if ((row = mysql_fetch_row(res))) + { cJSON_AddNumberToObject(result_json, "code", 0); cJSON_AddStringToObject(result_json, "nickname", "admin"); - } else { + } + else + { cJSON_AddNumberToObject(result_json, "code", 1); cJSON_AddStringToObject(result_json, "msg", "用户名或口令错误"); } diff --git a/www/cgi-bin/creat_table.sql b/www/cgi-bin/creat_table.sql old mode 100644 new mode 100755 diff --git a/www/cgi-bin/login.c b/www/cgi-bin/login.c new file mode 100755 index 0000000000000000000000000000000000000000..300a4ba265dd5f25140e393d8d28e9efd27a3eb4 GIT binary patch literal 14112 zcmeHOdvH|Oc|W@g0`pi20S*RSu3clxZnX#yM8UDWs~0Oq2n7k7CdF5)eMk$^?t1qw zuW4%~3K*HlRvp{Hou)$@nwU0iTql!aXCj12EvM;pFs)sZW;( zkKKFk?sYqz=^vfpX!d^R`H6xcxk%=t=>@gGj1|M9E(< z`DIqn=IaHkC}SE2NRR3|bt7j%dw51sMioNxORDs!dZah^*Qk_ekA+UjiYcnvM{T2D zw`^ax+YgR-KM~f z9dN$`{+fgReGc+I2YinM{+AB;CivCxv#0kRrVmGiUt;b?*J|3(pww%@7WW`TI zei3jcaWyY}h1;LcUYhT>*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lJS31>Z|)VB-e*SQvaB( z{r39*l}%rrcc}jlsV{gI8GHXzycD@m{?)lir#uk-z@~5a|6`P6)y$tE5>@B9>iNcV%Asttc#jZ zQT0>?l%C?RB14#JKf9@i7forL@YraP6ITfrAP=0A|GEMqGD^SJhLbEMMHeAo@Xbra yrNbxa0wpNRY%I5<#;!>n`%u9hmkp-jum(TXel`Em^I6XS#O*@=5!(Y}_y1phE3kF| literal 0 HcmV?d00001 diff --git a/www/cgi-bin/tmp.txt b/www/cgi-bin/tmp.txt new file mode 100755 index 0000000..38baac9 --- /dev/null +++ b/www/cgi-bin/tmp.txt @@ -0,0 +1 @@ +{"name":"disen","pwd":"123456"}disen12345 \ No newline at end of file diff --git a/www/index.html b/www/index.html new file mode 100755 index 0000000..6ca5f1d --- /dev/null +++ b/www/index.html @@ -0,0 +1,111 @@ + + + + + + + + 主页 + + + + +
+ +
+ [登出] +
+
+ +
+ +
+ +
+
+ + + + + \ No newline at end of file diff --git a/www/login.html b/www/login.html index 6d01031..7688daf 100755 --- a/www/login.html +++ b/www/login.html @@ -10,14 +10,18 @@