Pages: 1
|

Membre
|
Voila comme le titre l'indique je vous offre un petit cadeau de mon script de base (l'ancien avant je refais le design etc..)
Il faut Donc la table mail et instaler le script
Donc
Pour commencer:
instaler ceci:
<p><a href="mail.php"><?if (unread_messages($player->id, $db)>0) {echo "<font color=orange><blink>";}?> Telephone [<?=unread_messages($player->id, $db)?>]<?if (unread_messages($player->id, $db)>0) {echo "</blink></font>";}?></a></p>
Ce qui montrera si le joueur a des message il sera indiquer en rouge avec le nombre ..
2eme:
Creer la table mail
-- --------------------------------------------------------
--
-- Structure de la table `mail`
--
CREATE TABLE IF NOT EXISTS `mail` ( `id` int(11) NOT NULL
auto_increment, `to` int(11) NOT NULL, `from` int(11) NOT NULL,
`subject` varchar(255) collate latin1_general_ci NOT NULL, `body` text
collate latin1_general_ci NOT NULL, `time` int(11) NOT NULL, `status`
enum('read','unread') collate latin1_general_ci NOT NULL default
'unread', PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=3397 ;
Et le code de messagerie
<?php
define("PAGENAME", "Messagerie");
$errormsg = "<font color=\"red\">";
$errors = 0;
if ($_POST['sendmail'])
{
//Process mail info, show success message
$query = $db->execute("select `id` from `players` where `username`=?", array($_POST['to']));
if ($query->recordcount() == 0)
{
$errormsg .= "Ce joueur n'existe pas !<br />";
$errors = 1;
}
if (!$_POST['body'])
{
$errormsg .= "Un message... vide ?<br />";
$errors = 1;
}
if ($errors != 1)
{
$sendto = $query->fetchrow();
$insert['to'] = $sendto['id'];
$insert['from'] = $player->id;
$insert['body'] = $_POST['body'];
//$insert['body'] = str_replace("&", "&", $insert['body']);
//$insert['body'] = str_replace("<", "<", $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//$insert['body'] = str_replace("\"", """, $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//Hehe, found an easier way of doing that ^ with htmlentities():
$insert['body'] = htmlentities($_POST['body'], ENT_QUOTES);
//$insert['body'] = (!get_magic_quotes_gpc())?addslashes($insert['body']):$insert['body'];
$insert['subject'] = ($_POST['subject'] == "")?"Pas de sujet":$_POST['subject'];
if($_POST['subject']=="") {} else {$insert['subject'] = htmlentities($_POST['subject'], ENT_QUOTES);}
//$insert['subject'] = (!get_magic_quotes_gpc())?addslashes($insert['subject']):$insert['subject'];
$insert['time'] = time();
$query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`, `time`) values (?, ?, ?, ?, ?)", array($insert['to'], $insert['from'], $insert['body'], $insert['subject'], $insert['time']));
if ($query)
{
include("templates/private_header.php");
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
echo "Le message a bien été envoyé à " . $_POST['to'] . "!";
include("templates/private_footer.php");
exit;
}
else
{
$errormsg .= "Désolé, le message ne peut pas être envoyé.";
//Add to admin error log, or whatever, maybe for another version ;)
}
}
}
$errormsg .= "</font><br />\n";
include("templates/private_header.php");
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
?>
<script>
function checkAll() {
count = document.inbox.elements.length;
for (i=0; i < count; i++)
{
if(document.inbox.elements[i].checked == 1)
{document.inbox.elements[i].checked = 0; document.inbox.check.checked=0;}
else {document.inbox.elements[i].checked = 1; document.inbox.check.checked=1;}
}
}
</script>
<a href="mail.php">Boite de réception</a> | <a href="mail.php?act=compose">Écrire un message</a>
<br /><br />
<?php
switch($_GET['act'])
{
case "read": //Reading a message
$query = $db->execute("select `id`, `to`, `from`, `subject`, `body`, `time`, `status` from `mail` where `id`=? and `to`=?", array($_GET['id'], $player->id));
if ($query->recordcount() == 1)
{
$msg = $query->fetchrow();
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $msg['to'] . "\">" . $player->username . "</a></td></tr>\n";
$from = $db->GetOne("select `username` from `players` where `id`=?", array($msg['from']));
echo "<tr><td width=\"20%\"><b>De :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $from . "\">" . $from . "</a></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Date :</b></td><td width=\"80%\">" . date("F j, Y, g:i a", $msg['time']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\">" . stripslashes($msg['subject']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Message :</b></td><td width=\"80%\">" . stripslashes(nl2br($msg['body'])) . "</td></tr>";
echo "</table>";
if ($msg['status'] == "unread")
{
$query = $db->execute("update `mail` set `status`='read' where `id`=?", array($msg['id']));
}
echo "<br /><br />\n";
echo "<table width=\"30%\">\n";
echo "<tr><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mail.php?act=compose\">\n";
echo "<input type=\"hidden\" name=\"to\" value=\"" . $from . "\" />\n";
echo "<input type=\"hidden\" name=\"subject\" value=\"RE: " . stripslashes($msg['subject']) . "\" />\n";
$reply = explode("\n", $msg['body']);
foreach($reply as $key=>$value)
{
$reply[$key] = ">>" . $value;
}
$reply = implode("\n", $reply);
echo "<input type=\"hidden\" name=\"body\" value=\"\n\n\n" . $reply . "\" />\n";
echo "<input type=\"submit\" value=\"Répondre\" />\n";
echo "</form>\n";
echo "</td><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $msg['id'] . "\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>\n";
echo "</td></tr>\n</table>";
}
break;
case "compose": //Composing mail (justt he form, processing is at the top of the page)
echo $errormsg;
echo "<form method=\"POST\" action=\"mail.php?act=compose\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><input type=\"text\" name=\"to\" value=\"";
echo ($_POST['to'] != "")?$_POST['to']:$_GET['to'];
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\"><input type=\"text\" name=\"subject\" value=\"";
echo ($_POST['subject'] != "")?stripslashes($_POST['subject']):stripslashes($_GET['subject']);
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"></td><td width=\"80%\"><textarea name=\"body\" rows=\"15\" cols=\"50\">";
echo ($_POST['body'] != "")?stripslashes(stripslashes($_POST['body'])):stripslashes(stripslashes($_GET['body']));
echo "</textarea></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Envoyer\" name=\"sendmail\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
break;
case "delete":
if ($_POST['delone']) //Deleting message from viewing page, single delete
{
if (!$_POST['id'])
{
echo "Un message doit être séléctionné !";
}
else
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($_POST['id'], $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message ne t'es pas destiné !";
}
else
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $_POST['id'] . "\" />\n";
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
$query = $db->execute("delete from `mail` where `id`=?", array($_POST['id']));
echo "Le message a bien été supprimé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel
}
}
}
}
else if ($_POST['delmultiple']) //Deleting messages from inbox, multiple selections
{
if (!$_POST['id'])
{
echo "Je veux bien supprimer un message, mais tu n'as rien selectionné !<br />LOL !<br />xD<br />Sisi Fyl26 le créateur de Gangster-Life, tu peux pas test !!!<br />";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($msg, $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message n'est pas à toi !";
$delerror = 1;
}
}
if (!$delerror)
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
foreach($_POST['id'] as $msg)
{
echo "<input type=\"hidden\" name=\"id[]\" value=\"" . $msg . "\" />\n";
}
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->execute("delete from `mail` where `id`=?", array($msg));
}
echo "Le message a bien été effacé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel (TODO)
}
}
}
}
break;
default: //Show inbox
echo "<form method=\"post\" action=\"mail.php?act=delete\" name=\"inbox\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"5%\"><input type=\"checkbox\" onclick=\"javascript: checkAll();\" name=\"check\" /></td>\n";
echo "<td width=\"20%\"><b>De :</b></td>\n";
echo "<td width=\"35%\"><b>Sujet :</b></td>\n";
echo "<td width=\"40%\"><b>Date :</b></td>\n";
echo "</tr>\n";
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($player->id));
if ($query->recordcount() > 0)
{
$bool = 1;
while($msg = $query->fetchrow())
{
echo "<tr class=\"row" . $bool . "\">\n";
echo "<td width=\"5%\"><input type=\"checkbox\" name=\"id[]\" value=\"" . $msg['id'] . "\" /></td>\n";
$from = $db->GetOne("select `username` from `players` where `id`=?", array($msg['from']));
echo "<td width=\"20%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"profile.php?id=" . $from . "\">" . $from . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"35%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"mail.php?act=read&id=" . $msg['id'] . "\">" . stripslashes($msg['subject']) . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"40%\">" . date("F j, Y, g:i a", $msg['time']) . "</td>\n";
echo "</tr>\n";
$bool = ($bool==1)?2:1;
}
}
else
{
echo "<tr class=\"row1\">\n";
echo "<td colspan=\"4\"><b>Pas de messages.</b></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
break;
}
?>
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Ce script est basik bien sur ameliorable .. Nous avons Des case pour suprimer le message X lheure , la date, de qui, sujet .., suprimer tout dun coup .. de seulement toi , mais suprimera pas les message que l'autre personne ta envoyer etc etc ..
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Warning: include(templates/private_header.php) [function.include]: failed to open stream: No such file or directory in /home/site/mail.php on line 169
il manque pas un fichier ?
Fatal error: Call to a member function execute() on a non-object in /home/mov/public_html/site/mail.php on line 344
ça ne va pas ?
ligne 344 :
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($player->id));
|

Membre
|
Le code es fais avec les private_header(le haut) private_footer(le bas) Faut instaler + ou -
je vais redonner le code j'ai p-e oublier un truk ^^
Attention au $player->id .. Player a changer pour le nom de la table de tes joueur ou membre !
<?php
include("lib.php");
define("PAGENAME", "Messagerie");
$player = check_user($secret_key, $db);
$img = "<img src=images/messagerie_logo.PNG border=0 align=absmiddle><br /><br />";
$errormsg = "<font color=\"red\">";
$errors = 0;
if ($_POST['sendmail'])
{
//Process mail info, show success message
$query = $db->execute("select `id` from `players` where `username`=?", array($_POST['to']));
if ($query->recordcount() == 0)
{
$errormsg .= "Ce joueur n'existe pas !<br />";
$errors = 1;
}
if (!$_POST['body'])
{
$errormsg .= "Un message... vide ?<br />";
$errors = 1;
}
if ($errors != 1)
{
$sendto = $query->fetchrow();
$insert['to'] = $sendto['id'];
$insert['from'] = $player->id;
$insert['body'] = $_POST['body'];
//$insert['body'] = str_replace("&", "&", $insert['body']);
//$insert['body'] = str_replace("<", "<", $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//$insert['body'] = str_replace("\"", """, $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//Hehe, found an easier way of doing that ^ with htmlentities():
$insert['body'] = htmlentities($_POST['body'], ENT_QUOTES);
//$insert['body'] = (!get_magic_quotes_gpc())?addslashes($insert['body']):$insert['body'];
$insert['subject'] = ($_POST['subject'] == "")?"Pas de sujet":$_POST['subject'];
if($_POST['subject']=="") {} else {$insert['subject'] = htmlentities($_POST['subject'], ENT_QUOTES);}
//$insert['subject'] = (!get_magic_quotes_gpc())?addslashes($insert['subject']):$insert['subject'];
$insert['time'] = time();
$query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`, `time`) values (?, ?, ?, ?, ?)", array($insert['to'], $insert['from'], $insert['body'], $insert['subject'], $insert['time']));
if ($query)
{
include("templates/private_header.php");
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
echo "Le message a bien été envoyé à " . $_POST['to'] . "!";
include("templates/private_footer.php");
exit;
}
else
{
$errormsg .= "Désolé, le message ne peut pas être envoyé.";
//Add to admin error log, or whatever, maybe for another version ;)
}
}
}
$errormsg .= "</font><br />\n";
include("templates/private_header.php");
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
?>
<script>
function checkAll() {
count = document.inbox.elements.length;
for (i=0; i < count; i++)
{
if(document.inbox.elements[i].checked == 1)
{document.inbox.elements[i].checked = 0; document.inbox.check.checked=0;}
else {document.inbox.elements[i].checked = 1; document.inbox.check.checked=1;}
}
}
</script>
<a href="mail.php">Boite de réception</a> | <a href="mail.php?act=compose">Écrire un message</a>
<br /><br />
<?php
switch($_GET['act'])
{
case "read": //Reading a message
$query = $db->execute("select `id`, `to`, `from`, `subject`, `body`, `time`, `status` from `mail` where `id`=? and `to`=?", array($_GET['id'], $player->id));
if ($query->recordcount() == 1)
{
$msg = $query->fetchrow();
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $msg['to'] . "\">" . $player->username . "</a></td></tr>\n";
$from = $db->GetOne("select `username` from `players` where `id`=?", array($msg['from']));
echo "<tr><td width=\"20%\"><b>De :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $from . "\">" . $from . "</a></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Date :</b></td><td width=\"80%\">" . date("F j, Y, g:i a", $msg['time']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\">" . stripslashes($msg['subject']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Message :</b></td><td width=\"80%\">" . stripslashes(nl2br($msg['body'])) . "</td></tr>";
echo "</table>";
if ($msg['status'] == "unread")
{
$query = $db->execute("update `mail` set `status`='read' where `id`=?", array($msg['id']));
}
echo "<br /><br />\n";
echo "<table width=\"30%\">\n";
echo "<tr><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mail.php?act=compose\">\n";
echo "<input type=\"hidden\" name=\"to\" value=\"" . $from . "\" />\n";
echo "<input type=\"hidden\" name=\"subject\" value=\"RE: " . stripslashes($msg['subject']) . "\" />\n";
$reply = explode("\n", $msg['body']);
foreach($reply as $key=>$value)
{
$reply[$key] = ">>" . $value;
}
$reply = implode("\n", $reply);
echo "<input type=\"hidden\" name=\"body\" value=\"\n\n\n" . $reply . "\" />\n";
echo "<input type=\"submit\" value=\"Répondre\" />\n";
echo "</form>\n";
echo "</td><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $msg['id'] . "\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>\n";
echo "</td></tr>\n</table>";
}
break;
case "compose": //Composing mail (justt he form, processing is at the top of the page)
echo $errormsg;
echo "<form method=\"POST\" action=\"mail.php?act=compose\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><input type=\"text\" name=\"to\" value=\"";
echo ($_POST['to'] != "")?$_POST['to']:$_GET['to'];
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\"><input type=\"text\" name=\"subject\" value=\"";
echo ($_POST['subject'] != "")?stripslashes($_POST['subject']):stripslashes($_GET['subject']);
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"></td><td width=\"80%\"><textarea name=\"body\" rows=\"15\" cols=\"50\">";
echo ($_POST['body'] != "")?stripslashes(stripslashes($_POST['body'])):stripslashes(stripslashes($_GET['body']));
echo "</textarea></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Envoyer\" name=\"sendmail\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
break;
case "delete":
if ($_POST['delone']) //Deleting message from viewing page, single delete
{
if (!$_POST['id'])
{
echo "Un message doit être séléctionné !";
}
else
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($_POST['id'], $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message ne t'es pas destiné !";
}
else
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $_POST['id'] . "\" />\n";
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
$query = $db->execute("delete from `mail` where `id`=?", array($_POST['id']));
echo "Le message a bien été supprimé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel
}
}
}
}
else if ($_POST['delmultiple']) //Deleting messages from inbox, multiple selections
{
if (!$_POST['id'])
{
echo "Je veux bien supprimer un message, mais tu n'as rien selectionné !<br />LOL !<br />xD<br />Sisi , tu peux pas test !!!<br />";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($msg, $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message n'est pas à toi !";
$delerror = 1;
}
}
if (!$delerror)
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mail.php?act=delete\">\n";
foreach($_POST['id'] as $msg)
{
echo "<input type=\"hidden\" name=\"id[]\" value=\"" . $msg . "\" />\n";
}
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->execute("delete from `mail` where `id`=?", array($msg));
}
echo "Le message a bien été effacé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel (TODO)
}
}
}
}
break;
default: //Show inbox
echo "<form method=\"post\" action=\"mail.php?act=delete\" name=\"inbox\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"5%\"><input type=\"checkbox\" onclick=\"javascript: checkAll();\" name=\"check\" /></td>\n";
echo "<td width=\"20%\"><b>De :</b></td>\n";
echo "<td width=\"35%\"><b>Sujet :</b></td>\n";
echo "<td width=\"40%\"><b>Date :</b></td>\n";
echo "</tr>\n";
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($player->id));
if ($query->recordcount() > 0)
{
$bool = 1;
while($msg = $query->fetchrow())
{
echo "<tr class=\"row" . $bool . "\">\n";
echo "<td width=\"5%\"><input type=\"checkbox\" name=\"id[]\" value=\"" . $msg['id'] . "\" /></td>\n";
$from = $db->GetOne("select `username` from `players` where `id`=?", array($msg['from']));
echo "<td width=\"20%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"profile.php?id=" . $from . "\">" . $from . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"35%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"mail.php?act=read&id=" . $msg['id'] . "\">" . stripslashes($msg['subject']) . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"40%\">" . date("F j, Y, g:i a", $msg['time']) . "</td>\n";
echo "</tr>\n";
$bool = ($bool==1)?2:1;
}
}
else
{
echo "<tr class=\"row1\">\n";
echo "<td colspan=\"4\"><b>Pas de messages.</b></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
break;
}
include("templates/private_footer.php");
?>
et la lib.php
<?php
session_start();
include("config.php");
include("functions.php");
?>
Functions.php
<?php
//Function to check if user is logged in, and if so, return user data as an object
function check_user($secret_key, &$db)
{
if (!isset($_SESSION['userid']) || !isset($_SESSION['hash']))
{
header("Location: index.php");
exit;
}
else
{
$check = sha1($_SESSION['userid'] . $_SERVER['REMOTE_ADDR'] . $secret_key);
if ($check != $_SESSION['hash'])
{
session_unset();
session_destroy();
header("Location: index.php");
exit;
}
else
{
$query = $db->execute("select * from `players` where `id`=?", array($_SESSION['userid']));
$userarray = $query->fetchrow();
if ($query->recordcount() == 0)
{
session_unset();
session_destroy();
header("Location: index.php");
exit;
}
foreach($userarray as $key=>$value)
{
$user->$key = $value;
}
return $user;
}
}
}
//Gets the number of unread messages
function unread_messages($id, &$db)
{
$query = $db->getone("select count(*) as `count` from `mail` where `to`=? and `status`='unread'", array($id));
return $query['count'];
}
//Gets new log messages
function unread_log($id, &$db)
{
$query = $db->getone("select count(*) as `count` from `user_log` where `player_id`=? and `status`='unread'", array($id));
return $query['count'];
}
//Insert a log message into the user logs
function addlog($id, $msg, &$db)
{
$insert['player_id'] = $id;
$insert['msg'] = $msg;
$insert['time'] = time();
$query = $db->autoexecute('user_log', $insert, 'INSERT');
}
?>
effectivement j'ai oublier des truk desoler voila la totaliter
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
LA config.php es simple
<?php
$config_server = "localhost"; //Serveur de base de données (par exemple free : sql.free.fr)
$config_database = "Nom_de_la_base"; //Nom de base de données
$config_username = "utilisateur"; //Utilisateur de la base de données (c'est souvent le login du site)
$config_password = "password"; //Mot de passe de la base de données
$secret_key = "votremotsecret"; //Un mot secret, mettez ce que vous voulez
//Do not edit below this line
$version = "0.1";
$db = &ADONewConnection('mysql'); //Connect to database
$db->Connect($config_server, $config_username, $config_password, $config_database); //Select table
$db->SetFetchMode(ADODB_FETCH_ASSOC); //Fetch associative arrays
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Fetch associative arrays
//$db->debug = true; //Debug
?>
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
c'est quoi private footer et hearder ?
|

