forked from bastoniyahya/TA-LMS-LSKK-STEI-ITB
-
Notifications
You must be signed in to change notification settings - Fork 1
/
detail_topik.php
286 lines (235 loc) · 10.1 KB
/
detail_topik.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
<?php
require'template/header.php';
$topik = $_GET['topik'];
$id= base64_decode($topik);
?>
<div class="main">
<div class="main-inner">
<div class="container">
<div class="row">
</div>
<div class="row">
<div class="span12">
<div class="widget">
<div class="widget-header">
<i class="icon-comment"></i>
</div> <!-- /widget-header -->
<div class="widget-content">
<?php
$query=mysql_query("select * from tb_topik where id='$id' order by tanggal asc");
while($row=mysql_fetch_array($query)){
$username1 = $row['username'];
$id = $row['id'];
//Menghitung selisih tanggal post dengan tanggal hari ini
//Mengambil Waktu Komputer
$tgl = gmdate("Y-m-d H:i:s", time()+60*60*7); # WIB
$tgl1=$row['tanggal'];
$tgl2 = $tgl;
$selisih_waktu = strtotime($tgl2) - strtotime($tgl1);
$hari = floor($selisih_waktu/86400);
//Untuk menghitung jumlah dalam satuan jam:
$sisa = $selisih_waktu % 86400;
$jumlah_jam = floor($sisa/3600);
//Untuk menghitung jumlah dalam satuan menit:
$sisa = $sisa % 3600;
$jumlah_menit = floor($sisa/60);
//Untuk menghitung jumlah dalam satuan detik:
$sisa = $sisa % 60;
$jumlah_detik = floor($sisa/1);
//Cek user level admin
$query1=mysql_query("select * from tb_user where username='$username1'");
$row1=mysql_fetch_array($query1);
$cek1 = $row1['level'];
//Cek user level kordas
$query2=mysql_query("select * from tb_user where username='$username1'");
$row2=mysql_fetch_array($query2);
$cek2 = $row2['level'];
//Cek user level asisten
$query3=mysql_query("select * from tb_user where username='$username1'");
$row3=mysql_fetch_array($query3);
$cek3 = $row3['level'];
//Cek user level kalab
$query4=mysql_query("select * from tb_user where username='$username1'");
$row4=mysql_fetch_array($query4);
$cek4 = $row4['level'];
//Cek staf jabatan TU
$query5=mysql_query("select * from tb_staf where username='$username1'");
$row5=mysql_fetch_array($query4);
$cek5 = $row5['jabatan'];
//Cek staf jabatan teknisi
$query6=mysql_query("select * from tb_staf where username='$username1'");
$row6=mysql_fetch_array($query6);
$cek6 = $row6['jabatan'];
//Cek Dosen
$query7=mysql_query("select * from tb_dosen where username='$username1'");
$row7=mysql_fetch_array($query7);
$cek7 = $row7['foto'];
//Cek Mahasiswa
$query8=mysql_query("select * from tb_mahasiswa where username='$username1'");
$row8=mysql_fetch_array($query8);
$cek8 = $row8['foto'];
?>
<ul class="messages_layout">
<li class="from_user left">
<?php
if($username1 == $cek1 ){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row1['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek2){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row2['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek3){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row3['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek4){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row4['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek5){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row5['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek6){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row6['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek7 ){
?>
<a href="#" class="avatar"><img src="dosen/foto_dosen/<?php echo $row7['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 != $cek8 ){
?>
<a href="#" class="avatar"><img src="mahasiswa/foto_mahasiswa/<?php echo $row8['foto'] ?>" width="70" height="70"/></a>
<?php
}
?>
<div class="message_wrap"> <span class="arrow"></span>
<div class="info"> <a class="name"><?php echo $row['username']?></a> <span class="time"><?php echo "$hari hari, $jumlah_jam Jam, $jumlah_menit Menit, dan $jumlah_detik Detik";?> | Komentar <?php echo $row ['total_balasan'] ?> Kali</span>
<div class="options_arrow">
</div>
</div>
<div class="text"> <h3> <i class="icon-comment"> <?php echo $row['topik']?></h3></i></div>
<div class="text"><?php echo $row['isi']?></div>
</div>
</li>
<?php
$queryx = "select tb_topik.id, tb_topik.username, tb_topik.topik,tb_reply.id_topik, tb_reply.username, tb_reply.isi, tb_reply.tanggal
from tb_topik
inner join tb_reply on tb_reply.id_topik = tb_topik.id where tb_topik.id='$id'
order by tb_reply.tanggal desc limit 2";
$result = $mysqli->query($queryx)
or die('<b>-- Query failed -- </b> ' . mysql_error());
while ($data1 = $result->fetch_array()){
$username1 = $data1['username'];
$id = $row['id'];
//Menghitung selisih tanggal post dengan tanggal hari ini
//Mengambil Waktu Komputer
$tgl = gmdate("Y-m-d H:i:s", time()+60*60*7); # WIB
$tgl1=$data1['tanggal'];
$tgl2 = $tgl;
$selisih_waktu = strtotime($tgl2) - strtotime($tgl1);
$hari = floor($selisih_waktu/86400);
//Untuk menghitung jumlah dalam satuan jam:
$sisa = $selisih_waktu % 86400;
$jumlah_jam = floor($sisa/3600);
//Untuk menghitung jumlah dalam satuan menit:
$sisa = $sisa % 3600;
$jumlah_menit = floor($sisa/60);
//Untuk menghitung jumlah dalam satuan detik:
$sisa = $sisa % 60;
$jumlah_detik = floor($sisa/1);
//Cek user level admin
$query1=mysql_query("select * from tb_user where username='$username1'");
$row1=mysql_fetch_array($query1);
$cek1 = $row1['level'];
//Cek user level kordas
$query2=mysql_query("select * from tb_user where username='$username1'");
$row2=mysql_fetch_array($query2);
$cek2 = $row2['level'];
//Cek user level asisten
$query3=mysql_query("select * from tb_user where username='$username1'");
$row3=mysql_fetch_array($query3);
$cek3 = $row3['level'];
//Cek user level kalab
$query4=mysql_query("select * from tb_user where username='$username1'");
$row4=mysql_fetch_array($query4);
$cek4 = $row4['level'];
//Cek staf jabatan TU
$query5=mysql_query("select * from tb_staf where username='$username1'");
$row5=mysql_fetch_array($query4);
$cek5 = $row5['jabatan'];
//Cek staf jabatan teknisi
$query6=mysql_query("select * from tb_staf where username='$username1'");
$row6=mysql_fetch_array($query6);
$cek6 = $row6['jabatan'];
//Cek Dosen
$query7=mysql_query("select * from tb_dosen where username='$username1'");
$row7=mysql_fetch_array($query7);
$cek7 = $row7['username'];
//Cek Mahasiswa
$query8=mysql_query("select * from tb_mahasiswa where username='$username1'");
$row8=mysql_fetch_array($query8);
$cek8 = $row8['foto'];
?>
<li class="by_myself right">
<?php
if($username1 == $cek1 ){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row1['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek2){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row2['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek3){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row3['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek4){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row4['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek5){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row5['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek6){
?>
<a href="#" class="avatar"><img src="tatausaha/user/foto_user/<?php echo $row6['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 == $cek7){
?>
<a href="#" class="avatar"><img src="dosen/foto_dosen/<?php echo $row7['foto'] ?>" width="70" height="70"/></a>
<?php
}elseif($username1 != $cek8 ){
?>
<a href="#" class="avatar"><img src="mahasiswa/foto_mahasiswa/<?php echo $row8['foto'] ?>" width="70" height="70"/></a>
<?php
}
?>
<div class="message_wrap"> <span class="arrow"></span>
<div class="info"> <a class="name"><?php echo $data1['username']?></a> <span class="time"><?php echo "$hari hari, $jumlah_jam Jam, $jumlah_menit Menit, dan $jumlah_detik Detik";?></span>
</div><i class="icon-comments"> </i>
<div class="alert-info text"><?php echo $data1['isi']?> </div>
</div>
</li>
<?php
}
?>
</ul>
<?php
}
?>
</div>
<!-- /widget-content -->
</div> <!-- /spa12 -->
</div> <!-- /row -->
</div> <!-- /container -->
</div> <!-- /main-inner -->
</div> <!-- /main -->
<?php
require'template/footer.php';
?>