Jump to content
MakeWebGames

[mccode] mailbox with smilies


spellbyte ®

Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Re: [mccode] mailbox with smilies

I added this to my game and everything seems to be working fine other than when you send the mail all you see is the code is there a way for the smileys to show when you recieve the mail other than is saying ie: :cool?

Link to comment
Share on other sites

Re: [mccode] mailbox with smilies

<?php

/*

-----------------------------------------------------------------------

-- Ajax Mailbox Script

-- © 2006 Dabomstew

-----------------------------------------------------------------------

-- This script is distributed in the hope that

-- it will be useful, but WITHOUT A WARRANTY

-- OF ANY KIND.

-----------------------------------------------------------------------

-- Dabomstew, DBS-Network.net, and

-- everyone else involved with this script do not

-- take any liability for damage done to your game

-- by the use of this script.

-----------------------------------------------------------------------

*/

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.

 

Reason: {$ir['mb_reason']}</font>");

}

$http= $_SERVER['HTTP_HOST']; //we grab game's domain name!

?>

<script language="javascript" type="text/javascript">

function my_getbyid(special)

{

return document.getElementById(special);

}

var url = "ajaxmail.php?PHPSESSID=<?php print $_REQUEST["PHPSESSID"]; ?>&param="; // The server-side script

function handleHttpResponse() { if (http.readyState == 4) { // Split the comma delimited response into an array

results = http.responseText.split("<split>");

document.getElementById(results[1]).innerHTML=results[0]; } }

function showMail(mail_id) {

itm = my_getbyid("div_mail_"+mail_id);

itmer = my_getbyid("indicator_"+mail_id);

if (itmer.src == "http://<?php print $http; ?>/minus.gif")

{

document.getElementById("indicator_"+mail_id).src="http://<?php print $http; ?>/plus.gif";

document.getElementById("div_mail_"+mail_id).style.display="none";

}

else

{

document.getElementById("indicator_"+mail_id).src="http://<?php print $http; ?>/minus.gif";

document.getElementById("div_mail_"+mail_id).style.display="";

document.getElementById("div_mail_"+mail_id).innerHTML="Loading....";

}

if(itm.style.display=="")

{

var zipValue = mail_id;

http.open("GET", url + escape(zipValue), true);

http.onreadystatechange = handleHttpResponse;

http.send(null);

}

}

function getHTTPObject() {

var xmlhttp;

/*@cc_on

@if (@_jscript_version >= 5)

try {

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

try {

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {

xmlhttp = false;

}

}

@else

xmlhttp = false;

@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

try {

xmlhttp = new XMLHttpRequest();

} catch (e) {

xmlhttp = false;

}

}

return xmlhttp;

}

var http = getHTTPObject(); // We create the HTTP Object

</script>

<?

$_GET['ID'] = abs((int) $_GET['ID']);

print "<table width=75% border=2><tr><td>Inbox</td> <td>Sent Messages</td> <td>Compose Message</td> <td> Messages</td> <td>Archive Messages</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 $ir,$c,$userid,$h, $http;

print "Only the last 25 messages sent to you are visible.

<table width='95%' border=2><tr class='headercolor'><th>From</th><th>Subject/Message</th></tr>";

$q=mysql_query("SELECT m.mail_subject,m.mail_to,m.mail_from,m.mail_id,m.mail_time,m.mail_read, 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 "{$r['username']} [{$r['userid']}]";

}

else

{

print "SYSTEM";

}

$fm=urlencode($r['mail_id']);

if(!$r['mail_subject']) { $r['mail_subject'] = "No Subject"; }

if(!$r['mail_read']) { $ur="

New!"; } else { $ur=""; }

print "$ur</td>\n<td>{$r['mail_subject']}, Sent at: $sent

(Reply |

[/url] |

Report)</td><td><a onClick='showMail({$r['mail_id']})'>plus.gif</a></td></tr>

<tr><td colspan='3'><div id='div_mail_{$r['mail_id']}' style='display: none;'></div></td></tr>";

}

print "</table>";

}

function mail_outbox()

{

global $ir,$c,$userid,$h, $http;

print "Only the last 25 messages you have sent are visible.

 

<table width=75% border=2><tr class='headercolor'><th>To</th><th>Subject/Message</th><th></th></tr>";

$q=mysql_query("SELECT m.mail_id,m.mail_from,m.mail_to,m.mail_time,m.mail_subject,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))

{

if(!$r['mail_subject']) { $r['mail_subject'] = "No Subject"; }

$sent=date('F j, Y, g:i:s a',$r['mail_time']);

print "<tr><td>{$r['username']} [{$r['userid']}]</td><td>{$r['mail_subject']}, Sent at: $sent</td><td><a onClick='showMail({$r['mail_id']})'>plus.gif</a></td></tr>

<tr><td colspan='3'><div id='div_mail_{$r['mail_id']}' style='display: none;'></div></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>

smiley1.gif = :) smiley2.gif = ;) smiley3.gif = :o smiley4.gif = :D smiley5.gif = :s

smiley6.gif = :( smiley7.gif = :red smiley8.gif = :roll smiley9.gif = :x smiley10.gif = :green

smiley11.gif = :| smiley12.gif = ;( smiley13.gif = :] smiley14.gif = :horny smiley15.gif = :cool</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>Your last 5 mails to/from this person:</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>{$r['sender']} wrote: {$r['mail_text']}</td></tr>";

}

print "</table>";

}

}

function mail_send()

{

global $ir,$c,$userid,$h;

$subj=str_replace(array("'","\n"),array("''","

"),htmlentities($_POST['subject']));

$msg=str_replace(array("\n"),array("

"),htmlentities($_POST['message']));

$to= (int) $_POST['userid'];

if (eregi("(http://)|(com)|(.net)|(.org)|(.info)|(.co.uk)|(www.)", $subj)) {

die ("Quit sending off site links asshole, no one cares about your game");

}

else if (eregi("(http://)|(com)|(.net)|(.org)|(.info)|(.co.uk)|(www.)", $msg)) {

die ("Quit sending off site links asshole, no one cares about your game");

} else {

 

mysql_query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$msg')",$c) or die(mysql_error());

print "Message sent.

 

> Back";

}

}

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.

 

> Back";

}

function mail_delall()

{

global $ir,$c,$userid,$h;

print "This will delete all the messages in your inbox.

 

There is NO undo, so be sure.

 

> Yes, delete all messages

 

> No, go back";

}

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.

 

> Back";

}

function mail_archive()

{

global $ir,$c,$userid,$h;

print "This tool will download an archive of all your messages.

 

> Download Inbox

 

> Download Outbox";

}

$h->endpage();

?>

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
  • 4 months later...
  • 3 weeks later...

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