Changeset 72


Ignore:
Timestamp:
Nov 3, 2010, 9:33:06 AM (13 years ago)
Author:
g7moreau
Message:
  • Add export html for ip-free
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r71 r72  
    928928   print <<'END_HTML';
    929929<table class="sortable" summary="Klask export database">
    930  <caption>Klask database</caption>
     930 <caption>Klask Host Database</caption>
    931931 <thead>
    932932  <tr>
     
    11651165      );
    11661166
     1167   my %possible_format = (
     1168      txt  => \&cmd_ip_free_txt,
     1169      html => \&cmd_ip_free_html,
     1170      );
     1171   $format = 'txt' if not defined $possible_format{$format};
     1172
    11671173   @vlan_name = get_list_network() if not @vlan_name;
    1168 
    1169 #   my %possible_format = (
    1170 #      txt  => \&cmd_exportdb_txt,
    1171 #      html => \&cmd_exportdb_html,
    1172 #      );
    1173 #
    1174 #   $format = 'txt' if not defined $possible_format{$format};
    1175 #
    1176 #   $possible_format{$format}->(@ARGV);
    11771174
    11781175   my $computerdb = {};
     
    11821179   my $timestamp_barrier = $timestamp - (3600 * 24 * $days_to_dead );
    11831180
    1184    my %result_ip= ();
     1181   my %result_ip = ();
    11851182
    11861183   ALL_NETWORK:
     
    12171214      }
    12181215
     1216   $possible_format{$format}->(%result_ip);
     1217   }
     1218
     1219sub cmd_ip_free_txt {
     1220   my %result_ip = @_;
     1221   
    12191222   printf "%-15s %-40s %-16s %s\n", qw(IPv4-Address Hostname-FQ Date VLAN);
    12201223   print "-------------------------------------------------------------------------------\n";
    1221    LOOP_ON_RESULT:
     1224   LOOP_ON_IP_ADDRESS:
    12221225   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
    12231226         printf "%-15s %-40s %-16s %s\n", $ip, $result_ip{$ip}->{hostname_fq}, $result_ip{$ip}->{date_last_detection}, $result_ip{$ip}->{vlan};
    12241227      }
     1228   }
     1229
     1230sub cmd_ip_free_html {
     1231   my %result_ip = @_;
     1232
     1233   print <<'END_HTML';
     1234<table class="sortable" summary="Klask export database">
     1235 <caption>Klask IP Free Database</caption>
     1236 <thead>
     1237  <tr>
     1238   <th scope="col" class="hklask-ipv4">IPv4-Address</th>
     1239   <th scope="col" class="sorttable_alpha">Hostname-FQ</th>
     1240   <th scope="col" class="sorttable_alpha">VLAN</th>
     1241   <th scope="col" class="hklask-date">Date</th>
     1242  </tr>
     1243 </thead>
     1244 <tfoot>
     1245  <tr>
     1246   <th scope="col" class="fklask-ipv4">IPv4-Address</th>
     1247   <th scope="col" class="fklask-hostname">Hostname</th>
     1248   <th scope="col" class="fklask-vlan">VLAN</th>
     1249   <th scope="col" class="fklask-date">Date</th>
     1250  </tr>
     1251 </tfoot>
     1252 <tbody>
     1253END_HTML
     1254
     1255   my $typerow = 'even';
     1256
     1257   LOOP_ON_IP_ADDRESS:
     1258   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
     1259
     1260      $typerow = $typerow eq 'even' ? 'odd' : 'even';
     1261
     1262      my $ip_sort = sprintf '%03i%03i%03i%03i', split m/ \. /xms, $ip;
     1263      my ( $host_short ) = split m/ \. /xms, $result_ip{$ip}->{hostname_fq};
     1264
     1265      print <<"END_HTML";
     1266  <tr class="$typerow">
     1267   <td sorttable_customkey="$ip_sort">$ip</td>
     1268   <td sorttable_customkey="$host_short">$result_ip{$ip}->{hostname_fq}</td>
     1269   <td>$result_ip{$ip}->{vlan}</td>
     1270   <td>$result_ip{$ip}->{date_last_detection}</td>
     1271  </tr>
     1272END_HTML
     1273      }
     1274   print <<'END_HTML';
     1275 </tbody>
     1276</table>
     1277END_HTML
    12251278   }
    12261279
Note: See TracChangeset for help on using the changeset viewer.