Jump to content
MakeWebGames

Recommended Posts

Posted

i have this mailbox, (code posted below)

what i would like it to do it have the option check all and uncheck all funtioning,

i've tried to edit this, tried a few javascripts and havent been able to get it to work

could someone help me with this problem

 

<?php
include "globals.php";
require "bbcodestyle.css";
require "bbcode.php";

global $db,$ir,$r,$c,$userid,$h;
$db->query("UPDATE users SET lastpage='Mailbox' WHERE userid=$userid");


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=100% class='table' cellspacing='1'>
<tr>
<td align=center><a href='mailbox.php?action=inbox'><img src='images/indox.gif'></a></td>
<td align=center><a href='mailbox.php?action=outbox'><img src='images/sent.gif'></a></td>
<td align=center><a href='mailbox.php?action=compose'><img src='images/compose.gif'></a></td>
<td align=center><a href='mailbox.php?action=delall'><img src='images/deleteall.gif'></a></td>
<td align=center><a href='mailbox.php?action=archive'><img src='images/archiveall.gif'></a></td>
<td align=center><a href='contactlist.php'><img src='images/contacts.gif'></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;

case 'delall':
mail_delall();
break;

case 'delall2':
mail_delall2();
break;

case 'archive':
mail_archive();
break;

case 'del':
mail_massdel();
break;

case 'read':
mail_view();
break;

default:
mail_inbox();
break;
}

function mail_inbox()
{
global $db,$ir,$c,$userid,$h;
print<<<END
<SCRIPT><!-- HIDE
function setCheckboxes(the_form, do_check) {
var elts = (typeof(document.forms[the_form].elements['ID[]']) != 'undefined')
? document.forms[the_form].elements['ID[]']
: (typeof(document.forms[the_form].elements['ID[]']) != 'undefined')
? document.forms[the_form].elements['ID[]']
: document.forms[the_form].elements['ID[]'];
var elts_cnt = (typeof(elts.length) != 'undefined')
? elts.length
: 0;
if (elts_cnt) {
for (var i = 0; i < elts_cnt; i++) {
elts[i].checked = do_check;
} // end for
} else {
elts.checked = do_check;
} // end if... else
return true;
}
// STOP HIDING --></SCRIPT>
END;
print <<<OUT
Only the last 25 messages sent to you are visible.

<table width=100% class=table cellspacing="1" border="1">
<tr>
<td class="h" align=center>From</td>
<td class="h" align=center>Subject</td>
<td class="h" align=center>Status</td>
<td class="h" align=center>Read</td>
<td class="h" align=center>Delete</td>
</tr>
<form name='masssell' method=post action=mailbox.php?action=del>
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");
$i=0;
while($r=$db->fetch_row($q))
{
print "<tr class=\"d".($i & 1)."\"><td align=center>";
$i++;
if($r['userid'])
{
print "<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]";
}
else
{
print "SYSTEM";
}
$fm=$r['mail_subject'];
if($r['mail_read'] == 0)
{
$status="<font color=red>Unread</font>";
}
else
{
$status="<font color=green>Read</font>";
}
print "
</td>
<td align=center>
$fm
</td>
<td align=center>
$status
</td>
<td align=center>
<a href='mailbox.php?action=read&ID={$r['mail_id']}'>Open</a>
</td>
<td align=center>
<a href='mailbox.php?action=delete&ID={$r['mail_id']}'>
<img src=images/trash.gif height=20 width=20 >
</a>


<input type='checkbox' name='del$i' value='yes'>
<input type='hidden' name='id$i' value='{$r['mail_id']}'>


</td></tr>";
}
print<<<END
<tr>
<td colspan=5 align=center>
<input name=sellmass type=submit id=sellmass value='Delete selected'>


<br />


<a href=# onClick="setCheckboxes('masssell',true); return false;'>Check All</a> | 
<a href=# onClick="setCheckboxes('masssell',false); return true;'>Uncheck All </a>



</form>


</td>
</tr>
</table>
END;
}









































