diff --git a/src/client_backend/.vs/client_backend/v17/.suo b/src/client_backend/.vs/client_backend/v17/.suo index 3ddb7f5..f06ff57 100644 Binary files a/src/client_backend/.vs/client_backend/v17/.suo and b/src/client_backend/.vs/client_backend/v17/.suo differ diff --git a/src/client_backend/.vs/client_backend/v17/Browse.VC.db b/src/client_backend/.vs/client_backend/v17/Browse.VC.db index 1021a55..8c0940e 100644 Binary files a/src/client_backend/.vs/client_backend/v17/Browse.VC.db and b/src/client_backend/.vs/client_backend/v17/Browse.VC.db differ diff --git a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json index 147c002..ab97381 100644 --- a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json +++ b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json @@ -10,6 +10,22 @@ "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -22,14 +38,6 @@ "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -46,10 +54,6 @@ "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -70,11 +74,24 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 2, + "SelectedChildIndex": 3, "Children": [ { "$type": "Document", - "DocumentIndex": 2, + "DocumentIndex": 4, + "Title": "settings.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeDocumentMoniker": "settings.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeToolTip": "settings.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAA8AAAAcAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-09T13:50:21.91Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, "Title": "connect.h", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", "RelativeDocumentMoniker": "connect.h", @@ -82,12 +99,11 @@ "RelativeToolTip": "connect.h", "ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAABPAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-09T12:32:01.859Z", - "EditorCaption": "" + "WhenOpened": "2024-03-09T12:32:01.859Z" }, { "$type": "Document", - "DocumentIndex": 9, + "DocumentIndex": 11, "Title": "check_dir.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", "RelativeDocumentMoniker": "check_dir.cpp", @@ -105,26 +121,27 @@ "RelativeDocumentMoniker": "log.h", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", "RelativeToolTip": "log.h", - "ViewState": "AQIAAGYAAAAAAAAAAAAYwJMAAAAkAAAA", + "ViewState": "AQIAAGAAAAAAAAAAAAAAAIIAAACFAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", "WhenOpened": "2024-02-25T09:02:55.874Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 5, + "DocumentIndex": 3, "Title": "log.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp", "RelativeDocumentMoniker": "log.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp", "RelativeToolTip": "log.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAeAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAB8AAAAFAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-02-25T09:08:59.07Z" + "WhenOpened": "2024-02-25T09:08:59.07Z", + "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 12, + "DocumentIndex": 13, "Title": "local_com.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", "RelativeDocumentMoniker": "local_com.cpp", @@ -136,19 +153,20 @@ }, { "$type": "Document", - "DocumentIndex": 11, + "DocumentIndex": 5, "Title": "settings.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", "RelativeDocumentMoniker": "settings.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", "RelativeToolTip": "settings.cpp", - "ViewState": "AQIAAAYAAAAAAAAAAAAAABkAAAAUAAAA", + "ViewState": "AQIAALQAAAAAAAAAAAAAANEAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.264Z" + "WhenOpened": "2024-01-28T20:40:06.264Z", + "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 4, + "DocumentIndex": 8, "Title": "thread_ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", "RelativeDocumentMoniker": "thread_ctrl.cpp", @@ -160,19 +178,20 @@ }, { "$type": "Document", - "DocumentIndex": 6, + "DocumentIndex": 2, "Title": "client_backend.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", "RelativeDocumentMoniker": "client_backend.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", "RelativeToolTip": "client_backend.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAACwAAAAiAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAQAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.279Z" + "WhenOpened": "2024-01-28T20:40:06.279Z", + "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 8, + "DocumentIndex": 10, "Title": "scan.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", "RelativeDocumentMoniker": "scan.cpp", @@ -184,7 +203,7 @@ }, { "$type": "Document", - "DocumentIndex": 7, + "DocumentIndex": 9, "Title": "update.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp", "RelativeDocumentMoniker": "update.cpp", @@ -196,7 +215,7 @@ }, { "$type": "Document", - "DocumentIndex": 10, + "DocumentIndex": 12, "Title": "local_schedule.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp", "RelativeDocumentMoniker": "local_schedule.cpp", @@ -208,7 +227,7 @@ }, { "$type": "Document", - "DocumentIndex": 14, + "DocumentIndex": 15, "Title": "scan.h", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", "RelativeDocumentMoniker": "scan.h", @@ -220,7 +239,7 @@ }, { "$type": "Document", - "DocumentIndex": 13, + "DocumentIndex": 14, "Title": "queue _ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", "RelativeDocumentMoniker": "queue _ctrl.cpp", @@ -238,14 +257,14 @@ "RelativeDocumentMoniker": "connect.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", "RelativeToolTip": "connect.cpp", - "ViewState": "AQIAAJUAAAAAAAAAAAAQwLsAAAAaAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAADAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-01-28T20:40:06.315Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 3, + "DocumentIndex": 7, "Title": "virus_ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", "RelativeDocumentMoniker": "virus_ctrl.cpp", diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.ilk b/src/client_backend/client_backend/x64/Debug/client_backend.ilk index d0072bd..1a9e12f 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.ilk and b/src/client_backend/client_backend/x64/Debug/client_backend.ilk differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog index bc52c1c..20ec9cb 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog index 38529c9..7ea327d 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/vc143.idb b/src/client_backend/client_backend/x64/Debug/vc143.idb index ab1bd6e..57e8e77 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.idb and b/src/client_backend/client_backend/x64/Debug/vc143.idb differ diff --git a/src/client_backend/client_backend/x64/Debug/vc143.pdb b/src/client_backend/client_backend/x64/Debug/vc143.pdb index 5e925d3..20d73bf 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.pdb and b/src/client_backend/client_backend/x64/Debug/vc143.pdb differ diff --git a/src/client_backend/log.cpp b/src/client_backend/log.cpp index fac76fd..aac2a53 100644 --- a/src/client_backend/log.cpp +++ b/src/client_backend/log.cpp @@ -1,7 +1,6 @@ #ifndef LOG_CPP #define LOG_CPP #include "log.h" - std::string get_loglevel(LOGLEVEL level) { switch (level) { case LOGLEVEL::INFO: diff --git a/src/client_backend/log.h b/src/client_backend/log.h index f588513..5b7b85d 100644 --- a/src/client_backend/log.h +++ b/src/client_backend/log.h @@ -1,3 +1,4 @@ +#pragma once #ifndef LOG_H #define LOG_H @@ -9,8 +10,6 @@ #include "well_known.h" #include "settings.h" #include "security.h" -int srv_timeout = 0; -int timeout_reset = 0; enum class LOGLEVEL { INFO, WARN, @@ -28,7 +27,7 @@ std::string get_loglevel(LOGLEVEL level); template void log(LOGLEVEL level, const std::string& message, Args&&... args) { - timeout_reset++; + log_timeout_reset_set(log_timeout_reset_get()+1); std::string prefix = get_loglevel(level); std::time_t now = std::time(nullptr); std::tm tm; @@ -96,7 +95,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { fclose(fp); } //write to server log file only if we werent able to send the logs directly. this file will store them until we can upload them - if (fopen_s(&fp, SRV_LOGFILE, "a") == 0 && srv_timout>=5) { //if server already did not respon over 5 times, we add it to the log file + if (fopen_s(&fp, SRV_LOGFILE, "a") == 0 && log_timeout_get() >= 5) { //if server already did not respon over 5 times, we add it to the log file fprintf_s(fp, "%s\n", to_srv_string.c_str()); fclose(fp); } @@ -105,7 +104,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { //build up the log string: loglevel&logtext&machineid&date //to_srv_string=includes the log message //we now need to build up the request string and append the machineid - if (level!=LOGLEVEL::INFO_NOSEND && level!=LOGLEVEL::WARN_NOSEND && level!=LOGLEVEL::ERR_NOSEND && level!=LOGLEVEL::PANIC_NOSEND && srv_timeout<5) { + if (level!=LOGLEVEL::INFO_NOSEND && level!=LOGLEVEL::WARN_NOSEND && level!=LOGLEVEL::ERR_NOSEND && level!=LOGLEVEL::PANIC_NOSEND && log_timeout_get()<5) { char* url = new char[3000]; int res = 0; if (get_setting("server:server_url", url) == 0 or strcmp(url, "nan") == 0) { @@ -115,22 +114,24 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { strcat_s(url, 3000, get_machineid(SECRETS)); strcat_s(url, 3000, "&apikey="); strcat_s(url, 3000, get_apikey(SECRETS)); - res=fast_send(url, get_setting("communication:unsafe_tls"); + res=fast_send(url, get_setting("communication:unsafe_tls")); if (res != 0) { //we know that the server might be down, so we will increment the timeout counter - srv_timeout++; + log_timeout_set(log_timeout_get() + 1); } //we might not want to log an error occuring here because it will create a loop - delete[] url; - } - else { - delete[] url; - return; } + delete[] url; }//else we do not send the log to the server - if(timeout_reset>100){ //after 100 log entrys, we cna try again to reach out ot the server. - timeout_reset=0; - srv_timeout=0; + if (log_timeout_reset_get() > 100) + { + log_timeout_reset_set(0); + log_timeout_set(0); + } + //!!!i disabled this temporarely, because it does not really work and as long as the client is in lan the other code works anyway + if(log_timeout_reset_get()>100 && 1==0) { //after 100 log entrys, we cna try again to reach out ot the server. + log_timeout_reset_set(0); + log_timeout_set(0); //try to upload the server_log file, where we stored the logs which we could not upload. char* url = new char[3000]; int res = 0; @@ -142,7 +143,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { res=upload_to_srv(SRV_LOGFILE, url, get_setting("communication:unsafe_tls")); if (res != 0) { //we know that the server might be down, so we will increment the timeout counter - srv_timeout++; + log_timeout_set(log_timeout_get() + 1); } else { //remove the logfile diff --git a/src/client_backend/settings.cpp b/src/client_backend/settings.cpp index 6c9bc76..36ace93 100644 --- a/src/client_backend/settings.cpp +++ b/src/client_backend/settings.cpp @@ -11,6 +11,8 @@ char included_folders[100][300]; int included_folders_size = 0; bool setting_rtp_folder_scan_status = 1; //0=off, 1=on bool setting_communication_unsafe_tls = 0; //0=do not allow communication via unsfae, slef signed certs, 1=allwo communication via unsafe, self signed certs +int srv_log_timeout = 0; +int log_timeout_reset = 0; void load_included_folders(); void load_excluded_folders(); int load_settings() { @@ -205,4 +207,17 @@ void print_inclusuions() { log(LOGLEVEL::INFO, "[print_exclusions()]: Excluded folder: ", exluded_folders[i]); } } + +int log_timeout_get() { + return srv_log_timeout; +} +void log_timeout_set(int timeout) { + srv_log_timeout = timeout; +} +void log_timeout_reset_set(int timeout) { + log_timeout_reset = timeout; +} +int log_timeout_reset_get() { + return log_timeout_reset; +} #endif \ No newline at end of file diff --git a/src/client_backend/settings.h b/src/client_backend/settings.h index 76a3aa7..c63b54a 100644 --- a/src/client_backend/settings.h +++ b/src/client_backend/settings.h @@ -9,4 +9,9 @@ int load_settings(); bool is_folder_included(const char* path); bool is_folder_excluded(const char* path); void print_inclusions(); + +int log_timeout_get(); +void log_timeout_set(int timeout); +void log_timeout_reset_set(int timeout); +int log_timeout_reset_get(); #endif \ No newline at end of file diff --git a/src/client_backend/x64/Debug/client_backend.pdb b/src/client_backend/x64/Debug/client_backend.pdb index f97cf01..236c988 100644 Binary files a/src/client_backend/x64/Debug/client_backend.pdb and b/src/client_backend/x64/Debug/client_backend.pdb differ diff --git a/src/server/cyberhex-code/system/secure_zone/php/view_log.php b/src/server/cyberhex-code/system/secure_zone/php/view_log.php index 163b804..f8c80df 100644 --- a/src/server/cyberhex-code/system/secure_zone/php/view_log.php +++ b/src/server/cyberhex-code/system/secure_zone/php/view_log.php @@ -12,11 +12,11 @@ $username = $_SESSION['username']; $perms = $_SESSION["perms"]; $email = $_SESSION["email"]; if($perms[2]!=="1"){ - header("location:/system/insecure_zone/php/no_access.php"); - $block=1; - exit(); + header("location:/system/insecure_zone/php/no_access.php"); + $block=1; + exit(); }else{ - $block=0; + $block=0; } ?> @@ -25,7 +25,7 @@ if($perms[2]!=="1"){ - Change Password + Change Password @@ -37,152 +37,93 @@ if($perms[2]!=="1"){

View log

- - - You are not allowed to delete log entrys. (insufficient permissions) -
'; - }else{ - $id=htmlspecialchars($_GET["delete"]); - $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); - if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); - } - $sql = "DELETE FROM log WHERE id = ?"; - $stmt = $conn->prepare($sql); - $stmt->bind_param("i", $id); - // Execute the statement - $stmt->execute(); - $stmt->close(); - $conn->close(); - echo ''; - } - } - - //get count of log entrys - // Create a connection - $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); - - // Check the connection - if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); - } - $sql = "SELECT count(*) AS log_count FROM log"; - $stmt = $conn->prepare($sql); - // Execute the statement - $stmt->execute(); - // Get the result - $result = $stmt->get_result(); - $row = $result->fetch_assoc(); - $num_of_log_entrys=$row["log_count"]; - $stmt->close(); - $conn->close(); - - //list out log => id, loglevel, logtext, machine_id - // Create a connection - $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); - - // Check the connection - if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); - } - $last_id=-1; - //create the table header - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - - //put filter options here - if(isset($_GET["loglevel"])) - $loglevel_ss=$_GET["loglevel"]; //put the loglevel search string to that and afterwards show it in the filter optionss. so a user sees what he has filtered for - else - $loglevel_ss="Loglevel"; - - if(isset($_GET["logtext"])) - $logtext_ss=$_GET["logtext"]; - else - $logtext_ss="Logtext"; - - if(isset($_GET["machine_id"])) - $machine_id_ss=$_GET["machine_id"]; - else - $machine_id_ss="Machine id"; - - if(isset($_GET["time"])) - $time_ss=$_GET["time"]; - else - $time_ss="Date & time"; - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - - while($num_of_log_entrys!=0){ - $sql = "SELECT * FROM log where id > $last_id"; - $stmt = $conn->prepare($sql); - // Execute the statement - $stmt->execute(); - // Get the result - $result = $stmt->get_result(); - $row = $result->fetch_assoc(); - $last_id=$row["id"]; - $loglevel=$row["loglevel"]; - $logtext=$row["logtext"]; - $machine_id=$row["machine_id"]; - $time=$row["time"]; - $show=true; - //evaluate filter, decide if entry should be shown or not - if(isset($_GET["loglevel"]) && $_GET["loglevel"]!==""){ - if(stripos($loglevel,$_GET["loglevel"])===false){ - $show=false; - } - }if(isset($_GET["logtext"]) && $_GET["logtext"]!==""){ - if(stripos($logtext,$_GET["logtext"])===false){ - $show=false; - } - }if(isset($_GET["machine_id"]) && $_GET["machine_id"]!==""){ - if(stripos($machine_id,$_GET["machine_id"])===false){ - $show=false; - } - }if(isset($_GET["time"]) && $_GET["time"]!==""){ - if(stripos($time,$_GET["time"])===false){ - $show=false; - } - } - if($show==true){ - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - } - $stmt->close(); - $num_of_log_entrys--; - } - echo(''); - echo('
Entry idLoglevelLogtextMachine idTime & dateDelete entry
---
'.$last_id.''.$loglevel.''.$logtext.''.$machine_id.''.$time.'delete
'); - $conn->close(); - ?> + + + You are not allowed to delete log entries. (insufficient permissions) + '; + }else{ + $id=htmlspecialchars($_GET["delete"]); + $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); + if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); + } + $sql = "DELETE FROM log WHERE id = ?"; + $stmt = $conn->prepare($sql); + $stmt->bind_param("i", $id); + // Execute the statement + $stmt->execute(); + $stmt->close(); + $conn->close(); + echo ''; + } + } + + // Define page size and current page + $page_size = 100; + $current_page = isset($_GET['page']) ? intval($_GET['page']) : 1; + $offset = ($current_page - 1) * $page_size; + + // Get total number of log entries + $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); + if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); + } + $sql = "SELECT count(*) AS log_count FROM log"; + $result = $conn->query($sql); + $row = $result->fetch_assoc(); + $total_entries = $row["log_count"]; + + // Calculate total pages + $total_pages = ceil($total_entries / $page_size); + + // Query log entries for the current page + $sql = "SELECT * FROM log ORDER BY id DESC LIMIT ?, ?"; + $stmt = $conn->prepare($sql); + $stmt->bind_param("ii", $offset, $page_size); + $stmt->execute(); + $result = $stmt->get_result(); + + // Display log entries + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + while($row = $result->fetch_assoc()) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo '
Entry idLoglevelLogtextMachine idTime & dateDelete entry
' . $row["id"] . '' . $row["loglevel"] . '' . $row["logtext"] . '' . $row["machine_id"] . '' . $row["time"] . 'delete
'; + $conn->close(); + + // Display pagination links + echo ''; + ?>