LICENSE: AGPLv2 # # CHANGELOG # 80523-0134 - First Build # 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field # 80525-2351 - Added an audit log that is not to be editable # 80602-0641 - Fixed status update bug # 90508-0727 - Changed to PHP long tags # $version = '2.2.0-5'; $build = '90508-0727'; $StarTtimE = date("U"); $NOW_TIME = date("Y-m-d H:i:s"); $last_action_date = $NOW_TIME; $US='_'; $CL=':'; $AT='@'; $DS='-'; $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); $script_name = getenv("SCRIPT_NAME"); $server_name = getenv("SERVER_NAME"); $server_port = getenv("SERVER_PORT"); if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} else {$HTTPprotocol = 'http://';} if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} else {$server_port = "$CL$server_port";} $agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; $agcDIR = eregi_replace('timeclock.php','',$agcPAGE); if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} if (isset($_GET["commit"])) {$commit=$_GET["commit"];} elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];} if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];} elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} if (!isset($phone_login)) { if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} } if (!isset($phone_pass)) { if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} } ### security strip all non-alphanumeric characters out of the variables ### $DB=ereg_replace("[^0-9a-z]","",$DB); $phone_login=ereg_replace("[^\,0-9a-zA-Z]","",$phone_login); $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); $VD_campaign=ereg_replace("[^0-9a-zA-Z_]","",$VD_campaign); $user=ereg_replace("[^0-9a-zA-Z]","",$user); $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); $stage=ereg_replace("[^0-9a-zA-Z]","",$stage); $commit=ereg_replace("[^0-9a-zA-Z]","",$commit); $referrer=ereg_replace("[^0-9a-zA-Z]","",$referrer); require("dbconnect.php"); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,admin_home_url FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; while ($i < $qm_conf_ct) { $row=mysql_fetch_row($rslt); $non_latin = $row[0]; $welcomeURL = $row[1]; $i++; } ##### END SETTINGS LOOKUP ##### ########################################### header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 if ( ($stage == 'login') or ($stage == 'logout') ) { ### see if user/pass exist for this user in vicidial_users table $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $valid_user=$row[0]; print "\n"; if ($valid_user < 1) { ### NOT A VALID USER/PASS $VDdisplayMESSAGE = "Użytkownika i hasło podane nie są aktywne w systemie
Please try again:"; echo"\n"; echo"AgentTimeclock\n"; echo"\n"; echo"\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

$VDdisplayMESSAGE

"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
Timeclock
 
Login użytkownika:
Hasło użytkownika:
 

