DeathStar Posted March 21, 2007 Share Posted March 21, 2007 Hi there I managed to get the colapse working but.. I can close the thing alone. See for an example www.Gangsterterritory.com username:test password:death here is my code: <?php /*---Mailbox v1.0 BETA -- mailbox.php -----------------------------------------------------*/ 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']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); if($ir['mailban']) { die("<font color=red><h3>! ERROR</h3> You have been mail banned for {$ir['mailban']} days.<br /> <br /> <b>Reason: {$ir['mb_reason']}</font></b>"); } $_GET['ID'] = abs((int) $_GET['ID']); print " <script language='JavaScript' type='text/javascript'><!-- // --><![CDATA[ var current_header = false; function shrinkHeader(mode) { document.getElementById('upshrinkHeader').style.display = mode ? 'none' : ''; document.getElementById('upshrinkHeader2').style.display = mode ? 'none' : ''; current_header = mode; } // ]]></script> <script language='JavaScript' type='text/javascript'><!-- // --><![CDATA[ var current_header_ic = false; function shrinkHeaderIC(mode) { document.getElementById('upshrinkHeaderIC').style.display = mode ? 'none' : ''; current_header_ic = mode; } // ]]></script> <table width=75% border=2><tr><td><a href='mailbox.php?action=inbox'>Inbox</a></td> <td><a href='mailbox.php?action=outbox'>Sent Messages</a></td> <td><a href='mailbox.php?action=compose'>Compose Message</a></td> <td><a href='mailbox.php?action=delall'>Delete All Messages</a></td> <td><a href='mailbox.php?action=archive'>Archive Messages</a></td></tr> </table><br />"; 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; print "Only the last 25 messages sent to you are visible.<br /> <table width=75% border=2><tr style='background:silver'><th>Mail</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 " <table width='100%' cellpadding='0' cellspacing='0' border='0'> <tr height='32'> <td width='2%' align='left' bgcolor='#666666'><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]"; } else { print " <table width='100%' cellpadding='0' cellspacing='0' border='0'> <tr height='32'> <td width='2%' align='left' bgcolor='#666666'>SYSTEM"; } $fm=urlencode($r['mail_text']); print "</td> <td width='67%' align='center' bgcolor='#666666'>"; if ($r['mail_subject']){ print "{$r['mail_subject']}";} else { print "No subject";} print "</td> <td width='10%' align='right' bgcolor='#666666'><a href='#' onclick='shrinkHeader(!current_header); return false;'>Read</a></td> </tr> <tr id='upshrinkHeader' hight='80'><td width='20%' valign='middle' bgcolor='#CCCCCC'>"; if ($r['display_pic']){ print "<img src='{$r['display_pic']}' hight='50' width='50'>";} else { print "<img src='nopic.jpg' hight='50' width='50'>";} print "<br>"; if($r['laston'] >= time()-15*60) { print "<font color=green>Online</font>"; } else { print"<font color=red>Offline</font>"; } print "</td> <td width='60%' colspan='2' valign='top' align='center' bgcolor='#CCCCCC'>{$r['mail_text']}</td> </tr> </table> <table id='upshrinkHeader2' width='100%' cellpadding='4' cellspacing='0' border='0'> <tr> <td width='20%' bgcolor='#666666'>Details of Message: </td><td width='40%' bgcolor='#666666'><a href='mailbox.php?action=compose&ID={$r['userid']}'>Reply</a> <a href='mailbox.php?action=delete&ID={$r['mail_id']}'>Delete</a> <a href='preport.php?ID={$r['userid']}&report=Fradulent mail: {$fm}'>Report</a></td> <td width='40%' align='right' valign='top' nowrap='nowrap' bgcolor='#666666'> Sent at: $sent<</td> </tr> </table> </div>"; } 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.<br /> <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><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>"; } } 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 "<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>"; } print "</table>"; } } function mail_send() { global $ir,$c,$userid,$h; $subj=str_replace(array("\n"),array("<br />"),strip_tags($_POST['subject'])); $msg=str_replace(array("\n"),array("<br />"),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()); print "Message sent.<br /> <a href='mailbox.php'>> Back</a>"; } 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.<br /> <a href='mailbox.php'>> Back</a>"; } 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 $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.<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>"; } $h->endpage(); ?> Link to comment https://forums.phpfreaks.com/topic/43593-colapse-tabel/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.