ASNMTAP

 view release on metacpan or  search on metacpan

lib/ASNMTAP/Asnmtap/Applications.pm  view on Meta::CPAN

    $showJSFX .= "<script language=\"JavaScript\" SRC=\"$HTTPSURL/JSFX_Layer.js\"></script>\n<script language=\"JavaScript\" SRC=\"$HTTPSURL/JSFX_Browser.js\"></script>\n<script language=\"JavaScript\" SRC=\"$HTTPSURL/";

    if ( $cMonth == 01 and $cDay == 01 ) {
      $showJSFX .= 'JSFX_Fireworks2.js';
    } elsif ( ( $cMonth == 02 and $cDay == 14 ) || ( $cMonth == 10 and $cDay == 31 ) ) {
      $showJSFX .= 'JSFX_Halloween.js';
    } elsif ( $cMonth == 12 and $cDay == 31 ) {
      $showJSFX .= 'JSFX_Fireworks.js';
    } else {
      $showJSFX .= 'JSFX_Falling.js';
    }

    $showJSFX .= "\"></script>\n<script language=\"JavaScript\">\n  function JSFX_StartEffects() {\n";

    if ( $cMonth == 01 and $cDay == 01 ) {
      $showJSFX .= "    JSFX.FireworkDisplay2(1);\n";
    } elsif ( $cMonth == 02 and $cDay == 14 ) {
      $showJSFX .= "    JSFX.AddGhost(\"$IMAGESURL/cupido.gif\");\n";
    } elsif ( $cMonth == 04 and  $cDay == 18 ) {
      $showJSFX .= "    JSFX.Falling(1, \"E=mc²\", 60);\n";
    } elsif ( $cMonth == 10 and $cDay == 31 ) {
      $showJSFX .= "    JSFX.AddGhost(\"$IMAGESURL/ghost.gif\");\n";
    } elsif ( $cMonth == 12 ) {
      if ( $cDay > 21 and $cDay < 29 ) {
        $showJSFX .= "    JSFX.Falling(1, \"<IMG SRC='$IMAGESURL/snowflake-1.gif'>\", 20);\n    JSFX.Falling(1, \"<IMG SRC='$IMAGESURL/snowflake-2.gif'>\", 40);\n    JSFX.Falling(1, \"<IMG SRC='$IMAGESURL/snowflake-3.gif'>\", 60);\n    JSFX.Falling(1...
      } elsif ( $cDay == 31 ) {
        $showJSFX .= "    JSFX.FireworkDisplay(1);\n";
      }
    } else {
      $showJSFX .= "    JSFX.Falling(1, \"Happy Birthday\", 60);\n";
    }

    $showJSFX .= "  }\n\n  JSFX_StartEffects()\n</script>\n";
  }

  print $HTML <<EndOfHtml;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>${ENVIRONMENT{$environment}}: $APPLICATION @ $BUSINESS</title>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <META HTTP-EQUIV="Expires" CONTENT="Wed, 10 Dec 2003 00:00:01 GMT">
  <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
  $metaRefresh
  <link rel="stylesheet" type="text/css" href="$HTTPSURL/$stylesheet">
  $headScript
  <script language="JavaScript1.2" type="text/javascript">
    var pagedir_prefix = new Array();
    pagedir_prefix[0] = "";
    pagedir_prefix[1] = "-cv";
    pagedir_prefix[2] = "-mcv";

    function getPageDirCookie( name ) {
      var prefix = name + '=';
      var ca = document.cookie.split( ';' );

      for( var i=0; i < ca.length; i++ ) {
        var c = ca[i];
        while ( c.charAt( 0 ) == ' ' ) c = c.substring( 1, c.length );
        if ( c.indexOf( prefix ) == 0 ) return unescape( c.substring( prefix.length, c.length ) );
      }

      return null;
    }

    function deletePageDirCookie( name ) { setPageDirCookie( name, '', '', -1 ); }

    function setPageDirCookie( name, url, value, days ) {
      var expires = '';

      if ( days ) {
        (time = new Date()).setTime( new Date().getTime() + days * 24 * 60 * 60 * 1000);
        expires = "; expires=" + time.toGMTString();
      }

	  document.cookie = name + "=" + escape(value) + expires + "; path=/";
    }

    function loadEnvironmentPageDirCookie ( pageDir, environment ) {
      var name = 'pagedir_id_' + pageDir + '_' + environment;
      var url  = '$HTTPSURL/nav/' + pageDir + '/';
      if (environment != 'P') { url += environment + '/'; }
      reloadPageDirCookie( name, url );
    }

    function reloadPageDirCookie( name, url ) {
      var pagedir_id = getPageDirCookie( name );

      if (pagedir_id == null || pagedir_id == "" || pagedir_id < 0 || pagedir_id > 2) {
        pagedir_id = 0;
        setPageDirCookie ( name, url, pagedir_id, 365 );
      }

      window.location = url + "/index" + pagedir_prefix[pagedir_id] + ".html";
    }

    function togglePageDirCookie( name, url ) {
      var pagedir_id = getPageDirCookie( name );

      if (pagedir_id != null && pagedir_id != "" && pagedir_id > 0 && pagedir_id <= 2) {
        if (pagedir_id < 2) {
          pagedir_id++;
        } else {
          pagedir_id = 0;
        }
      } else {
        pagedir_id = 1;
      }

      setPageDirCookie ( name, url, pagedir_id, 365 );
      window.location = url + "/index" + pagedir_prefix[pagedir_id] + ".html";
    }

    function setSoundCookie( name, value, days ) {
      var expires = '';

      if ( days ) {
        (time = new Date()).setTime( new Date().getTime() + days * 24 * 60 * 60 * 1000);
        expires = "; expires=" + time.toGMTString();
      }

	  document.cookie = name + "=" + escape(value) + expires + "; path=$HTTPSURL/nav/";
    }

    function getSoundCookie( name ) {
      var prefix = name + '=';
      var ca = document.cookie.split( ';' );

      for( var i=0; i < ca.length; i++ ) {
        var c = ca[i];
        while ( c.charAt( 0 ) == ' ' ) c = c.substring( 1, c.length );
        if ( c.indexOf( prefix ) == 0 ) return unescape( c.substring( prefix.length, c.length ) );
      }

      return null;
    }

    function deleteSoundCookie( name ) { setSoundCookie( name, '', -1 ); }

    function dynamicContentNS4NS6FF (elementID, content, booleanBlur) {
      if (document.all)
        document.getElementById(elementID).innerHTML=content
      else if (document.getElementById) {
        var range = document.createRange ();
        var element = document.getElementById (elementID);
        range.setStartBefore (element);
        var htmlFragment = range.createContextualFragment (content);
        while ( element.hasChildNodes() ) element.removeChild (element.lastChild);
        element.appendChild (htmlFragment);
        if (booleanBlur) blur ();
      }
    }

    function initSound( ) {
      var soundState = getSoundCookie( 'soundState' );

      if (document.all) {
        if ( soundState == null || soundState == 'on' ) { startSound( ); } else { stopSound( ); }
      } else {
        if ( soundState == null || soundState == 'off' ) { stopSound( ); } else { startSound( ); }
      }
    }

    function startSound( ) {
      setSoundCookie ( 'soundState', 'on', 1 );
      document.getElementById('soundID').innerHTML='<A HREF=\"javascript:stopSound();\" title=\"Stop Sound\" alt=\"Stop Sound\"><img src=\"$IMAGESURL/on.gif\" WIDTH=\"32\" HEIGHT=\"27\" BORDER=0><\\/A>'
    }

    function stopSound( ) {
      setSoundCookie ( 'soundState', 'off', 1 );
      document.getElementById('soundID').innerHTML='<A HREF=\"javascript:startSound();\" title=\"Start Sound\" alt=\"Start Sound\"><img src=\"$IMAGESURL/off.gif\" WIDTH=\"32\" HEIGHT=\"27\" BORDER=0<\\/A>'
    }

    function LegendSound( sound ) {
      var soundState = getSoundCookie( 'soundState' );
EndOfHtml

  if ($subTitle !~ /^Reports\&nbsp\;\&nbsp\;/) {
    $showSound = "<span id=\"soundID\" class=\"LegendLastUpdate\"></span>";

    print $HTML <<EndOfHtml;

      if ( soundState != null && soundState == 'on' ) {
        playSound = '<embed src="$HTTPSURL/sound/' + sound + '" width="" height="" alt="" hidden="true" autostart="true" loop="false"><\\/embed>';
        dynamicContentNS4NS6FF ('LegendSound', playSound, 1);
      } else {
        dynamicContentNS4NS6FF ('LegendSound', '&nbsp;', 1);
      }
EndOfHtml
  }

  print $HTML "    }\n";

lib/ASNMTAP/Asnmtap/Applications.pm  view on Meta::CPAN

  </script>
EndOfHtml
  }

  print $HTML <<EndOfHtml;
