<commit_before>#! /usr/bin/perl

use strict;
use Data::Dumper;
use Socket;
use Date::Manip;
use Time::Local;

## Config:
my $vhostConfig = "/home/avi/bin/test/etc/apache2/sites-enabled/*";
# how many seconds old a log file has to be for the site to count as inactive:
# This is 90 days:
my $old = 8640000;



# Handy global vars:
my (@vhosts, %VirtualHosts, %system, @inactive, @active);
my @months=("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
my @localIPAddresses;
&getLocalIPAddresses();

# Get all vhost config into %virtualHosts
&getVhostInfo($vhostConfig);
foreach(@vhosts){
#	print Dumper $_;
	&parseVhostConfig($_);
}


#print "||======================================================================\n";

foreach(keys(%VirtualHosts)){
	my $ServerName = $_;
if (1 == 1){	
	if ($ServerName !~ /\//){
		my @logFiles = @{$VirtualHosts{$_}{'logFiles'}};
		my $ConfigFile = $VirtualHosts{$_}{'configFile'};
		my $DocumentRoot = $VirtualHosts{$_}{'DocumentRoot'};
		my @ServerAliases = @{$VirtualHosts{$_}{'ServerAliases'}};

		if ( (&filesInDocumentRoot($DocumentRoot) < 1) || ( (&lastMentionInLogs($ServerName) + $old) < time() ) || (!&domainNamePointsHere($ServerName)) ){
			push (@inactive, $ServerName);
		}else{
			push (@active, $ServerName)
		}
	}
	
}else{
	if ($ServerName !~ /\//){
		my @logFiles = @{$VirtualHosts{$_}{'logFiles'}};
		my $LogFormat = $VirtualHosts{$_}{'LogFormat'};
		my $ConfigFile = $VirtualHosts{$_}{'configFile'};
		my $numAliases = $VirtualHosts{$_}{'NumAliases'};
		my $DocumentRoot = $VirtualHosts{$_}{'DocumentRoot'};
		my @ServerAliases = @{$VirtualHosts{$_}{'ServerAliases'}};
	
		print   "|| ServerName:  $ServerName";
		print "\n|| ServerNames: ";
		foreach(@ServerAliases){ print "$_ "; }
		print "\n|| Config file:  $ConfigFile";
		print "\n|| DocumentRoot:  $DocumentRoot";
		print "\n|| Files in DocumentRoot:  ".&filesInDocumentRoot($DocumentRoot);
		print "\n|| Log Files: ";
		foreach(@logFiles) { print "$_ "; }
		print "\n|| Last mention in logs:  ".&lastMentionInLogs($ServerName);<commit_msg>spelling mistakes<commit_after>#! /usr/bin/perl

use strict;
use Data::Dumper;
use Socket;
use Time::Local;

## Config:
my $vhostConfig = "/home/avi/bin/test/etc/apache2/sites-enabled/*";
# how many seconds old a log file has to be for the site to count as inactive:
# This is 90 days:
my $old = 8640000;



# Handy global vars:
my (@vhosts, %VirtualHosts, %system, @inactive, @active);
my @months=("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
my @localIPAddresses;
&getLocalIPAddresses();

# Get all vhost config into %virtualHosts
&getVhostInfo($vhostConfig);
foreach(@vhosts){
#	print Dumper $_;
	&parseVhostConfig($_);
}


#print "||======================================================================\n";

foreach(keys(%VirtualHosts)){
	my $ServerName = $_;
if (1 == 11){	
	if ($ServerName !~ /\//){
		my @logFiles = @{$VirtualHosts{$_}{'logFiles'}};
		my $ConfigFile = $VirtualHosts{$_}{'configFile'};
		my $DocumentRoot = $VirtualHosts{$_}{'DocumentRoot'};
		my @ServerAliases = @{$VirtualHosts{$_}{'ServerAliases'}};

		if ( (&filesInDocumentRoot($DocumentRoot) < 1) || ( (&lastMentionInLogs($ServerName) + $old) < time() ) || (!&domainNamePointsHere($ServerName)) ){
			push (@inactive, $ServerName);
		}else{
			push (@active, $ServerName)
		}
	}
	
}else{
	if ($ServerName !~ /\//){
		my @logFiles = @{$VirtualHosts{$_}{'logFiles'}};
		my $LogFormat = $VirtualHosts{$_}{'LogFormat'};
		my $ConfigFile = $VirtualHosts{$_}{'configFile'};
		my $numAliases = $VirtualHosts{$_}{'NumAliases'};
		my $DocumentRoot = $VirtualHosts{$_}{'DocumentRoot'};
		my @ServerAliases = @{$VirtualHosts{$_}{'ServerAliases'}};
	
		print   "|| ServerName:  $ServerName";
		print "\n|| ServerNames: ";
		foreach(@ServerAliases){ print "$_ "; }
		print "\n|| Config file:  $ConfigFile";
		print "\n|| DocumentRoot:  $DocumentRoot";
		print "\n|| Files in DocumentRoot:  ".&filesInDocumentRoot($DocumentRoot);
		print "\n|| Log Files: ";
		foreach(@logFiles) { print "$_ "; }
		print "\n|| Last mention in logs:  ".&lastMentionInLogs($ServerName);
{'fraction_non_alphanumeric': 0.23499759961593855, 'fraction_numerical': 0.006481036965914546, 'mean_word_length': 5.45046439628483, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663943', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1465, 'n_words': 338}