<commit_before>#!/usr/bin/perl

use strict;
use warnings;

#use Carp;
use Time::HiRes qw(usleep);
use Carp::Assert;
use IO::Socket::INET;
use IO::Socket::UNIX;
use IO::Select;
use Data::Dumper;

use xConfig;
use xUser;
use xSYS;

#$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

$| = 1;

{
    my %clients = ();
    my $config = new xConfig();
    my $stop = 0;
    my $sysadmin = 0;

    my %callbacks = (
        'Identify' => sub {
            my($socket, $username, $privKey) = @_;

            $clients{$socket} = new xUser($config, $username, $privKey, $sysadmin);
            my $result = $clients{$socket}->authentificate();
            if ($result != 0)
            {
                $clients{$socket} = undef; # Avoid further processing
            }

            return $result;
        },

        'UsedBandwith' => sub {
            my($socket) = @_;
            return $clients{$socket}->getBandwith();
        },

        'Quota' => sub {
            my($socket) = @_;
            return $clients{$socket}->getQuota();
        },

        'SYS_DAEMON_STOP' => sub
        {
            $stop = 1;
            return 0;
        },
        
        'SYS_FreeSpace' => sub {
            return $config->getFreeSpace();
        },

        'SYS_UserAdd' => sub {
            my($socket, $username, $password) = @_;
            return xSYS::AddUser($config, $username, $password);
        },
        
        'SYS_UserDel' => sub {
            my($socket, $username) = @_;
            return xSYS::DelUser($config, $username);
        },

        'SYS_BandwithCalc' => sub {
            my($socket, $username) = @_;
            return xSYS::CalculateQuota($config, $username);
        },

        'SYS_RestoreQuota' => sub {
            my($socket, $username) = @_;
            return xSYS::RestoreQuota($config, $username);
        }
    );
    
    # Set free space
    my $dir = chop($config->getWWWDir()); # Delete the last /
    my $freeSpace = `df $dir | head -2 | tail -1 | awk '{print $4}'`;
    $config->setFreeSpace($freeSpace);

    # Fork and start setting variables
    my $pid = fork;
    my $socket = undef;
    my $socketPath = '/var/run/xmanager.sock';

    sub sockconnect
    {
        # Only for parent!
        if ($pid == 0)
            return;
        
        unlink($socketPath);<commit_msg>Core/Main: Fix syntax<commit_after>#!/usr/bin/perl

use strict;
use warnings;

#use Carp;
use Time::HiRes qw(usleep);
use Carp::Assert;
use IO::Socket::INET;
use IO::Socket::UNIX;
use IO::Select;
use Data::Dumper;

use xConfig;
use xUser;
use xSYS;

#$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

$| = 1;

{
    my %clients = ();
    my $config = new xConfig();
    my $stop = 0;
    my $sysadmin = 0;

    my %callbacks = (
        'Identify' => sub {
            my($socket, $username, $privKey) = @_;

            $clients{$socket} = new xUser($config, $username, $privKey, $sysadmin);
            my $result = $clients{$socket}->authentificate();
            if ($result != 0)
            {
                $clients{$socket} = undef; # Avoid further processing
            }

            return $result;
        },

        'UsedBandwith' => sub {
            my($socket) = @_;
            return $clients{$socket}->getBandwith();
        },

        'Quota' => sub {
            my($socket) = @_;
            return $clients{$socket}->getQuota();
        },

        'SYS_DAEMON_STOP' => sub
        {
            $stop = 1;
            return 0;
        },
        
        'SYS_FreeSpace' => sub {
            return $config->getFreeSpace();
        },

        'SYS_UserAdd' => sub {
            my($socket, $username, $password) = @_;
            return xSYS::AddUser($config, $username, $password);
        },
        
        'SYS_UserDel' => sub {
            my($socket, $username) = @_;
            return xSYS::DelUser($config, $username);
        },

        'SYS_BandwithCalc' => sub {
            my($socket, $username) = @_;
            return xSYS::CalculateQuota($config, $username);
        },

        'SYS_RestoreQuota' => sub {
            my($socket, $username) = @_;
            return xSYS::RestoreQuota($config, $username);
        }
    );
    
    # Set free space
    my $dir = chop($config->getWWWDir()); # Delete the last /
    my $freeSpace = `df $dir | head -2 | tail -1 | awk '{print $4}'`;
    $config->setFreeSpace($freeSpace);

    # Fork and start setting variables
    my $pid = fork;
    my $socket = undef;
    my $socketPath = '/var/run/xmanager.sock';

    sub sockconnect
    {
        # Only for parent!
        if ($pid == 0)
        {
            return;
        }
        
        unlink($socketPath);
{'fraction_non_alphanumeric': 0.15683760683760684, 'fraction_numerical': 0.004273504273504274, 'mean_word_length': 1.7470657276995305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '3410244', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1473, 'n_words': 329}