notice: this is just some stuff to help the needed ones. i didn't
create this script i just posted it for the people who wants it
#
# Table structure for table `mail`
#
CREATE TABLE `mail` (
`id` int(11) NOT NULL auto_increment,
`sender` varchar(15) NOT NULL default '',
`senderid` varchar(100) NOT NULL default '0',
`owner` varchar(100) NOT NULL default '0',
`subject` varchar(50) NOT NULL default '',
`body` text NOT NULL,
`unread` char(1) NOT NULL default 'T',
`kbox` char(1) NOT NULL default 'N',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1600 ;
# --------------------------------------------------------
you would need to add your own smiles ... to images/smileys/
and edit some inorder to gain the full features of this mail box
BTW this script if from savage lands.. i just posted it so that people
who don't use savagelands can still get what they want..
Logged In: YES
user_id=1051218
save it as mail.php
<?php
if ($view == 'inbox') {
$box = '- Inbox';
}
if ($view == 'kbox') {
$box = '- Keeper Box';
}
if ($view == 'write') {
$box = '- Compose';
}
if ($read >= '0') {
$box = '- Read';
} else {
$box = '';
}
?>
<?php $title = "Mail $box"; include("header.php"); ?>
<script language="JavaScript" type="text/JavaScript">
function sendText(e, text)
{
e.value += text
}
</script>
<?php
if (!$view && !$read) {
print "What are you going to do?<br><br>
- <a href=mail.php?view=inbox>Inbox</a><br>
- <a href=mail.php?view=kbox>Keeper box</a><br>
- <a href=mail.php?view=write>Compose</a>";
}
if ($view == 'inbox') {
$hmail = mysql_num_rows(mysql_query("select * from mail where
owner=$stat[id] and kbox='N'"));
if ($hmail >= '1') {
print "<table width=100% cellspacing=0>";
print "<tr><td width=25><b><u></td><td
width=75><b><u>From</td><td width=75><b><u>ID</td><td
width=100><b><u>Subject</td><td width=50><b><u>Options</
td></tr>";
$msel = mysql_query("select * from mail where owner=$stat[id]
and kbox='N' and unread='T' order by id desc");
while ($mail = mysql_fetch_array($msel)) {
print "<tr onmouseover=\"this.style.backgroundColor='003366';\"
onmouseout=\"this.style.backgroundColor='';\"><td><img src=images/
unread.gif border=0></td><td><font style=\"color: FFD700;
\">$mail[sender]</font></td><td>$mail[senderid]</
td><td>$mail[subject]</td><td><a href=mail.php?
read=$mail[id]>Read</a> - <a href=mail.php?
view=delete&dmail=$mail[id]><img src=images/trash.gif border=0></
a></td></tr>";
}
$msel = mysql_query("select * from mail where owner=$stat[id]
and kbox='N' and unread='F' order by id desc");
while ($mail = mysql_fetch_array($msel)) {
print "<tr onmouseover=\"this.style.backgroundColor='003366';\"
onmouseout=\"this.style.backgroundColor='';\"><td><img src=images/
read.gif border=0></td><td><font style=\"color: FFD700;
\">$mail[sender]</font></td><td>$mail[senderid]</
td><td>$mail[subject]</td><td><a href=mail.php?
read=$mail[id]>Read</a> - <a href=mail.php?
view=delete&dmail=$mail[id]><img src=images/trash.gif border=0></
a></td></tr>";
}
}
if ($hmail == '0') {
print "<div align=center>
<center><font class=me><b>You Have No Mail In Your Inbox!</b></
font></center>
<br><center>[<a href=mail.php?view=write>Compose</a>] [<a
href=mail.php?view=kbox>Kbox</a>]</center>
";
} else {
print "</table><div align=center><br><center>[<a href=mail.php?
view=inbox&step=clear>Clear Inbox</a>] [<a href=mail.php?
view=write>Compose</a>] [<a href=mail.php?view=kbox>Kbox</
a>]</center>
</div>";
}
if ($step == clear) {
print "<br>Inbox cleared. [<a href=mail.php?
view=inbox>refresh</a>]";
mysql_query("delete from mail where owner=$stat[id] and
kbox='N'");
}
}
if ($view == 'kbox') {
$kboxmail = mysql_num_rows(mysql_query("select * from mail where
owner=$stat[id] and kbox='Y'"));
if ($kboxmail != '') {
print "<table cellspacing=0>";
print "<tr><td width=25><b><u></td><td
width=75><b><u>From</td><td width=75><b><u>ID</td><td
width=100><b><u>Subject</td><td width=50><b><u>Options</
td></tr>";
$msel = mysql_query("select * from mail where owner=$stat[id]
and kbox='Y' order by id desc");
while ($mail = mysql_fetch_array($msel)) {
if ($mail[unread] == T) {
print "<div align=center>";
print "<tr onmouseover=\"this.style.backgroundColor='003366';
\" onmouseout=\"this.style.backgroundColor='';\"><td><img
src=images/unread.gif border=0></td><td>$mail[sender]</
td><td>$mail[senderid]</td><td>$mail[subject]</td><td><a
href=mail.php?read=$mail[id]>Read</a> - <a href=mail.php?
view=delete&dmail=$mail[id]><img src=images/trash.gif border=0></
a>";
} else {
print "<div align=center>";
print "<tr
onmouseover=\"this.style.backgroundColor='003366';\"
onmouseout=\"this.style.backgroundColor='';\"><td><img src=images/
read.gif border=0></td><td>$mail[sender]</
td><td>$mail[senderid]</td><td>$mail[subject]</td><td><a
href=mail.php?read=$mail[id]>Read</a> - <a href=mail.php?
view=delete&dmail=$mail[id]><img src=images/trash.gif border=0></
a>";
}
}
print "</table>";
}else{
print "<center><font class=me><b>This is your Keeper box, You have
no Keeper messages.</b></font></center>
<br><center>[<a href=mail.php?view=write>Compose</a>] [<a
href=mail.php?view=inbox>Inbox</a>]</center>";
}
if ($kboxmail != '') {
print "<br><center>[<a href=mail.php?
view=kbox&step=clear>Clear kbox</a>] [<a href=mail.php?
view=write>Compose</a>] [<a href=mail.php?view=inbox>Inbox</
a>]</center>";
}
if ($step == clear) {
print "<br>Kbox cleared. [<a href=mail.php?
view=kbox>refresh</a>]";
mysql_query("delete from mail where owner=$stat[id] and
kbox='Y'");
}
}
if ($view == 'write') {
print "<table>
<tr><td colspan=3 align=center>";
?>
<img name="1" img src="images/smileys/1.gif" border="0" alt=":)"
onClick="sendText(document.form1.body, ' :) ')">
<img name="2" img src="images/smileys/2.gif" border="0" alt=":("
onClick="sendText(document.form1.body, ' :( ')">
<img name="3" img src="images/smileys/3.gif" border="0" alt=":-D"
onClick="sendText(document.form1.body, ' :-D ')">
<img name="4" img src="images/smileys/4.gif" border="0" alt=":-o"
onClick="sendText(document.form1.body, ' :-o ')">
<img name="5" img src="images/smileys/5.gif" border="0" alt=":-P"
onClick="sendText(document.form1.body, ' :-P ')">
<img name="6" img src="images/smileys/6.gif" border="0" alt=";-)"
onClick="sendText(document.form1.body, ' ;-) ')">
<br><img name="7" img src="images/bold.gif" border="0" alt="Bold"
onClick="sendText(document.form1.body, '[b] [/b]')">
<img name="7" img src="images/italic.gif" border="0" alt="Italic"
onClick="sendText(document.form1.body, '[i] [/i]')">
<img name="7" img src="images/underline.gif" border="0"
alt="Underline" onClick="sendText(document.form1.body, '[u] [/u]')">
<img name="7" img src="images/strikethrough.gif" border="0"
alt="Strikethrough" onClick="sendText(document.form1.body, '[s] [/
s]')">
</td>
<?
print "
<form name=form1 method=post action=mail.php?view=send>
<tr><td>To [ID Number]:</td><td><input type=text name=to
value=$to></td></tr>
<tr><td>Subject:</td><td width=100%><input type=text
name=subject value=$re></td></tr>
<tr><td valign=top>Body:</td><td width=100%><textarea
name=body rows=5 cols=60%></textarea>
</td></tr>
<tr><td colspan=2 align=center><input type=submit value=Send></
td></tr>
</form></table>
<br><center>[<a href=mail.php?view=inbox>Inbox</a>] [<a
href=mail.php?view=write>Compose</a>] [<a href=mail.php?
view=kbox>Kbox</a>]</center>
";
}
if ($view == send) {
$to = htmlspecialchars($to);
$body = htmlspecialchars($body);
$c = explode(" ",$body);
$body = str_replace(":)", '<img src="images/smileys/
1.gif">',$body);
$body = str_replace(":-)", '<img src="images/smileys/
1.gif">',$body);
$body = str_replace(":(", '<img src="images/smileys/
2.gif">',$body);
$body = str_replace(":-(", '<img src="images/smileys/
2.gif">',$body);
$body = str_replace(":D", '<img src="images/smileys/
3.gif">',$body);
$body = str_replace(":-D", '<img src="images/smileys/
3.gif">',$body);
$body = str_replace(":o", '<img src="images/smileys/
4.gif">',$body);
$body = str_replace(":-o", '<img src="images/smileys/
4.gif">',$body);
$body = str_replace(":p", '<img src="images/smileys/
5.gif">',$body);
$body = str_replace(":P", '<img src="images/smileys/
5.gif">',$body);
$body = str_replace(":-p", '<img src="images/smileys/
5.gif">',$body);
$body = str_replace(":-P", '<img src="images/smileys/
5.gif">',$body);
$body = str_replace(";)", '<img src="images/smileys/
6.gif">',$body);
$body = str_replace(";-)", '<img src="images/smileys/
6.gif">',$body);
$body = str_replace("[b]","<b>",$body);
$body = str_replace("[u]","<u>",$body);
$body = str_replace("[i]","<i>",$body);
$body = str_replace("[s]","<s>",$body);
$body = str_replace("[red]","<font style=\"color: FF0000;
\">",$body);
$body = str_replace("[blue]","<font style=\"color: 0000FF;
\">",$body);
$body = str_replace("[green]","<font style=\"color: 00FF00;
\">",$body);
$body = str_replace("[yellow]","<font style=\"color: FFFF00;
\">",$body);
$body = str_replace("[/red]","</font>",$body);
$body = str_replace("[/blue]","</font>",$body);
$body = str_replace("[/green]","</font>",$body);
$body = str_replace("[/yellow]","</font>",$body);
$body = str_replace("[/b]","</b>",$body);
$body = str_replace("[/u]","</u>",$body);
$body = str_replace("[/i]","</i>",$body);
$body = str_replace("[/s]","</s>",$body);
$body = nl2br($body);
if (empty ($to) || empty ($body)) {
print "Please fill out all fields.";
include("footer.php");
exit;
}
if (empty ($subject)) {
$subject = "None";
}
$rec = mysql_fetch_array(mysql_query("select * from players where
id=$to"));
if (empty ($rec[id])) {
print "No such player.";
include("footer.php");
exit;
}
mysql_query("insert into mail (sender,senderid,owner,subject,body)
values('$stat[user]','$stat[id]',$to,'$subject','$body')") or die("Could not
send mail.");
print "You sent mail to $rec[user].
<br><br><center>[<a href=mail.php?view=inbox>Inbox</a>] [<a
href=mail.php?view=kbox>Kbox</a>] [<a href=mail.php?
view=write>Compose</a>]</center>
";
}
if ($view == 'delete') {
$dmail = mysql_fetch_array(mysql_query("select * from mail where
id='$dmail'"));
if (empty ($dmail[id])) {
print "No such mail.";
include("footer.php");
exit;
}
if ($dmail[owner] != $stat[id]) {
print "That's not your mail.";
include("footer.php");
exit;
}
mysql_query("delete from mail where id=$dmail[id]");
print "Mail deleted";
print "<br><br><center>[<a href=mail.php?view=inbox>Inbox</
a>] [<a href=mail.php?view=kbox>Kbox</a>] [<a href=mail.php?
view=write>Compose</a>]</center>";
}
if ($view == 'addkbox') {
$kmail = mysql_fetch_array(mysql_query("select * from mail where
id='$amail'"));
if (empty ($kmail[id])) {
print "No such mail.";
include("footer.php");
exit;
}
if ($kmail[owner] != $stat[id]) {
print "That's not your mail.";
include("footer.php");
exit;
}
mysql_query("update mail set kbox='Y' where id=$kmail[id]");
print "Mail was put into the Kbox";
print "<br><br><center>[<a href=mail.php?view=inbox>Inbox</
a>] [<a href=mail.php?view=kbox>Kbox</a>] [<a href=mail.php?
view=write>Compose</a>]</center>";
}
if ($view == 'remkbox') {
$kmail = mysql_fetch_array(mysql_query("select * from mail where
id='$amail'"));
if (empty ($kmail[id])) {
print "No such mail.";
include("footer.php");
exit;
}
if ($kmail[owner] != $stat[id]) {
print "That's not your mail.";
include("footer.php");
exit;
}
mysql_query("update mail set kbox='N' where id=$kmail[id]");
print "Mail was put into the Inbox";
print "<br><br><center>[<a href=mail.php?view=inbox>Inbox</
a>] [<a href=mail.php?view=kbox>Kbox</a>] [<a href=mail.php?
view=write>Compose</a>]</center>";
}
if ($read) {
$mail = mysql_fetch_array(mysql_query("select * from mail where
id='$read'"));
if (empty ($mail['id'])) {
print "No such mail.";
include("footer.php");
exit;
}
if ($mail[owner] != $stat[id]) {
print "That's not your mail.";
include("footer.php");
exit;
}
mysql_query("update mail set unread='F' where id=$mail[id]");
print "<br>
<div align=center>
<table border=2 width=90% bordercolor=$table_border>
<tr bordercolor=000000>
<td width=50%>
<p align=left><b>From: <font style=\"color: FFD700;
\">$mail[sender]</font></b> </td>
<td width=50%>
<p align=right><b>ID: <font style=\"color: FFD700;
\">$mail[senderid]</font></b> </td>
</tr>
<tr>
<td width=60% colspan=2><br>$mail[body]
<br>
</td>
</tr>
</table>
</div>";
if ($mail[kbox] == 'N') {
print "<br><br><center>[<a href=mail.php?view=inbox>Inbox</a>]
[<a href=mail.php?view=write>Compose</a>] [<a href=mail.php?
view=write&to=$mail[senderid]&re=RE:$mail[subject]>Reply</a>] [<a
href=mail.php?view=delete&dmail=$mail[id]>Delete</a>] [<a
href=mail.php?view=addkbox&amail=$mail[id]>Add to Kbox</a>]</
center>";
} else {
print "<br><br><center>[<a href=mail.php?view=kbox>Kbox</a>]
[<a href=mail.php?view=write>Compose</a>] [<a href=mail.php?
view=write&to=$mail[senderid]&re=RE:$mail[subject]>Reply</a>] [<a
href=mail.php?view=delete&dmail=$mail[id]>Delete</a>] [<a
href=mail.php?view=remkbox&amail=$mail[id]>Remove From Kbox</
a>]</center>";
}
}
?>
<?php include("footer.php"); ?>