KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /config/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //config/new_get_bw.pl
#!/usr/bin/perl

use lib qw(/config);

use modDB qw(mysql hosting provision pr0v1s10n 192.168.25.115);


opendir(DIR, "/domains/");
@dirs = readdir(DIR);
closedir(DIR);
my ($machine_id) = modDB::fetchRow(q[select id from machine_table where name = ?],'fbsdweb2');


foreach $username (@dirs)
{
  my ($login_id) = modDB::fetchRow(q[select login_id from user_table where username=?],$username);
  next unless $login_id;
  
  $path = "/domains/$username/logs/";
  opendir(LOG, $path);
  @logs = readdir(LOG);
  closedir(LOG);

  foreach $log (@logs)
  {
    next unless -f "$path$log";
    next unless $log =~ m/\.log$/;
    next unless $log =~ m/ex(\d\d\d\d)(\d\d)(\d\d).log/;
    $date = "$1-$2-$3";
    my ($size) = modDB::fetchRow(q[select filesize from bandwidth_table where logdate = ? and login_id = ? and machine_id = ?], $date, $login_id, $machine_id);
    $new_size =  -s "$path$log";
    #next if( $new_size == $size );

     print $new_size 
     print " $path$log   $size \n";
    $total = get_total("$path$log");
    #modDB::dbDo(q[delete from bandwidth_table where logdate = ? and login_id = ? and machine_id = ?], $date, $login_id, $machine_id);
    #modDB::dbDo(q[insert into bandwidth_table set logdate = ? ,  login_id = ? ,machine_id = ?, filesize=?, data=? ], $date, $login_id, $machine_id, $new_size , $total);
    print " $username - $date - $total\n";
  }
}

exit;


sub get_total
{
 my $file = shift;

open (FILE, $file);
my @data = <FILE>;
close (FILE);
my $total = 0;
foreach(@data)
{
 my (@a) = split ' ', $_;

# s/"(.*?)"/spaceless($1)/ge;
# s/[\[\]]//g;
# my (@a) = split;
 $total += $a[9];
}
return $total;
}

exit;
sub spaceless
{
 my $item = shift;
 $item =~ s/ /+/g;
 return $item;
}

Anon7 - 2021