<?php
//Function Pge.
//MySQL server information.
$MySQLInfo = array (
"Server" => "l",
"DBName" => "",
"Username" => "",
"Password" => ""
);
$CoreSettings = array (
"TimeZone" => "America/New_York"
);
$UserSettings = array (
"MaxPunches" => 2,
"UserLength" => 30,
"PwdLength" => 7
);
function safe($value){
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = mysql_escape_string($value);
}
return $value;
}
function sql($query){
mysql_connect("","","");
mysql_select_db("");
$result = mysql_query($query);
mysql_close();
return $result;
}
function encryption($password,$seed){
$result = md5($password).md5($seed);
$encrypted = md5($result);
return $encrypted;
}
function authentication($username,$password){
$result = sql("SELECT Passwd FROM SCAccounts WHERE UserName='".$username."'");
if(mysql_num_rows($result) < 1){
return 1; ##If user does not exist
}else{
$row = mysql_fetch_array($result);
if($row['Passwd'] == $password){
return 2; ##If user and password matches
}else{
return 3; //If username does not match with password.
}
}
}
function checkstatus($username){
$result = sql("SELECT ID,UserName FROM SCTimeBook WHERE UserName ='".$username."' ORDER BY ID DESC LIMIT 1"); //DESC Means descending in MySQL.
if(mysql_num_rows($result) == 0){
return 0;
}
$row = mysql_fetch_array($result);
$TimeStampIn = $row['TimeStampIn'];
$TimeStampOut = $row['TimeStampOut'];
if($TimeStampIn == NULL){
return 0;
}else{
return 1;
}
}
function gettotalpunches($username){
$result = sql("SELECT TimeStampOut FROM SCTimeBook WHERE UserName ='".$username."' AND GET_FORMAT(FROM_UNIXTIME(TimeStampOut),'ISO') = CURDATE() ");
return mysql_num_rows($result);
}
//function signin($username){
// if(gettotalpunches($username) <= $UserSettigns["MaxPunches"]){
// sql("INSERT INTO SCTimeBook(UserName, TimeStampIn) VALUES('".$username."',".time().")");
// return header('Location: index.php?Msg=SignInOk');
// }else{
// return header('Location: index.php?Msg=MaxPunchesExceed');
// }
// }
?>