Membre
|
Ton contenu qui fais ton haut de page avec colonne gauche le private header (pour les membre connecter) et private footer (est le bas de ta page avec la colone droite)
simplement sa sa evite de refaire le totu 1000 fois et quand tu change quelque chose aulieu de refaire chaque page .. bien tu fais 1 fois et tout es appliquer au reste du site ^^
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
je suis navrai mais je n'y arrive pas :s
est-il possible que tu m'ajoute juste la fonction supprimé sur ma page ?
si oui voici mon code source :
<?php
include('config.php');
/******************************************************
----------------Configuration Utilisateurs-------------
******************************************************/
$dn = mysql_query('select id, username, email, avatar, signup_date, rang from users where username="'.htmlentities(trim($_SESSION['username'])).'"');
$dnn = mysql_fetch_array($dn);
$rang = $dnn['rang'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Page générée - L'indentation peut être génante. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.: Movies Of Artistes - Tes messages :.</title>
<link rel="stylesheet" type="text/css" href="http://movies-of-artistes.geekheberg.net/design.css" />
<script>
function visibilite(thingId)
{
var targetElement;
targetElement = document.getElementById(thingId) ;
if (targetElement.style.display == "none")
{
targetElement.style.display = "" ;
} else {
targetElement.style.display = "none" ;
}
}
</script>
</head>
<body>
<div id="header">
<div class="menu-rapide">
<?php require('Smenu.php'); ?>
</div>
<?php
//Si lutilisateur est connecte, on lui donne un lien pour modifier ses informations, pour voir ses messages et un pour se deconnecter
//On compte le nombre de nouveaux messages que lutilisateur a
$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"'));
//Le nombre de nouveaux messages est stoque dans la variable $nb_new_pm
$nb_new_pm = $nb_new_pm['nb_new_pm'];
//On affiche les liens
?>
</div>
<br /><div id="menu-gauche">
<div class="element">
<div class="bordure-haut">
<img src="http://movies-of-artistes.geekheberg.net/images/menu/papi.png" alt="-"/>
<span class="surlignage">Principal</span>
</div>
<div class="bordure-milieu">
<ul>
<li><a href="http://movies-of-artistes.geekheberg.net/" title="Un petit clic et vous voilà sur l'accueil du site.">Accueil</a></li>
<li><a href="infos.php" title="Tout savoir sur le site.">Infos</a></li>
<li><a href="film.php" title="Envie de voir un film ?">Film</a></li>
<li><a href="contact.php" title="Pour contacter le site.">Contact</a></li>
</ul>
</div>
<div class="bordure-bas">
</div>
<img src="http://movies-of-artistes.geekheberg.net/images/menu/sepa.png" style="margin-left:13px;" alt="Séparation"/>
</div>
<div class="element">
<div class="bordure-haut">
<img src="http://movies-of-artistes.geekheberg.net/images/menu/papi.png" alt="-"/>
<span class="surlignage">Espace Membres</span>
</div>
<div class="bordure-milieu">
<ul>
<?php
if(!isset($_SESSION['username']))
{
?>
<li><a href=connexion.php" title="Connecte toi.">Connexion</a></li>
<li><a href="inscription.php" title="Rejoind-Nous !">Inscription</a></li>
<?php
}else {
?>
<li><?php echo htmlentities($dnn['username']); ?></li>
<li><a href="mon_compte.php">Mon Compte</a></li>
<li><a href="list_pm.php">Mes MPs</a> (<?php echo $nb_new_pm; ?>)</li>
<?php
}
?>
<?php
if ($rang == 2 OR $rang == 3 OR $rang == 4)
{
echo '<li><a href="mod/"> Modération</a></li>';
}
if ($rang == 4)
{
echo '<li><a href="Admin/"> Administration</a></li>';
}
if ($rang == 1 OR $rang == 2 OR $rang == 3 OR $rang == 4)
{
echo '<li><a href="connexion.php">Déconnexion</a></li>';
}
?>
</ul>
</div>
<div class="bordure-bas">
</div>
<img src="http://movies-of-artistes.geekheberg.net/images/menu/sepa.png" style="margin-left:13px;" alt="Séparation"/>
</div>
<div class="element">
<div class="bordure-haut">
<img src="http://movies-of-artistes.geekheberg.net/images/menu/papi.png" alt="-"/>
<span class="surlignage">Site</span>
</div>
<div class="bordure-milieu">
<ul>
<li><a href="concept.php" title="Pour connaître le concept du site.">Concept</a></li>
<li><a href="user.php" title="Liste de tous les membres">Membres</a></li>
<li><a href="team.php" title="Découvre la team du site.">Best Team</a></li>
</ul>
</div>
<div class="bordure-bas">
</div>
</div>
<a href="http://www.blablaland.com/site/fansites.php?vote=29" alt="Voter pour Movies Of Artistes"><img src="http://movies-of-artistes.geekheberg.net/images/menu/sepabas.png" style="margin-left:13px;" alt="Séparation" border="0"/></a>
</div> <div id="milieu"><div class="haut"></div>
<div class="milieu">
<?php
//On verifie que lutilisateur est connecte
if(isset($_SESSION['username']))
{
//On affiche la liste des messages de l'utilisateur sous la forme dun tableau
//Deux requettes sont executees, une pour recuperer les messages non-lus et une pour les messages lus
$req1 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="no" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="no" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
$req2 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="yes" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="yes" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
?>
<a href="new_pm.php" class="link_new_pm">Ecrire un nouveau MP.</a><br />
<center><h3>Messages non-lus(<?php echo intval(mysql_num_rows($req1)); ?>):</h3>
<table>
<tr>
<th class="title_cell">Titre</th>
<th>Réponses</th>
<th>Auteur</th>
<th>Date</th>
</tr>
<?php
//On affiche la liste des messages non-lus
while($dn1 = mysql_fetch_array($req1))
{
?>
<tr>
<td class="left"><a href="read_pm.php?id=<?php echo $dn1['id']; ?>"><?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $dn1['reps']-1; ?></td>
<td><a href="profile.php?id=<?php echo $dn1['userid']; ?>"><?php echo htmlentities($dn1['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo date('d/m/Y H:i:s' ,$dn1['timestamp']); ?></td>
</tr>
<?php
}
//Sil na aucun message non-lu, on le dit
if(intval(mysql_num_rows($req1))==0)
{
?>
<tr>
<td colspan="4" class="center">Vous n'avez aucun message non-lu.</td>
</tr>
<?php
}
?>
</table>
<br />
<h3>Messages lus(<?php echo intval(mysql_num_rows($req2)); ?>):</h3>
<table>
<tr>
<th class="title_cell">Titre</th>
<th>Réponses</th>
<th>Auteur</th>
<th>Date</th>
</tr>
<?php
//On affiche la liste des messages lus
while($dn2 = mysql_fetch_array($req2))
{
?>
<tr>
<td class="left"><a href="read_pm.php?id=<?php echo $dn2['id']; ?>"><?php echo htmlentities($dn2['title'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $dn2['reps']-1; ?></td>
<td><a href="profile.php?id=<?php echo $dn2['userid']; ?>"><?php echo htmlentities($dn2['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo date('d/m/Y H:i:s' ,$dn2['timestamp']); ?></td>
</tr>
<?php
}
//Sil na aucun message lu, on le dit
if(intval(mysql_num_rows($req2))==0)
{
?>
<tr>
<td colspan="4" class="center">Vous n'avez aucun message lu.</td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
echo '<div class="message">Pour accéder à cette page, tu dois être connecté.<br />
<a href="connexion.php"><b>Connecte - toi</b></a> ou <a href="inscription.php"><b>Inscrit - toi</b></a></div>';
}
?></center></div>
<div class="bas"></div>
</div>
<div class="droite">
</div> <!-- Bas de page -->
<div style="background-image: url('http://imm.io/media/2Z/2ZoD.png');margin-left:370px;position: fixed;bottom: 0px;width: 100%;height: 30px; color: #404040; text-decoration: none; text-shadow: 0 1px 0px rgba(255,255,255,0.15);">
<a href="javascript:visibilite('divid');"><img src="http://movies-of-artistes.geekheberg.net/images/copy.png"></a></div>
<div id="divid" style="display:none;"><div id="coper">
<p class="copyright"><img src="images/spacer.gif" width="340" height="0">Movies Of Artistes ©<br />
<img src="images/spacer.gif" width="260" height="0">Graphisme par <a href="http://www.blablaland.com/site/membres.php?p=294955" title="Voir son profil de Blablaland">X_Amiral_X</a> et Programmation par <a href="http://www.blablaland.com/site/membres.php?p=1630" title="Voir son profil de Blablaland">Bonhomme</a>.</p>
</div></div>
</body>
</html>
merci d'avance ^^
|

Membre
|
Pour une fonction suprimer .. Ses ta table a regler en fonction apres ses facile Delete delete * from 'ta table' where 'id'", array($membre->id)); pour tous et 1 seul
delete 'id'=? from 'ta table' where 'id'", array($message->id, $membre->id));
Les id son en auto increment
par exemple aussi simple ke sa
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Fatal error: Call to a member function execute() on a non-object in /home/mov/public_html/site/mp.php on line 354
|

Membre
|
tu a instaler mon code ou c le tien ?
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
J'ai pris le code que tu as donné dans ton 1er message après j'ai modifié les textes pour que ça aille avec ma BDD
|

Membre
|
montre ton code ..
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Voilà (connexion à la BDD est faite)
<?php
define("PAGENAME", "Messagerie");
$errormsg = "<font color=\"red\">";
$errors = 0;
if ($_POST['sendmail'])
{
//Process mail info, show success message
$query = $db->execute("select `id` from `users` where `username`=?", array($_POST['to']));
if ($query->recordcount() == 0)
{
$errormsg .= "Ce joueur n'existe pas !<br />";
$errors = 1;
}
if (!$_POST['body'])
{
$errormsg .= "Un message... vide ?<br />";
$errors = 1;
}
if ($errors != 1)
{
$sendto = $query->fetchrow();
$insert['to'] = $sendto['id'];
$insert['from'] = $player->id;
$insert['body'] = $_POST['body'];
//$insert['body'] = str_replace("&", "&", $insert['body']);
//$insert['body'] = str_replace("<", "<", $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//$insert['body'] = str_replace("\"", """, $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//Hehe, found an easier way of doing that ^ with htmlentities():
$insert['body'] = htmlentities($_POST['body'], ENT_QUOTES);
//$insert['body'] = (!get_magic_quotes_gpc())?addslashes($insert['body']):$insert['body'];
$insert['subject'] = ($_POST['subject'] == "")?"Pas de sujet":$_POST['subject'];
if($_POST['subject']=="") {} else {$insert['subject'] = htmlentities($_POST['subject'], ENT_QUOTES);}
//$insert['subject'] = (!get_magic_quotes_gpc())?addslashes($insert['subject']):$insert['subject'];
$insert['time'] = time();
$query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`, `time`) values (?, ?, ?, ?, ?)", array($insert['to'], $insert['from'], $insert['body'], $insert['subject'], $insert['time']));
if ($query)
{
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
echo "Le message a bien été envoyé à " . $_POST['to'] . "!";
exit;
}
else
{
$errormsg .= "Désolé, le message ne peut pas être envoyé.";
//Add to admin error log, or whatever, maybe for another version ;)
}
}
}
$errormsg .= "</font><br />\n";
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
?>
<script>
function checkAll() {
count = document.inbox.elements.length;
for (i=0; i < count; i++)
{
if(document.inbox.elements[i].checked == 1)
{document.inbox.elements[i].checked = 0; document.inbox.check.checked=0;}
else {document.inbox.elements[i].checked = 1; document.inbox.check.checked=1;}
}
}
</script>
<a href="mp.php">Boite de réception</a> | <a href="mp.php?act=compose">Écrire un message</a>
<br /><br />
<?php
switch($_GET['act'])
{
case "read": //Reading a message
$query = $db->execute("select `id`, `to`, `from`, `subject`, `body`, `time`, `status` from `mail` where `id`=? and `to`=?", array($_GET['id'], $player->id));
if ($query->recordcount() == 1)
{
$msg = $query->fetchrow();
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $msg['to'] . "\">" . $player->username . "</a></td></tr>\n";
$from = $db->GetOne("select `username` from `users` where `id`=?", array($msg['from']));
echo "<tr><td width=\"20%\"><b>De :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $from . "\">" . $from . "</a></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Date :</b></td><td width=\"80%\">" . date("F j, Y, g:i a", $msg['time']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\">" . stripslashes($msg['subject']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Message :</b></td><td width=\"80%\">" . stripslashes(nl2br($msg['body'])) . "</td></tr>";
echo "</table>";
if ($msg['status'] == "unread")
{
$query = $db->execute("update `mail` set `status`='read' where `id`=?", array($msg['id']));
}
echo "<br /><br />\n";
echo "<table width=\"30%\">\n";
echo "<tr><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mp.php?act=compose\">\n";
echo "<input type=\"hidden\" name=\"to\" value=\"" . $from . "\" />\n";
echo "<input type=\"hidden\" name=\"subject\" value=\"RE: " . stripslashes($msg['subject']) . "\" />\n";
$reply = explode("\n", $msg['body']);
foreach($reply as $key=>$value)
{
$reply[$key] = ">>" . $value;
}
$reply = implode("\n", $reply);
echo "<input type=\"hidden\" name=\"body\" value=\"\n\n\n" . $reply . "\" />\n";
echo "<input type=\"submit\" value=\"Répondre\" />\n";
echo "</form>\n";
echo "</td><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $msg['id'] . "\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>\n";
echo "</td></tr>\n</table>";
}
break;
case "compose": //Composing mail (justt he form, processing is at the top of the page)
echo $errormsg;
echo "<form method=\"POST\" action=\"mp.php?act=compose\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><input type=\"text\" name=\"to\" value=\"";
echo ($_POST['to'] != "")?$_POST['to']:$_GET['to'];
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\"><input type=\"text\" name=\"subject\" value=\"";
echo ($_POST['subject'] != "")?stripslashes($_POST['subject']):stripslashes($_GET['subject']);
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"></td><td width=\"80%\"><textarea name=\"body\" rows=\"15\" cols=\"50\">";
echo ($_POST['body'] != "")?stripslashes(stripslashes($_POST['body'])):stripslashes(stripslashes($_GET['body']));
echo "</textarea></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Envoyer\" name=\"sendmail\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
break;
case "delete":
if ($_POST['delone']) //Deleting message from viewing page, single delete
{
if (!$_POST['id'])
{
echo "Un message doit être séléctionné !";
}
else
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($_POST['id'], $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message ne t'es pas destiné !";
}
else
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $_POST['id'] . "\" />\n";
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
$query = $db->execute("delete from `mail` where `id`=?", array($_POST['id']));
echo "Le message a bien été supprimé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel
}
}
}
}
else if ($_POST['delmultiple']) //Deleting messages from inbox, multiple selections
{
if (!$_POST['id'])
{
echo "Je veux bien supprimer un message, mais tu n'as rien selectionné !<br />LOL !<br />xD<br />Sisi Fyl26 le créateur de Gangster-Life, tu peux pas test !!!<br />";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($msg, $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message n'est pas à toi !";
$delerror = 1;
}
}
if (!$delerror)
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
foreach($_POST['id'] as $msg)
{
echo "<input type=\"hidden\" name=\"id[]\" value=\"" . $msg . "\" />\n";
}
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->execute("delete from `mail` where `id`=?", array($msg));
}
echo "Le message a bien été effacé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel (TODO)
}
}
}
}
break;
default: //Show inbox
echo "<form method=\"post\" action=\"mp.php?act=delete\" name=\"inbox\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"5%\"><input type=\"checkbox\" onclick=\"javascript: checkAll();\" name=\"check\" /></td>\n";
echo "<td width=\"20%\"><b>De :</b></td>\n";
echo "<td width=\"35%\"><b>Sujet :</b></td>\n";
echo "<td width=\"40%\"><b>Date :</b></td>\n";
echo "</tr>\n";
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($player->id));
if ($query->recordcount() > 0)
{
$bool = 1;
while($msg = $query->fetchrow())
{
echo "<tr class=\"row" . $bool . "\">\n";
echo "<td width=\"5%\"><input type=\"checkbox\" name=\"id[]\" value=\"" . $msg['id'] . "\" /></td>\n";
$from = $db->GetOne("select `username` from `username` where `id`=?", array($msg['from']));
echo "<td width=\"20%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"profile.php?id=" . $from . "\">" . $from . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"35%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"mp.php?act=read&id=" . $msg['id'] . "\">" . stripslashes($msg['subject']) . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"40%\">" . date("F j, Y, g:i a", $msg['time']) . "</td>\n";
echo "</tr>\n";
$bool = ($bool==1)?2:1;
}
}
else
{
echo "<tr class=\"row1\">\n";
echo "<td colspan=\"4\"><b>Pas de messages.</b></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
break;
}
?>
|

Membre
|
?
|

Membre
|
OUps jvais te faire sa jai oublier avec le taff attten vais te revenir
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
ah ok merci ^^
|

Membre
|
Essaie ceci
ta oublier de changer $player .. id par user .. xD
<?php
define("PAGENAME", "Messagerie");
$errormsg = "<font color=\"red\">";
$errors = 0;
if ($_POST['sendmail'])
{
//Process mail info, show success message
$query = $db->execute("select `id` from `users` where `username`=?", array($_POST['to']));
if ($query->recordcount() == 0)
{
$errormsg .= "Ce joueur n'existe pas !<br />";
$errors = 1;
}
if (!$_POST['body'])
{
$errormsg .= "Un message... vide ?<br />";
$errors = 1;
}
if ($errors != 1)
{
$sendto = $query->fetchrow();
$insert['to'] = $sendto['id'];
$insert['from'] = $user->id;
$insert['body'] = $_POST['body'];
//$insert['body'] = str_replace("&", "&", $insert['body']);
//$insert['body'] = str_replace("<", "<", $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//$insert['body'] = str_replace("\"", """, $insert['body']);
//$insert['body'] = str_replace(">", ">", $insert['body']);
//Hehe, found an easier way of doing that ^ with htmlentities():
$insert['body'] = htmlentities($_POST['body'], ENT_QUOTES);
//$insert['body'] = (!get_magic_quotes_gpc())?addslashes($insert['body']):$insert['body'];
$insert['subject'] = ($_POST['subject'] == "")?"Pas de sujet":$_POST['subject'];
if($_POST['subject']=="") {} else {$insert['subject'] = htmlentities($_POST['subject'], ENT_QUOTES);}
//$insert['subject'] = (!get_magic_quotes_gpc())?addslashes($insert['subject']):$insert['subject'];
$insert['time'] = time();
$query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`, `time`) values (?, ?, ?, ?, ?)", array($insert['to'], $insert['from'], $insert['body'], $insert['subject'], $insert['time']));
if ($query)
{
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
echo "Le message a bien été envoyé à " . $_POST['to'] . "!";
exit;
}
else
{
$errormsg .= "Désolé, le message ne peut pas être envoyé.";
//Add to admin error log, or whatever, maybe for another version ;)
}
}
}
$errormsg .= "</font><br />\n";
echo "<div class=\"contenu\">
<div class=\"contenu_bloc\">
<h1>Messagerie</h1>";
?>
<script>
function checkAll() {
count = document.inbox.elements.length;
for (i=0; i < count; i++)
{
if(document.inbox.elements[i].checked == 1)
{document.inbox.elements[i].checked = 0; document.inbox.check.checked=0;}
else {document.inbox.elements[i].checked = 1; document.inbox.check.checked=1;}
}
}
</script>
<a href="mp.php">Boite de réception</a> | <a href="mp.php?act=compose">Écrire un message</a>
<br /><br />
<?php
switch($_GET['act'])
{
case "read": //Reading a message
$query = $db->execute("select `id`, `to`, `from`, `subject`, `body`, `time`, `status` from `mail` where `id`=? and `to`=?", array($_GET['id'], $user->id));
if ($query->recordcount() == 1)
{
$msg = $query->fetchrow();
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $msg['to'] . "\">" . $player->username . "</a></td></tr>\n";
$from = $db->GetOne("select `username` from `users` where `id`=?", array($msg['from']));
echo "<tr><td width=\"20%\"><b>De :</b></td><td width=\"80%\"><a href=\"profile.php?id=" . $from . "\">" . $from . "</a></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Date :</b></td><td width=\"80%\">" . date("F j, Y, g:i a", $msg['time']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\">" . stripslashes($msg['subject']) . "</td></tr>";
echo "<tr><td width=\"20%\"><b>Message :</b></td><td width=\"80%\">" . stripslashes(nl2br($msg['body'])) . "</td></tr>";
echo "</table>";
if ($msg['status'] == "unread")
{
$query = $db->execute("update `mail` set `status`='read' where `id`=?", array($msg['id']));
}
echo "<br /><br />\n";
echo "<table width=\"30%\">\n";
echo "<tr><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mp.php?act=compose\">\n";
echo "<input type=\"hidden\" name=\"to\" value=\"" . $from . "\" />\n";
echo "<input type=\"hidden\" name=\"subject\" value=\"RE: " . stripslashes($msg['subject']) . "\" />\n";
$reply = explode("\n", $msg['body']);
foreach($reply as $key=>$value)
{
$reply[$key] = ">>" . $value;
}
$reply = implode("\n", $reply);
echo "<input type=\"hidden\" name=\"body\" value=\"\n\n\n" . $reply . "\" />\n";
echo "<input type=\"submit\" value=\"Répondre\" />\n";
echo "</form>\n";
echo "</td><td width=\"50%\">\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $msg['id'] . "\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>\n";
echo "</td></tr>\n</table>";
}
break;
case "compose": //Composing mail (justt he form, processing is at the top of the page)
echo $errormsg;
echo "<form method=\"POST\" action=\"mp.php?act=compose\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr><td width=\"20%\"><b>Pour :</b></td><td width=\"80%\"><input type=\"text\" name=\"to\" value=\"";
echo ($_POST['to'] != "")?$_POST['to']:$_GET['to'];
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"><b>Sujet :</b></td><td width=\"80%\"><input type=\"text\" name=\"subject\" value=\"";
echo ($_POST['subject'] != "")?stripslashes($_POST['subject']):stripslashes($_GET['subject']);
echo "\" /></td></tr>\n";
echo "<tr><td width=\"20%\"></td><td width=\"80%\"><textarea name=\"body\" rows=\"15\" cols=\"50\">";
echo ($_POST['body'] != "")?stripslashes(stripslashes($_POST['body'])):stripslashes(stripslashes($_GET['body']));
echo "</textarea></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Envoyer\" name=\"sendmail\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
break;
case "delete":
if ($_POST['delone']) //Deleting message from viewing page, single delete
{
if (!$_POST['id'])
{
echo "Un message doit être séléctionné !";
}
else
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($_POST['id'], $player->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message ne t'es pas destiné !";
}
else
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $_POST['id'] . "\" />\n";
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delone\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
$query = $db->execute("delete from `mail` where `id`=?", array($_POST['id']));
echo "Le message a bien été supprimé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel
}
}
}
}
else if ($_POST['delmultiple']) //Deleting messages from inbox, multiple selections
{
if (!$_POST['id'])
{
echo "Je veux bien supprimer un message, mais tu n'as rien selectionné !<br />LOL !<br />xD<br />Sisi Fyl26 le créateur de Gangster-Life, tu peux pas test !!!<br />";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->getone("select count(*) as `count` from `mail` where `id`=? and `to`=?", array($msg, $user->id));
if ($query['count'] = 0)
{
//In case there are some funny guys out there ;)
echo "Ce message n'est pas à toi !";
$delerror = 1;
}
}
if (!$delerror)
{
if (!$_POST['deltwo'])
{
echo "Tu veux vraiment effacer ce message ?<br /><br />\n";
echo "<form method=\"post\" action=\"mp.php?act=delete\">\n";
foreach($_POST['id'] as $msg)
{
echo "<input type=\"hidden\" name=\"id[]\" value=\"" . $msg . "\" />\n";
}
echo "<input type=\"hidden\" name=\"deltwo\" value=\"1\" />\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
}
else
{
foreach($_POST['id'] as $msg)
{
$query = $db->execute("delete from `mail` where `id`=?", array($msg));
}
echo "Le message a bien été effacé !";
//Redirect back to inbox, or show success message
//Can be changed in the admin panel (TODO)
}
}
}
}
break;
default: //Show inbox
echo "<form method=\"post\" action=\"mp.php?act=delete\" name=\"inbox\">\n";
echo "<table width=\"100%\" border=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"5%\"><input type=\"checkbox\" onclick=\"javascript: checkAll();\" name=\"check\" /></td>\n";
echo "<td width=\"20%\"><b>De :</b></td>\n";
echo "<td width=\"35%\"><b>Sujet :</b></td>\n";
echo "<td width=\"40%\"><b>Date :</b></td>\n";
echo "</tr>\n";
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($user->id));
if ($query->recordcount() > 0)
{
$bool = 1;
while($msg = $query->fetchrow())
{
echo "<tr class=\"row" . $bool . "\">\n";
echo "<td width=\"5%\"><input type=\"checkbox\" name=\"id[]\" value=\"" . $msg['id'] . "\" /></td>\n";
$from = $db->GetOne("select `username` from `username` where `id`=?", array($msg['from']));
echo "<td width=\"20%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"profile.php?id=" . $from . "\">" . $from . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"35%\">";
echo ($msg['status'] == "unread")?"<b>":"";
echo "<a href=\"mp.php?act=read&id=" . $msg['id'] . "\">" . stripslashes($msg['subject']) . "</a>";
echo ($msg['status'] == "unread")?"</b>":"";
echo "</td>\n";
echo "<td width=\"40%\">" . date("F j, Y, g:i a", $msg['time']) . "</td>\n";
echo "</tr>\n";
$bool = ($bool==1)?2:1;
}
}
else
{
echo "<tr class=\"row1\">\n";
echo "<td colspan=\"4\"><b>Pas de messages.</b></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<input type=\"submit\" name=\"delmultiple\" value=\"Supprimer\" />\n";
echo "</form>";
break;
}
?>
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
ça me fait la même chose :s
Fatal error: Call to undefined function unread_messages() in /home/mov/public_html/site/mp.php on line 119
a cette ligne il se trouve ça :
<a href="mp.php"><?if (unread_messages($user->id, $db)>0) {echo "<font color=orange><blink>";}?> Telephone [<?=unread_messages($user->id, $db)?>]<?if (unread_messages($id->id, $db)>0) {echo "</blink></font>";}?></a>
|

Membre
|
se code es pas fais pour dans la messagerie .. mais sur tes page pour montrer si luser a oui ou non des messages la table a tu fais un enum read unread ?
et a tu fais page functions.php avec ceci ?
<?php
//Gets the number of unread messages
function unread_messages($id, &$db)
{
$query = $db->getone("select count(*) as `count` from `mail` where `to`=? and `status`='unread'", array($id));
return $query['count'];
}
?>
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Comme le dis mtn tu a changer du non-object a mank la fonction alors mtn sa devrais y aller
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Re.
Oui j'ai bien mis un enum dans la table.
Mais il y a un autre bug dans un autre ligne :
Fatal error: Call to a member function execute() on a non-object in /home/mov/public_html/site/mp.php on line 360
Ligne 360 :
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($users->id));
if ($query->recordcount() > 0)
Désolé de te déranger encore é_è
|

Membre
|
Fatal error: Call to a member function execute() on a non-object in /home/mov/public_html/site/mp.php on line 360
se son les functions le probleme
donc atten que je trouve les fonctions qui te faut parce que disons j''ai plus de 5 000ligne de function par page sur 5 xD
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
la fonction la voici
<?php function &Execute($sql,$inputarr=false)
{
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret =& $fn($this,$sql,$inputarr);
if (isset($ret)) return $ret;
}
if ($inputarr) {
if (!is_array($inputarr)) $inputarr = array($inputarr);
$element0 = reset($inputarr);
# is_object check because oci8 descriptors can be passed in
$array_2d = is_array($element0) && !is_object(reset($element0));
//remove extra memory copy of input -mikefedyk
unset($element0);
if (!is_array($sql) && !$this->_bindInputArray) {
$sqlarr = explode('?',$sql);
if (!$array_2d) $inputarr = array($inputarr);
foreach($inputarr as $arr) {
$sql = ''; $i = 0;
//Use each() instead of foreach to reduce memory usage -mikefedyk
while(list(, $v) = each($arr)) {
$sql .= $sqlarr[$i];
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types
$typ = gettype($v);
if ($typ == 'string')
//New memory copy of input created here -mikefedyk
$sql .= $this->qstr($v);
else if ($typ == 'double')
$sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
else if ($typ == 'boolean')
$sql .= $v ? $this->true : $this->false;
else if ($typ == 'object') {
if (method_exists($v, '__toString')) $sql .= $this->qstr($v->__toString());
else $sql .= $this->qstr((string) $v);
} else if ($v === null)
$sql .= 'NULL';
else
$sql .= $v;
$i += 1;
}
if (isset($sqlarr[$i])) {
$sql .= $sqlarr[$i];
if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
} else if ($i != sizeof($sqlarr))
ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
$ret =& $this->_Execute($sql);
if (!$ret) return $ret;
}
} else {
if ($array_2d) {
if (is_string($sql))
$stmt = $this->Prepare($sql);
else
$stmt = $sql;
foreach($inputarr as $arr) {
$ret =& $this->_Execute($stmt,$arr);
if (!$ret) return $ret;
}
} else {
$ret =& $this->_Execute($sql,$inputarr);
}
}
} else {
$ret =& $this->_Execute($sql,false);
}
return $ret;
}
function &_Execute($sql,$inputarr=false)
{
if ($this->debug) {
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
$this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
} else {
$this->_queryID = @$this->_query($sql,$inputarr);
}
/************************
// OK, query executed
*************************/
if ($this->_queryID === false) { // error handling if query fails
if ($this->debug == 99) adodb_backtrace(true,5);
$fn = $this->raiseErrorFn;
if ($fn) {
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
}
$false = false;
return $false;
}
if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
$rs = new ADORecordSet_empty();
return $rs;
}
// return real recordset from select statement
$rsclass = $this->rsPrefix.$this->databaseType;
$rs = new $rsclass($this->_queryID,$this->fetchMode);
$rs->connection = &$this; // Pablo suggestion
$rs->Init();
if (is_array($sql)) $rs->sql = $sql[0];
else $rs->sql = $sql;
if ($rs->_numOfRows <= 0) {
global $ADODB_COUNTRECS;
if ($ADODB_COUNTRECS) {
if (!$rs->EOF) {
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
$rs->_queryID = $this->_queryID;
} else
$rs->_numOfRows = 0;
}
}
return $rs;
}
?>
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|

Membre
|
Ok je mets ça où ? (je l'ai mis n'importe où je ne sais pas si c'est ça qu'il faut faire)
En mettant le code n'importe où j'ai eu une autre erreur du même genre dans une autre ligne :
Fatal error: Call to a member function execute() on a non-object in /home/mov/public_html/site/mp.php on line 484
à la ligne 484 se trouve ceci :
$query = $db->execute("select `id`, `from`, `subject`, `time`, `status` from `mail` where `to`=? order by `time` desc", array($users->id));
if ($query->recordcount() > 0)
|

Membre
|
non creer une page functions.php et fais une include tout en haut comme ceci
include("functions.php");
et met tout les codes functions que je t donner dedans ..
ta msn sa irais mieux je croit pour se parler
add moi my_life_me@hotmail.com
https://guerredesgangs.net & http://www.bazinio.ca & http://www.thestreet2.ca
|
Pages: 1
|