##################################################### ##common.sub ## ## This file contains subroutines and ## variables ## ## that are used in multiple ##scripts. ## ## Configure what is ##needed. ## ##################################################### ## Authentication Variables #my ($user, $admin); $user = $ENV{"REMOTE_USER"}; $admin = "admin"; # Set to the Administrators username ########################################## ## Authentication Error ########################################## sub print_error{ print <
Authentication Failed. Please Restart your Browser.
";
exit;
} else {
$sth->execute;
} # End of if..else
return ($sth);
} # End of Do_SQL subroutine
#################################################################
####################################
### Filter - Gets rid of ###
### characters that screw up the ###
### program. ###
####################################
sub filter{
$_[0]=~s/\'/\\\'/g;
return $_[0];
} # End of filter subroutine
#################################################################
1; # Required or won't work!
####
#!/usr/bin/perl
use CGI qw/:standard/;
require "common.sub";
#my ($date, $time, $username);
$username = "$user";
&in_time_date;
#get time/date
sub in_time_date{
#my ($min, $hour, $day, $month, $year, $calc_year, $calc_month);
($min, $hour, $day, $month, $year) = (localtime)[1,2,3,4,5];
$calc_year = $year+1900;
$calc_month = $month+1;
$date = "$calc_year-$calc_month-$day";
$time = "$hour:$min";
}
print header;
if($username eq "$admin"){
&Create_DB_Connection;
&admin_get_users_in;
&print_admin_data;
}
elsif ($username eq ""){
&print_error;
}else{
&Create_DB_Connection;
&check_for_in;
}
$dbh->disconnect;
################ BEGIN GET USERS CLOCKED IN SUBROUTINE - ADMIN
sub admin_get_users_in{
$SQL="SELECT oid,username,start_stamp FROM timeclock WHERE total_hours = NULL AND total_minutes = NULL AND end_stamp = NULL ORDER BY username";
&Do_SQL;
}
################ END GET USERS CLOCKED IN SUBROUTINE
################ CHECK IF CLOCKED IN SUBROUTINE - NORMAL
sub check_for_in{
$SQL="SELECT oid,* FROM timeclock WHERE end_stamp = NULL AND total_hours = NULL AND total_minutes = NULL";
&Do_SQL;
@clocked_in = $sth->fetchrow();
unless ($clocked_in[1] eq "$username"){
&clock_in_form;
}else{
$SQL="SELECT oid,* FROM timeclock WHERE username = '$username' AND oid = $clocked_in[0]";
&Do_SQL;
while(@out_oid = $sth->fetchrow()){
@date_array01 = split(/ /,$out_oid[2]);
$print_date = $date_array01[0];
$in_time_sec = $date_array01[1];
@in_time_array = split(/:/,$in_time_sec);
$in_time = join(":",$in_time_array[0],$in_time_array[1]);
$hidden_oid = $out_oid[0];
&clock_out_form;
}
}
}
################ END CHECK FOR IN SUBROUTINE