#!/usr/bin/perl ############################################################################ # S U B R O U T I N E S ############################################################################ ######################################################## sub valid_cookie{ $flag=0; my $session_file=$companyrepository."/session.txt"; #file where sessions are stored unless(open(INTT, "$session_file")){print "Session not found $session_file. $cookie
";} while (){ #find existing cookie if($_=~/^$cookie\;/){#if cookie exist $flag=1; last; } } close INTT; return $flag; } ############################################################################ sub writeData { my $j=0; open (OUT,">".$datafile); # Print header foreach $head (@header_names){ print OUT "$head\t"; } print OUT "\n"; # Print data $i=0; # $i represents each row for ($i=0;$i<=$#write_data;$i++){ for ($j=0;$j<=$#{$write_data[$i]};$j++){ print OUT "$write_data[$i][$j]\t"; } print OUT "\n"; } close (OUT); } ############################################################################ sub readData { my @temp=""; open (IN,"<".$datafile); $i=0; # $i represents each row while () { if ($i==0){ # ignore the header $i++; next; }elsif ($_=~/^(.*?)\t/){# read in and split tabs @temp=split("\t", $_); $j=0; foreach $t (@temp){ # each column $j in row $i $read_data[$i-1][$j]="$t"; # store names $j++; } $i++; } } close (IN); } ############################################################################ sub validate_input{ my $p_name=shift; my $p_value=shift; my $vflag=shift; # cosname must contain an aphanumeric character if ($p_name=~/col0/){ if ($p_value!~/[0-9]/){ $vflag=0; } # cosnum must be a digit between 1 and 32767 }elsif($p_name=~/col1/){ if ($p_value!~/[A-Za-z0-9_]/){ $vflag=0; } } return $vflag; } ############################################################################ # E N D S U B R O U T I N E S ############################################################################ ############################################################################ # M A I N ############################################################################ use CGI; $query = new CGI; # initial global variables $repository="/home/warp/userdata/"; $paramcount=0; $formcomplete=1; @header_names=("LATA"); @read_data=(); @read_names=(); @read_cos=(); @data=(); @cos=(); @names=(); $error=""; # pluck out some common params that may have been passed $answer=$query->param("answer"); ####check for valid cookie#### $cookie=""; @temp=""; $cookie=$ENV{'HTTP_COOKIE'}; #identify cookie @temp_cookie=split(';',$cookie); $cookie=$temp_cookie[0]; ($sess_id,$company,$site,$user)=split('%2C', $cookie); $companyrepository=$repository.$company."/".$site; valid_cookie(); # If cookie not valid, then redirect to login page if ($flag==0){print $query->redirect('http://services.genband.com/cgi-bin/dbq/na/DBQ_welcome.cgi'); }#redirect to another location if ($flag==1){ $dbqfile=$companyrepository."/dbq_finished.txt"; if (-e $dbqfile){ # DBQ has been finished and database has been built print $query->redirect('http://services.genband.com/cgi-bin/dbq/na/home.cgi'); #redirect to home } } print "Content-type: text/html\n\n"; # create company specific variables $datafile=$companyrepository."/latas.txt"; ################################ # start html $header_file = "header1.html"; open(FILE,"$header_file"); while() { print $_; } close FILE; print <<'ENDHTML'; "; print <<'ENDHTML';

Call Processing Resources : LATAs

ENDHTML # if the screens file exists then we have already been here once and saved valid data, read this data in if (!$answer) { if (-e $datafile){ readData; $formprocessed=1; }else{$formcomplete=0;} } # process passed parameters foreach $paramname ($query->param) { # $paramcount++; $paramvalue=$query->param($paramname); $$paramname=$paramvalue; $$paramname =~ s/\s+/_/g; # place the values in the appropriate array location if ($paramname =~ /row(\d+)col(\d+)/) { # row(i) and column(j) as read from webpage $match1="$1"; $match2="$2"; $write_data[$1][$2]="$$paramname"; if ($match2==0){ if ($$paramname=~/[0-9]/){ # validate name push @fail, $match1; } } if ($$paramname=~/\D/){ $formcomplete=0; $error="Lata value must be numeric"; } } # print "$paramname, $$paramname, $paramvalue, $$paramvalue
"; if (($paramname eq "answer") && ($answer eq "finish")) { $finished=1; } } # trunkate list where Profile names are undefined $len=@fail; @write_data = splice (@write_data, $fail[0], $len); ##################################################################### # if the finish button has been clicked # ##################################################################### ##################################################################### # when entering this page from the main DBQ the answer will be null # ##################################################################### if (($finished) && ($formcomplete)) { writeData; print "
"; print "

"; print "The class of service data has been saved. Please click next to continue. "; print "

"; # if we are arriving from the main page, a next or re-submit button was clicked, or there # was an error in the form when the finish button was clicked then redraw the }else{ # if we are here from the main page and this form has been processed before then print this message if ($formprocessed) { print "

"; print "The Class of Service form has already been processed at least once, the data last submitted is below.

"; print "

"; } # print instructions print "

"; print "In the table below is a list of the termination types that will be data filled in the switch. "; print "To define a Class of Service, provide a name in the box at the top of the column and then to the "; print "right of each termination type click the check box to allow that termination type "; print "for the given screening class. An uncheck box will indicate that the termination type is to be "; print "blocked for the screening class. For more details click the help button."; print "

"; print "
"; print ""; # present form print "
"; print ""; print ""; print ""; # Print rows for ($i=0;$i<=10;$i++) { print ""; for ($j=0;$j<=0;$j++){ $type=""; print ""; } print ""; } print "
LATASpecify the LATA in which you will be providing service.
"; $paramname="row".$i."col".$j; if ($read_data[$i][$j]){ $type=""; }else{$type="";} print "$type"; print "
"; print "
"; # initial presentation of the page if ((!$formcomplete) && ($error eq "")) { print ""; print " Click 'cancel' to return to Main Menu without saving your data.
"; print "Click 'submit' to proceed with this form."; # errors found when processing }elsif((!$formcomplete) && ($error ne "")){ print ""; print " $error"; print "Click 'cancel' to return to the Main Menu
without saving your data or"; print " please make corrections and click re-submit to proceed with this form."; # form has been completed without errors }elsif ($formcomplete) { print ""; print ""; print " "; print "The data on the form has been validated. Click 'cancel' to return to the Main Menu
without saving your data,"; print " click 're-submit' to make changes, or click 'finish' to save your data and return to the Main Menu."; } print ""; } print "

 

ENDHTML $footer_file = "footer1.html"; open(FILE,"$footer_file"); while() { print $_; } close FILE;