#!/usr/bin/perl -w #--------------------------------------------------------------- # Study Log: Clock In CGI # By Michael Pierce and modified by Crystal White and Todd Vandenbark # April 4, 2009 (last modified April 26, 2009) # Task: # -get ID from a cookie # -get the epox time # -append file by writing the id, epox time twice (one for place holder) and a duration of "0" (for a place holder) # -Direct to a "Logged Out" Page # -use cookies to maintain the state of pages # Input: ID number, epox time # Output: id number:epox time:epox time place holder:duration 0 place holder #--------------------------------------------------------------- use CGI qw(:standard -debug); use CGI::Carp qw(fatalsToBrowser); use Time::Local; # retrieve cookie $cookiedata=cookie('id'); if (!$cookiedata) { $cookiedata=param("id1"); } # file $session='../session.txt'; # Set stylesheet $css = ''; # HTML forms $form1 = "http://studylog.firesidelibrarian.com/studentid.html"; #append the file with the id and start time if (-r $session) { #get the epoch time for the start time (clock in) $st=time; # append file open(OUT, ">>$session") || die "can't append $session"; my $string = join(":",$cookiedata,$st,$st,0); print (OUT "$string\n"); close OUT; } # ---- delete cookie and page time out-------------------- # $delcookie = cookie(-name=>'id',-value=>'0',-expires=>'-1h'); $jscript = 'function jumptostart () ' . "\n" . 'window.location = "../studentid.html"' . "\n" . '}' . "\n"; $function = "setTimeout('jumptostart()', 5000)"; #Print HTML for Student Log Main Menu print header(-cookie=>$delcookie); print start_html(-title=>"Logged Out", -head=>$css, -script=>$jscript, -onLoad=>"$function" ); print h1("Logged Out"); print "\n"; print qq|Back to Main Login|; print "\n"; print ''. "\n" . '
'. "\n" . '' . "\n"; print end_html();