-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodmpri.php
More file actions
193 lines (187 loc) · 11.6 KB
/
odmpri.php
File metadata and controls
193 lines (187 loc) · 11.6 KB
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
<?php
include('rest.php');
include('conectar.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mi mafia, Tu mafia</title>
<link rel="stylesheet" href="css/geral.css" type="text/css" />
</head>
<body leftmargin="0" topmargin="0" background="img/back2.png">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td width="10%"> </td>
<td align="center" valign="bottom"><p><img src="img/tit.png"></p></td>
<td width="10%"> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#c12a19" align="center" style="box-shadow: 0px 5px 15px #000;" height="50"><?php include ('menu.php');?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#FFFFFF" style="box-shadow: 0px 5px 15px #000;" height="500" valign="top">
<table width="100%" border="0">
<?php include ('headodm.php');?>
<tr>
<td> </td>
<td align="center">
<!---- TABELA POSTS ----->
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td valign="top" width="66%" colspan="2" align="left">
<font face="Georgia, Times New Roman, Times, serif"><h2><i>Últimos Posts</i></h2></font>
<table border="0" width="100%">
<tr>
<?php
// Look for last 3 posts
$query_posts = "SELECT * FROM posts ORDER BY id_post DESC LIMIT 3";
$stmt_posts = $conexao->prepare($query_posts);
$stmt_posts->execute();
$rs_posts = $stmt_posts->get_result();
$nposts = $rs_posts->num_rows;
if($nposts == 0){
?>
<br />
<b>Ainda não há nenhum post! :|</b>
<?php
}else{
while($postinfo = $rs_posts->fetch_assoc()){
$id_post = $postinfo['id_post'];
$tit_post = $postinfo['tit_post'];
$text_post = $postinfo['text_post'];
$cat_post = $postinfo['cat_post'];
?>
<td valign="top" bgcolor="#FFFFFF" align="left" width="33%">
<a style="font-family:Georgia, 'Times New Roman', Times, serif;" href="readpost.php?i=<?=$id_post;?>">
<h4><b>
<i>
<?php
if($tit_post == ''){
echo 'Sem título';
}else{
echo $tit_post;
}
?>
</i>
</b></h4>
</a> ...<br />
<a href="readpost.php?i=<?=$id_post;?>"><b><i>Saiba +</i></b></a>
</td>
<?php }
} ?>
</tr>
</table>
</td>
<td width="33%" align="center">
<h2><font face="Georgia, Times New Roman, Times, serif"><b><i>« <a href="addpost.php">Faz um novo post!</a> »</i></b></font></h2>
</td>
</tr>
<tr>
<td colspan="5">
<hr width="100%" size="1" color="#CCCCCC" />
<hr width="100%" size="2" color="#CCCCCC" />
</td>
</tr>
<tr>
<?php
// Defines all areas in an array
$area_texts = [
'nn' => 'Notícias Nacionais',
'ni' => 'Notícias Internacionais',
'c' => 'Cursos',
'co' => 'Concursos',
'uu' => 'Utilidade Universitária',
'a' => 'Anúncios',
'p' => 'Política',
'hi' => 'Humor Instrutivo',
'ri' => 'RI',
'm' => 'Notícias Mafiosas',
];
$i = 0;
foreach($area_texts as $area_code => $area_name) {
$i++;
?>
<!--- SEC <?=strtoupper($area_name);?> --->
<td width="33%" align="left" valign="top">
<font face="Georgia, Times New Roman, Times, serif"><h2><i>Seção <?=$area_name;?></i></h2></font>
<table border="0" width="100%">
<?php
$query_popost = "SELECT * FROM posts WHERE cat_post = ? ORDER BY id_post DESC LIMIT 5";
$stmt_popost = $conexao->prepare($query_popost);
$stmt_popost->bind_param("s", $area_code);
$stmt_popost->execute();
$rs_popost = $stmt_popost->get_result();
$npopost = $rs_popost->num_rows;
// Check if there are no posts in this category
if($npopost == 0){
?>
<tr>
<td colspan="2" style="font-family:Georgia, 'Times New Roman', Times, serif">
Ainda não há nenhum artigo nesta seção!
</td>
</tr>
<?php
}else{
while($popost_info = $rs_popost->fetch_assoc()){
$id_popost = $popost_info['id_post'];
$tit_popost = $popost_info['tit_post'];
$creat_popost = $popost_info['creat_post'];
$query_popostu = "SELECT * FROM user WHERE id_user = ?";
$stmt_popostu = $conexao->prepare($query_popostu);
$stmt_popostu->bind_param("s", $creat_popost);
$stmt_popostu->execute();
$rs_popostu = $stmt_popostu->get_result();
$popostu_info = $rs_popostu->fetch_assoc();
$photo_popost = $popostu_info['photo_user'] ?? 'back.png';
?>
<tr>
<td width="82%" style="font-family:Georgia, 'Times New Roman', Times, serif">
<a href="readpost.php?i=<?=$id_popost;?>"><i><b><?=$tit_popost;?></b></i></a>
</td>
<td width="18%">
<a href="<?=($creat_popost == 0) ? '#' : 'perfil.php?p=' . $creat_popost; ?>"><img src="photos/user/<?=$photo_popost;?>" alt="" style="width: 40px;
height: 40px;
border-radius: 40px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
background: url(photos/user/<?=$photo_popost?>);
background-size:contain;
box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, .8);" /></a>
</td>
</tr>
<tr>
<td colspan="2">
<hr width="90%" size="1" color="#CCCCCC" />
</td>
</tr>
<?php
}
}
?>
</table>
<!----- END <?=strtoupper($area_name);?> SEC ----------->
</td>
<?php
if($i % 3 == 0) {
echo '</tr><tr>'; // Start a new row after every 3 areas
}
}
?>
</tr>
</table>
</td>
<td> </td>
</tr>
</table>
</td>
<td> </td>
</tr>
</table>
</body>
</html>