-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsearch.php
More file actions
112 lines (104 loc) · 3.54 KB
/
search.php
File metadata and controls
112 lines (104 loc) · 3.54 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
<?php
require "verifSession.php";
require_once "mysqliConnect.php";
require_once "function.php";
/*PDO connect*/
require_once "PDOConnect.php";
$info = infoUser($PDO, $_SESSION["idutil"]);
$nb_par_page = 10;
if(!isset($_GET['idarticle'])) {
// pour pagination
if (isset($_GET['pg']) && ctype_digit($_GET['pg'])) {
$pg = (int)$_GET['pg'];
} else {
$pg = 1;
}
}
/*/*
* calcul pour la pagination
*/
// nombre total d'article
$requete = $PDO->query( "SELECT COUNT(idmessage) AS nb FROM themessage;");
$requete_assoc = $requete->fetch(PDO::FETCH_ASSOC);
$nb_tot = $requete_assoc['nb'];
// calcul pour le premier argument du LIMIT
$limit = ($pg-1)*$nb_par_page;
// requête pour récupérer tous les articles suivant la pagination
$resultat_search = [];
$pagination = maPagination($nb_tot, $pg,"pg",$nb_par_page);
if(isset($_POST['toto'])){
$lulu = htmlspecialchars(trim($_POST['toto']),ENT_QUOTES);
$iquery_count = $PDO->query( "SELECT m.*,u.thelogin,u.thecolor
FROM themessage m
INNER JOIN theuser u
ON u.idutil = m.theuser_idutil WHERE `thecontent` LIKE '%$lulu%' ORDER BY thedatetime desc");
$count = $iquery_count->rowCount();
if($count){
$resultat_search = $iquery_count->fetchAll(PDO::FETCH_ASSOC);
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Tchat: Search</title>
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon.ico">
<script src="js/ajax.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" media="screen" href="css/style.css">
</head>
<body class="tchat" >
<div id="particles-js"></div>
<!-- scripts -->
<script src="js/particles.min.js"></script>
<script src="js/app.min.js"></script>
<nav>
<div class="display">
<a href="profil.php">
<div class="user-tchat">
<img src="img/profil/thumbs/<?=$info["theimage"];?>">
<li>Bonjour, <b><?= $_SESSION["thelogin"]; ?></b></li>
</div>
</a>
<li><a href="index.php">Return</a></li>
<a href="deco.php"><li class="signout"><b>Sign out</b></li></a>
<form action='search.php' id="demo-2" method='POST'>
<input type="search" name='toto' placeholder="Search & enter" required>
</form>
</div>
</nav>
<h1>Archives : Mini chat</h1>
<div class="formulaire">
</div>
<div id="searchresults">
<?php
if(!$count){
echo "<h3>No message yet !</h3>";
}else {
foreach ($resultat_search as $ligne) {
?>
<div class="archives-message"><?php echo $ligne['thecontent'] = traiteChaine(links(Censurer($ligne['thecontent']))) ?><a href="?idarticle=<?= $ligne['idmessage'] ?>"></a>
<h4><?= $ligne['thedatetime'] ?> -
<a href="#"><?= $ligne['thelogin'] ?></a></h4></div>
<?php
}
}
?>
</div>
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//statistiques.cf2m.be/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
</body>
</html>