WERSJA: $version       KOMPILACJA: $build
\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; exit; } else { ### VALID USER/PASS, CONTINUE ### get name and group for this user $stmt="SELECT full_name,user_group from vicidial_users where user='$user' and pass='$pass';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $full_name = $row[0]; $user_group = $row[1]; print "\n"; ### get vicidial_timeclock_status record count for this user $stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $vts_count = $row[0]; $last_action_sec=99; if ($vts_count > 0) { ### vicidial_timeclock_status record found, grab status and date of last activity $stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $status = $row[0]; $event_epoch = $row[1]; $last_action_date = date("Y-m-d H:i:s", $event_epoch); $last_action_sec = ($StarTtimE - $event_epoch); if ($last_action_sec > 0) { $totTIME_H = ($last_action_sec / 3600); $totTIME_H_int = round($totTIME_H, 2); $totTIME_H_int = intval("$totTIME_H"); $totTIME_M = ($totTIME_H - $totTIME_H_int); $totTIME_M = ($totTIME_M * 60); $totTIME_M_int = round($totTIME_M, 2); $totTIME_M_int = intval("$totTIME_M"); $totTIME_S = ($totTIME_M - $totTIME_M_int); $totTIME_S = ($totTIME_S * 60); $totTIME_S = round($totTIME_S, 0); if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";} if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";} if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";} $totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S"; } else { $totTIME_HMS='0:00:00'; } print "\n"; } else { ### No vicidial_timeclock_status record found, insert one $stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $status='START'; $totTIME_HMS='0:00:00'; $affected_rows = mysql_affected_rows($link); print "\n"; } if ( ($last_action_sec < 30) and ($status != 'START') ) { ### You cannot log in or out within 30 sekundy of your last login/logout $VDdisplayMESSAGE = "Nie można zalogować się w ciągu 30 sekund od ostatniego logowania lub wylogowywania"; echo"\n"; echo"AgentTimeclock\n"; echo"\n"; echo"\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

$VDdisplayMESSAGE

"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
Timeclock
 
Login użytkownika:
Hasło użytkownika:
 

WERSJA: $version       KOMPILACJA: $build
\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; exit; } if ($commit == 'YES') { if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) and ($stage=='login') ) { $VDdisplayMESSAGE = "You have now logged-in"; $LOGtimeMESSAGE = "You logged in at $NOW_TIME"; ### Add a record to the timeclock log $stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); $timeclock_id = mysql_insert_id($link); print "\n"; ### Update the user's timeclock status record $stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; ### Add a record to the timeclock audit log $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; } if ( ($status=='LOGIN') and ($stage=='logout') ) { $VDdisplayMESSAGE = "Musisz się zalogować-out"; $LOGtimeMESSAGE = "Możesz zalogować się na$NOW_TIME
Czas był zalogowany w:$totTIME_HMS"; ### Add a record to the timeclock log $stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); $timeclock_id = mysql_insert_id($link); print "\n"; ### Update last login record in the timeclock log $stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; ### Update the user's timeclock status record $stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; ### Add a record to the timeclock audit log $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; ### Update last login record in the timeclock audit log $stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); print "\n"; } if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) ) {echo "ERROR: timeclock wpisu już wykonane:$status|$stage"; exit;} if ($referrer=='agent') {$BACKlink = "POWRÓT pełnomocnika do ekranu logowania";} if ($referrer=='admin') {$BACKlink = "POWRÓT do administracji";} if ($referrer=='welcome') {$BACKlink = "Powrót do ekranu powitalnego";} echo"\n"; echo"AgentTimeclock\n"; echo"\n"; echo"\n"; echo "\n"; echo "

$VDdisplayMESSAGE

"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Timeclock
 
$LOGtimeMESSAGE
 
$BACKlink
 

WERSJA: $version       KOMPILACJA: $build
\n"; echo "\n\n"; echo "\n\n"; exit; } if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) { $VDdisplayMESSAGE = "Czas od twojego ostatniego logowania w:$totTIME_HMS"; $log_action = 'login'; $button_name = 'LOGIN'; $LOGtimeMESSAGE = "Ostatniego zalogowanego obecnie pod adresem:$last_action_date

Kliknij poniżej, aby LOGOWANIE log-in"; } if ($status=='LOGIN') { $VDdisplayMESSAGE = "Kwota czas były rejestrowane w:$totTIME_HMS"; $log_action = 'logout'; $button_name = 'LOGOUT'; $LOGtimeMESSAGE = "Możesz zalogować się na stronie: $last_action_date
Kwota czas były rejestrowane w:$totTIME_HMS

Kliknij poniżej, aby zalogować LOGOUT-out"; } echo"\n"; echo"AgentTimeclock\n"; echo"\n"; echo"\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

$VDdisplayMESSAGE

"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Timeclock
 
$LOGtimeMESSAGE
 
 

WERSJA: $version       KOMPILACJA: $build
\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; exit; } } else { echo"\n"; echo"AgentTimeclock\n"; echo"\n"; echo"\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

$VDdisplayMESSAGE

"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
Timeclock
 
Login użytkownika:
Hasło użytkownika:
 

WERSJA: $version       KOMPILACJA: $build
\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; } exit; ?>