function mail_outbox()
{
global $db,$ir,$c,$userid,$h; 
print "Only the last 25 messages you have sent are visible.<br />
<table width=75% cellspacing=1 class='table'><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");
if($r=$db->fetch_row($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print "<tr><td><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]</td><td>{$r['mail_subject']}</td></tr><tr><td>Sent at: $sent<br /></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>
<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>
<center>
<input type="button" class="bbcode_hover" onClick="insert(this.form.message,'[b][/b]'); return false;" value="" />
<input type="button" class="bbcode_hover1" onClick="insert(this.form.message,'[i][/i]'); return false;" value="" />
<input type="button" class="bbcode_hover2" onClick="insert(this.form.message,'[u][/u]'); return false;" value="" />
<input type="button" class="bbcode_hover3" onClick="insert(this.form.message,'[url][/url]'); return false;" value="" />
<input type="button" class="bbcode_hover4" onClick="insert(this.form.message,''); return false;" value="" />
<input type="button" class="bbcode_hover5" onClick="insert(this.form.message,'[img][/img]'); return false;" value="" />
<input type="button" class="bbcode_hover6" onClick="insert(this.form.message,''); return false;" value="" />
<input type="button" class="bbcode_hover7" onClick="insert(this.form.message,'[color=#xxxxxx][/color]'); return false;"

value="" />
<textarea name='message' rows='10' cols='70' style='color: black; background-color: white'></textarea><br />
<input type="image" src="smilies/smiley1.gif" alt="Smile" title="smile" onclick="insert(this.form.message,':)'); return false;" />
<input type="image" src="smilies/smiley2.gif" alt="Wink" title="Wink" onclick="insert(this.form.message,';)'); return false;" />
<input type="image" src="smilies/smiley3.gif" alt="Suprised" title="Suprised" onclick="insert(this.form.message,':o'); return false;" />
<input type="image" src="smilies/smiley4.gif" alt="Cheesy Grin" title="Cheesy Grin" onclick="insert(this.form.message,':D'); return false;" />
<input type="image" src="smilies/smiley5.gif" alt="Confused" title="Confused" onclick="insert(this.form.message,':s'); return false;" />
<input type="image" src="smilies/smiley6.gif" alt="Sad" title="Sad" onclick="insert(this.form.message,':('); return false;" />
<input type="image" src="smilies/smiley7.gif" alt="Angry" title="Angry" onclick="insert(this.form.message,':red'); return false;" />
<input type="image" src="smilies/smiley8.gif" alt="Clown" title="Clown" onclick="insert(this.form.message,':clown'); return false;" />
<input type="image" src="smilies/smiley9.gif" alt="Embarrassed" title="Embarrassed" onclick="insert(this.form.message,':bashful'); return false;" />
<input type="image" src="smilies/smiley10.gif" alt="Star" title="Star" onclick="insert(this.form.message,':x'); return false;" />
<input type="image" src="smilies/smiley11.gif" alt="Sick" title="Sick" onclick="insert(this.form.message,':green'); return false;" />
<input type="image" src="smilies/smiley12.gif" alt="Bored" title="Bored" onclick="insert(this.form.message,':|'); return false;" />
<input type="image" src="smilies/smiley13.gif" alt="Begging" title="Begging" onclick="insert(this.form.message,';('); return false;" />
<input type="image" src="smilies/smiley14.gif" alt="Smug" title="Smug" onclick="insert(this.form.message,':]'); return false;" />
<input type="image" src="smilies/smiley15.gif" alt="Horny" title="Horny" onclick="insert(this.form.message,':horny'); return false;" />
<input type="image" src="smilies/smiley16.gif" alt="Cool" title="Cool" onclick="insert(this.form.message,':cool'); return false;" /></center>
</td></tr><tr>
</td></tr><td colspan=2><input type='submit' value='Send' class='btn'></td></tr></table></form>
EOF;
if($_GET['ID'])
{
print "<br /><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>";
}
}
}

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

$msg=bb2html($_POST['message']);

$codes = array(":)", ";)", ":o", ":D", ":s", ":(", ":red", ":clown", ":bashful", ":x", ":green", ":|", ";(", ":]", ":horny", ":cool");
$images  = array("<img src=smilies/smiley1.gif>", "<img src=smilies/smiley2.gif>", "<img src=smilies/smiley3.gif>", "<img

src=smilies/smiley4.gif>", "<img src=smilies/smiley5.gif>", "<img src=smilies/smiley6.gif>", "<img

src=smilies/smiley7.gif>", "<img src=smilies/smiley8.gif>", "<img src=smilies/smiley9.gif>", "<img

src=smilies/smiley10.gif>", "<img src=smilies/smiley11.gif>", "<img src=smilies/smiley12.gif>", "<img

src=smilies/smiley13.gif>", "<img src=smilies/smiley14.gif>", "<img src=smilies/smiley15.gif>", "<img src=smilies/smiley16.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());
mysql_query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$to}")  or die(mysql_error()); 
print "Message sent.<br />
<a href='mailbox.php'>> Back</a>";
}

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.<br />
<a href='mailbox.php'>> Back</a>";
}














