-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreply.php
More file actions
executable file
·74 lines (58 loc) · 1.88 KB
/
reply.php
File metadata and controls
executable file
·74 lines (58 loc) · 1.88 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
<?
include('config.php');
function displayContent(){
global $idUnif, $university, $longUnif, $dbUnif, $dbAdmin, $connectionAdmin, $dbNetwork, $connectionNetwork, $titleInUrl;
$YouAreHere = "reply";
require('header.php');
echo "<div id=\"content\">\n";
include('content_reply.php');
echo " <a class=\"goTop\" href=\"#wrapper\">Haut de la page</a>\n";
echo "</div> <!-- /content -->\n";
echo "<div id=\"sidebar\">\n";
include('sidebar.php');
echo"</div> <!-- /sidebar -->\n";
//Affiche le code du footer
include('footer.php');
} //displayContent()
if(isset($_POST['posting_button_reply'])){
/**** POSTING ****/
// Récupère les variables par la méthode POST
$name = $_COOKIE['username'];
$post = $_POST['comment'];
$idForum = $_POST['idForum']; //hidden input
// Timestamp
//set time zone
date_default_timezone_set('Europe/Brussels');
$time = date("Y-m-d H:i:s");
//Sanitize 'name'
if(strlen($name) == 0){
echo "Vous devez choisir un nom.";
die();
}
if(strlen($name) > 35){
echo "Votre nom est trop long!";
die();
}
$name = strip_tags($name);
$name = mysql_real_escape_string($name);
//Sanitize 'post'
if(strlen($post) == 0){
echo "Vous n'avez rien écrit.";
die();
}
$post = strip_tags($post, '<a>'); //strip all html tags except '<a>'.
// check si c'est un lien et le rend cliquable.
$post = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $post);
$post = mysql_real_escape_string($post);
// Insert the data in the database
$insertion = "INSERT INTO reply (idForum, authorReply, messageReply, timestampReply) VALUES ('$idForum', '$name', '$post', '$time')";
$result1 = mysql_query($insertion)
or die ('Erreur : '.mysql_error() );
// reload la page avec le nouveau contenu
displayContent();
} //if(isset())
//Quand la page est loadée, affiche le contenu
else{
displayContent();
}
?>