|
Server IP : 2a02:4780:3:1493:0:3736:a38e:7 / Your IP : 216.73.216.60 Web Server : LiteSpeed System : Linux sg-nme-web1393.main-hosting.eu 4.18.0-553.77.1.lve.el8.x86_64 #1 SMP Wed Oct 8 14:21:00 UTC 2025 x86_64 User : u926327694 ( 926327694) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u926327694/domains/smsoft.in/public_html/demo/../att/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
$qs = str_replace('$', '', $_SERVER['QUERY_STRING']); // get rid of the $
$qs = str_replace('*', '', $qs); // get rid of the *
$submissions = explode(',', $qs); // split the subs
$SID = ""; // store for sid
$MID = ""; // store for mid
include "dbconnect.php";
// loop
for ($i = 0; $i < count($submissions); $i++) {
$sections = explode('&', $submissions[$i]);
if ($i == 0) {
$SID = $sections[0];
$MID = $sections[1];
$RFID = $sections[2];
$DOT = $sections[3];
} else {
$RFID = $sections[0];
$DOT = $sections[1];
}
//select school
$con_school = mysqli_connect($servername, $username, $password, $dbname);
$sel_school = mysqli_query($con_school, "select * from schools where bio_machine_id='$MID'");
// echo "select * from schools where bio_machine_id='$MID'"; exit;
$main_username = "";
$main_password = "";
$main_dbname = "";
//for sms
$smsId = "";
$smsAPI = "";
$smsURL = "";
$smsTempId = "";
$smsIsActive = 0;
$sms_schoolname = "";
$receiver_admin = "";
$smsIsActive_stu = 0;
$second_from = "00:00:00";
$second_to = "00:00:00";
$is_active_second_time = 1;
while ($row_school = mysqli_fetch_array($sel_school)) {
$main_username = $row_school['dbUsernameStudent'];
$main_password = $row_school['dbPassword'];
$main_dbname = $row_school['dbStudent'];
//for sms
$smsId = $row_school['smsId'];
$smsAPI = $row_school['smsAPI'];
$smsURL = $row_school['smsURL'];
$smsTempId = $row_school['smsTempIdAtten'];
$smsIsActive = $row_school['smsIsActive_Teacher'];
$smsIsActive_stu = $row_school['smsIsActive_Student'];
$sms_schoolname = $row_school['sms_schoolname'];
$receiver_admin = $row_school['Bio_SMS'];
$second_from = $row_school['second_from'];
$second_to = $row_school['second_to'];
$is_active_second_time = $row_school['is_active_second_time'];
}
$con = mysqli_connect("localhost", $main_username, $main_password, $main_dbname);
// Check connection
if (!$con) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit;
}
$string = $DOT;
$day = substr($string, 0, 2);
$month = substr($string, 2, 2);
$year = substr($string, 4, 4);
$hour = substr($string, 8, 2);
$min = substr($string, 10, 2);
$sec = substr($string, 12, 2);
$result_date = $year . '-' . $month . '-' . $day;
$result_time = $hour . ':' . $min . ':' . $sec;
// check register student base on rfid
$chk_reg = mysqli_query($con, "SELECT * FROM `student_registration` WHERE `RFID`='$RFID'");
if(mysqli_num_rows($chk_reg)>0)
{
mysqli_query($con, "ALTER TABLE `attendreports` ADD `TimeIN` TIME NOT NULL AFTER `TimeOfTransaction`, ADD `TimeOUT` TIME NOT NULL AFTER `TimeIN`;");
$insert = mysqli_query($con, "INSERT INTO `attendreports`(`OrgId`, `MachineId`, `RFId`, `DateOfTransaction`, `TimeIN`, `TimeOUT`) VALUES ('$SID','$MID','$RFID','$result_date','$result_time','$result_time')");
if ($insert) {
$result_check = mysqli_query($con, "select * from attendence as att inner join student_registration as st on st.S_id=att.S_id where att.date='$result_date' and st.RFId='$RFID' and (att.IN_TIME != '00:00:00' OR att.IN_TIME!='')");
$result_check1 = mysqli_num_rows($result_check);
if ($result_check1 == 1) {
// this condition for out attedance set from time and to time between this time only make absent this is work only when we can make is_active_second_time = 1
if((strtotime($second_from)<=strtotime($result_time) && strtotime($second_to)>=strtotime($result_time)) || $is_active_second_time=="0")
{
$result_student = mysqli_query($con, "select att.id as AttendanceId from attendence as att inner join student_registration as st on st.S_id=att.S_id where att.date='$result_date' and st.RFId='$RFID' and (att.IN_TIME != '00:00:00' OR att.IN_TIME!='')");
$res_student = mysqli_fetch_array($result_student);
$AttendanceId = $res_student['AttendanceId'];
mysqli_query($con, "UPDATE `attendence` SET `OUT_TIME` = '$result_time' where id=$AttendanceId");
$res15 = mysqli_query($con, "SELECT * FROM `student_registration` WHERE `RFID`='$RFID'");
$res16 = mysqli_fetch_array($res15);
if ($res16['Class'] == "Teacher") {
if ($smsIsActive == "1") {
$Communication_number = $res16['Communication_number'];
$receiver_admin_sms = '';
if ($Communication_number != '') {
if ($receiver_admin != '') {
$receiver_admin_sms = $receiver_admin . "," . $Communication_number;
} else {
$receiver_admin_sms = $Communication_number;
}
} else {
if ($receiver_admin != '') {
$receiver_admin_sms = $receiver_admin;
}
}
$new_time_format = Date('h:i a',strtotime($result_time));
$bd = $result_date . " " . $new_time_format;
if ($receiver_admin_sms != '') {
sendAttensms($res16['Name'], $bd, $sms_schoolname, $receiver_admin_sms, $smsURL, $smsAPI, $smsId, $smsTempId);
}
}
} else {
if ($smsIsActive_stu == "1") {
$result_time_123 = mysqli_query($con, "select min(AttendanceId) from attendreports where `DateOfTransaction`='$result_date' and `RFId`='$RFID'");
$result_student = mysqli_fetch_array($result_time_123);
$result_time11 = mysqli_query($con, "select * from attendreports where AttendanceId=$result_student[0]");
$result_student1_123 = mysqli_fetch_array($result_time11);
$new_time_format_in = Date('h:i a',strtotime($result_student1_123['TimeIN']));
$new_time_format_out = Date('h:i a',strtotime($result_time));
$bd = $result_date . " " . $new_time_format_in . " To " . $new_time_format_out;
if ($MID >= 50) {
sendAttensms($res16['Name'], $bd, $sms_schoolname, $res16['Communication_number'], $smsURL, $smsAPI, $smsId, $smsTempId);
}
}
}
}
} else {
$result_time = mysqli_query($con, "select min(AttendanceId) from attendreports where `DateOfTransaction`='$result_date' and `RFId`='$RFID'");
$result_student = mysqli_fetch_array($result_time);
$result_time11 = mysqli_query($con, "select * from attendreports where AttendanceId=$result_student[0]");
$result_student1 = mysqli_fetch_array($result_time11);
$res15 = mysqli_query($con, "SELECT * FROM `student_registration` WHERE `RFID`='$result_student1[RFId]' ");
$res16 = mysqli_fetch_array($res15);
$orderdate = explode('-', $result_date);
$year = $orderdate[0];
$month = $orderdate[1];
$day = $orderdate[2];
$S_id = $res16['S_id'];
mysqli_query($con, "INSERT INTO `attendence`(`S_id`, `Class`, `Division`, `Subject`, `Roll_number`, `Name`, `Sex`, `Mobile`, `date`, `Status`, `DD`, `MM`, `YYYY`, `Nature_Student`, `IN_TIME`, `OUT_TIME`, `Att_Time`) VALUES ('$S_id','$res16[Class]','$res16[Division]','Day', '$res16[Roll_number]', '$res16[Name]', '$res16[Sex]','$res16[Communication_number]','$result_date', 'PRESENT', '$day', '$month', '$year','$res16[Nature_Student]','$result_student1[TimeIN]','','$result_student1[DateOfTransaction]')") or die("error");
if ($res16['Class'] == "Teacher" && $MID >= 50) {
if ($smsIsActive == "1") {
$new_time_format = Date('h:i a',strtotime($result_student1['TimeIN']));
$bd = $result_date . " " . $new_time_format;
$Communication_number = $res16['Communication_number'];
$receiver_admin_sms = '';
if ($Communication_number != '') {
if ($receiver_admin != '') {
$receiver_admin_sms = $receiver_admin . "," . $Communication_number;
} else {
$receiver_admin_sms = $Communication_number;
}
} else {
if ($receiver_admin != '') {
$receiver_admin_sms = $receiver_admin;
}
}
if ($receiver_admin_sms != '') {
sendAttensms($res16['Name'], $bd, $sms_schoolname, $receiver_admin_sms, $smsURL, $smsAPI, $smsId, $smsTempId);
}
}
}
}
} else {
echo 'Values are not registered';
}
} else {
echo 'Values are not registered';
}
}
if ($RFID != "") {
//Successfully received/inserted the data
echo '$RFID=0#';
}