Code improvements and updates

This commit is contained in:
Valentino Orlandi 2022-08-21 21:55:15 +02:00
parent 8422a97c95
commit 49aa984671
Signed by: elB4RTO
GPG key ID: 1719E976DB2D4E71
2 changed files with 180 additions and 111 deletions

View file

@ -218,6 +218,7 @@ MainWindow::MainWindow(QWidget *parent)
QString rich_text; QString rich_text;
RichText::richLogsDefault( rich_text ); RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setText( rich_text );
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
rich_text.clear(); rich_text.clear();
} }
@ -330,6 +331,13 @@ void MainWindow::readConfigs()
if ( proceed == true ) { if ( proceed == true ) {
std::vector<std::string> aux, list, configs; std::vector<std::string> aux, list, configs;
try { try {
// reset the lists when a config file is found
for ( int w=this->APACHE_ID; w<=this->IIS_ID; w++ ) {
for ( const int& f : std::vector<int>({11,12,20,21}) ) {
this->craplog.setWarnlist( w, f, {} );
}
this->craplog.setBlacklist( w, 20, {} );
}
std::string content; std::string content;
IOutils::readFile( this->configs_path, content ); IOutils::readFile( this->configs_path, content );
StringOps::splitrip( configs, content ); StringOps::splitrip( configs, content );
@ -416,18 +424,33 @@ void MainWindow::readConfigs()
} else if ( var == "ApacheWarnlistMethod" ) { } else if ( var == "ApacheWarnlistMethod" ) {
this->craplog.setWarnlist( this->APACHE_ID, 11, this->string2list( val ) ); this->craplog.setWarnlist( this->APACHE_ID, 11, this->string2list( val ) );
} else if ( var == "ApacheWarnlistMethodUsed" ) {
this->craplog.setWarnlistUsed( this->APACHE_ID, 11, this->s2b.at( val ) );
} else if ( var == "ApacheWarnlistURI" ) { } else if ( var == "ApacheWarnlistURI" ) {
this->craplog.setWarnlist( this->APACHE_ID, 12, this->string2list( val ) ); this->craplog.setWarnlist( this->APACHE_ID, 12, this->string2list( val ) );
} else if ( var == "ApacheWarnlistURIUsed" ) {
this->craplog.setWarnlistUsed( this->APACHE_ID, 12, this->s2b.at( val ) );
} else if ( var == "ApacheWarnlistClient" ) { } else if ( var == "ApacheWarnlistClient" ) {
this->craplog.setWarnlist( this->APACHE_ID, 20, this->string2list( val ) ); this->craplog.setWarnlist( this->APACHE_ID, 20, this->string2list( val ) );
} else if ( var == "ApacheWarnlistClientUsed" ) {
this->craplog.setWarnlistUsed( this->APACHE_ID, 20, this->s2b.at( val ) );
} else if ( var == "ApacheWarnlistUserAgent" ) { } else if ( var == "ApacheWarnlistUserAgent" ) {
this->craplog.setWarnlist( this->APACHE_ID, 21, this->string2list( val ) ); this->craplog.setWarnlist( this->APACHE_ID, 21, this->string2list( val, true ) );
} else if ( var == "ApacheWarnlistUserAgentUsed" ) {
this->craplog.setWarnlistUsed( this->APACHE_ID, 21, this->s2b.at( val ) );
} else if ( var == "ApacheBlacklistClient" ) { } else if ( var == "ApacheBlacklistClient" ) {
this->craplog.setBlacklist( this->APACHE_ID, 20, this->string2list( val ) ); this->craplog.setBlacklist( this->APACHE_ID, 20, this->string2list( val ) );
} else if ( var == "ApacheBlacklistClientUsed" ) {
this->craplog.setBlacklistUsed( this->APACHE_ID, 20, this->s2b.at( val ) );
} else if ( var == "NginxLogsPath" ) { } else if ( var == "NginxLogsPath" ) {
this->craplog.setLogsPath( this->NGINX_ID, this->resolvePath( val ) ); this->craplog.setLogsPath( this->NGINX_ID, this->resolvePath( val ) );
@ -437,18 +460,33 @@ void MainWindow::readConfigs()
} else if ( var == "NginxWarnlistMethod" ) { } else if ( var == "NginxWarnlistMethod" ) {
this->craplog.setWarnlist( this->NGINX_ID, 11, this->string2list( val ) ); this->craplog.setWarnlist( this->NGINX_ID, 11, this->string2list( val ) );
} else if ( var == "NginxWarnlistMethodUsed" ) {
this->craplog.setWarnlistUsed( this->NGINX_ID, 11, this->s2b.at( val ) );
} else if ( var == "NginxWarnlistURI" ) { } else if ( var == "NginxWarnlistURI" ) {
this->craplog.setWarnlist( this->NGINX_ID, 12, this->string2list( val ) ); this->craplog.setWarnlist( this->NGINX_ID, 12, this->string2list( val ) );
} else if ( var == "NginxWarnlistURIUsed" ) {
this->craplog.setWarnlistUsed( this->NGINX_ID, 12, this->s2b.at( val ) );
} else if ( var == "NginxWarnlistClient" ) { } else if ( var == "NginxWarnlistClient" ) {
this->craplog.setWarnlist( this->NGINX_ID, 20, this->string2list( val ) ); this->craplog.setWarnlist( this->NGINX_ID, 20, this->string2list( val ) );
} else if ( var == "NginxWarnlistClientUsed" ) {
this->craplog.setWarnlistUsed( this->NGINX_ID, 20, this->s2b.at( val ) );
} else if ( var == "NginxWarnlistUserAgent" ) { } else if ( var == "NginxWarnlistUserAgent" ) {
this->craplog.setWarnlist( this->NGINX_ID, 21, this->string2list( val ) ); this->craplog.setWarnlist( this->NGINX_ID, 21, this->string2list( val, true ) );
} else if ( var == "NginxWarnlistUserAgentUsed" ) {
this->craplog.setWarnlistUsed( this->NGINX_ID, 21, this->s2b.at( val ) );
} else if ( var == "NginxBlacklistClient" ) { } else if ( var == "NginxBlacklistClient" ) {
this->craplog.setBlacklist( this->NGINX_ID, 20, this->string2list( val ) ); this->craplog.setBlacklist( this->NGINX_ID, 20, this->string2list( val ) );
} else if ( var == "NginxBlacklistClientUsed" ) {
this->craplog.setBlacklistUsed( this->NGINX_ID, 20, this->s2b.at( val ) );
} else if ( var == "IisLogsPath" ) { } else if ( var == "IisLogsPath" ) {
this->craplog.setLogsPath( this->IIS_ID, this->resolvePath( val ) ); this->craplog.setLogsPath( this->IIS_ID, this->resolvePath( val ) );
@ -471,18 +509,33 @@ void MainWindow::readConfigs()
} else if ( var == "IisWarnlistMethod" ) { } else if ( var == "IisWarnlistMethod" ) {
this->craplog.setWarnlist( this->IIS_ID, 11, this->string2list( val ) ); this->craplog.setWarnlist( this->IIS_ID, 11, this->string2list( val ) );
} else if ( var == "IisWarnlistMethodUsed" ) {
this->craplog.setWarnlistUsed( this->IIS_ID, 11, this->s2b.at( val ) );
} else if ( var == "IisWarnlistURI" ) { } else if ( var == "IisWarnlistURI" ) {
this->craplog.setWarnlist( this->IIS_ID, 12, this->string2list( val ) ); this->craplog.setWarnlist( this->IIS_ID, 12, this->string2list( val ) );
} else if ( var == "IisWarnlistURIUsed" ) {
this->craplog.setWarnlistUsed( this->IIS_ID, 12, this->s2b.at( val ) );
} else if ( var == "IisWarnlistClient" ) { } else if ( var == "IisWarnlistClient" ) {
this->craplog.setWarnlist( this->IIS_ID, 20, this->string2list( val ) ); this->craplog.setWarnlist( this->IIS_ID, 20, this->string2list( val ) );
} else if ( var == "IisWarnlistClientUsed" ) {
this->craplog.setWarnlistUsed( this->IIS_ID, 20, this->s2b.at( val ) );
} else if ( var == "IisWarnlistUserAgent" ) { } else if ( var == "IisWarnlistUserAgent" ) {
this->craplog.setWarnlist( this->IIS_ID, 21, this->string2list( val ) ); this->craplog.setWarnlist( this->IIS_ID, 21, this->string2list( val, true ) );
} else if ( var == "IisWarnlistUserAgentUsed" ) {
this->craplog.setWarnlistUsed( this->IIS_ID, 21, this->s2b.at( val ) );
} else if ( var == "IisBlacklistClient" ) { } else if ( var == "IisBlacklistClient" ) {
this->craplog.setBlacklist( this->IIS_ID, 20, this->string2list( val ) ); this->craplog.setBlacklist( this->IIS_ID, 20, this->string2list( val ) );
} else if ( var == "IisBlacklistClientUsed" ) {
this->craplog.setBlacklistUsed( this->IIS_ID, 20, this->s2b.at( val ) );
} else if ( var == "CrapviewDialogLevel" ) { } else if ( var == "CrapviewDialogLevel" ) {
this->crapview.setDialogsLevel( std::stoi( val ) ); this->crapview.setDialogsLevel( std::stoi( val ) );
@ -618,19 +671,29 @@ void MainWindow::writeConfigs()
configs += "\nApacheLogsPath=" + this->craplog.getLogsPath( this->APACHE_ID ); configs += "\nApacheLogsPath=" + this->craplog.getLogsPath( this->APACHE_ID );
configs += "\nApacheLogsFormat=" + this->craplog.getLogsFormatString( this->APACHE_ID ); configs += "\nApacheLogsFormat=" + this->craplog.getLogsFormatString( this->APACHE_ID );
configs += "\nApacheWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 11 ) ); configs += "\nApacheWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 11 ) );
configs += "\nApacheWarnlistMethodUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->APACHE_ID, 11 ) );
configs += "\nApacheWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 12 ) ); configs += "\nApacheWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 12 ) );
configs += "\nApacheWarnlistURIUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->APACHE_ID, 12 ) );
configs += "\nApacheWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 20 ) ); configs += "\nApacheWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 20 ) );
configs += "\nApacheWarnlistClientUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->APACHE_ID, 20 ) );
configs += "\nApacheWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 21 ), true ); configs += "\nApacheWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->APACHE_ID, 21 ), true );
configs += "\nApacheWarnlistUserAgentUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->APACHE_ID, 21 ) );
configs += "\nApacheBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->APACHE_ID, 20 ) ); configs += "\nApacheBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->APACHE_ID, 20 ) );
configs += "\nApacheBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( this->APACHE_ID, 20 ) );
//// NGINX //// //// NGINX ////
configs += "\n\n[Nginx]"; configs += "\n\n[Nginx]";
configs += "\nNginxLogsPath=" + this->craplog.getLogsPath( this->NGINX_ID ); configs += "\nNginxLogsPath=" + this->craplog.getLogsPath( this->NGINX_ID );
configs += "\nNginxLogsFormat=" + this->craplog.getLogsFormatString( this->NGINX_ID ); configs += "\nNginxLogsFormat=" + this->craplog.getLogsFormatString( this->NGINX_ID );
configs += "\nNginxWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 11 ) ); configs += "\nNginxWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 11 ) );
configs += "\nNginxWarnlistMethodUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->NGINX_ID, 11 ) );
configs += "\nNginxWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 12 ) ); configs += "\nNginxWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 12 ) );
configs += "\nNginxWarnlistURIUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->NGINX_ID, 12 ) );
configs += "\nNginxWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 20 ) ); configs += "\nNginxWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 20 ) );
configs += "\nNginxWarnlistClientUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->NGINX_ID, 20 ) );
configs += "\nNginxWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 21 ), true ); configs += "\nNginxWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->NGINX_ID, 21 ), true );
configs += "\nNginxWarnlistUserAgentUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->NGINX_ID, 21 ) );
configs += "\nNginxBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->NGINX_ID, 20 ) ); configs += "\nNginxBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->NGINX_ID, 20 ) );
configs += "\nNginxBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( this->NGINX_ID, 20 ) );
//// IIS //// //// IIS ////
configs += "\n\n[IIS]"; configs += "\n\n[IIS]";
configs += "\nIisLogsPath=" + this->craplog.getLogsPath( this->IIS_ID ); configs += "\nIisLogsPath=" + this->craplog.getLogsPath( this->IIS_ID );
@ -643,10 +706,15 @@ void MainWindow::writeConfigs()
configs += "\nIisLogsModule=" + module; configs += "\nIisLogsModule=" + module;
configs += "\nIisLogsFormat=" + this->craplog.getLogsFormatString( this->IIS_ID ); configs += "\nIisLogsFormat=" + this->craplog.getLogsFormatString( this->IIS_ID );
configs += "\nIisWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 11 ) ); configs += "\nIisWarnlistMethod=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 11 ) );
configs += "\nIisWarnlistMethodUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->IIS_ID, 11 ) );
configs += "\nIisWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 12 ) ); configs += "\nIisWarnlistURI=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 12 ) );
configs += "\nIisWarnlistURIUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->IIS_ID, 12 ) );
configs += "\nIisWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 20 ) ); configs += "\nIisWarnlistClient=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 20 ) );
configs += "\nIisWarnlistClientUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->IIS_ID, 20 ) );
configs += "\nIisWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 21 ), true ); configs += "\nIisWarnlistUserAgent=" + this->list2string( this->craplog.getWarnlist( this->IIS_ID, 21 ), true );
configs += "\nIisWarnlistUserAgentUsed=" + this->b2s.at( this->craplog.isWarnlistUsed( this->IIS_ID, 21 ) );
configs += "\nIisBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->IIS_ID, 20 ) ); configs += "\nIisBlacklistClient=" + this->list2string( this->craplog.getBlacklist( this->IIS_ID, 20 ) );
configs += "\nIisBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( this->IIS_ID, 20 ) );
//// CRAPVIEW //// //// CRAPVIEW ////
configs += "\n\n[Crapview]"; configs += "\n\n[Crapview]";
configs += "\nCrapviewDialogLevel=" + std::to_string( this->crapview.getDialogsLevel() ); configs += "\nCrapviewDialogLevel=" + std::to_string( this->crapview.getDialogsLevel() );
@ -698,23 +766,14 @@ void MainWindow::geometryFromString( const std::string& geometry )
const std::string MainWindow::list2string( const std::vector<std::string>& list, const bool& user_agent ) const std::string MainWindow::list2string( const std::vector<std::string>& list, const bool& user_agent )
{ {
int i, max=list.size()-1;
std::string string; std::string string;
if ( user_agent == true ) { if ( user_agent == true ) {
for ( const std::string& str : list ) { for ( const std::string& str : list ) {
string += StringOps::replace( str, " ", "%@#" ); string += StringOps::replace( str, " ", "%@#" ) + " ";
if ( i < max ) {
string.push_back( ' ' );
i++;
}
} }
} else { } else {
for ( const std::string& str : list ) { for ( const std::string& str : list ) {
string += str; string += str + " ";
if ( i < max ) {
string.push_back( ' ' );
i++;
}
} }
} }
return string; return string;
@ -725,7 +784,7 @@ const std::vector<std::string> MainWindow::string2list( const std::string& strin
StringOps::splitrip( aux, string, " " ); StringOps::splitrip( aux, string, " " );
if ( user_agent == true ) { if ( user_agent == true ) {
for ( const std::string& str : aux ) { for ( const std::string& str : aux ) {
list.push_back( StringOps::replace( str, " ", "%@#" ) ); list.push_back( StringOps::replace( str, "%@#", " " ) );
} }
} else { } else {
for ( const std::string& str : aux ) { for ( const std::string& str : aux ) {
@ -1227,6 +1286,7 @@ void MainWindow::on_button_LogFiles_Apache_clicked()
QString rich_text; QString rich_text;
RichText::richLogsDefault( rich_text ); RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setText( rich_text );
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
rich_text.clear(); rich_text.clear();
// load the list // load the list
this->on_button_LogFiles_RefreshList_clicked(); this->on_button_LogFiles_RefreshList_clicked();
@ -1246,6 +1306,7 @@ void MainWindow::on_button_LogFiles_Nginx_clicked()
QString rich_text; QString rich_text;
RichText::richLogsDefault( rich_text ); RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setText( rich_text );
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
rich_text.clear(); rich_text.clear();
// load the list // load the list
this->on_button_LogFiles_RefreshList_clicked(); this->on_button_LogFiles_RefreshList_clicked();
@ -1265,6 +1326,7 @@ void MainWindow::on_button_LogFiles_Iis_clicked()
QString rich_text; QString rich_text;
RichText::richLogsDefault( rich_text ); RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setText( rich_text );
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
rich_text.clear(); rich_text.clear();
// load the list // load the list
this->on_button_LogFiles_RefreshList_clicked(); this->on_button_LogFiles_RefreshList_clicked();
@ -1286,6 +1348,7 @@ void MainWindow::on_button_LogFiles_RefreshList_clicked()
this->refreshing_list = true; this->refreshing_list = true;
this->craplog_thread = std::thread( &MainWindow::refreshLogsList, this ); this->craplog_thread = std::thread( &MainWindow::refreshLogsList, this );
// periodically check if thread finished // periodically check if thread finished
delete this->craplog_timer;
this->craplog_timer = new QTimer(this); this->craplog_timer = new QTimer(this);
connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(check_CraplogLLT_Finished())); connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(check_CraplogLLT_Finished()));
this->craplog_timer->start(250); this->craplog_timer->start(250);
@ -1434,6 +1497,7 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked()
QString rich_text; QString rich_text;
RichText::richLogsFailure( rich_text ); RichText::richLogsFailure( rich_text );
this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setText( rich_text );
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
rich_text.clear(); rich_text.clear();
} }
} }
@ -1516,6 +1580,7 @@ void MainWindow::on_button_MakeStats_Start_clicked()
if ( proceed == true ) { if ( proceed == true ) {
// periodically update perfs // periodically update perfs
delete this->craplog_timer;
this->craplog_timer = new QTimer(this); this->craplog_timer = new QTimer(this);
connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(update_Craplog_PerfData())); connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(update_Craplog_PerfData()));
this->craplog_timer->start(250); this->craplog_timer->start(250);
@ -1729,6 +1794,7 @@ void MainWindow::on_button_StatsWarn_Draw_clicked()
{ {
if ( this->checkDataDB() == true ) { if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsWarn())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsWarn()));
@ -1827,6 +1893,7 @@ void MainWindow::on_button_StatsSpeed_Draw_clicked()
{ {
if ( this->checkDataDB() == true ) { if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsSpeed())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsSpeed()));
@ -1950,112 +2017,104 @@ void MainWindow::resetStatsCountButtons()
} }
} }
void MainWindow::on_button_StatsCount_Protocol_clicked() void MainWindow::startCountDrawing()
{ {
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Protocol->text();
this->ui->button_StatsCount_Protocol->setFlat( false );
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250); this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Protocol_clicked()
{
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons();
this->ui->button_StatsCount_Protocol->setFlat( false );
this->count_fld = this->ui->button_StatsCount_Protocol->text();
startCountDrawing();
}
}
void MainWindow::on_button_StatsCount_Method_clicked() void MainWindow::on_button_StatsCount_Method_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Method->text(); this->count_fld = this->ui->button_StatsCount_Method->text();
this->ui->button_StatsCount_Method->setFlat( false ); this->ui->button_StatsCount_Method->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Request_clicked() void MainWindow::on_button_StatsCount_Request_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Request->text(); this->count_fld = this->ui->button_StatsCount_Request->text();
this->ui->button_StatsCount_Request->setFlat( false ); this->ui->button_StatsCount_Request->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Query_clicked() void MainWindow::on_button_StatsCount_Query_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Query->text(); this->count_fld = this->ui->button_StatsCount_Query->text();
this->ui->button_StatsCount_Query->setFlat( false ); this->ui->button_StatsCount_Query->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Response_clicked() void MainWindow::on_button_StatsCount_Response_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Response->text(); this->count_fld = this->ui->button_StatsCount_Response->text();
this->ui->button_StatsCount_Response->setFlat( false ); this->ui->button_StatsCount_Response->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Referrer_clicked() void MainWindow::on_button_StatsCount_Referrer_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Referrer->text(); this->count_fld = this->ui->button_StatsCount_Referrer->text();
this->ui->button_StatsCount_Referrer->setFlat( false ); this->ui->button_StatsCount_Referrer->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Cookie_clicked() void MainWindow::on_button_StatsCount_Cookie_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Cookie->text(); this->count_fld = this->ui->button_StatsCount_Cookie->text();
this->ui->button_StatsCount_Cookie->setFlat( false ); this->ui->button_StatsCount_Cookie->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_UserAgent_clicked() void MainWindow::on_button_StatsCount_UserAgent_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_UserAgent->text(); this->count_fld = this->ui->button_StatsCount_UserAgent->text();
this->ui->button_StatsCount_UserAgent->setFlat( false ); this->ui->button_StatsCount_UserAgent->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsCount_Client_clicked() void MainWindow::on_button_StatsCount_Client_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->resetStatsCountButtons(); this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Client->text(); this->count_fld = this->ui->button_StatsCount_Client->text();
this->ui->button_StatsCount_Client->setFlat( false ); this->ui->button_StatsCount_Client->setFlat( false );
this->setDbWorkingState( true ); startCountDrawing();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
} }
void MainWindow::drawStatsCount() void MainWindow::drawStatsCount()
@ -2065,7 +2124,9 @@ void MainWindow::drawStatsCount()
this->ui->table_StatsCount, this->ui->chart_StatsCount, this->ui->table_StatsCount, this->ui->chart_StatsCount,
this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS, this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS,
this->ui->box_StatsCount_WebServer->currentText(), this->ui->box_StatsCount_WebServer->currentText(),
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(), this->ui->box_StatsCount_Year->currentText(),
this->ui->box_StatsCount_Month->currentText(),
this->ui->box_StatsCount_Day->currentText(),
this->count_fld ); this->count_fld );
this->setDbWorkingState( false ); this->setDbWorkingState( false );
} }
@ -2247,6 +2308,7 @@ void MainWindow::on_button_StatsDay_Draw_clicked()
{ {
if ( this->checkDataDB() == true ) { if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsDay())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsDay()));
@ -2441,6 +2503,7 @@ void MainWindow::on_button_StatsRelat_Draw_clicked()
{ {
if ( this->checkDataDB() == true ) { if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsRelat())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsRelat()));
@ -2603,36 +2666,40 @@ void MainWindow::resetStatsGlobals()
void MainWindow::on_button_StatsGlob_Apache_clicked() void MainWindow::globalsButtonClicked()
{ {
this->glob_ws = "Apache2";
this->setDbWorkingState( true ); this->setDbWorkingState( true );
delete this->crapview_timer;
this->crapview_timer = new QTimer(this); this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true ); this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals())); connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250); this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsGlob_Apache_clicked()
{
if ( this->checkDataDB() == true ) {
this->glob_ws = "Apache2";
this->globalsButtonClicked();
}
}
void MainWindow::on_button_StatsGlob_Nginx_clicked() void MainWindow::on_button_StatsGlob_Nginx_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->glob_ws = "Nginx"; this->glob_ws = "Nginx";
this->setDbWorkingState( true ); this->globalsButtonClicked();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250);
} }
void MainWindow::on_button_StatsGlob_Iis_clicked() void MainWindow::on_button_StatsGlob_Iis_clicked()
{ {
if ( this->checkDataDB() == true ) {
this->glob_ws = "IIS"; this->glob_ws = "IIS";
this->setDbWorkingState( true ); this->globalsButtonClicked();
this->crapview_timer = new QTimer(this); }
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250);
} }
@ -3010,7 +3077,7 @@ void MainWindow::on_box_ConfApache_Warnlist_Field_currentTextChanged(const QStri
this->ui->list_ConfApache_Warnlist_List->addItem( QString::fromStdString( item ) ); this->ui->list_ConfApache_Warnlist_List->addItem( QString::fromStdString( item ) );
} }
// check/uncheck the usage option // check/uncheck the usage option
bool used = this->craplog.isWarnlistUsed( const bool used = this->craplog.isWarnlistUsed(
this->APACHE_ID, this->APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ) ); this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ) );
this->ui->checkBox_ConfApache_Warnlist_Used->setChecked( used ); this->ui->checkBox_ConfApache_Warnlist_Used->setChecked( used );
@ -3342,7 +3409,7 @@ void MainWindow::on_box_ConfNginx_Warnlist_Field_currentTextChanged(const QStrin
this->ui->list_ConfNginx_Warnlist_List->addItem( QString::fromStdString( item ) ); this->ui->list_ConfNginx_Warnlist_List->addItem( QString::fromStdString( item ) );
} }
// check/uncheck the usage option // check/uncheck the usage option
bool used = this->craplog.isWarnlistUsed( const bool used = this->craplog.isWarnlistUsed(
this->NGINX_ID, this->NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ) ); this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ) );
this->ui->checkBox_ConfNginx_Warnlist_Used->setChecked( used ); this->ui->checkBox_ConfNginx_Warnlist_Used->setChecked( used );
@ -3715,7 +3782,7 @@ void MainWindow::on_box_ConfIis_Warnlist_Field_currentTextChanged(const QString
this->ui->list_ConfIis_Warnlist_List->addItem( QString::fromStdString( item ) ); this->ui->list_ConfIis_Warnlist_List->addItem( QString::fromStdString( item ) );
} }
// check/uncheck the usage option // check/uncheck the usage option
bool used = this->craplog.isWarnlistUsed( const bool used = this->craplog.isWarnlistUsed(
this->IIS_ID, this->IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ) ); this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ) );
this->ui->checkBox_ConfIis_Warnlist_Used->setChecked( used ); this->ui->checkBox_ConfIis_Warnlist_Used->setChecked( used );

View file

@ -593,9 +593,11 @@ private:
void checkStatsRelatDrawable(); void checkStatsRelatDrawable();
// count // count
QString count_fld; QString count_fld;
void startCountDrawing();
void resetStatsCountButtons(); void resetStatsCountButtons();
// globals // globals
QString glob_ws; QString glob_ws;
void globalsButtonClicked();
void resetStatsGlobals(); void resetStatsGlobals();