From 6e3d9489fb91cb9196c88cbca993d475eb8c9360 Mon Sep 17 00:00:00 2001
From: zifan <1461978311@qq.com>
Date: Thu, 21 Sep 2023 10:47:57 +0800
Subject: [PATCH 1/2] =?UTF-8?q?arp=E5=88=97=E8=A1=A8=E7=BB=88=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
www/arp.html | 74 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 49 insertions(+), 25 deletions(-)
diff --git a/www/arp.html b/www/arp.html
index 3f9bde3..2b39223 100755
--- a/www/arp.html
+++ b/www/arp.html
@@ -6,39 +6,63 @@
ARP列表
+
+
-
-
- ID |
- ip地址 |
- mac地址 |
-
-
+
+
+
+
+ ID |
+ ip地址 |
+ mac地址 |
+
+
-
-
+
+
+
+
+
From b7bc51ed2fec4f2359d1d55da4d192f492174072 Mon Sep 17 00:00:00 2001
From: wang_chengh <13383929+wang_chengh@user.noreply.gitee.com>
Date: Thu, 21 Sep 2023 11:23:55 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E9=98=B2=E7=81=AB=E5=A2=99=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
www/cgi-bin/c_mysql_ip_fw_view.c | 59 ++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 www/cgi-bin/c_mysql_ip_fw_view.c
diff --git a/www/cgi-bin/c_mysql_ip_fw_view.c b/www/cgi-bin/c_mysql_ip_fw_view.c
new file mode 100644
index 0000000..339b412
--- /dev/null
+++ b/www/cgi-bin/c_mysql_ip_fw_view.c
@@ -0,0 +1,59 @@
+#include
+#include
+#include
+#include
+#include
+
+int main() {
+ MYSQL *conn;
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+
+ conn = mysql_init(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) {
+ fprintf(stderr, "mysql_real_connect() failed\n");
+ mysql_close(conn);
+ exit(1);
+ }
+
+ if (mysql_query(conn, "SELECT * FROM ip_fw")) {
+ fprintf(stderr, "SELECT query failed. Error: %s\n", mysql_error(conn));
+ mysql_close(conn);
+ exit(1);
+ }
+
+ res = mysql_store_result(conn);
+ if (res == NULL) {
+ fprintf(stderr, "mysql_store_result() failed\n");
+ mysql_close(conn);
+ exit(1);
+ }
+
+ cJSON *result_array = cJSON_CreateArray();
+
+ while ((row = mysql_fetch_row(res))) {
+ cJSON *item = cJSON_CreateObject();
+ cJSON_AddStringToObject(item, "id", row[0]);
+ cJSON_AddStringToObject(item, "ip", row[1]);
+ cJSON_AddItemToArray(result_array, item);
+ }
+
+ char *result_json_string = cJSON_Print(result_array);
+
+ printf("Content-Type: application/json;charset=utf-8\r\n");
+ printf("\r\n");
+ printf("%s", result_json_string);
+
+ free(result_json_string);
+ cJSON_Delete(result_array);
+ mysql_free_result(res);
+ mysql_close(conn);
+
+ return 0;
+}