Ok so in mccode lite im not sure if it's the same in v2 but when someone sends a mail it goes to the mail logs in the game but if that person deletes the mail it goes away from the mail logs and your databass.
So what i have done is made it so all users are able to delete there mail but all mail also go into another field so you can read the mail after they have been deleted by the user.
This is only for mccode lite.
Open mailbox.php and replace with
<?php
/*
MCCodes Lite
mailbox.php Rev 1.0.0
Copyright (C) 2006 Dabomstew
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();
if($ir['mailban'])
{
die("<font color=red><h3>! ERROR</h3>
You have been mail banned for {$ir['mailban']} days.
[b]Reason: {$ir['mb_reason']}</font>[/b]");
}
$_GET['ID'] = abs((int) $_GET['ID']);
print "<table width=75% border=2><tr><td>[url='mailbox.php?action=inbox']Inbox[/url]</td> <td>[url='mailbox.php?action=outbox']Outbox[/url]</td> <td>[url='mailbox.php?action=compose']Compose Message[/url]</td> <td>[url='mailbox.php?action=delall']Delete All Messages[/url]</td>
";
switch($_GET['action'])
{
case 'inbox':
mail_inbox();
break;
case 'outbox':
mail_outbox();
break;
case 'compose':
mail_compose();
break;
case 'delete':
mail_delete();
break;
case 'send':
mail_send();
break;
case 'delall':
mail_delall();
break;
case 'delall5':
mail_delall();
break;
case 'delall2':
mail_delall2();
break;
case 'archive':
mail_archive();
break;
default:
mail_inbox();
break;
}
function mail_inbox()
{
global $ir,$c,$userid,$h;
print "Only the last 25 messages sent to you are visible.
<table width=75% border=2><tr style='background:gray'><th>From</th><th>Subject/Message</th></tr>";
$q=mysql_query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC LIMIT 25",$c);
while($r=mysql_fetch_array($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print "<tr><td>";
if($r['userid'])
{
print "[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]";
}
else
{
print "SYSTEM";
}
$fm=urlencode($r['mail_text']);
print "</td>\n<td>{$r['mail_subject']}</td></tr><tr><td>Sent at: $sent
[url='mailbox.php?action=compose&ID={$r[']Reply[/url]
[url='mailbox.php?action=delete&ID={$r[']Delete[/url]
[url='preport.php?ID={$r[']Report[/url]</td><td>{$r['mail_text']}</td></tr>";
}
mysql_query("UPDATE mail SET mail_read=1 WHERE mail_to=$userid",$c);
}
function mail_outbox()
{
global $ir,$c,$userid,$h;
print "Only the last 25 messages you have sent are visible.
<table width=75% border=2><tr style='background:gray'><th>To</th><th>Subject/Message</th></tr>";
$q=mysql_query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_to=u.userid WHERE m.mail_from=$userid ORDER BY mail_time DESC LIMIT 25",$c);
while($r=mysql_fetch_array($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print "<tr><td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td><td>{$r['mail_subject']}</td></tr><tr><td>Sent at: $sent
</td><td>{$r['mail_text']}</td></tr>";
}
}
function mail_compose()
{
global $ir,$c,$userid,$h;
print "<form action='mailbox.php?action=send' method='post'>
<table width=75% border=2> <tr>
<td>ID to send to:</td> <td><input type='text' name='userid' value='{$_GET['ID']}' /></td></tr><tr>
<td>Subject:</td> <td><input type='text' name='subject' /></td></tr><tr>
<td>Message:</td>
<td><textarea rows=5 cols=40 name='message'></textarea></td></tr><tr> <td colspan=2><input type='submit' value='Send' /></td></tr></table></form>";
if($_GET['ID'])
{
print "
<table width=75% border=2><tr><td colspan=2>[b]Your last 5 mails to/from this person:[/b]</td></tr>";
$q=mysql_query("SELECT m.*,u1.username as sender from mail m left join users u1 on m.mail_from=u1.userid WHERE (m.mail_from=$userid AND m.mail_to={$_GET['ID']}) OR (m.mail_to=$userid AND m.mail_from={$_GET['ID']}) ORDER BY m.mail_time DESC LIMIT 5",$c);
while($r=mysql_fetch_array($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print "<tr><td>$sent</td> <td>[b]{$r['sender']} wrote:[/b] {$r['mail_text']}</td></tr>";
}
print "</table>";
}
}
function mail_send()
{
global $ir,$c,$userid,$h;
$subj=str_replace(array("\n"),array("
"),strip_tags($_POST['subject']));
$msg=str_replace(array("\n"),array("
"),strip_tags($_POST['message']));
$to= (int) $_POST['userid'];
mysql_query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$msg')",$c) or die(mysql_error());
mysql_query("INSERT INTO mailall VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$msg')",$c) or die(mysql_error());
print "Message sent.
[url='mailbox.php']> Back[/url]";
}
function mail_delete()
{
global $ir,$c,$userid,$h;
mysql_query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid",$c);
print "Message deleted.
[url='mailbox.php']> Back[/url]";
}
function mail_delall()
{
global $ir,$c,$userid,$h;
print "This will delete all the messages in your inbox.
[url='mailbox.php?action=delall5']> Yes[/url]
[url='mailbox.php']> No[/url]";
}
function mail_delall5()
{
global $ir,$c,$userid,$h;
print "Are you sure
You [b]<font color=red>Cannot</font>[/b] undo this.
[url='mailbox.php?action=delall2']> Yes. I am sure.[/url]
[url='mailbox.php']> No, go back[/url]";
}
function mail_delall2()
{
global $ir,$c,$userid,$h;
mysql_query("DELETE FROM mail WHERE mail_to=$userid",$c);
print "All ".mysql_affected_rows($c)." mails in your inbox were deleted.
[url='mailbox.php']> Back[/url]";
}
function mail_archive()
{
global $ir,$c,$userid,$h;
print "This tool will download an archive of all your messages.
[url='dlarchive.php?a=inbox']> Download Inbox[/url]
[url='dlarchive.php?a=outbox']> Download Outbox[/url]";
}
$h->endpage();
?>
Open admin.php Find
function view_mail_logs()
{
global $ir,$c,$h,$userid;
$_GET['st']=abs((int) $_GET['st']);
$rpp=100;
print "<h3>Mail Logs</h3>
<table width=75% border=2> \n<tr style='background:gray'> <th>ID</th> <th>Time</th> <th>User From</th> <th>User To</th> <th width>Subj</th> <th width=30%>Msg</th> <th></th> </tr>";
$q=mysql_query("SELECT m.*,u1.username as sender, u2.username as sent FROM mail m LEFT JOIN users u1 ON m.mail_from=u1.userid LEFT JOIN users u2 ON m.mail_to=u2.userid WHERE m.mail_from != 0 ORDER BY m.mail_time DESC LIMIT {$_GET['st']},$rpp",$c) or die(mysql_error()."
"."SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid ORDER BY cx.cxTIME DESC LIMIT {$_GET['st']},$rpp");
while($r=mysql_fetch_array($q))
{
print "\n<tr><td>{$r['mail_id']}</td> <td>" . date("F j, Y, g:i:s a",$r['mail_time']) . "</td><td>{$r['sender']} [{$r['mail_from']}] </td> <td>{$r['sent']} [{$r['mail_to']}] </td> \n<td> {$r['mail_subject']}</td> \n<td>{$r['mail_text']}</td> <td> [[url='admin.php?action=mailform&XID={$r[']MailBan Sender[/url]] [[url='admin.php?action=mailform&XID={$r[']MailBan Receiver[/url]]</td> </tr>";
}
print "</table>
";
$q2=mysql_query("SELECT mail_id FROM mail WHERE mail_from != 0",$c);
$rs=mysql_num_rows($q2);
$pages=ceil($rs/20);
print "Pages: ";
for($i=1;$i<=$pages;$i++)
{
$st=($i-1)*20;
print "[url='admin.php?action=maillogs&st=$st']$i[/url]";
if($i % 7 == 0) { print "
\n"; }
}
}
Replace with
print "<h3>Mail Logs</h3>
<table width=75% border=2> \n<tr style='background:gray'> <th>ID</th> <th>Time</th> <th>User From</th> <th>User To</th> <th width>Subj</th> <th width=30%>Msg</th> <th></th> </tr>";
$q=mysql_query("SELECT m.*,u1.username as sender, u2.username as sent FROM mailall m LEFT JOIN users u1 ON m.mail_from=u1.userid LEFT JOIN users u2 ON m.mail_to=u2.userid WHERE m.mail_from != 0 ORDER BY m.mail_time DESC LIMIT {$_GET['st']},$rpp",$c) or die(mysql_error()."
"."SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid ORDER BY cx.cxTIME DESC LIMIT {$_GET['st']},$rpp");
while($r=mysql_fetch_array($q))
{
print "\n<tr><td>{$r['mail_id']}</td> <td>" . date("F j, Y, g:i:s a",$r['mail_time']) . "</td><td>{$r['sender']} [{$r['mail_from']}] </td> <td>{$r['sent']} [{$r['mail_to']}] </td> \n<td> {$r['mail_subject']}</td> \n<td>{$r['mail_text']}</td> <td> [[url='admin.php?action=mailform&XID={$r[']MailBan Sender[/url]] [[url='admin.php?action=mailform&XID={$r[']MailBan Receiver[/url]]</td> </tr>";
}
print "</table>
";
$q2=mysql_query("SELECT mail_id FROM mail WHERE mail_from != 0",$c);
$rs=mysql_num_rows($q2);
$pages=ceil($rs/20);
print "Pages: ";
for($i=1;$i<=$pages;$i++)
{
$st=($i-1)*20;
print "[url='admin.php?action=maillogs&st=$st']$i[/url]";
if($i % 7 == 0) { print "
\n"; }
}
}
Go to PhpMyAdmin and add the SQL [mysql]
CREATE TABLE `mailall` (
`mail_id` int(11) NOT NULL auto_increment,
`mail_read` int(11) NOT NULL default '0',
`mail_from` int(11) NOT NULL default '0',
`mail_to` int(11) NOT NULL default '0',
`mail_time` int(11) NOT NULL default '0',
`mail_subject` varchar(255) NOT NULL default '',
`mail_text` text NOT NULL,
PRIMARY KEY (`mail_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 [/mysql]
Thanks
Brad