forked from ardirsaputra/Tarung-Soal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting.php
147 lines (144 loc) · 10.2 KB
/
setting.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
<?php
include('./classes/DB.php');
include('./classes/Login.php');
include('./classes/Navigation.php');
include('./classes/Content.php');
include('./classes/Page.php');
$idUser = Login::isLoggedIn();
if ($idUser != false){
$notif = '';
//---------------------------------
if(isset($_POST['setPassword'])){
if((isset($_POST['oldPassword']))&&(isset($_POST['newPassword']))&&(isset($_POST['matchNewPassword']))){
$password = $_POST['oldPassword'];
$newPassword = $_POST['newPassword'];
$matchNewPassword = $_POST['matchNewPassword'];
if(password_verify($password,DB::query('SELECT passwordUser FROM user WHERE idUser=:idUser', array(':idUser'=>$idUser))[0]['passwordUser'])){
if($newPassword == $matchNewPassword){
if(strlen($newPassword) >=8 and strlen($newPassword) <=60){
DB::query('UPDATE user SET passwordUser=:passwordUser WHERE idUser=:idUser',array(':passwordUser'=>password_hash($newPassword,PASSWORD_BCRYPT),':idUser'=>$idUser));
$notif = "Password berhasil diganti !";
}else $notif = "Password Salah" ;
}else $notif = "password tidak sama ";
}else $notif = "Password lama salah";
}else $notif = "ada borang yang kosong";
}elseif(isset($_POST['forgotpassword'])){
$nomorInduk = DB::query('SELECT nomorInduk FROM user WHERE idUser = :idUser',array(':idUser'=>$idUser))[0]['nomorInduk'];
if($nomorInduk != ''){
if(isset($_POST['pertanyaan'])){
if(isset($_POST['jawabaan'])){
DB::query('INSERT INTO forgot VALUES ( \'\',:idUser,:pertanyaan,:jawabaan)',array(':idUser'=>$idUser,':pertanyaan'=>$_POST['pertanyaan'],':jawabaan'=>$_POST['jawabaan']));
$notif = "Menambah Pengaturan Lupa Password Berhasil";
}
}
}else $notif = 'Nomor induk harus terisi untuk bisa mengatur fitur ini';
}elseif(isset($_POST['updaterecovery'])){
$nomorInduk = DB::query('SELECT nomorInduk FROM user WHERE idUser = :idUser',array(':idUser'=>$idUser))[0]['nomorInduk'];
if($nomorInduk != ''){
if(isset($_POST['idrecovery'])){
if(isset($_POST['pertanyaan'])){
if(isset($_POST['jawaban'])){
DB::query('UPDATE forgot SET pertanyaan = :pertanyaan , jawaban = :jawaban WHERE idForgot = :idForgot)',array(':idForgot'=>$_POST['idrecovery'],':pertanyaan'=>$_POST['pertanyaan'],':jawaban'=>$_POST['jawaban']));
$notif = "Mengubah Pengaturan Lupa Password Berhasil";
}else $notif = "Jawaban tidak ada";
}else $notif ="Pertanyaan tidak ada";
}else $notif = "Lupa id user";
}else $notif = 'Nomor induk harus terisi untuk bisa mengatur fitur ini';
}elseif(isset($_POST['updateUser'])){
if(isset($_POST['namaLengkap']) && strlen($_POST['namaLengkap']) >= 4 ){
if(isset($_POST['email']) && $_POST['email']!=''){
if(isset($_POST['idGolongan'])&& $_POST['idGolongan']!=''){
if(isset($_POST['gender'])&& $_POST['gender']!=''){
if(isset($_POST['tempatLahir'])&& $_POST['tempatLahir']!=''){
if(isset($_POST['tanggalLahir'])&& $_POST['tanggalLahir']!=''){
$idUser = Login::isLoggedIn();
$namaLengkap = $_POST['namaLengkap'];
$email = $_POST['email'];
$idGolongan = $_POST['idGolongan'];
$nomorInduk = $_POST['nomorInduk'];
$sekolahUser =$_POST['sekolahUser'];
$gender = $_POST['gender'];
$tempatLahir = $_POST['tempatLahir'];
$tanggalLahir = $_POST['tanggalLahir'];
$diskripsiUser = $_POST['deskripsiUser'];
$maxsize = 1024 * 200;
if(!empty($_FILES['foto']['tmp_name'])){
if($_FILES['foto']['size'] <= $maxsize){
$foto = file_get_contents($_FILES['foto']['tmp_name']);
DB::query('UPDATE user SET
namaLengkap = :namaLengkap,
email = :email,
idGolongan = :idGolongan ,
nomorInduk = :nomorInduk ,
sekolahUser = :sekolahUser,
gender = :gender,
tempatLahir = :tempatLahir,
tanggalLahir = :tanggalLahir,
foto = :foto,
diskripsiUser = :diskripsiUser
WHERE
idUser = :idUser',
array(
':namaLengkap' =>$namaLengkap,
':email' =>$email,
':idGolongan' =>$idGolongan,
':nomorInduk' =>$nomorInduk,
':sekolahUser' =>$sekolahUser,
':gender' =>$gender,
':tempatLahir' =>$tempatLahir,
':tanggalLahir' =>$tanggalLahir,
':foto' =>$foto,
':diskripsiUser'=>$diskripsiUser,
':idUser' =>$idUser
));
$notif = 'Pembaharuan data profil berhasil';
}else{
DB::query('UPDATE user SET
namaLengkap = :namaLengkap,
email = :email,
idGolongan = :idGolongan ,
nomorInduk = :nomorInduk ,
sekolahUser = :sekolahUser,
gender = :gender,
tempatLahir = :tempatLahir,
tanggalLahir = :tanggalLahir,
diskripsiUser = :diskripsiUser
WHERE
idUser = :idUser',
array(
':namaLengkap' =>$namaLengkap,
':email' =>$email,
':idGolongan' =>$idGolongan,
':nomorInduk' =>$nomorInduk,
':sekolahUser' =>$sekolahUser,
':gender' =>$gender,
':tempatLahir' =>$tempatLahir,
':tanggalLahir' =>$tanggalLahir,
':diskripsiUser'=>$diskripsiUser,
':idUser' =>$idUser
));
$notif = 'Ukuran foto terlalu besar (maksimal 200kb)';
}
}else{
DB::query('UPDATE user SET namaLengkap = :namaLengkap, email = :email ,idGolongan =:idGolongan ,nomorInduk =:nomorInduk,sekolahUser = :sekolahUser,gender = :gender, tempatLahir = :tempatLahir, tanggalLahir = :tanggalLahir, diskripsiUser = :diskripsiUser WHERE idUser = :idUser',array(':idUser' => $idUser ,':namaLengkap'=>$namaLengkap,':email'=>$email,':idGolongan'=>$idGolongan,':nomorInduk'=>$nomorInduk,':sekolahUser'=>$sekolahUser,':gender'=>$gender,':tempatLahir'=>$tempatLahir,':tanggalLahir'=>$tanggalLahir,':diskripsiUser'=>$diskripsiUser));
$notif = 'Pembaharuan data profil berhasil!';
}
}else $notif = 'Tanggal lahir harus ada';
}else $notif = 'Tempat lahir harus ada';
}else $notif = 'gender harus ada';
}else $notif = 'Pendidikan terakhir harus ada';
}else $notif = 'Email harus ada';
}else $notif = 'Nama Lengkap harus ada';
}
//---------------------------------
$profil = Page::Title('Data Profil',Content::profil($idUser));
$password = Page::Title('Ganti Password',Content::password($idUser));
$recovery = Page::Title('Pemulihan Akun',Content::passwordRecovery());
$login = Page::Title('Keluar dari semua perangkat',Content::FormDataLogin($idUser));
$recovery .= Page::BlockContent($login,'','');
$content = Page::BlockContent($profil,$password,$recovery);
echo Page::DefaultPage('Setting - Tarung Soal',$notif,$content);
}else{
Login::redirect('./login.php');
}
?>