Location: PHPKode > projects > Open ShareLive > F3-OSL-pre_alpha-2005_05_30/messagecentre.php
<?php
/******************************************************************************
*
*    Open ShareLive (main site code)
*    Copyright (C) 2002-2005  ShareLive
*
*    This program is free software; you can redistribute it and/or
*    modify it under the terms of the GNU General Public License
*    as published by the Free Software Foundation; either version 2
*    of the License, or (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
******************************************************************************/

	// Message Archive
	
	require('Connections/Default.php');
	require('backend/usermgr_functions.php');
	
	if (!QuickCheck()) {
		echo "no permission";
		exit();
	}
	
	if (!$_GET['folder']) $_GET['folder'] = 'rec';
	
	function GetInactiveRow($id, $date, $from, $msg) {

	?>
	
<tr>
    <td width="17" bgcolor="#E7EEF7"><a href="messagecentre.php?expand=<?php echo $id ?>&folder=<?php echo $_GET['folder']; ?>"><img src="images/mar/right_arrow.gif" width="17" height="20" border="0" alt="&gt;" title="Display Full Message"></a></td>
    <td width="1" bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="134" bgcolor="#E7EEF7" class="smallprint">&nbsp;<?php echo $date ?></td>
    <td width="1" bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="95" bgcolor="#E7EEF7" class="smallprint">&nbsp;<a href="javascript:window.open('newmsg.php?user=<?php echo $from ?>','swim','width=444, height=356, resizable=no'); void(0);"><?php echo $from ?></a></td>
    <td width="1" bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="351" bgcolor="#E7EEF7" class="smallprint">&nbsp;<?php echo $msg ?></td>
  </tr>
	<?php
	}
	function GetActiveRow($id, $date, $from, $msg) {
	?>
<tr>
    <td width="17" valign="top" bgcolor="#FFFFFF"><a href="messagecentre.php?folder=<?php echo $_GET['folder'] ?>"><img src="images/mar/arrow_expanded.gif" width="17" height="20" border="0"  alt="v" title="Close Message"></a></td>
    <td width="1" bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="134" valign="top" bgcolor="#FFFFFF" class="smallprint">    <table width="100%" height="20" border="0" cellpadding="3" cellspacing="0" class="smallprint">
      <tr>
        <td><?php echo $date ?></td>
      </tr>
    </table></td>
    <td width="1" bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="95" valign="top" bgcolor="#FFFFFF" class="smallprint"><table width="100%" height="20" border="0" cellpadding="3" cellspacing="0" class="smallprint">
      <tr>
        <td><a href="javascript:window.open('newmsg.php?user=<?php echo $from ?>','swim','width=444, height=356, resizable=no'); void(0);"><?php echo $from ?></a></td>
      </tr>
    </table></td>
    <td width="1"  bgcolor="#C9CFD7"><img src="spacer.gif" width="1" height="1"></td>
    <td width="351" align="left" valign="top" bgcolor="#FFFFFF" class="smallprint"><table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr>
        <td align="left" valign="top" class="bodytext"><?php echo $msg ?></td>
      </tr>
    </table></td>
  </tr>	
	<?php
	}
	
	
?>
<html>
<head>
<title>Personal Message Archive</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="sl_theme_proz.css" rel="stylesheet" type="text/css">
</head>
<style type="text/css">
	form { margin: 0; }
</style>
<body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#FF6600" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="images/mar/<?php echo $_GET['folder'] ?>.gif" alt="Message Archive" width="600" height="83"></td>
      </tr>
    </table>
      <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
        <?php
  	
	$im = $dbprefix . 'wim';
	$us = $dbprefix . 'users';
	
	global $is_super_admin;
	
  	if (($_GET['folder'] == 'all' && $is_super_admin)) {	
		$q = mysql_query("SELECT *, $us.username FROM $im INNER JOIN $us ON ($im.from_id = $us.user_id) ORDER BY datetime DESC");
	} elseif ($_GET['folder'] == 'rec') {
		$q = mysql_query("SELECT *, $us.username FROM $im INNER JOIN $us ON ($im.from_id = $us.user_id) WHERE to_id = $userid ORDER BY datetime DESC");
	} elseif ($_GET['folder'] == 'sent') {
		$q = mysql_query("SELECT *, $us.username FROM $im INNER JOIN $us ON ($im.to_id = $us.user_id) WHERE from_id = $userid ORDER BY datetime DESC");
	}
	//echo "SELECT * FROM ".$dbprefix."wim WHERE to_id = $userid";
	if ($q && mysql_num_rows($q)) {
		while ($row = mysql_fetch_array($q)) {
			if ($row['wid'] == $_GET['expand']) {
				// this is an active item
				GetActiveRow($row['wid'], date('d F Y H:i', $row['datetime']), $row['username'], $row['message']);					
			} else {
				$row['message'] = substr(strip_tags($row['message']), 0, 60) . '...';
				GetInactiveRow($row['wid'], date('d F Y H:i', $row['datetime']), $row['username'], $row['message']);	
			}
		}
	}
  ?>
      </table>
      <br>
      <br>
      <table width="360" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="154" class="bodytext"><div align="left">Change Current Folder</div>
          </td>
          <td width="246"><form name="form1" method="get" action="messagecentre.php">
              <div align="right">
                <select name="folder" id="folder">
                  <option value="rec"<?php if ($_GET['folder'] == 'rec') echo " selected"; ?>>&gt; Received Messages
                  <option value="sent"<?php if ($_GET['folder'] == 'sent') echo " selected"; ?>>&gt; Sent Messages
                </select>
                <input type="submit" name="Submit" value="Go">
              </div>
            </form>
          </td>
        </tr>
      </table>
      <p align="center" class="smallprint">ShareLive keeps a permanent copy of
        all messages sent/received using this service.<br>
  Code &amp; Design Copyright(c) 2003, Si. Please report bugs in the forum.<br>
&nbsp;  <br>
    </p></td>
  </tr>
</table>
</body>
</html>
Return current item: Open ShareLive