FestivAlgo/new_reply.php

130 lines
5.3 KiB
PHP

<?php
//Cette page permet de répondre à un sujet
include('config.php');
include_once 'mail.php';
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
if(isset($_SESSION['username']))
{
$dn1 = mysql_fetch_array(mysql_query('select count(t.id) as nb1, t.title, t.parent, c.name from topics as t, categories as c where t.id="'.$id.'" and t.id2=1 and c.id=t.parent group by t.id'));
if($dn1['nb1']>0)
{
?>
<!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" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script src="jquery.js"></script>
<script src="menus.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="Images/favicon_ie.ico">
<title>Festiv'Algo - <?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></title>
<script type="text/javascript" src="functions.js"></script>
</head>
<body>
<div id="content">
<?php include("menu.php"); ?>
<div class="content">
<?php
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
?>
<div class="box">
<div class="box_left">
<a href="<?php echo $url_home; ?>">Index du forum</a> &gt; <a href="list_topics.php?parent=<?php echo $dn1['parent']; ?>"><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></a> &gt; <a href="read_topic.php?id=<?php echo $id; ?>"><?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></a> &gt; Répondre
</div>
<div class="box_right">
<a href="list_pm.php">Vos messages (<?php echo $nb_new_pm; ?>)</a> - <a href="login.php">Déconnexion</a>
</div>
<div class="clean"></div>
</div>
<?php
if(isset($_POST['message']) and $_POST['message']!='')
{
include('bbcode_function.php');
$message = $_POST['message'];
if(get_magic_quotes_gpc())
{
$message = stripslashes($message);
}
$message = mysql_real_escape_string(bbcode_to_html($message));
$time1 = time();
if(mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$dn1['parent'].'", "'.$id.'", max(id2)+1, "", "'.$message.'", "'.$_SESSION['userid'].'", "'.$time1.'", "'.time().'" from topics where id="'.$id.'"') and mysql_query('update topics set timestamp2="'.time().'" where id="'.$id.'" and id2=1'))
{
$req = mysql_fetch_array(mysql_query('select username from users where id = '.$_SESSION['userid']));
$req2 = mysql_fetch_array(mysql_query('select id from topics where timestamp = '.$time1));
$message =
$req['username']." a posté un nouveau message sur le forum<br /><br /><i>"
.$_POST['message']."</i><br /><br />
<center><b><a href='".$base_url."/read_topic.php?id=".$req2['id']."'>>>> lien <<<</a></b></center>
";
send_mail("bruno-godefroy@sfr.fr", "Nouveau message sur Festiv'Algo", $message);
?>
<div class="message">Le message a bien &eacute;t&eacute; envoy&eacute;.<br />
<a href="read_topic.php?id=<?php echo $id; ?>">Retourner au sujet</a></div>
<?php
}
else
{
echo 'Une erreur s\'est produite lors de l\'envoi du message.';
}
}
else
{
?>
<form action="new_reply.php?id=<?php echo $id; ?>" method="post">
<div class="message_buttons">
<input type="button" value="Gras" onclick="javascript:insert('[b]', '[/b]', 'message');" /><!--
--><input type="button" value="Italique" onclick="javascript:insert('[i]', '[/i]', 'message');" /><!--
--><input type="button" value="Souligne" onclick="javascript:insert('[u]', '[/u]', 'message');" /><!--
--><input type="button" value="Gauche" onclick="javascript:insert('[left]', '[/left]', 'message');" /><!--
--><input type="button" value="Centre" onclick="javascript:insert('[center]', '[/center]', 'message');" /><!--
--><input type="button" value="Droite" onclick="javascript:insert('[right]', '[/right]', 'message');" />
</div>
<textarea name="message" id="message" cols="70" rows="6"></textarea><br />
<input type="submit" value="Envoyer" />
</form>
<?php
}
?>
</div>
</span>
</span>
</div>
</body>
<?php include("bas_de_page.php"); ?>
</html>
<?php
}
else
{
echo '<h2>Le sujet auquel vous désirez répondre n\'existe pas.</h2>';
}
}
else
{
?>
<h2>Vous devez être connecté pour accéder à cette page:</h2>
<div class="box_login">
<form action="login.php" method="post">
<label for="username">Nom d'utilisateur</label><input type="text" name="username" id="username" /><br />
<label for="password">Mot de passe</label><input type="password" name="password" id="password" /><br />
<label for="memorize">Se souvenir</label><input type="checkbox" name="memorize" id="memorize" value="yes" />
<div class="center">
<input type="submit" value="Login" /> <input type="button" onclick="javascript:document.location='signup.php';" value="S'inscrire" />
</div>
</form>
</div>
<?php
}
}
else
{
echo '<h2>L\'identifiant du sujet auquel vous désirez répondre n\'est pas défini.</h2>';
}
?>