-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathportada.php
More file actions
85 lines (85 loc) · 3.61 KB
/
portada.php
File metadata and controls
85 lines (85 loc) · 3.61 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
<?php
/* posts de portada */
$master=$sql->Query("SELECT * FROM forotes order by orden");
while($ma = $master->fetch_object()) {
?>
<div class="bg-dark text-white py-1 px-3">
<h2><?php echo stripslashes($ma->nombre); ?></h2>
</div>
Foros:
<?php
$res=$sql->Query("SELECT * FROM foros WHERE master='".$ma->id."'");
while($k = $res->fetch_object()) {
printf('<a href="%s?foro=%d#%s">%s</a> / ',$sitio,$k->id,$k->titulo,$k->titulo);
}
?>
<div class="card-deck">
<?php
$rex=$sql->Query("SELECT * FROM foros WHERE master='".$ma->id."' order by orden");
while($foro = $rex->fetch_object()) {
$res=$sql->Query("SELECT * FROM posts WHERE foro='".$foro->id."' AND padre=0 order by id desc limit 2");
while($k = $res->fetch_object()) {
//
$last=$sql->Query("SELECT fecha FROM posts WHERE padre='".$k->id."' order by id desc limit 1");
if($last->num_rows>0) { $last = $last->fetch_object(); $last = $last->fecha; }
else { $last = $k->fecha; }
//
$no = $sql->Query("SELECT count(id) as no FROM posts WHERE padre='".$k->id."'");
$no = $no->fetch_object();
$image=null;
preg_match("/<img(.*)src=\"(.*)up(.*)\.(jpg|gif|png)\"/",stripslashes($k->contenido),$y);
$len=250;
if(isset($y[3])) {
$image = "up/".$y[3].".".$y[4];
$len=100;
}
$texto = mb_substr(strip_tags(stripslashes($k->contenido)),0,$len,'UTF-8');
$texto = explode(" ",$texto);
array_pop($texto);
$texto = implode(" ",$texto);
?>
<div class="card">
<?php
if(!empty($image)) {
?>
<a href="<?php echo $sitio;?>?view=<?php echo $k->id;?>">
<img class="card-img-top picportada" src="s.gif" style="background:url(<?php echo $image;?>)" alt="Card image cap">
</a>
<?php
}
?>
<div class="card-body">
<h4 class="card-title"><a href="<?php echo $sitio;?>?view=<?php echo $k->id;?>"><?php echo stripslashes($k->titulo);?></a></h4>
<h6 class="card-subtitle mb-2 text-muted"><?php echo $foro->titulo;?></h6>
<p class="card-text">
<?php
echo $texto;
?>
</p>
</div>
<div class="card-footer text-muted small">
<?php
if($no->no>0) echo $no->no." respuesta".($no->no>1?'s':'');
else echo "🙄";
//leido?
if(isset($_SESSION[ME])) {
$read=sprintf("SELECT * FROM postslog WHERE postid='%d' and me='%d'",$k->id,$_SESSION[ME]);
$read=$sql->Query($read);
if($read->num_rows<1) {
echo ' <span class="badge badge-warning">sin leer</span>';
} else {
$read = $read->fetch_object();
if(strtotime($read->fecha) > strtotime($last)) echo ' <span class="badge badge-light">leído</span>';
else echo ' <span class="badge badge-info">nuevo</span>';
}
}
?>
</div>
</div>
<?php
}
}
?>
</div>
<?php
}