#!/usr/bin/perl -I/usr5/site_univ # Script: javascript.pl use strict; #use Apache(); use CGI; use DBI; # global variable defintions go here; if the main body of your script # uses a variable that is also used by a subroutine in this file then # define it here as follows: # # use vars qw/$variable_name/; # use vars qw/$dbh $uvd $uv_auth $q $sth/; use vars qw/@file_atc_center @file_aftn_add @ac_type/; use vars qw/%file_atc_center/; use vars qw/$file_atc_center/; use vars qw/$v_product_name $v_service_name $remote_user/; use vars qw/$eng_pop_up @eng_type $ac_pop /; use vars qw/@designator $eng_hash $count @file $html_file/; $dbh = undef; $q = new CGI; undef @designator; undef $eng_hash; undef @ac_type; undef @eng_type; undef $count; $count = 1; $html_file = "../enterspecs.html"; # define variables that are only used by the main body of script here # using my() as follows: # # my($variable_name); # or # my($variable_name) = "some value"; # my($variable_name) = $another_variable; # # Note: my() variables defined here cannot be referenced in # subroutines defined in this file. sub read_file { open(INPUT,"< $html_file") or die "Could not open $html_file for reading: $!\n"; @file = ; close (INPUT); ### chomp newlines chomp @file; } sub query_info { my ($manufacturer) = @_; my $selected; my $sth; my ($c0) = qq/ SELECT distinct aircraft_type, series FROM uwa_aircraft_type WHERE NAVTECH = 'Y' ORDER BY aircraft_type/; $sth = $dbh->prepare($c0); $sth->execute(); push (@ac_type,"Aircraft Types"); push (@eng_type,"Engine Types"); while (my ($temp, $temp2) = $sth->fetchrow()) { next if length($temp) == 0; $temp =~ s/"/\\'\\'/; $temp2 =~ s/"/\\'\\'/; $temp = $temp . " - " . $temp2; push(@ac_type, "$temp"); } my ($c3) = qq/ SELECT distinct aircraft_type, engine_type, series FROM uwa_aircraft_type WHERE NAVTECH = 'Y' ORDER BY aircraft_type/; my ($sth3) = $dbh->prepare($c3); $sth3->execute(); while (my ($temp, $temp2, $temp3) = $sth3->fetchrow()) { next if length($temp) == 0; next if length($temp2) == 0; $temp3 =~ s/"/\\'\\'/; $temp2 =~ s/"/\\'\\'/; $temp =~ s/"/\\'\\'/; $temp = $temp . " - " . $temp3; $eng_hash = $eng_hash . "\x1c" . $temp . "\x1c" . $temp2; } } sub make_pop_up { print $q->popup_menu(-name=>'select_aft_type' . $count, -values=>[@ac_type], -onChange=>"change_eng(this.value,'$eng_hash','$count')"); } sub eng_pop_up { print $q->popup_menu(-name=>'select_eng_type'. $count, -values=>[@eng_type]); } sub print_form { for (my $i = 0; $i <= $#file; $i++) { if ($file[$i] =~ /select_aft_type/) { make_pop_up(); $count++; $count=1 if $count>4; $i++; next; } if ($file[$i] =~ /select_eng_type/) { eng_pop_up(); $count++; $count=1 if $count>4; $i++; next; } print "$file[$i]"; } } #print $q->header(); my $path = "/js/engine_form.js"; print $q->start_html(-title=>'Subscribe to UVflightplanner.com', -script=>[ { -language=>'JavaScript', -src=>"$path"} ] ); $dbh = DBI->connect("DBI:Oracle:acrs","acars", "acarsprod", { AutoCommit =>0, PrintError => 1, RaiseError => 0} ) or die("Can't connect to Oracle Database: $DBI::errstr\n"); read_file(); query_info(); print_form();