-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.php
executable file
·95 lines (85 loc) · 2.03 KB
/
session.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
<?php
/**
* Created by PhpStorm.
* User: deyelovi
* Date: 05/04/2016
* Time: 17:02
*/
session_start();
date_default_timezone_set('Asia/Jakarta');
spl_autoload_register(function ($class) {
include 'class/' . $class . '.php';
});
if (!function_exists('kelas')) {
function kelas()
{
return [
'X', 'XI', 'XII'
];
}
}
if (!function_exists('success')) {
function success($text = null)
{
if ($text) {
$_SESSION['success'] = $text;
} else {
$_SESSION['success'] = 'Berhasil tambah data baru';
}
}
}
if (!function_exists('info')) {
function info($text = null)
{
if ($text) {
$_SESSION['info'] = $text;
} else {
$_SESSION['info'] = 'Berhasil perbaruhi data';
}
}
}
if (!function_exists('error')) {
function error($text = null)
{
if ($text) {
$_SESSION['error'] = $text;
} else {
$_SESSION['error'] = 'Gagal menghapus data';
}
}
}
if (!function_exists('rupiah')) {
function rupiah($angka)
{
$hasil_rupiah = 'Rp. ' . number_format($angka, 0, ',', '.');
return $hasil_rupiah;
}
}
if (!function_exists('bulan')) {
function bulan()
{
return [
'1' => 'Januari',
'2' => 'Februari',
'3' => 'Maret',
'4' => 'April',
'5' => 'Mei',
'6' => 'Juni',
'7' => 'Juli',
'8' => 'Agustus',
'9' => 'September',
'10' => 'Oktober',
'11' => 'November',
'12' => 'Desember'
];
}
}
$tajaran = new TahunAjaran();
$th = $tajaran->getByActive();
$user = new Auth();
// // if user session is not active(not loggedin) this page will help 'home.php and profile.php' to redirect to login page
// // put this file within secured pages that users (users can't access without login)
if (!$user->cek_login()) {
// session no set redirects to login page
$user->redirect('login.php');
}