Prv8 Shell
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4
System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64
User : jackjohn ( 502)
PHP Version : 5.3.17
Disable Function : NONE
Directory :  /usr/local/bandmin/IP/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/bandmin/IP/UserAcct.pm
#
#****************************************
#Bandmin (c)1998-1999 J. Nick Koston (BlueDraco)
# - A simple Bandwidth Monitor
#****************************************
#
#To use this package you must have a OS that has ipacct
#

package IP::UserAcct;

require 5.002;
require Exporter;
use strict;
use Carp;

use vars qw(@ISA $VERSION);

$VERSION = 0.10;
@ISA = qw(Exporter);



sub new 
{
	my ($backend);
	my  $self = {};

	bless($self);

	if (-e "/sbin/ipacct" && -e "/proc/net/ip_acct_user") {
		$self->{"backend"} = "ipacct";
	} else {
		return 0;
	}

	return($self);

}

sub clearcounter {
	my ($self) = @_;

	if ($self->{"backend"} eq "ipacct") {
		system("/sbin/ipacct","-C");
	}
}

sub getuserbytes {
        my ($self) = @_;

	my($user,$ipdata,@IPMASS,$bytes,%userbytemap,$uid);
	my($address,$sent,$recv,$user);

        if ($self->{"backend"} eq "ipacct") {
		open(IPACCTUSER,"/proc/net/ip_acct_user");
		@IPMASS=<IPACCTUSER>;
		close(IPACCTUSER);
	} else {
		die "getuserbytes called without a backend"; 
	}

	foreach $ipdata (@IPMASS) {
        	$ipdata =~ s/\t/ /g;
        	$ipdata =~ s/\s(\s*|.)\s/ /g;
        	$ipdata =~ s/^ //g;
		$bytes = 0;
	        if ($self->{"backend"} eq "ipacct") {
			($uid,$address,$sent,$recv,undef) =
				split(/\s/, $ipdata);
			$bytes = ($sent + $recv);
	        }
        	if ($uid > -1 && $address eq "*") {
			$user = (getpwuid($uid))[0];
                	$uid =~ s/\n//g;
                	$bytes =~ s/\n//g;
			$userbytemap{$user} = ($userbytemap{$user} + $bytes);
		}
	}
	
	return(%userbytemap);

}


haha - 2025