</head>
<BODY $onload>
  $showJSFX
  <TABLE WIDTH="100%"><TR>
    <TD ALIGN="LEFT" WIDTH="292">
      $showToggle
      $showReport
      $showOnDemand
      $showData
      $showAwstats
      $showInfo
      $showRefresh
      $showSound
    </TD>
	<td class="HeaderTitel">$htmlTitle</td><td width="180" class="HeaderSubTitel">$subTitle</td><td width="1" valign="middle">$selectEnvironment</td>
  </TR></TABLE>
  <HR>
EndOfHtml

  if ( $pagedir ne '<NIHIL>' and $pageset ne '<NIHIL>' ) {
    my $showToggle   = "<A HREF=\"#\" onClick=\"reloadPageDirCookie('pagedir_id_${pageDir}_${environment}', '$HTTPSURL/nav/$pagedir')\">";
    $showToggle     .= "<IMG SRC=\"$IMAGESURL/toggle.gif\" title=\"Toggle\" alt=\"Toggle\" WIDTH=\"32\" HEIGHT=\"27\" BORDER=0></A>";

    my $directory = $HTTPSPATH ."/nav/". $pagedir;
    next unless (-e "$directory");
    my $reportFilename = $directory . '/reports-' . $pageset . '.html';

    unless ( -e "$reportFilename" ) { # create $reportFilename
      my $rvOpen = open(REPORTS, ">$reportFilename");

      if ($rvOpen) {
        print REPORTS <<EndOfHtml;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
<html>
<head>
  <title>${ENVIRONMENT{$environment}}: $APPLICATION @ $BUSINESS</title>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <META HTTP-EQUIV="Expires" CONTENT="Wed, 10 Dec 2003 00:00:01 GMT">
  <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
  <META HTTP-EQUIV="Refresh" CONTENT="$refresh">
  <link rel="stylesheet" type="text/css" href="$HTTPSURL/asnmtap.css">
  <script language="JavaScript1.2" type="text/javascript">
    var pagedir_prefix = new Array();
    pagedir_prefix[0] = "";
    pagedir_prefix[1] = "-cv";
    pagedir_prefix[2] = "-mcv";

    function getPageDirCookie( name ) {
      var prefix = name + '=';
      var ca = document.cookie.split( ';' );

      for( var i=0; i < ca.length; i++ ) {
        var c = ca[i];
        while ( c.charAt( 0 ) == ' ' ) c = c.substring( 1, c.length );
        if ( c.indexOf( prefix ) == 0 ) return unescape( c.substring( prefix.length, c.length ) );
      }

      return null;
    }

    function deletePageDirCookie( name ) { setPageDirCookie( name, '', '', -1 ); }

    function setPageDirCookie( name, url, value, days ) {
      var expires = '';

      if ( days ) {
        (time = new Date()).setTime( new Date().getTime() + days * 24 * 60 * 60 * 1000);
        expires = "; expires=" + time.toGMTString();
      }

	  document.cookie = name + "=" + escape(value) + expires + "; path=/";
    }

    function loadEnvironmentPageDirCookie ( pageDir, environment ) {
      var name = 'pagedir_id_' + pageDir + '_' + environment;
      var url  = '$HTTPSURL/nav/' + pageDir + '/';
      if (environment != 'P') { url += environment + '/'; }
      reloadPageDirCookie( name, url );
    }

    function reloadPageDirCookie( name, url ) {
      var pagedir_id = getPageDirCookie( name );

      if (pagedir_id == null || pagedir_id == "" || pagedir_id < 0 || pagedir_id > 2) {
        pagedir_id = 0;
        setPageDirCookie ( name, url, pagedir_id, 365 );
      }

      window.location = url + "/index" + pagedir_prefix[pagedir_id] + ".html";
    }

    function togglePageDirCookie( name, url ) {
      var pagedir_id = getPageDirCookie( name );

      if (pagedir_id != null && pagedir_id != "" && pagedir_id > 0 && pagedir_id <= 2) {
        if (pagedir_id < 2) {
          pagedir_id++;
        } else {
          pagedir_id = 0;
        }
      } else {
        pagedir_id = 1;
      }

      setPageDirCookie ( name, url, pagedir_id, 365 );
      window.location = url + "/index" + pagedir_prefix[pagedir_id] + ".html";
    }
  </script>
</head>
<BODY $onload>
  <TABLE WIDTH="100%"><TR>
    <TD ALIGN="LEFT" WIDTH="260">
      $showToggle
      $showReport
      $showOnDemand
      $showData
      $showAwstats
      $showInfo
    </TD>
	<td class="HeaderTitel">$htmlTitle</td><td width="180" class="HeaderSubTitel">Reports Menu</td><td width="1" valign="middle">$selectEnvironment</td>
  </TR></TABLE>
  <HR>

  <br>
  <table border="0" cellpadding="0" cellspacing="0" summary="menu" width="100%">
    <tr><td class="ReportItem"><a href="$HTTPSURL/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl?pagedir=$pagedir&amp;pageset=$pageset&amp;CGICOOKIE=1&amp;detailed=on">Detailed Statistics &amp; Report Generation</a></td></t...
    <tr><td>&nbsp;</td></tr>
    <tr><td class="ReportItem"><a href="$HTTPSURL/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl?pagedir=$pagedir&amp;pageset=$pageset&amp;CGICOOKIE=1&amp;detailed=off">Compare Response Time Trends</a></td></tr>
    <tr><td>&nbsp;</td></tr>
EndOfHtml

lib/ASNMTAP/Asnmtap/Applications.pm  view on Meta::CPAN

    if (-e "$emailReport") {
      my $emailMessage;
      $rvOpen = open($EMAILREPORT, "$emailReport");

      if ($rvOpen) {
        while (<$EMAILREPORT>) { $emailMessage .= $_; }
        close($EMAILREPORT);

        if (defined $emailMessage) {
          use Sys::Hostname;
          my $subject = $prgtext .' / Daily status from '. hostname() .': '. get_csvfiledate();
          $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $emailMessage, $debug );
          print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
        }
      } else {
        print "Cannot open $emailReport to send email report information\n";
      }
    } else {
      print "$emailReport to send email report information doesn't exist\n";
    }
  }

  return ($returnCode);
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub sending_mail {
  my ( $serverListSMTP, $mailTo, $mailFrom, $mailSubject, $mailBody, $debug ) = @_;

  # look at Mail.pm !!!
  use Mail::Sendmail qw(sendmail %mailcfg);
  $mailcfg{port}     = 25;
  $mailcfg{retries}  = 3;
  $mailcfg{delay}    = 1;
  $mailcfg{mime}     = 0;
  $mailcfg{debug}    = ($debug eq 'T') ? 1 : 0;
  $mailcfg{smtp}     = $serverListSMTP;

  use Sys::Hostname;
  my %mail = ( To => $mailTo, From => $mailFrom, Subject => $mailSubject .' from '. hostname(), Message => $mailBody );
  my $returnCode = ( sendmail %mail ) ? 1 : 0;
  print "\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log, "\n" if ($debug eq 'T');
  return ( $returnCode );
}

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

sub CSV_prepare_table {
  my ($path, $tableFilename, $extention, $tableName, $columnSequence, $tableDefinition, $logger, $debug) = @_;

  my $rv = 1;
  my $dbh = DBI->connect ("DBI:CSV:", "", "", {f_schema => undef, f_dir => $path, f_ext => $extention} ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot connect to the database", $logger, $debug);

  if ( $rv ) {
    $dbh->{csv_tables}{$tableName}  = { file => $tableFilename };

    $dbh->{csv_null}                = 1;
    $dbh->{csv_allow_whitespace}    = 0;
    $dbh->{csv_allow_loose_quotes}  = 0;
    $dbh->{csv_allow_loose_escapes} = 0;

    $dbh->{csv_eol}                 = $\;
    $dbh->{csv_sep_char}            = ',';
    $dbh->{csv_quote_char}          = '"';
    $dbh->{csv_escape_char}         = '"';

    if ( -e "$path$tableFilename$extention" ) {
      @{$columnSequence} = ();

      use Text::CSV;
      my $csv = Text::CSV->new( { binary => 1 } );

      if ( open my $rvOpen, "<", "$path$tableFilename$extention" ) {
        if ( my $fields = $csv->getline ($rvOpen) ) {
          @{$columnSequence} = @$fields;
        } else {
          CSV_error_message (*EMAILREPORT, 'Failed to parse line: '. $csv->error_input, $debug);
        }

        close $rvOpen;
      } else {
        CSV_error_message (*EMAILREPORT, "Cannot open $path$tableFilename$extention to print debug information", $debug);
      }
    } else {
      my $create;

      foreach my $columnName ( @{$columnSequence} ) {
        $create .= "  $columnName " .$tableDefinition->{$columnName}. ",\n";
      }

      chomp $create; chop $create;
      my $sql = "CREATE TABLE $tableName (\n$create\n)";
      print "$sql\n\n" if ($debug);

      $dbh->do ($sql) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot dbh->do: $sql", $logger, $debug);
    }

    if ( $debug ) {
      foreach my $columnName ( @{$columnSequence} ) { print "$columnName\n"; };
      print "\n";
    }

    return $dbh;
  } else {
    return undef;
  }
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub CSV_insert_into_table {
  my ($rv, $dbh, $tableName, $columnSequence, $tableValues, $columnNameAutoincrement, $logger, $debug) = @_;

  if ( defined $dbh and $rv ) {
	my ($column, $placeholders, @values);

    foreach my $columnName ( @{$columnSequence} ) { 
	    $column .= $columnName .',';
      $placeholders .= '?,';
	    push ( @values, ( ( $columnName eq $columnNameAutoincrement ) ? '' : $tableValues->{$columnName} ) );
    }

    if ( defined $column and defined $placeholders) {
      chop $column; chop $placeholders;
      my $sql = "INSERT INTO $tableName ($column) VALUES ($placeholders)";



( run in 0.541 second using v1.01-cache-2.11-cpan-39bf76dae61 )