2022-06-21 21:07:06 +02:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
2022-06-20 21:44:58 +02:00
|
|
|
|
2022-07-26 20:44:47 +02:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QCloseEvent>
|
2022-06-20 21:44:58 +02:00
|
|
|
|
2022-07-26 20:44:47 +02:00
|
|
|
#include <QFontDatabase>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QChartView>
|
2022-06-21 21:07:06 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
#include <thread>
|
|
|
|
|
2022-06-24 19:56:34 +02:00
|
|
|
#include "utilities.h"
|
2022-06-27 21:55:14 +02:00
|
|
|
#include "modules.h"
|
2022-06-26 22:31:45 +02:00
|
|
|
#include "tools/craplog/craplog.h"
|
2022-07-21 21:45:52 +02:00
|
|
|
#include "tools/crapview/crapview.h"
|
2022-06-23 04:00:37 +02:00
|
|
|
|
2022-06-20 21:44:58 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
2022-06-21 21:07:06 +02:00
|
|
|
namespace Ui { class MainWindow; }
|
2022-06-20 21:44:58 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
class MainWindow : public QMainWindow
|
2022-06-20 21:44:58 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-20 21:44:58 +02:00
|
|
|
public:
|
2022-07-26 20:44:47 +02:00
|
|
|
MainWindow( QWidget *parent=nullptr );
|
2022-06-21 21:07:06 +02:00
|
|
|
~MainWindow();
|
2022-07-26 20:44:47 +02:00
|
|
|
void closeEvent( QCloseEvent *event );
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
//void operator()( int a );
|
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
private slots:
|
2022-07-21 21:45:52 +02:00
|
|
|
// custom
|
|
|
|
void wait_ActiveWindow();
|
|
|
|
|
|
|
|
void update_Craplog_PerfData();
|
|
|
|
|
|
|
|
// Qt's
|
2022-06-30 20:47:05 +02:00
|
|
|
void on_button_LogFiles_ViewFile_clicked();
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-25 21:17:40 +02:00
|
|
|
void on_checkBox_LogFiles_CheckAll_stateChanged(int arg1);
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void on_button_LogFiles_RefreshList_clicked();
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
void on_listLogFiles_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-22 21:37:35 +02:00
|
|
|
void on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column);
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-26 23:12:57 +02:00
|
|
|
void on_button_LogFiles_Apache_clicked();
|
|
|
|
|
|
|
|
void on_button_LogFiles_Nginx_clicked();
|
|
|
|
|
|
|
|
void on_button_LogFiles_Iis_clicked();
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void on_button_MakeStats_Start_clicked();
|
|
|
|
|
2022-07-25 21:57:45 +02:00
|
|
|
void on_box_StatsWarn_WebServer_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsWarn_LogsType_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsWarn_Year_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsWarn_Month_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsWarn_Day_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_checkBox_StatsWarn_Hour_stateChanged(int state);
|
|
|
|
|
|
|
|
void on_box_StatsWarn_Hour_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_button_StatsWarn_Draw_clicked();
|
|
|
|
|
2022-07-28 22:45:38 +02:00
|
|
|
void on_button_StatsWarn_Update_clicked();
|
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
void on_box_StatsSpeed_WebServer_currentIndexChanged(int index);
|
2022-07-09 18:16:09 +02:00
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
void on_box_StatsSpeed_Year_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsSpeed_Month_currentIndexChanged(int index);
|
|
|
|
|
2022-07-25 21:57:45 +02:00
|
|
|
void on_box_StatsSpeed_Day_currentIndexChanged(int index);
|
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
void on_button_StatsSpeed_Draw_clicked();
|
2022-06-30 20:47:05 +02:00
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_box_StatsCount_WebServer_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_tabs_StatsCount_AccErr_currentChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsCount_Year_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsCount_Month_currentIndexChanged(int index);
|
|
|
|
|
2022-07-25 21:57:45 +02:00
|
|
|
void on_box_StatsCount_Day_currentIndexChanged(int index);
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_button_StatsCount_Protocol_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Method_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Request_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Query_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Response_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Referrer_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Cookie_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_UserAgent_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_AccClient_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Level_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Message_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Source_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_Port_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsCount_ErrClient_clicked();
|
|
|
|
|
|
|
|
void on_box_StatsDay_WebServer_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsDay_LogsType_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsDay_LogsField_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsDay_FromYear_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsDay_FromMonth_currentIndexChanged(int index);
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void on_box_StatsDay_FromDay_currentIndexChanged(int index);
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_checkBox_StatsDay_Period_stateChanged(int state);
|
|
|
|
|
|
|
|
void on_box_StatsDay_ToYear_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsDay_ToMonth_currentIndexChanged(int index);
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void on_box_StatsDay_ToDay_currentIndexChanged(int index);
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_button_StatsDay_Draw_clicked();
|
|
|
|
|
|
|
|
void on_box_StatsRelat_WebServer_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_LogsType_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_LogsField_1_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_LogsField_2_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_FromYear_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_FromMonth_currentIndexChanged(int index);
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void on_box_StatsRelat_FromDay_currentIndexChanged(int index);
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_box_StatsRelat_ToYear_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_StatsRelat_ToMonth_currentIndexChanged(int index);
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void on_box_StatsRelat_ToDay_currentIndexChanged(int index);
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void on_button_StatsRelat_Draw_clicked();
|
|
|
|
|
2022-07-29 20:13:06 +02:00
|
|
|
void on_button_StatsGlob_Apache_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsGlob_Nginx_clicked();
|
|
|
|
|
|
|
|
void on_button_StatsGlob_Iis_clicked();
|
|
|
|
|
2022-08-03 21:36:13 +02:00
|
|
|
void on_checkBox_ConfGeneral_Window_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_slider_ConfGeneral_General_sliderReleased();
|
|
|
|
|
|
|
|
void on_slider_ConfGeneral_Logs_sliderReleased();
|
|
|
|
|
|
|
|
void on_slider_ConfGeneral_Stats_sliderReleased();
|
|
|
|
|
|
|
|
void on_box_ConfGeneral_Theme_Window_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_ConfGeneral_Theme_TextBrowser_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_box_ConfGeneral_Theme_Charts_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_checkBox_ConfControl_Usage_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_checkBox_ConfControl_Size_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_spinBox_ConfControl_Size_editingFinished();
|
|
|
|
|
|
|
|
void on_checkBox_ConfApache_Paths_Different_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Paths_AccPath_textChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Paths_ErrPath_textChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_button_ConfApache_Paths_SavePaths_clicked();
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Formats_AccString_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_button_ConfApache_Format_AccSave_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Formats_AccSample_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Formats_AccHelp_clicked();
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Formats_ErrString_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_button_ConfApache_Format_ErrSave_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Formats_ErrSample_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Formats_ErrHelp_clicked();
|
|
|
|
|
|
|
|
void on_box_ConfApache_Warnlist_Acc_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_checkBox_ConfApache_Warnlist_AccUsed_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Warnlist_Acc_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Warnlist_Acc_returnPressed();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_AccAdd_clicked();
|
|
|
|
|
|
|
|
void on_list_ConfApache_Warnlist_Acc_itemSelectionChanged();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_AccRemove_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_AccUp_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_AccDown_clicked();
|
|
|
|
|
|
|
|
void on_box_ConfApache_Warnlist_Err_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_checkBox_ConfApache_Warnlist_ErrUsed_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Warnlist_Err_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Warnlist_Err_returnPressed();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_ErrAdd_clicked();
|
|
|
|
|
|
|
|
void on_list_ConfApache_Warnlist_Err_itemSelectionChanged();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_ErrRemove_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_ErrUp_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Warnlist_ErrDown_clicked();
|
|
|
|
|
|
|
|
void on_box_ConfApache_Blacklist_Acc_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_checkBox_ConfApache_Blacklist_AccUsed_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Blacklist_Acc_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Blacklist_Acc_returnPressed();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_AccAdd_clicked();
|
|
|
|
|
|
|
|
void on_list_ConfApache_Blacklist_Acc_itemSelectionChanged();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_AccRemove_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_AccUp_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_AccDown_clicked();
|
|
|
|
|
|
|
|
void on_box_ConfApache_Blacklist_Err_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_checkBox_ConfApache_Blacklist_ErrUsed_clicked(bool checked);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Blacklist_Err_cursorPositionChanged(int arg1, int arg2);
|
|
|
|
|
|
|
|
void on_inLine_ConfApache_Blacklist_Err_returnPressed();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_ErrAdd_clicked();
|
|
|
|
|
|
|
|
void on_list_ConfApache_Blacklist_Err_itemSelectionChanged();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_ErrRemove_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_ErrUp_clicked();
|
|
|
|
|
|
|
|
void on_button_ConfApache_Blacklist_ErrDown_clicked();
|
|
|
|
|
2022-06-20 21:44:58 +02:00
|
|
|
private:
|
2022-06-21 21:07:06 +02:00
|
|
|
Ui::MainWindow *ui;
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-06-27 19:49:09 +02:00
|
|
|
// quantoty of informational dialogs to display
|
|
|
|
int dialogs_Level = 1; // 0: essential, 1: usefull, 2: explanatory
|
|
|
|
|
2022-08-03 21:36:13 +02:00
|
|
|
// web servers ID constants
|
|
|
|
const unsigned int APACHE_ID=11, NGINX_ID=12, IIS_ID=13;
|
|
|
|
// log type constants
|
|
|
|
const unsigned int FAILED=0, ACCESS_LOGS=1, ERROR_LOGS=2;
|
|
|
|
|
2022-07-09 18:16:09 +02:00
|
|
|
void makeInitialChecks();
|
|
|
|
|
2022-07-06 21:03:58 +02:00
|
|
|
//////////////////
|
|
|
|
//// GRAPHICS ////
|
|
|
|
//////////////////
|
2022-08-03 21:36:13 +02:00
|
|
|
// remember window position and sizes
|
|
|
|
bool remember_window = true;
|
|
|
|
// themes
|
|
|
|
int window_theme = 0,
|
|
|
|
charts_theme = 0;
|
|
|
|
// color schemes
|
2022-06-27 21:55:14 +02:00
|
|
|
std::unordered_map<int, std::unordered_map<std::string, QString>> TB_COLOR_SCHEMES;
|
2022-06-24 19:56:34 +02:00
|
|
|
std::unordered_map<std::string, QColor> COLORS;
|
2022-08-03 21:36:13 +02:00
|
|
|
// fonts
|
2022-06-25 18:48:08 +02:00
|
|
|
std::unordered_map<std::string, QFont> FONTS;
|
|
|
|
int font_size = 13,
|
|
|
|
font_size_big = 16,
|
|
|
|
font_size_small = 10;
|
|
|
|
// base font families, to build fonts from
|
2022-06-30 20:47:05 +02:00
|
|
|
QString main_font_family,
|
|
|
|
script_font_family;
|
|
|
|
|
2022-07-06 21:03:58 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
/////////////////////
|
|
|
|
//// GENERAL USE ////
|
2022-07-06 21:03:58 +02:00
|
|
|
/////////////////////
|
2022-06-30 20:47:05 +02:00
|
|
|
// get a printable size, from Bytes to the best fit
|
2022-07-10 18:14:00 +02:00
|
|
|
QString printableSize( const int bytes ),
|
2022-07-04 21:08:23 +02:00
|
|
|
printableSpeed( const int bytes, const int secs ),
|
|
|
|
printableTime( const int seconds );
|
2022-06-25 18:48:08 +02:00
|
|
|
|
2022-07-06 21:03:58 +02:00
|
|
|
//////////////////
|
|
|
|
//// DATABASE ////
|
|
|
|
std::string db_stats_path,
|
|
|
|
db_hashes_path;
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////
|
|
|
|
//// CRAPLOG ////
|
|
|
|
/////////////////
|
|
|
|
Craplog craplog;
|
|
|
|
std::thread craplog_thread;
|
|
|
|
QTimer *craplog_timer;
|
2022-07-08 21:40:58 +02:00
|
|
|
std::chrono::system_clock::time_point craplog_timer_start;
|
2022-07-06 21:03:58 +02:00
|
|
|
std::chrono::system_clock::duration craplog_timer_elapsed;
|
|
|
|
void craplogStarted();
|
|
|
|
void craplogFinished();
|
|
|
|
|
2022-06-27 19:49:09 +02:00
|
|
|
//////////////
|
|
|
|
//// LOGS ////
|
|
|
|
// web servers related
|
|
|
|
bool loading_LogsList = false;
|
|
|
|
std::unordered_map<int, bool> allowed_web_servers;
|
2022-06-30 20:47:05 +02:00
|
|
|
void disableAllButtons_LogFiles_WS(),
|
|
|
|
enableAllButtons_LogFiles_WS();
|
2022-06-27 19:49:09 +02:00
|
|
|
// logs list related
|
2022-07-01 21:30:15 +02:00
|
|
|
bool display_access_logs = true,
|
|
|
|
display_error_logs = true,
|
|
|
|
display_used_files = true,
|
2022-06-30 20:47:05 +02:00
|
|
|
display_warnsize_files = true;
|
2022-06-25 18:48:08 +02:00
|
|
|
// text browser related
|
2022-06-27 21:55:14 +02:00
|
|
|
TextBrowser TB;
|
|
|
|
|
2022-07-01 21:30:15 +02:00
|
|
|
//////////////////////////
|
|
|
|
//// LOGS PERFORMANCE ////
|
2022-07-04 21:08:23 +02:00
|
|
|
void update_MakeStats_labels(),
|
2022-07-10 18:14:00 +02:00
|
|
|
update_MakeStats_graphs(),
|
|
|
|
reset_MakeStats_labels(),
|
|
|
|
reset_MakeStats_graphs();
|
2022-07-01 21:30:15 +02:00
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
|
|
|
|
//////////////////
|
|
|
|
//// CRAPVIEW ////
|
|
|
|
//////////////////
|
|
|
|
Crapview crapview;
|
|
|
|
// refresh dates: query a new collection from the db and apply to the tabs
|
|
|
|
void refreshStatsDates();
|
2022-07-22 22:56:49 +02:00
|
|
|
// check if drawing conditions are met
|
2022-07-25 21:57:45 +02:00
|
|
|
void checkStatsWarnDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
void checkStatsSpeedDrawable();
|
|
|
|
void checkStatsCountDrawable();
|
|
|
|
void checkStatsDayDrawable();
|
|
|
|
void checkStatsRelatDrawable();
|
|
|
|
// polishing
|
|
|
|
void resetStatsCountAccButtons();
|
|
|
|
void resetStatsCountErrButtons();
|
2022-07-26 20:44:47 +02:00
|
|
|
// draw
|
|
|
|
void drawStatsCount( const QString& field );
|
2022-07-21 21:45:52 +02:00
|
|
|
|
2022-06-20 21:44:58 +02:00
|
|
|
};
|
2022-06-21 21:07:06 +02:00
|
|
|
#endif // MAINWINDOW_H
|