## Global Links package common::links; use strict; #use CGI::Carp qw(fatalsToBrowser); #warn "this is a complaint"; #die "But this is serious"; use vars qw ($timeclock_link $searchform_link); $timeclock_link = "timeclock.cgi"; $searchform_link = "search_form.cgi"; ## Global Authentication Variables package common::auth; use vars qw($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 -w
use CGI qw/:standard/;
require "common.sub";
use strict;
#use CGI::Carp qw(fatalsToBrowser);
#warn "this is a complaint";
#die "But this is serious";
my $username = "$common::auth::user";
my ($time, $date); # Declare current_time_date() args
#my ($in_time, $print_date, $hidden_oid, @out_oid); # Declare check_for_in() args
print header;
if ($username eq ""){
&common::auth::print_error;
}elsif($username eq "$common::auth::admin"){
&common::sql::Create_DB_Connection;
admin_get_users_in();
current_time_date();
print_admin_data();
}else{
&common::sql::Create_DB_Connection;
current_time_date();
check_for_in ($username);
}
$common::sql::dbh->disconnect;
####################### GET TIME AND DATE FOR IN FORM
sub current_time_date {
my ($min, $hour, $day, $month, $year, $calc_year, $calc_month);
($date, $time) = @_;
($min, $hour, $day, $month, $year) = (localtime)[1,2,3,4,5];
#($calc_year, $calc_month);
$calc_year = $year+1900;
$calc_month = $month+1;
$date = "$calc_year-$calc_month-$day";
$time = sprintf("%d:%02d", $hour,$min);
}
####################### END GET TIME AND DATE FOR IN FORM
################ BEGIN GET USERS CLOCKED IN SUBROUTINE - ADMIN
sub admin_get_users_in {
$main::SQL="SELECT oid,username,start_stamp FROM timeclock WHERE total_hours = NULL AND total_minutes = NULL AND end_stamp = NULL ORDER BY username";
common::sql::Do_SQL();
}
################ END GET USERS CLOCKED IN SUBROUTINE
################ CHECK IF CLOCKED IN SUBROUTINE - NORMAL
sub check_for_in ($) {
my ($username) = @_;
my (@clocked_in, @date_array01, $in_time_sec, @in_time_array, $print_date, $in_time, $hidden_oid);
# $main::SQL="SELECT oid,* FROM timeclock WHERE end_stamp = NULL AND total_hours = NULL AND total_minutes = NULL AND username = #'$username'";
$main::SQL="SELECT oid,* FROM timeclock WHERE end_stamp = NULL AND username = '$username'";
common::sql::Do_SQL();
@clocked_in = $common::sql::sth->fetchrow();
unless ($clocked_in[1] eq "$username"){
clock_in_form($username, $date, $time);
}else{
$main::SQL="SELECT oid,* FROM timeclock WHERE username = '$username' AND oid = $clocked_in[0]";
common::sql::Do_SQL();
while(my @out_oid = $common::sql::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($hidden_oid, $username, $time, $print_date, $in_time, @out_oid);
}
}
}
################ END CHECK FOR IN SUBROUTINE
####
main::check_for_in() called too early to check prototype at /home/httpd/cgi-bin/timeclock-1.0.1/timeclock.cgi line 28.
Name "common::sql::dbh" used only once: possible typo at /home/httpd/cgi-bin/timeclock-1.0.1/timeclock.cgi line 30.
Name "common::auth::admin" used only once: possible typo at /home/httpd/cgi-bin/timeclock-1.0.1/timeclock.cgi line 20.
Name "common::auth::user" used only once: possible typo at /home/httpd/cgi-bin/timeclock-1.0.1/timeclock.cgi line 11.
Use of uninitialized value in string eq at /home/httpd/cgi-bin/timeclock-1.0.1/timeclock.cgi line 68.