403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/(Del)pathways.org.hk/MIS_bk/student/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS_bk/student/index.php
<?php
require_once(__DIR__ . '/../checkuser.php');
function index() {
	global $dbh;
	
	$message = $_GET['message'] ?: null;
	$search = $_GET['search'] ?: array();
	$sort = $_GET['sort'] ?: array();
	
	$sort_by_columns = array(
		'name' => 'Name',
		'zh_name' => 'Chinese Name',
		'student_grade_id' => 'Year / Grade',
		'emergency_contact_name' => 'Emergency Contact Person',
		'emergency_contact_number' => 'Emergency Contact No.',
	);
	$sort_by_options = array(
		'asc' => 'A - Z',
		'desc' => 'Z - A',
	);
	
	
	$sql = "
SELECT student.*, grade.title AS student_grade
FROM mis_student student
LEFT JOIN mis_student_grade grade ON grade.id = student.student_grade_id
WHERE student.is_latest = ? AND student.deleted = ?
	AND CASE WHEN COALESCE(LENGTH(?), 0) = 0 THEN 1 = 1 ELSE student.root_id = ? END
	AND CASE WHEN COALESCE(LENGTH(?), 0) = 0 THEN 1 = 1 ELSE student.reg_campus_id = ? END
	AND CASE WHEN COALESCE(LENGTH(?), 0) = 0 THEN 1 = 1 ELSE student.status = ? END
ORDER BY ";
	$order_by_sql = '';
	foreach ($sort as $index => $info) {
		if (!empty($info['column']) && !empty($info['option']) && in_array($info['column'], array_keys($sort_by_columns))) {
			if (!empty($order_by_sql)) {
				$order_by_sql .= ', ';
			}
			$direction = strtoupper($info['option']) != 'DESC' ? 'ASC' : 'DESC';
			switch ($info['column']) {
				case 'name': {
					$order_by_sql .= "CONCAT(last_name, ' ', first_name) $direction";
					break;
				}
				default: {
					$column = $info['column'];
					$order_by_sql .= "`$column` $direction";
					break;
				}
			}
		}
	}
	if (empty($order_by_sql)) {
		$order_by_sql = "student.last_name, student.first_name, student.registration_number, student.root_id";
	}
	$sql .= $order_by_sql;
	$parameters = array(
		1, 0,
		$search['student_root_id'], $search['student_root_id'],
		$search['campus_id'], $search['campus_id'],
		$search['status'], $search['status'],
	);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$students = $sth->fetchAll();
	
	$sql = "SELECT * FROM mis_campus WHERE deleted = ? ORDER BY sort";
	$parameters = array(0);
	$sth = Db\Util::execute($dbh, $sql, $parameters);
	$campuses = $sth->fetchAll();
	
	return array(
		'students' => $students,
		'message' => $message,
		'campuses' => $campuses,
		'studentStatusOptions' => Student::statusOptions(),
		
		'search' => $search,
		'sort' => $sort,
		'sort_by_columns' => $sort_by_columns,
		'sort_by_options' => $sort_by_options,
	);
}
extract(index());
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	
	<?php require(__DIR__ . '/../inc/_head_meta.php'); ?>
	
	<?php require(__DIR__ . '/../inc/_head_css.php'); ?>
	
	<?php require(__DIR__ . '/../inc/_head_script.php'); ?>
	