function mail_view()
{
global $db,$ir,$c,$userid,$h;
print <<<OUT
<table width=100% class="table" border="1" cellspacing="1">
<tr>
<td class="h" width=25%>From</td>
<td class="h" width=75%>Subject/Message</td>
</tr>
OUT;
$id= abs((int) $_GET['ID']);
$q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_id=$id LIMIT 1");
$r=$db->fetch_row($q);
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print "<tr><td>";
if($r['userid'])
{
print "<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]";
}
else
{
print "SYSTEM";
}
$fm=urlencode($r['mail_text']);
print "</td>\n<td>{$r['mail_subject']}</td></tr><tr><td>Sent at: $sent<br />
";
if($ir['mailban'] == 0)
{
print "<a href='mailbox.php?action=compose&ID={$r['userid']}'>Reply</a><br />
";
}
print "<a href='mailbox.php?action=delete&ID={$r['mail_id']}'>Delete</a><br />

<a href='preport.php?ID={$r['userid']}'>Report</a></td><td>{$r['mail_text']}</td></tr>";
if($r['mail_read'] == 0)
{
$db->query("UPDATE mail SET mail_read=1 WHERE mail_to=$userid AND mail_id=$id LIMIT 1");
$db->query("UPDATE users SET new_mail=new_mail-1 WHERE userid=$userid");
}
print "</table>";
}



function mail_delall()
{
global $ir,$c,$userid,$h;
print "This will delete all the messages in your inbox.<br />
There is <b>NO</b> undo, so be sure.<br />
<a href='mailbox.php?action=delall2'>> Yes, delete all messages</a><br />
<a href='mailbox.php'>> No, go back</a>";
}
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.<br />
<a href='mailbox.php'>> Back</a>";
}
function mail_archive()
{
global $ir,$c,$userid,$h;
print "This tool will download an archive of all your messages.<br />
<a href='dlarchive.php?a=inbox'>> Download Inbox</a><br />
<a href='dlarchive.php?a=outbox'>> Download Outbox</a>";
}

function mail_massdel()
{
global $db,$ir,$c,$userid,$h;
$counter = 1;
$deleted=0;
while ($counter < 25) {
$dodel = "del" . $counter;
if ($_POST[$dodel] == "yes") {
$delid = "id" . $counter;
$db->query("DELETE FROM mail WHERE mail_to=$userid AND mail_id={$_POST[$delid]}") or die(mysql_error());
$deleted++;
}
$counter++;
}
print "<center>

$deleted messages deleted.
<a href=mailbox.php>> Back</a>";
}
print "

Mail count mixed up? Click <a href='fix.php?fix=1'>Here</a> to fix";
$h->endpage();
?>

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