Jump to content
MakeWebGames

Mail Box Error


cm31

Recommended Posts

When I get new mail it wont show Mailbox (1) it will just stay at (0) and I have looked and it looks to me the codes are right if any one can help thanks

 

Mainmenu.php

 

<?php
global $db,$c,$ir, $set;
$hc=$set['hospital_count'];
$jc=$set['jail_count'];
$ec=$ir['new_events'];
$mc=$ir['new_mail'];
$var2['num_users_on'] = mysql_query("SELECT userid FROM users WHERE laston >= UNIX_TIMESTAMP()-900", $c);
$var['num_users_on'] = mysql_num_rows($var2['num_users_on']);
if($ir['hospital'])
{
 print "[url='hospital.php']Hospital ($hc)[/url]

 [url='inventory.php']Inventory[/url]
";
}
elseif($ir['jail'])
{
 print "[url='jail.php']Jail ($jc)[/url]
";
}
else
{

print "<a href='index.php'><font>Home</font>

 [url='inventory.php']Inventory[/url]
";
}
if($ec > 0) { print "[url='events.php']Events ($ec)[/url]
"; }
else { print "[url='events.php']Events (0)[/url]
"; }
if($mc > 0) { print "[url='mailbox.php']Mailbox ($mc)[/url]
"; }
else { print "[url='mailbox.php']Mailbox (0)[/url]
"; }
if($ir['jail'] and !$ir['hospital'])
{
 print "[url='inventory.php']Inventory[/url]

 [url='gym.php']Jail Gym[/url]

 [url='hospital.php']Hospital ($hc)[/url]
";
}
else if (!$ir['hospital'])
{
 print "<a href='explore.php'><font>Explore</font>

 [url='street.php']Streets[/url]

 [url='gym.php']Gym[/url]

 [url='criminal.php']Crimes[/url]

 [url='job.php']Your Job[/url]

 [url='education.php']Local School[/url]

 [url='hospital.php']Hospital ($hc)[/url]

 [url='jail.php']Jail ($jc)[/url]
";
}
else
{
 print "[url='jail.php']Jail ($jc)[/url]
";
}
print "<a href='donator.php'><font color=red size=+1>Donate</font>
";
print "<a href='forums.php'><font color=white>Forums</font>
";


if($ir['new_announcements'])
{
print "[url='announcements.php']Announcements ({$ir['new_announcements']})</font>[/url]
";
}
else
{
print "<a href='announcements.php'><font color=white>Announcements (0)</font>
";
}
print "
<a href='newspaper.php'><font color=white>News Paper</font>

[url='chat.php']Chat[/url]

[url='usersonline.php']Users Online [b]({$var['num_users_on']})[/b][/url]

[url='search.php']Search[/url]
";
if(!$ir['jail'] && $ir['gang'])
{
 print "<a href='yourplatoon.php'><font color=red>Your Platoon</font>
";
}
if($ir['user_level'] > 1)
{
print "<hr />
[b]Staff Only[/b]
\n";
if($ir['user_level']==7)
{
print "[url='owner.php']Owner Panel[/url]
\n";
}
if($ir['user_level']==2)
{
print "[url='admpanel.php']Admin Panel[/url]
\n";
}
if($ir['user_level']==3)
{
print "[url='secpanel.php']Secretary Panel[/url]
\n";
}
if($ir['user_level']==4)
{
print "[url='asspanel.php']Assistant Panel[/url]
\n";
}
if($ir['user_level']==5)
{
print "[url='modpanel.php']Moderator Panel[/url]
\n";
}
if($ir['user_level']==6)
{
print "[url='helperpanel.php']Helper Panel[/url]
";
}

}
if($ir['user_level'] > 0)
{



print "<hr />[b]DS Staff Online:[/b]
";
$q=$db->query("SELECT * FROM users WHERE laston>(unix_timestamp()-15*60) AND user_level > 1 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
$la=time()-$r['laston'];
$unit="secs";
if($la >= 60)
{
$la=(int) ($la/60);
$unit="mins";
}
if($la >= 60)
{
$la=(int) ($la/60);
$unit="hours";
if($la >= 24)
{
$la=(int) ($la/24);
$unit="days";
}
}
print "[url='viewuser.php?u={$r[']{$r['username']}[/url] ($la $unit)
";
}
}
if($ir['donatordays'])
{
print "<hr />
[b]Donators Only[/b]

[url='ddreward.php']Daily Donator Reward[/url]

[url='friendslist.php']Friends List[/url]

[url='blacklist.php']Black List[/url]

[url='calc.php']Calculator[/url]";
}
print "<hr />
[url='preferences.php']Preferences[/url]

[url='preport.php']Report Player[/url]

[url='bugtracker.php']Bug Report[/url]

[url='helptutorial.php']Help Tutorial[/url]

[url='gamerules.php']Game Rules[/url]

[url='viewuser.php?u={$ir[']My Profile[/url]

[url='logout.php']Logout[/url]


Time is now

";
echo date ('F j, Y')."
".date('g:i:s a');

?>

 

 

Mailbox.php

 

 
<?php
include "globals.php";
include "bbcodestyle.css";
include "bbcode.php";
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=90% class='' cellspacing=''><tr><td>[url='mailbox.php?action=inbox']Inbox[/url]</td> <td>[url='mailbox.php?action=outbox']Sent Messages[/url]</td> <td>[url='mailbox.php?action=compose']Compose Message[/url]</td> <td>[url='mailbox.php?action=delall']Delete All Messages[/url]</td> <td>[url='mailbox.php?action=archive']Archive Messages[/url]</td><td>[url='contactlist.php']My Contacts[/url]</td> <tr><td>[url='ignore.php?action=inbox']Ignore List[/url]</td> </tr></table>
";

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 'delall2':
mail_delall2();
break;

case 'archive':
mail_archive();
break;

default:
mail_inbox();
break;
}
function mail_inbox()
{
global $db,$ir,$c,$userid,$h;
print <<<OUT
Only the last 25 messages sent to you are visible.

<table width=75% class=\"\" border=\"1\" cellspacing=\"1\">
<tr>
<td class="h" width="30%">From</td>
<td class="h" width="70%">Subject/Message</td>
</tr>
OUT;
$q=$db->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");
while($r=$db->fetch_row($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 <<<EOF
</td>
<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>
EOF;
}
if($ir['new_mail'] > 0)
{
$db->query("UPDATE mail SET mail_read=1 WHERE mail_to=$userid");
$db->query("UPDATE users SET new_mail=0 WHERE userid=$userid");
}
echo '</table>';
}
function mail_outbox()
{
global $db,$ir,$c,$userid,$h;
print "Only the last 25 messages you have sent are visible.

<table width=75% cellspacing=1 class=\"\" border=\"1\" cellspacing=\"1\"><tr style='background:gray'><th>To</th><th>Subject/Message</th></tr>";
$q=$db->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");
while($r=$db->fetch_row($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>

<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=bb2html($_POST['message']);
$newmsg = str_replace($codes, $images, $msg);
$to= (int) $_POST['userid'];
mysql_query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$newmsg')",$c) or die(mysql_error());
print "Message sent.

[url='mailbox.php']> Back[/url]";
}
function mail_delete()
{
global $db,$ir,$c,$userid,$h;
$db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid");
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.

There is [b]NO[/b] undo, so be sure.

[url='mailbox.php?action=delall2']> Yes, delete all messages[/url]

[url='mailbox.php']> No, go back[/url]";
}
function mail_delall2()
{
global $db,$ir,$c,$userid,$h;
$db->query("DELETE FROM mail WHERE mail_to=$userid");
print "All ".$db->affected_rows()." 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();
?>

 

Thanks guys for the help and if you can let me know how to fix this THANKS =D :D

Link to comment
Share on other sites

The reason it isn't showing up is because no message is being sent! I have a suspicion that the problem lies in the function to send the mail.

function mail_send()
{
global $ir,$c,$userid,$h;
$subj=str_replace(array("\n"),array("
"),strip_tags($_POST['subject']));

$msg=bb2html($_POST['message']);
$newmsg = str_replace($codes, $images, $msg);
$to= (int) $_POST['userid'];
mysql_query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$newmsg')",$c) or die(mysql_error());
print "Message sent.

> Back";
}

 

I think the reason it's not being sent is due to the mysql_query line. You'll need to declare a variable for it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...