</head>
<body>
	
	<?php require( __DIR__ . '/../inc/_navbar.php'); ?>
	
	<div class="text-right">
		<ul class="breadcrumb">
			<li><a href="#">Master</a> <span class="divider">&gt;</span></li>
			<li class="active">Student</li>
		</ul>
	</div>
	
	<div class="container-fluid pathways-container">
		
		<?php if (isset($message) && !empty($message)): ?>
		<div class="alert alert-info">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h5 class="alert-heading">Note:</h5>
			<p><?=$message?></p>
		</div>
		<?php endif; ?>

		<a href="form.php" class="btn pull-right"><i class="icon-plus"></i> Add</a>
		<h3>Student</h3>
		
		<div class="pathways-search">
			<form id="search_form" class="form-inline" action="" method="get">
				<div class="pathways-inline-block">
					<?php $attribute = 'campus_id'; $label = 'Campus'; ?>
					<label class="" for="<?=$attribute?>"><?=$label?></label>
					<select id="<?=$attribute?>" name="search[<?=$attribute?>]" class="input-medium" placeholder="<?=h($label)?>">
						<option value="">All</option>
						<?php foreach ($campuses as $campus): ?>
						<option value="<?=h($campus['id'])?>"<?=$campus['id'] == $search[$attribute] ? ' selected="selected"' : ''?>><?=h($campus['name'])?></option>
						<?php endforeach; ?>
					</select>
				</div>
				
				<div class="pathways-inline-block">
					<?php $attribute = 'status'; $label = 'Status'; ?>
					<label class="" for="<?=$attribute?>"><?=$label?></label>
					<select id="<?=$attribute?>" name="search[<?=$attribute?>]" class="input-small" placeholder="<?=h($label)?>">
						<option value="">All</option>
						<?php foreach ($studentStatusOptions as $studentStatusValue => $studentStatusLabel): ?>
						<option value="<?=$studentStatusValue?>"<?=$studentStatusValue == $search[$attribute] ? ' selected="selected"' : ''?>><?=h($studentStatusLabel)?></option>
						<?php endforeach; ?>
					</select>
				</div>
				
				<div class="pathways-inline-block">
					<?php $attribute = 'student_root_id'; $label = 'Name'; ?>
					<label class="" for="<?=$attribute?>"><?=$label?></label>
					<!-- <input type="text" id="<?=$attribute?>" name="search[<?=$attribute?>]" class="input-medium" value="<?=h($search[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" /> -->
					<input type="hidden" id="<?=$attribute?>" name="search[<?=$attribute?>]" placeholder="Select a <?=$label?>" />
				</div>
				<script type="text/javascript">
					$(function() {
						$('#student_root_id').select2({
							minimumInputLength: 1,
							ajax: {
								url: 'students.json.php',
								dataType: 'json',
								data: function(term, page) {
									return { q: term };
								},
								results: function(data, page) {
									return { results: data.results };
								}
							}
						});
					});
				</script>
				
				<div class="pathways-inline-block">
					<?php foreach ($sort as $index => $info): ?>
					<?php if (!empty($info['column']) && !empty($info['option'])): ?>
					<?php $attribute = 'column'; ?>
					<input type="hidden" name="sort[<?=h($index)?>][<?=$attribute?>]" value="<?=h($info[$attribute])?>" />
					<?php $attribute = 'option'; ?>
					<input type="hidden" name="sort[<?=h($index)?>][<?=$attribute?>]" value="<?=h($info[$attribute])?>" />
					<?php endif; ?>
					<?php endforeach; ?>
					
					<?php $attribute = 'column'; $label = 'Sort by'; ?>
					<label class="" for="<?=$attribute?>"><?=$label?></label>
					<select id="<?=$attribute?>" name="sort[<?=max(array_keys($sort?:array(0)))+1?>][<?=$attribute?>]" class="input-medium" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($sort_by_columns as $value => $label): ?>
						<option value="<?=$value?>"<?=$value == $search[$attribute] ? ' selected="selected"' : ''?>><?=h($label)?></option>
						<?php endforeach; ?>
					</select>
					<?php $attribute = 'option'; $label = 'Option'; ?>
					<!-- <label class="" for="<?=$attribute?>"><?=$label?></label> -->
					<select id="<?=$attribute?>" name="sort[<?=max(array_keys($sort?:array(0)))+1?>][<?=$attribute?>]" class="input-mini" placeholder="<?=h($label)?>">
						<option value=""></option>
						<?php foreach ($sort_by_options as $value => $label): ?>
						<option value="<?=$value?>"<?=$value == $search[$attribute] ? ' selected="selected"' : ''?>><?=h($label)?></option>
						<?php endforeach; ?>
					</select>
					<button type="button" id="clear_sorting_btn" class="btn"><i class="icon-remove"></i> Clear sorting</button>
					<script type="text/javascript">
						$(function() {
							$('#clear_sorting_btn').click(function() {
								var $search_form = $('#search_form');
								$('input[type="hidden"][name^="sort["]', $search_form).remove();
								$search_form.submit();
							});
						});
					</script>
					<button type="submit" class="btn" style="margin-left:30px">GO</button>
				</div>
			</form>
		</div>
		
		<?php if (empty($students)): ?>
		<p>There are no records.</p>
		<?php else: ?>
		<div class="row-fluid" style="margin-bottom:10px">
			<div class="btn-group">
				<button id="select_all_btn" class="btn btn-small">Select All</button>
				<button id="delete_btn" class="btn btn-small">Delete</button>
			</div>
		</div>
		<script type="text/javascript">
			$(function() {
				$('#select_all_btn').click(function() {
					var $selectAllCheckbox = $('.select-all-checkbox');
					$selectAllCheckbox.prop('checked', !$selectAllCheckbox.prop('checked'));
				});
				$('#delete_btn').click(function() {
					if ($('.select-all-checkbox:checked').length == 0) {
						bootbox.alert('At least select 1 record.');
					} else {
						bootbox.dialog('Delete selected records?', [
							{
								'label': 'Delete',
								'class': 'btn-danger',
								'callback': function() {
									$('#form').attr('action', 'delete.php').submit();
								}
							},
							{
								'label': 'Cancel',
								'class': 'btn'
							}
						]);
					}
				});
			});
		</script>
		
		<form id="form" action="" method="post">
			<table class="table table-striped table-bordered table-hover table-condensed">
				<thead>
					<tr>
						<th style="min-width:20px; width:20px"></th>
						<th style="min-width:50px; width:50px">Edit</th>
						<th>Name <?=Util::getSortDirectionCaretHtml($sort, 'name')?></th>
						<th>Chinese Name <?=Util::getSortDirectionCaretHtml($sort, 'zh_name')?></th>
						<th>Year / Grade <?=Util::getSortDirectionCaretHtml($sort, 'student_grade_id')?></th>
						<th>Emergency Contact Person <?=Util::getSortDirectionCaretHtml($sort, 'emergency_contact_name')?></th>
						<th>Emergency Contact No. <?=Util::getSortDirectionCaretHtml($sort, 'emergency_contact_number')?></th>
					</tr>
				</thead>
				<tbody>
					<?php foreach ($students as $student): ?>
					<tr>
						<td><input type="checkbox" name="student[selected][]" class="select-all-checkbox" value="<?=h($student['root_id'])?>" /></td>
						<td><a href="form.php?root_id=<?=h($student['root_id'])?>" class="btn"><i class="icon-pencil"></i></a></td>
						<td><?=h($student['last_name'] . ' ' . $student['first_name'])?></td>
						<td><?=h($student['zh_name'])?></td>
						<td><?=h($student['student_grade'])?></td>
						<td><?=h($student['emergency_contact_name'])?></td>
						<td><?=h($student['emergency_contact_number'])?></td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
		</form>
		<script type="text/javascript">
			$(function() {
				$('#form').validate();
			});
		</script>
		<?php endif; ?>
	
		<?php require( __DIR__ . '/../inc/_footer.php'); ?>

	</div> <!-- /container -->
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit