-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
118 lines (111 loc) · 3.88 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
session_start();
if(!$_SESSION['token']){
session_destroy();
header('location:login.php');
}else{
include_once 'views/templates/header.php';
include_once 'views/templates/navbar.php';
include_once 'views/templates/sidebar.php';
include_once 'controller/connection.php';
include_once 'lib/functions.php';
$devices = mysqli_query($conn, "SELECT * FROM mesin");
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<?php
if(isset($_GET['ip']) && !empty($_GET['ip'])){
$status = cekMesin($_GET['ip']);
?>
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-md-12">
<?php
$cekData = cekDataSiswa($_SESSION['token'], $_GET['ip']);
if($cekData == FALSE){
echo '<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h5><i class="icon fas fa-ban"></i> Data Server dan lokal belum sinkron</h5>
Silahkan klik tombol sync untuk melakukan sinkronasi data server dengan lokal. <a href="controller/sinkronData.php?ip='.$_GET['ip'].'" class="ml-2 btn btn-xs btn-info">Sync</a>
</div>';
}
?>
</div>
<div class="col-sm-6">
<h1 class="m-0 text-dark"><?=$_GET['ip']?></h1>
<?php
if ($status) {
echo "<span class='btn btn-xs btn-success'>ONLINE</span>";
} else {
echo "<span class='btn btn-xs btn-danger'>OFFLINE</span>";
}
?>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<?php
}else{
?>
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">Beranda</h1>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<?php } ?>
<?php
if(isset($_GET['page']) && !empty($_GET['page'])){
$page = $_GET['page'];
switch($page){
case 'beranda':
require __DIR__ . '/views/beranda.php';
break;
case 'tambah-mesin':
require __DIR__ . '/views/add_device.php';
break;
case 'edit-mesin':
require __DIR__ . '/views/edit_device.php';
break;
case 'presensi':
require __DIR__ . '/views/presensi.php';
break;
case 'siswa':
require __DIR__ . '/views/siswa.php';
break;
case 'rekap':
require __DIR__ . '/views/rekap.php';
break;
case 'konfigurasi':
require __DIR__ .'/views/setting_sistem.php';
break;
default:
require __DIR__ . '/views/error.php';
break;
}
}else{
require __DIR__ . '/views/beranda.php';
}
?>
<!-- /.content-wrapper -->
<?php
include_once 'views/templates/footer.php';
} // end else cek session
?>
<script type="text/javascript">
//fungsi untuk menampilkan jam saat ini
function tampilkanwaktu(){
var waktu = new Date();
var sh = waktu.getHours() + ""; //memunculkan nilai jam, //tambahan script + "" supaya variable sh bertipe string sehingga bisa dihitung panjangnya : sh.length //ambil nilai menit
var sm = waktu.getMinutes() + ""; //memunculkan nilai detik
var ss = waktu.getSeconds() + ""; //memunculkan jam:menit:detik dengan menambahkan angka 0 jika angkanya cuma satu digit (0-9)
document.getElementById("clock").innerHTML = (sh.length==1?"0"+sh:sh) + ":" + (sm.length==1?"0"+sm:sm) + ":" + (ss.length==1?"0"+ss:ss);
}
</script>