Jump to content
MakeWebGames

Recommended Posts

Posted

Hi MWG i am having a slight problem with my mailbox for some reason when i compose a mail and click send it does nothing...

It would be great if someone could help me with this.

Screenshot (Composing mail):

http://www.image-upload.net/viewer.php?file=s78n3k5gzi6hujgd2lyi.jpg

Screenshot (Clicked send):

http://www.image-upload.net/viewer.php?file=ikvtebd5fb7d7y3v85.jpg

 

<?php
include_once(DIRNAME(__FILE__) . '/includes/system.php');
include_once(DIRNAME(__FILE__) . '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']);
echo "<table width='100%' align='center' cellspacing='0'>
<tr>
<td style='text-align:center;'><a href='mail.php?action=inbox'>[img=images/inbox.png]
Inbox</a></td>
<td style='text-align:center;'><a href='mail.php?action=outbox'>[img=images/outbox.png]
Outbox</a></td>
<td style='text-align:center;'><a href='mail.php?action=compose'>[img=images/compose.png]
Compose</a></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;
   	default:
           	mail_inbox();
           	break;
}
function mail_inbox()
{
   	global $db, $ir, $c, $userid, $h;
   	print <<<OUT
<div class="h3">Mail Inbox</div>
Below are the last 15 messages you have recieved.
<table width="100%" class="table" cellspacing="0">
<tr>
<th width="25%">From</th>
<th>Subject/Message</th>
</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 15");
   	while ($r = $db->fetch_row($q)) {
           	$sent = date('F j, Y, g:i:s a', $r['mail_time']);
           	echo "<tr><td>";
           	if ($r['userid']) {
                   	echo "[url='profile.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]";
           	} else {
                   	echo "SYSTEM";
           	}
           	$fm = urlencode($r['mail_text']);
           	print <<<EOF
</td>
<td>{$r['mail_subject']}</td>
</tr>
<tr>
<td>Sent at: {$sent}
[url='mail.php?action=compose&ID={$r[']Reply[/url]


[url='mail.php?action=delete&ID={$r[']Delete[/url]


[url='preport.php?ID={$r[']Report[/url]
</td>
<td>{$r['mail_text']}</td>
</tr></table>
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;
   	echo '<div class="h3">Mail Outbox</div>
Below are the last 15 messages you have sent.
<table width="100%" class="table" cellspacing="0">
<tr>
<th width="25%">Receiver</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 15");
   	while ($r = $db->fetch_row($q)) {
           	$sent = date('F j, Y, g:i:s a', $r['mail_time']);
           	echo "<tr><td>[url='profile.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>";
   	}
   	echo "</table>";
}
function mail_compose()
{
   	global $ir, $c, $userid, $h;
   	echo <<< EOF
<script type="text/javascript">
function insert(el,ins) {
if (el.setSelectionRange){
el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) +

el.value.substring(el.selectionEnd,el.value.length);
}
else if (document.selection && document.selection.createRange) {
el.focus();
var range = document.selection.createRange();
range.text = ins + range.text;
}
}
</script>
<div class="h3">Mail Compose</div>
<form action='mail.php?action=send' method='post'>
<table width="100%" class='table' cellspacing='0'>
<tr>
<td width='24%'>Receiver ID:</td><td><input type='text' name='userid' value='{$_GET['ID']}'/> [size="1"][i](Example: 1234)[/i][/size]</td>
</tr>
<tr>
<td>Subject:</td> <td><input type='text' name='subject'/> [size="1"][i](Example: Hello!)[/i][/size]</td>
</tr>
<tr>
<td>Message:</td>
<td>
<textarea name='message' rows='10' cols='50'></textarea>

<input type="image" src="smileys/smile.gif" alt="Smile" title="Smile" onclick="insert(this.form.message,':)'); return false;" />
<input type="image" src="smileys/wink.gif" alt="Wink" title="Wink" onclick="insert(this.form.message,';)'); return false;" />
<input type="image" src="smileys/surprise.gif" alt="Suprised" title="Suprised" onclick="insert(this.form.message,':o'); return false;" />
<input type="image" src="smileys/teeth.gif" alt="Cheesy Grin" title="Cheesy Grin" onclick="insert(this.form.message,':D'); return false;" />
<input type="image" src="smileys/confuse.gif" alt="Confused" title="Confused" onclick="insert(this.form.message,':s'); return false;" />
<input type="image" src="smileys/frown.gif" alt="Sad" title="Sad" onclick="insert(this.form.message,':('); return false;" />
<input type="image" src="smileys/angry.gif" alt="Angry" title="Angry" onclick="insert(this.form.message,':angry'); return false;" />
<input type="image" src="smileys/bigwink.gif" alt="Big Wink" title="Big Wink" onclick="insert(this.form.message,':bigwink'); return false;" />
<input type="image" src="smileys/laugh.gif" alt="Laugh" title="Laugh" onclick="insert(this.form.message,':laugh'); return false;" />
<input type="image" src="smileys/star.gif" alt="Star" title="Star" onclick="insert(this.form.message,':star'); return false;" />
<input type="image" src="smileys/blue.gif" alt="Sick" title="Sick" onclick="insert(this.form.message,':sick'); return false;" />
<input type="image" src="smileys/neutral.gif" alt="Neutral" title="Neutral" onclick="insert(this.form.message,':|'); return false;" />
<input type="image" src="smileys/tongue.gif" alt="Tongue" title="Tongue" onclick="insert(this.form.message,':P'); return false;" />
<input type="image" src="smileys/smile3.gif" alt="Smile other" title="Smile other" onclick="insert(this.form.message,':]'); return false;" />
<input type="image" src="smileys/saint.gif" alt="Saint" title="Saint" onclick="insert(this.form.message,':saint'); return false;" />
<input type="image" src="smileys/cool.gif" alt="Cool" title="Cool" onclick="insert(this.form.message,':cool'); return false;" />
<input type="image" src="smileys/heart.gif" alt="Heart" title="Heart" onclick="insert(this.form.message,':heart'); return false;" />
</td></tr><tr>
</td></tr><td></td><td><input type='submit' value='Send Mail'></td></tr></table></form>
EOF;
   	if ($_GET['ID']) {
           	echo "
<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']);
                   	echo "<tr><td>$sent</td> <td>[b]{$r['sender']} wrote:[/b] {$r['mail_text']}</td></tr>";
           	}
   	}
   	OUT;
}
function mail_send()
{
   	global $ir, $c, $userid, $h;
   	$subj   = str_replace(array(
           	"\n"
   	), array(
           	"
"
   	), strip_tags($_POST['subject']));
   	$msg	= bb2html($_POST['message']);
   	$codes  = array(
           	":)",
           	";)",
           	":o",
           	":D",
           	":s",
           	":(",
           	":angry",
           	":bigwink",
           	":laugh",
           	":star",
           	":sick",
           	":|",
           	":P",
           	":]",
           	":saint",
           	":cool",
           	":heart"
   	);
   	$images = array(
           	"<img src=smilies/smile.gif>",
           	"<img src=smilies/wink.gif>",
           	"<img src=smilies/surprise.gif>",
           	"<imgsrc=smilies/teeth.gif>",
           	"<img src=smilies/confuse.gif>",
           	"<img src=smilies/frown.gif>",
           	"<imgsrc=smilies/angry.gif>",
           	"<img src=smilies/bigwink.gif>",
           	"<img src=smilies/laugh.gif>",
           	"<imgsrc=smilies/star.gif>",
           	"<img src=smilies/blue.gif>",
           	"<img src=smilies/neutral.gif>",
           	"<imgsrc=smilies/tongue.gif>",
           	"<img src=smilies/smile3.gif>",
           	"<img src=smilies/saint.gif>",
           	"<imgsrc=smilies/cool.gif>",
           	"<img src=smilies/heart.gif>"
   	);
   	$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());
   	echo "Mail has been sent!
&gt [url='mail.php']Return[/url]";
}
function mail_delete()
{
   	global $db, $ir, $c, $userid, $h;
   	$db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid");
   	echo "Mail deleted!
&gt [url='mail.php']Return[/url]";
}
$h->footer();
?> 

 

If you require me to post anything else, Let me know. Thank you!

Posted
(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']);
                       echo "<tr><td>$sent</td> <td>[b]{$r['sender']} wrote:[/b] {$r['mail_text']}</td></tr>";
               }
       }
       OUT;

Remove the OUT; (LINE: 161)

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...