Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 18. október 2026

Rozdiely pre scripts/perl/accounting/netacct-stats.cgi medzi verziami 1.3 a 1.4

verzia 1.3, 2005/03/27 00:34:51 verzia 1.4, 2005/03/27 22:12:15
Riadok 12 
Riadok 12 
 # 2005-03-14 - created  # 2005-03-14 - created
 #  #
   
 # $Platon: scripts/perl/accounting/netacct-stats.cgi,v 1.2 2005/03/26 13:29:05 rajo Exp $  # $Platon: scripts/perl/accounting/netacct-stats.cgi,v 1.3 2005/03/27 00:34:51 rajo Exp $
   
 use strict;  use strict;
 umask 002;  umask 002;
Riadok 47  use vars qw (
Riadok 47  use vars qw (
         $start_gener_time $output          $start_gener_time $output
         $template_data          $template_data
         @http_cookies @errors @messages          @http_cookies @errors @messages
         $log_tables          $table_prefix $log_tables
 );  );
   
 sub print_output($$;);  sub print_output($$;);
   sub is_num (@);
   
 $start_gener_time       = Time::HiRes::time;  $start_gener_time       = Time::HiRes::time;
   
Riadok 72  $config  = config->new();
Riadok 73  $config  = config->new();
 $template       = templates->new($config, "./templates/$output");  $template       = templates->new($config, "./templates/$output");
 #$tt    = templates->new([ . "./templates/$output", './templates']);  #$tt    = templates->new([ . "./templates/$output", './templates']);
 $db                     = db->new($config);  $db                     = db->new($config);
   $table_prefix = 'net_acct_';
 $admin  = Platon::MySQL::Admin->new($db, { # {{{  $admin  = Platon::MySQL::Admin->new($db, { # {{{
                 table   => 'net_acct_config',                  table   => "${table_prefix}config",
                 primary_key_name        => 'config_id',                  primary_key_name        => 'config_id',
                 select_columns          => [ qw(                  select_columns          => [ qw(
                         config_id                          config_id
Riadok 102  $user->{logged_in} = 1;
Riadok 104  $user->{logged_in} = 1;
 # MAIN:  # MAIN:
 #  #
   
   $log_tables = $db->selectall_hashref("/* log_tables " . __FILE__ . ':' . __LINE__ . " */
            SHOW TABLE STATUS LIKE '${table_prefix}20%'
   ", 'Name');
   
   foreach my $key (keys %$log_tables) {
           $log_tables->{$key}->{Date} = join('-', $key =~ m/(\d+)_(\d+)$/g);
           warn "$key = $log_tables->{$key}->{Date}";
   }
   
 $template_data = {  $template_data = {
           query           => \%query,
         errors          => \@errors,          errors          => \@errors,
         messages        => \@messages,          messages        => \@messages,
         query           => \%query,          log_tables      => $log_tables,
 };  };
   
 $log_tables = $db->selectcol_arrayref("/* log_tables " . __FILE__ . ':' . __LINE__ . " */  
          SHOW TABLES LIKE 'net_acct_20%'  
 ");  
   
 unless(defined $query{template}) {  unless(defined $query{template}) {
         $query{template} = 'intro';          $query{template} = 'intro';
 }  }
Riadok 145  elsif ($query{template} eq 'netacct/dele
Riadok 153  elsif ($query{template} eq 'netacct/dele
 } # }}}  } # }}}
 elsif ($query{template} eq 'netacct/clearassign') { # {{{  elsif ($query{template} eq 'netacct/clearassign') { # {{{
         my $retval;          my $retval;
         foreach my $table (@$log_tables) {          foreach my $table (sort keys %$log_tables) {
                 $retval = $db->do("/* netacct/clearassign " . __FILE__ . ':' . __LINE__ . " */                  $retval = $db->do("/* netacct/clearassign " . __FILE__ . ':' . __LINE__ . " */
                         UPDATE $table SET config_id = NULL                          UPDATE $table SET config_id = NULL
                         ");                          ");
Riadok 167  elsif ($query{template} eq 'netacct/assi
Riadok 175  elsif ($query{template} eq 'netacct/assi
                         AND (source_port = ?    OR ? = 0)                          AND (source_port = ?    OR ? = 0)
                         AND (dest_port = ?              OR ? = 0)                          AND (dest_port = ?              OR ? = 0)
                 ");                  ");
         foreach my $i (1) {          foreach my $i (1..3, 10..13) {
                 $update->bind_param($i, 0, SQL_INTEGER);                  $update->bind_param($i, 0, SQL_INTEGER);
         }          }
   
         foreach my $table (@$log_tables) {          foreach my $table (sort keys %$log_tables) {
                 push @messages, "Table $table:";                  push @messages, "Table $table:";
                 foreach my $entry (@$data) {                  foreach my $entry (@$data) {
                         $update->execute(                          $update->execute(
Riadok 188  elsif ($query{template} eq 'netacct/assi
Riadok 196  elsif ($query{template} eq 'netacct/assi
         }          }
         $query{template} = 'netacct/config';          $query{template} = 'netacct/config';
 } # }}}  } # }}}
   elsif ($query{template} eq 'netacct/typeless') { # {{{
           $query{page}    = 1             unless(is_num($query{page}) and $query{page} > 0);
           $query{pager}   = 10    unless(is_num($query{pager}) and $query{pager} > 0);
           if (is_num($query{record})) {
                   $query{page} = int($query{record} / $query{pager});
                   $query{page} = 1 if ($query{page} == 0);
           }
           else {
                   $query{record}  = ($query{page} - 1) * $query{pager};
           }
           my $table = $table_prefix . '2005_01';
           if ($query{date} =~ m/^(\d{4})-(\d{2})$/g) {
                   $table = "$table_prefix$1_$2";
           }
           else {
                   $query{date} = '2005-01';
           }
   
           my $sql_search = $db->prepare("/* netacct/assign " . __FILE__ . ':' . __LINE__ . " */
                   SELECT SQL_CALC_FOUND_ROWS
                           id, created, ip_proto, source_ip, source_port, dest_ip, dest_port,
                           packet_count, data_size, interface, ppp_user
                   FROM ?
                   WHERE config_id IS NULL
                   ORDER BY id
                   LIMIT ?, ?
           ");
           foreach my $i (1..3) {
                   $sql_search->bind_param($i, 0, SQL_INTEGER);
           }
   
           $sql_search->execute(
                   $table,
                   $query{pager} * ($query{page} - 1),
                   $query{pager}
           );
           $template_data->{data}                  = $sql_search->fetchall_arrayref({});
           $template_data->{found_rows}    = $db->selectrow_array('SELECT FOUND_ROWS() AS found_rows');
           $template_data->{max_pages}             = int($template_data->{found_rows} / $query{pager}) + 1;
           $query{page} = $template_data->{max_pages} if ($query{page} > $template_data->{max_pages});
           $sql_search->finish();
   
   } # }}}
   
 if ($query{template} eq 'netacct/config') {  if ($query{template} eq 'netacct/config') {
         $template_data->{data} = $admin->get_data();          $template_data->{data} = $admin->get_data();
Riadok 242  sub print_output($$;)
Riadok 293  sub print_output($$;)
   
 } # }}} print_output  } # }}} print_output
   
   sub is_num (@)
   { # {{{
           my (@arr) = @_;
   
           if (@arr) {
                   foreach my $val (@arr) {
                           if (!defined $val or $val eq '' or $val !~ m/^\d+$/) {
                                   return 0;
                           }
                   }
                   return 1;
           }
           else {
                   return 0;
           }
   
   } # }}}
   
 # vim: ts=4  # vim: ts=4
 # vim600: fdm=marker fdl=0 fdc=3  # vim600: fdm=marker fdl=0 fdc=3
   

Legend:
Odstranené z verzie1.3  
zmenené riadky
  Pridané vo verzii1.4

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok