This repository was archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotification.php
More file actions
executable file
·116 lines (94 loc) · 3.77 KB
/
Copy pathnotification.php
File metadata and controls
executable file
·116 lines (94 loc) · 3.77 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
<?php
//Inclusion de la sécurité
include('securite.php');
//Init page
include('inc/initPage.php');
//On vérifie si il faut mettre toute les notification en vu
if(isset($_GET['all_vu']))
{
$sql = "DELETE FROM notification WHERE ID_personne = ".$_SESSION['ID'];
$requete = $bdd->query($sql);
}
if(isset($_GET['loading']))
{
//Inclusion du template
include('inc/loading.html');
//Fermeture de la page
exit();
}
//On vérifie si l'utilisateur recherche uniquement les nouveautées
if(isset($_GET['rapide']))
{
//On recherche les notifications
$sql = "SELECT * FROM `notification` WHERE `ID_personne` = ? AND `vu` = 0 ORDER BY `ID` LIMIT 1";
$requete = $bdd->prepare($sql);
$requete->execute(array($_SESSION['ID']));
ob_start();
if($notification = $requete->fetch())
{
//Arrêt de la sécurité des erreurs!
ob_end_clean();
//On met la notification en vu
$sql = "UPDATE notification SET vu = 1 WHERE ID = ".$notification['ID'];
$update = $bdd->query($sql);
//We search the informations about the personn
$info = cherchenomprenom($notification['ID_createur'], $bdd);
//We show the notification
echo corrige_caracteres_speciaux($info['prenom']." ".$info['nom']." ".$notification['message'])."\n";
}
else
{
ob_end_clean();
}
//Fermeture du curseur
$requete->closeCursor();
//On quitte le script courant
exit();
}
//Searching the last notifications
$notifications = searchnotification($_SESSION['ID'], $bdd, 10, 0, '0');
if(count($notifications) == 0)
{
echo "<div>Il n'y a rien à afficher pour le moment.</div>";
}
else
{
//We show the notifications
foreach($notifications as $show)
{
//We search the informations about the personn
$info = cherchenomprenom($show['ID_createur'], $bdd);
//We show the notification
if($show['adresse'] != "")
{
if(preg_match('<page:>', $show['adresse']))
{
$adresse = str_replace('page:', '', $show['adresse']);
if(preg_match('<post:>', $show['adresse']))
{
$adresse = str_replace("post:", "|", $adresse);
$array_adresse = explode('|', $adresse);
echo "<a href='#' onClick='ajax_rapide(\"action.php?actionid=6&idnotification=".$show['ID']."\"); affiche_notifications(\"0\"); change_page_personne_with_post(".$array_adresse[0].", ".$array_adresse[1].")'>";
}
else
{
echo "<a href='#' onClick='ajax_rapide(\"action.php?actionid=6&idnotification=".$show['ID']."\"); affiche_notifications(\"0\"); change_page_personne(".$adresse.")'>";
}
}
elseif(preg_match('<private_chat:>', $show['adresse']))
{
$adresse = str_replace('private_chat:', '', $show['adresse']);
echo "<a href='#' onClick='ajax_rapide(\"action.php?actionid=6&idnotification=".$show['ID']."\"); affiche_notifications(\"0\"); affiche_chat_prive(".$adresse.")'>";
}
else
echo "<a href='action.php?actionid=5&idnotification=".$show['ID']."'>";
}
echo "<div>".avatar($show['ID_createur'], "./", 32, 32);
echo ($show['vu'] == 0 ? "<strong>" : "");
echo corrige_caracteres_speciaux($info['prenom']." ".$info['nom']." ".$show['message']);
echo ($show['vu'] == 0 ? "</strong>" : "") ;
echo " <a title='Mettre la notification en vu' href='#' onClick='if(check_if_we_are_on_user_page()) { ajax_rapide(\"action.php?actionid=6&idnotification=".$show['ID']."\"); affiche_notifications(\"0\"); } else { location.href=\"action.php?actionid=5&idnotification=".$show['ID']."\" }'>vu</a></div>";
if($show['adresse'] != "")
echo "</a>";
}
}