Location: PHPKode > projects > WH Community > wh_community/inbox.php
<?php require('layout/header.php'); ?>

<div id="content_wrapper">
    <div class="content"><?php

        if(!isset($_SESSION['signed_in'])) {
        
		echo '<p class="false">' . $lang['just_for_users'] . '!</p>
              <p>' . $lang['you_need_to'] . ' <a href="signin.php">' . $lang['signin_s'] . '</a>.
              - ' . $lang['not_yet'] . ' <a href="signup.php">' . $lang['registered'] . '</a>?</p>';

		}else{

		echo '<table align="center" class="usertable">
		<tr>
			<td align="center"><ul class="usermenu">
				<li><a href="myprofile.php">' . $lang['my_profile'] . '</a></li>
				<li><a href="guestbook.php">' . $lang['guestbook'] . '</a></li>
				<li><a href="messagebox.php">' . $lang['messagebox'] . '</a></li>
				<li><a href="password.php">' . $lang['password'] . '</a></li>
				<li><a href="inbox.php">' . $lang['inbox'] . '</a></li>
				<li><a href="outbox.php">' . $lang['outbox'] . '</a></li>
				<li><a href="create_pm.php">' . $lang['m_newpm'] . '</a></li>
				<li><a href="mypostings.php">' . $lang['my_posts'] . '</a></li>
				<li><a href="infos.php">' . $lang['informations'] . '</a></li>
				<li><a href="todo.php">' . $lang['m_todo'] . '</a></li>
				<li><a href="news.php">' . $lang['news'] . '</a></li>
			</ul></td>
		</tr>
		<tr>
			<td><h1>' . $lang['inbox'] . '</h1></td>
		</tr>';
		
		echo '<tr><td>';
		
		$sql = mysql_query("SELECT m1.pm_id, m1.title, m1.timestamp, count(m2.pm_id) AS reps, users.user_id AS user_id, users.user_name FROM messages AS m1, messages AS m2,users WHERE ((m1.user1 = '" . (int)$_SESSION['user_id'] . "' AND m1.user1read = 'no' AND users.user_id = m1.user2) OR (m1.user2 = '" . (int)$_SESSION['user_id'] . "' AND m1.user2read = 'no' AND users.user_id = m1.user1)) AND m1.pm_id2 = '1' AND m2.pm_id = m1.pm_id GROUP BY m1.pm_id ORDER BY m1.pm_id DESC") OR die(mysql_error());
		
		echo '<a href="create_pm.php"><img src="images/new_pm.png" border="0" vspace="5" title="' . $lang['new_pm'] . '"></a> <a href="outbox.php"><img src="images/outbox.png" border="0" hspace="15" vspace="5" title="' . $lang['sent_pm'] . '"></a>
		      <br><br><strong>' . $lang['unread_messages'] . ' (' . intval(mysql_num_rows($sql)) . ')</strong>';
		
		echo '<table align="center" cellpadding="5" class="pmtable">
    		  <tr>
    		  <td width="20%"><span class="blue">' . $lang['by_b'] . '</span></td>
    		  <td width="55%"><span class="blue">' . $lang['subject'] . '</span></td>
    		  <td width="10%"><span class="blue">' . $lang['replies'] . '</span></td>
    		  <td width="15%"><span class="blue">' . $lang['date'] . '</span></td>
    		  </tr>';
		
		echo '<tr><td colspan="4"><div id="pm_line">&nbsp;</div></td></tr>';
		
			while($row = mysql_fetch_array($sql)) {
			
    			$answer = $row['reps'] - 1;
    			
    			echo '<tr>
    			      <td width="20%"><a href="profile.php?user_id=' . (int)$row['user_id'] . '">' . htmlentities($row['user_name'], ENT_QUOTES) . '</a></td>
    			      <td width="55%"><a href="read_pm.php?user_id=' . (int)$_SESSION['user_id'] . '&pm_id=' . (int)$row['pm_id'] . '">' . htmlentities($row['title'], ENT_QUOTES) . '</a></td>
    			      <td width="10%">' . (int)$answer . '</td>
    			      <td width="15%">';
                
                      if($language == "de") {
                          echo date('d.m.Y - H:i', $row['timestamp']);
        
                      }elseif($language == "en") {
                          echo date('Y-m-d - H:i', $row['timestamp']); }
                
                echo '</td></tr>';
    			}
		
		if(intval(mysql_num_rows($sql)) == 0) {
		
		echo '<tr>
		      <td colspan="4"><span class="false">' . $lang['no_unread_messages'] . '</span></td>
		      </tr>';
		      }

		$query = mysql_query("SELECT m1.pm_id, m1.title, m1.timestamp, count(m2.pm_id) AS reps, users.user_id AS user_id, users.user_name FROM messages AS m1, messages AS m2,users WHERE ((m1.user1 = '" . (int)$_SESSION['user_id'] . "' AND m1.user1read = 'yes' AND users.user_id = m1.user2) OR (m1.user2 = '" . (int)$_SESSION['user_id'] . "' AND m1.user2read = 'yes' AND users.user_id = m1.user1)) AND m1.pm_id2 = '1' AND m2.pm_id = m1.pm_id GROUP BY m1.pm_id ORDER BY m1.pm_id DESC") OR die(mysql_error());
		
		echo '</table><br>';
		
		echo '<br><strong>' . $lang['readed_messages'] . ' (' . intval(mysql_num_rows($query)) . ')</strong>
    		  <table align="center" cellpadding="5" class="pmtable">
    		  <tr>
    		  <td width="20%"><span class="blue">' . $lang['by_b'] . ' / ' . $lang['to'] . '</span></td>
    		  <td width="55%"><span class="blue">' . $lang['subject'] . '</span></td>
    		  <td width="10%"><span class="blue">' . $lang['replies'] . '</span></td>
    		  <td width="15%"><span class="blue">' . $lang['date'] . '</span></td>
    		  </tr>';
		
		echo '<tr>
		      <td colspan="4"><div id="pm_line">&nbsp;</div></td>
		      </tr>';
		
			while($pm_row = mysql_fetch_assoc($query)) {
			
			$answer2 = $pm_row['reps'] - 1;
			
			echo '<tr>
			      <td width="20%"><a href="profile.php?user_id=' . (int)$pm_row['user_id'] . '">' . htmlentities($pm_row['user_name'], ENT_QUOTES) . '</a></td>
			      <td width="55%"><a href="read_pm.php?user_id=' . (int)$_SESSION['user_id'] . '&pm_id=' . (int)$pm_row['pm_id'] . '">' . htmlentities($pm_row['title'], ENT_QUOTES) . '</a></td>
			      <td width="10%">' . (int)$answer2 . '</td>
			      <td width="15%">';
            
                  if($language == "de") {
                      echo date('d.m.Y - H:i', $pm_row['timestamp']);
    
                  }elseif($language == "en") {
                      echo date('Y-m-d - H:i', $pm_row['timestamp']); }
            
            echo '</td></tr>';
			}
		
		if(intval(mysql_num_rows($query)) == 0) {
		
		echo '<tr>
		      <td colspan="4"><span class="false">' . $lang['no_unread_messages'] . '</span></td>
		      </tr>';
		      }
		}
		
		echo '</table></td></tr>
		      </table>';
		
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community