-
Notifications
You must be signed in to change notification settings - Fork 37
/
index.php
317 lines (282 loc) · 11 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<?php
ob_start();
session_start();
//cek session
if(isset($_SESSION['admin'])){
header("Location: ./admin.php");
die();
}
require_once 'include/config.php';
require_once 'include/functions.php';
$config = conn($host, $username, $password, $database);
?>
<!--
Name : Aplikasi Sederhana Manajemen Surat Menyurat
Version : v1.0.1
Description : Aplikasi untuk mencatat data surat masuk dan keluar secara digital.
Date : 2016
Developer : M. Rudianto
Phone/WA : 0852-3290-4156
Email : rudi@masrud.com
Website : https://masrud.com
-->
<!doctype html>
<html lang="en">
<!-- Head START -->
<head>
<title>Aplikasi Manajemen Surat</title>
<!-- Meta START -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<?php
$query = mysqli_query($config, "SELECT logo from tbl_instansi");
list($logo) = mysqli_fetch_array($query);
echo '<link rel="shortcut icon" href="upload/'.$logo.'">';
?>
<!-- Meta END -->
<!--[if lt IE 9]>
<script src="../asset/js/html5shiv.min.js"></script>
<![endif]-->
<!-- Global style START -->
<link type="text/css" rel="stylesheet" href="asset/css/materialize.css">
<style type="text/css">
body {
background: #fff;
}
.bg::before {
content: '';
background-image: url('./asset/img/background.jpg');
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: 0.15;
filter:alpha(opacity=15);
height:100%;
width:100%;
}
@media only screen and (min-width: 993px) {
.container {
width: 60%!important;
}
}
.container {
max-width: 100%;
margin-top: 2.5rem;
}
#logo {
display: block;
margin: -20px auto -5px;
}
img {
border-radius: 50%;
margin: 0 auto;
width: 100px;
height: 100px;
}
#login {
margin-top: -2%;
}
#smk {
font-size: 2rem;
margin-bottom: 10px;
}
.batas {
border-bottom: 1px dotted #444;
margin: 0 auto;
width: 90%;
}
#title {
margin: 5px 0 35px;
}
.btn-large {
font-size: 1.25rem;
margin: 0;
}
#alert-message {
border-radius: 3px;
color: #f44336 ;
font-size: 1.15rem;
margin: 15px 15px -15px;
}
.error {
padding: 10px;
}
.upss {
font-size: 1.2rem;
margin-left: 20px;
}
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
-webkit-transform: translate3d(0, -50px, 0);
-ms-transform: translate3d(0, -50px, 0);
transform: translate3d(0, -50px, 0);
-webkit-transition: -webkit-transform .5s ease-out;
-ms-transition: -webkit-transform .5s ease-out;
transition: transform .5s ease-out;
}
.pace.pace-active {
-webkit-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.pace .pace-progress {
display: block;
position: fixed;
z-index: 2000;
top: 0;
right: 100%;
width: 100%;
height: 3px;
background: #2196f3;
pointer-events: none;
}
noscript {
color: #42a5f5;
}
.input-field label {
font-size: 1.2rem;
}
.input-field label.active {
font-size: 1rem;
}
</style>
<!-- Global style END -->
</head>
<!-- Head END -->
<!-- Body START -->
<body class="blue-grey lighten-3 bg">
<!-- Container START -->
<div class="container">
<!-- Row START -->
<div class="row">
<!-- Col START -->
<div class="col s12 m6 offset-m3 offset-m3">
<!-- Box START -->
<div class="card-panel z-depth-2" id="login">
<!-- Row Form START -->
<div class="row">
<?php
$query = mysqli_query($config, "SELECT * FROM tbl_instansi");
while($data = mysqli_fetch_array($query)){
?>
<!-- Logo and title START -->
<div class="col s12">
<div class="card-content">
<h5 class="center" id="title">Aplikasi Manajemen Surat</h5>
<?php echo '<img id="logo" src="upload/'.$data['logo'].'">';?>
<h4 class="center" id="smk">
<?php echo ''.$data['nama'].'';?>
</h4>
<div class="batas"></div>
</div>
</div>
<!-- Logo and title END -->
<?php
}
?>
<?php
if(isset($_REQUEST['submit'])){
//validasi form kosong
if($_REQUEST['username'] == "" || $_REQUEST['password'] == ""){
echo '<div class="upss red-text"><i class="material-icons">error_outline</i> <strong>ERROR!</strong> Username dan Password wajib diisi.
<a class="btn-large waves-effect waves-light blue-grey col s11" href="" style="margin: 20px 0 0 5px;"><i class="material-icons md-24">arrow_back</i> Kembali ke login form</a></div>';
} else {
$username = trim(htmlspecialchars(mysqli_real_escape_string($config, $_REQUEST['username'])));
$password = trim(htmlspecialchars(mysqli_real_escape_string($config, $_REQUEST['password'])));
$query = mysqli_query($config, "SELECT id_user, username, nama, nip, admin FROM tbl_user WHERE username=BINARY'$username' AND password=MD5('$password')");
if(mysqli_num_rows($query) > 0){
list($id_user, $username, $nama, $nip, $admin) = mysqli_fetch_array($query);
//buat session
$_SESSION['id_user'] = $id_user;
$_SESSION['username'] = $username;
$_SESSION['nama'] = $nama;
$_SESSION['nip'] = $nip;
$_SESSION['admin'] = $admin;
header("Location: ./admin.php");
die();
} else {
//session error
$_SESSION['errLog'] = '<center>Username & Password tidak ditemukan!</center>';
header("Location: ./");
die();
}
}
} else {
?>
<!-- Form START -->
<form class="col s12 m12 offset-4 offset-4" method="POST" action="" >
<div class="row">
<?php
if(isset($_SESSION['errLog'])){
$errLog = $_SESSION['errLog'];
echo '<div id="alert-message" class="error red lighten-5"><div class="center"><i class="material-icons">error_outline</i> <strong>LOGIN GAGAL!</strong></div>
'.$errLog.'</div>';
unset($_SESSION['errLog']);
}
if(isset($_SESSION['err'])){
$err = $_SESSION['err'];
echo '<div id="alert-message" class="error red lighten-5"><div class="center"><i class="material-icons">error_outline</i> <strong>ERROR!</strong></div>
'.$err.'</div>';
unset($_SESSION['err']);
}
?>
</div>
<div class="input-field col s12">
<i class="material-icons prefix md-prefix">account_circle</i>
<input id="username" type="text" class="validate" name="username" required>
<label for="username">Username</label>
</div>
<div class="input-field col s12">
<i class="material-icons prefix md-prefix">lock</i>
<input id="password" type="password" class="validate" name="password" required">
<label for="password">Password</label>
</div>
<div class="input-field col s12">
<button type="submit" class="btn-large waves-effect waves-light blue-grey col s12" name="submit">LOGIN</button>
</div>
</form>
<!-- Form END -->
<?php
}
?>
</div>
<!-- Row Form START -->
</div>
<!-- Box END-->
</div>
<!-- Col END -->
</div>
<!-- Row END -->
</div>
<!-- Container END -->
<!-- Javascript START -->
<script type="text/javascript" src="asset/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="asset/js/materialize.min.js"></script>
<script type="text/javascript" src="asset/js/bootstrap.min.js"></script>
<script data-pace-options='{ "ajax": false }' src='./asset/js/pace.min.js'></script>
<!-- Jquery auto hide untuk menampilkan pesan error -->
<script type="text/javascript">
$("#alert-message").alert().delay(3000).slideUp('slow');
</script>
<!-- Javascript END -->
<noscript>
<meta http-equiv="refresh" content="0;URL='/enable-javascript.html'" />
</noscript>
</body>
<!-- Body END -->
</html>