Location: PHPKode > scripts > WH Board > wh_board/inbox.php
<?php require('style/layout/header.php'); ?>

    <div class="content_left">
        <ul id="breadcrumbs">
            <li><a href="index.php"><?php echo $lang['main_page']; ?></a></li>
            <li><a href="myprofile.php"><?php echo $lang['user_area']; ?></a></li>
            <li><a href="inbox.php" class="actual"><?php $lang['inbox']; ?></a></li>
        </ul>
    </div>
    <div class="content_right"><form method="post" id="search" action="search.php?search">
        <input type="text" name="search" placeholder="<?php echo $lang['enter_search_term']; ?>..." class="searchfield">
        <input type="hidden" name="submit" value="<?php echo $lang['search']; ?>" alt="<?php echo $lang['search']; ?>">
        </form>
    </div>

    <div class="clear"></div>

    <div id="headline">&nbsp;</div>

    <?php

        if(!isset($_SESSION['signed_in'])) {

    	echo '<p class="false">' . $lang['only_for_registered'] . '</p>
        <p>' . $lang['you_have_to'] . ' <a href="signin.php">' . $lang['small_signin'] . '</a>. ' . $lang['not_yet'] . ' <a href="signup.php">' . $lang['registered'] . '</a>?</p>';

    	}else{

    	echo '<h1>' . $lang['inbox'] . '</h1>';

        echo '<a href="create_pm.php"><img src="style/images/notification/create_pm.png" border="0" title="' . $lang['new_pm'] . '"></a> <a href="outbox.php"><img src="style/images/notification/outbox.png" border="0" hspace="10" title="' . $lang['all_sendet_pms'] . '"></a>
        <div class="spacer"></div>';

    	$sql = mysql_query("SELECT m1.msg_id, m1.msg_title, m1.msg_date, count(m2.msg_id) AS reps, users.user_id AS user_id, users.user_name FROM messages AS m1, messages AS m2,users WHERE ((m1.msg_user1 = '" . (int)$_SESSION['user_id'] . "' AND m1.msg_user1read = 'no' AND users.user_id = m1.msg_user2) OR (m1.msg_user2 = '" . (int)$_SESSION['user_id'] . "' AND m1.msg_user2read = 'no' AND users.user_id = m1.msg_user1)) AND m1.msg_id2 = '1' AND m2.msg_id = m1.msg_id GROUP BY m1.msg_id ORDER BY m1.msg_id DESC") OR die(mysql_error());

        if(!$sql) {

		echo '<p class="false">' . $lang['no_unread_messages'] . '</p>';

			}else{

			if(intval(mysql_num_rows($sql)) == 0) {

			echo '<p class="false">' . $lang['no_unread_messages'] . '</p>';

		}else{

    	echo '<div class="clear_blog"></div>
        <span class="green">Ungelesene Nachrichten (' . intval(mysql_num_rows($sql)) . ')</span>';

    	echo '<table width="100%" class="tables">
        <tr>
        <td width="20%"><strong>' . $lang['by'] . '</strong></td>
        <td width="55%"><strong>' . $lang['subject'] . '</strong></td>
        <td width="10%"><strong>' . $lang['replies'] . '</strong></td>
        <td width="15%"><strong>' . $lang['date'] . '</strong></td>
        </tr>';

		while($row = mysql_fetch_assoc($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'] . '&msg_id=' . (int)$row['msg_id'] . '">' . htmlentities($row['msg_title'], ENT_QUOTES) . '</a></td>
            <td width="10%">' . $answer . '
            <td width="15%">' . date('d.m.Y - H:i', strtotime($row['msg_date'])) . '
            </tr>';
			}

    	echo '</table>';
    	}
        }

    	$query = mysql_query("SELECT m1.msg_id, m1.msg_title, m1.msg_date, count(m2.msg_id) AS reps, users.user_id AS user_id, users.user_name FROM messages AS m1, messages AS m2,users WHERE ((m1.msg_user1 = '" . (int)$_SESSION['user_id'] . "' AND m1.msg_user1read = 'yes' AND users.user_id = m1.msg_user2) OR (m1.msg_user2 = '" . (int)$_SESSION['user_id'] . "' AND m1.msg_user2read = 'yes' AND users.user_id = m1.msg_user1)) AND m1.msg_id2 = '1' AND m2.msg_id = m1.msg_id GROUP BY m1.msg_id ORDER BY m1.msg_id DESC") OR die(mysql_error());

        if(!$query) {

		echo '<p class="false">' . $lang['no_read_messages'] . '</p>';

			}else{

			if(intval(mysql_num_rows($query)) == 0) {

			echo '<p class="false">' . $lang['no_read_messages'] . '</p>';

		}else{

    	echo '<br><span class="green">Gelesene Nachrichten (' . intval(mysql_num_rows($query)) . ')</span>';

    	echo '<table width="100%" class="tables">
        <tr>
        <td width="20%"><strong>' . $lang['by'] . ' / ' . $lang['blank_to'] . '</strong></td>
        <td width="55%"><strong>' . $lang['subject'] . '</strong></td>
        <td width="10%"><strong>' . $lang['replies'] . '</strong></td>
        <td width="15%"><strong>' . $lang['date'] . '</strong></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'] . '&msg_id=' . (int)$pm_row['msg_id'] . '">' . htmlentities($pm_row['msg_title'], ENT_QUOTES) . '</a></td>
            <td width="10%">' . $answer2 . '</td>
            <td width="15%">' . date('d.m.Y - H:i', strtotime($pm_row['msg_date'])) . '</td>
            </tr>';
    		}

        echo '</table>';

        }}}

    ?>

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