#! /usr/bin/perl -w use strict; use CGI; use CGI::Carp 'fatalsToBrowser'; use File::Listing qw(parse_dir); use CGI::Session; my $htm = new CGI; my %vars = $htm->Vars(); print $htm->header({ -type => "text/html"}); print $htm->start_html( -title => "Welcome", -style=>{'src'=>'../stdbstyle.css'}); if(defined($vars{'file_creation'}) and $vars{'file_creation'} eq 'FILE CREATION') { fnShowFileCreationForm(); }elsif(defined($vars{'submit_login'}) and $vars{'submit_login'} eq 'Send') { fnSubmitLogin(); }else { fnLoginForm(); } #-------Login Page-------------------------------- sub fnLoginForm { #FORM TO SHOW LOGIN PAGE----- print $htm->start_form({-method=>'post'}), $htm->start_table({-width=>'50%',-height=>'50%',-length=>'50%',-align=>'center'}); print $htm->Tr({-bgcolor=>'#888888'}, $htm->th({-colspan=>2,-align=>'center'},"LOGIN")); print $htm->Tr({-bgcolor=>'#A8A8A8',-align=>'center'}, $htm->th("Enter username:", $htm->textarea({-name=>'uname',-cols=>'20',-rows=>'1',-default=>'',-override=>'1'}))); print $htm->Tr({-bgcolor=>'#A8A8A8',-align=>'center'}, $htm->th("Enter Password:", $htm->textarea({-name=>'passwd',-cols=>'20',-rows=>'1',-default=>'',-override=>'1'}))); print $htm->Tr({-bgcolor=>'#505050'}, $htm->th( $htm->submit({-name=>'submit_login',-label=>'Send'}))); } #-----------------START FUNCTION 'FNSubmitLogin'----------- sub fnSubmitLogin { my $cgi = new CGI; my $session = new CGI::Session(undef,undef,{Directory=>'/tmp/sessions'}); my $cookie = $cgi->cookie(CGISESSID => $session->id); print $cgi->header( -cookie=>$cookie ); $session->param('user_id',$username ); fnShowMainMenu(); } #----------------------Login Page ends here---------- #-----------------------Main Menu Form--------------------- sub fnShowMainMenu { print $htm->start_form({-method=>'post'}), $htm->start_table({-width=>'100%',-length=>'100%',-align=>'center'}); print $htm->Tr({-bgcolor=>'#20B2AA', -fontsize=>+50}, print $htm->Tr({-bgcolor=>'#20B2AA'}, $htm->th({-colspan=>3,-align=>'center'},"Select the Task by pressing button given below::")); my $username = $vars{'uname'}; print "UserName = $username"; $htm->end_form(); } #--------Main Menu Form ends here--------------------- #-----------File Creation Form starts here-------# sub fnShowFileCreationForm { print "Content-type: text/html\n\n"; my $cgi = new CGI; my $sid=$cgi->cookie("CGISESSID"); my $session = new CGI::Session(undef,$sid,{Directory=>'/tmp/sessions'}); my $username = $session->param('user_id'); print "Username = $username";