freeside/FS/FS cust_svc.pm,1.43,1.44

ivan ivan at pouncequick.420.am
Tue Oct 5 09:28:33 PDT 2004


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv10168/FS/FS

Modified Files:
	cust_svc.pm 
Log Message:
RADIUS session viewing

Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cust_svc.pm	30 Jul 2004 04:54:40 -0000	1.43
+++ cust_svc.pm	5 Oct 2004 16:28:28 -0000	1.44
@@ -547,48 +547,22 @@
 sub get_session_history {
   my($self, $start, $end, $attrib) = @_;
 
-  my $username = $self->svc_x->username;
+  #$attrib ???
 
-  my @part_export = $self->part_svc->part_export('sqlradius')
-    or die "no sqlradius export configured for this service type";
+  my @part_export = $self->part_svc->part_export('sqlradius');
+  push @part_export, $self->part_svc->part_export('sqlradius_withdomain');
+  die "no sqlradius or sqlradius_withdomain export configured for this".
+      "service type"
+    unless @part_export;
     #or return undef;
                      
   my @sessions = ();
 
   foreach my $part_export ( @part_export ) {
-                                            
-    my $dbh = DBI->connect( map { $part_export->option($_) }
-                            qw(datasrc username password)    )
-      or die "can't connect to sqlradius database: ". $DBI::errstr;
-
-    #select a unix time conversion function based on database type
-    my $str2time;                                                 
-    if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) {
-      $str2time = 'UNIX_TIMESTAMP(';          
-    } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) {
-      $str2time = 'EXTRACT( EPOCH FROM ';       
-    } else {
-      warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
-           "; guessing how to convert to UNIX timestamps";
-      $str2time = 'extract(epoch from ';                  
-    }
-
-    my @fields = qw( acctstarttime acctstoptime acctsessiontime
-                     acctinputoctets acctoutputoctets framedipaddress );
-     
-    my $sth = $dbh->prepare('SELECT '. join(', ', @fields).
-                            "  FROM radacct
-                               WHERE UserName = ?
-                                 AND $str2time AcctStopTime ) >= ?
-                                 AND $str2time AcctStopTime ) <=  ?
-                                 ORDER BY AcctStartTime DESC
-    ") or die $dbh->errstr;                                 
-    $sth->execute($username, $start, $end) or die $sth->errstr;
-
-    push @sessions, map { { %$_ } } @{ $sth->fetchall_arrayref({}) };
-
+    push @sessions, $part_export->usage_sessions( $self->svc_x, $start, $end );
   }
-  \@sessions
+
+  \@sessions;
 
 }
 




More information about the freeside-commits mailing list