diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile index 7bb1ea1..0161651 100644 --- a/cgi-bin/Makefile +++ b/cgi-bin/Makefile @@ -1,7 +1,7 @@ all: sqlite_cgi_base: - gcc sqlite3.c sqlite_cgi_base.c -o sqlite_cgi_base -lpthread -ldl -lcjson + gcc sqlite3.c sqlite_cgi_base.c -o sqlite_cgi_base.cgi -lpthread -ldl -lcjson clean: - rm -rf sqlite_cgi_base \ No newline at end of file + rm -rf *.cgi \ No newline at end of file diff --git a/cgi-bin/login.cgi b/cgi-bin/login.cgi deleted file mode 100755 index b152300..0000000 Binary files a/cgi-bin/login.cgi and /dev/null differ diff --git a/cgi-bin/sqlite_cgi_base b/cgi-bin/sqlite_cgi_base deleted file mode 100755 index b5b7f8d..0000000 Binary files a/cgi-bin/sqlite_cgi_base and /dev/null differ diff --git a/cgi-bin/sqlite_cgi_base.c b/cgi-bin/sqlite_cgi_base.c index 2ccfe64..37d9d70 100644 --- a/cgi-bin/sqlite_cgi_base.c +++ b/cgi-bin/sqlite_cgi_base.c @@ -3,6 +3,10 @@ // #include "cJSON.h" #include "sqlite3.h" +// sqlite3的回调函数 +// sqlite 每查到一条记录,就调用一次这个回调 +int sql_search_callback(void* NotUsed, int argc, char** argv, char** azColName); + int main(int argc, char const* argv[]) { // 连接到 SQLite 数据库 sqlite3* db; // 声明 sqlite3 类型变量,即声明一个数据库对象 @@ -36,7 +40,7 @@ int main(int argc, char const* argv[]) { cJSON* password = cJSON_GetObjectItemCaseSensitive(json_buf, "password"); if (user == NULL || password == NULL || !cJSON_IsString(user) || - !cJSON_IsString(password)) { + !cJSON_IsString(password)) { // 是否是非法输入 fprintf(stderr, "Error getting username and/or password from JSON data\n"); cJSON_Delete(json_buf); @@ -58,7 +62,9 @@ int main(int argc, char const* argv[]) { username_from_frontend, password_from_frontend); // 构建查询语句 // 执行查询语句 - rc = sqlite3_exec(db, query_sql, 0, 0, &zErrMsg); // 执行查询语句 + // rc = sqlite3_exec(db, query_sql, 0, 0, &zErrMsg); // 执行查询语句 + rc = sqlite3_exec(db, query_sql, sql_search_callback, 0, + &zErrMsg); // 执行查询语句 if (rc != SQLITE_OK) { fprintf(stderr, "SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); @@ -84,3 +90,8 @@ int main(int argc, char const* argv[]) { return 0; } + +int sql_search_callback(void* NotUsed, + int argc, + char** argv, + char** azColName) {} \ No newline at end of file diff --git a/html/login.html b/html/login.html index 2b29245..57ef2ec 100644 --- a/html/login.html +++ b/html/login.html @@ -129,7 +129,7 @@
用户名 | +操作指令 | +操作时间 | + + + + + +
---|
diff --git a/html/record_of_operations_history.html b/html/record_of_operations_history.html index 8552c4e..46c4725 100644 --- a/html/record_of_operations_history.html +++ b/html/record_of_operations_history.html @@ -1,14 +1,52 @@ - +
- - -
+ + +