Location: PHPKode > scripts > WH Social > wh_social/read.php
<?php require('framework/session.php'); ?>
<?php require('framework/ready.php'); ?>
<?php require('style/layout/header.php'); ?>

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

    <?php

        echo '<div class="content_left">
        <div id="breadcrumb">
            <ul class="crumbs">
                <li class="first"><a href="index.php" style="z-index:9;"><span></span>' . $lang['index'] . '</a></li>
                <li><a href="messages.php" style="z-index:8;">' . $lang['messages'] . '</a></li>
                <li><a href="read.php?id= ' . intval($_GET['id']) . '" style="z-index:7;">' . $lang['read_message'] . '</a></li>
            </ul>
        </div>
        </div>

        <div class="content_right">';

            include('modules/search.inc.php');
        echo '</div>

        <div class="clear_long"></div>';

        $ret = 1;

        echo '<div class="main_menu">';

            $ret = include 'framework/templates/'.$main_content['menu'];
        echo '<div id="line"></div>';

            $ret = include 'framework/templates/'.$main_content['infos'];
        echo '</div>';

        echo '<div class="main_content">';

		echo '<h1 class="p_space">' . $lang['read_message'] . '</h1>';

		if((isset($_GET['id'])) && (is_numeric($_GET['id']))) {

		$id = mysql_real_escape_string($_GET['id']);
		$id = intval($_GET['id']);

			}else{

			echo '<p class="false">' . $lang['invalid_id'] . '</p>';
			exit();
			}

		$sql = mysql_query("SELECT * FROM messages WHERE msg = '" . $id . "' AND assign = '1'") OR die(mysql_error());
		$row = mysql_fetch_assoc($sql);

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

		if($row['user1'] == (int)$_SESSION['id'] OR $row['user2'] == (int)$_SESSION['id']) {
		if($row['user1'] == (int)$_SESSION['id']) {

		mysql_query("UPDATE messages SET user1read = 'yes' WHERE msg = '" . $id . "' AND assign = '1'");
		$user_partic = 2;

    		}else{

    		mysql_query("UPDATE messages SET user2read = 'yes' WHERE msg = '" . $id . "' AND assign = '1'");
    		$user_partic = 1;
    		}
        }

		$query = mysql_query("SELECT messages.date, messages.content, members.id AS id, members.name FROM messages, members WHERE messages.msg = '" . $id . "' AND members.id = messages.user1 ORDER BY messages.assign") OR die(mysql_error());

		if(isset($_POST['content']) AND $_POST['content']!='') {

        $content = mysql_real_escape_string($_POST['content']);

		if(mysql_query("INSERT INTO messages (msg, assign, title, user1, user2, content, date, user1read, user2read) VALUES('" . $id . "', '" . (intval(mysql_num_rows($query))+1) . "', '', '" . (int)$_SESSION['id'] . "', '', '" . $content . "', NOW(), '', '')") AND mysql_query("UPDATE messages SET user" . $user_partic . "read = 'yes' WHERE msg = '" . $id . "' AND assign = '1'")) {

		echo '<p class="success">' . $lang['message_sent_successfully'] . '</p>
		<p><a href="read.php?id=' . $id . '">' . $lang['go_to_discussion'] . '</a></p>';

			}else{

			echo '<p class="false">' . $lang['message_not_sent'] . '</p>
			<p><a href="read.php?id=' . $id . '">' . $lang['back_to_discussion'] . '</a></p>';
			}

		}else{

		echo '<p><span class="blue_span">&raquo; ' . htmlentities($row['title'], ENT_QUOTES) . '</span></p>';

		while($pm_row = mysql_fetch_assoc($query)) {

            include_once('framework/filter.php');
            include_once('framework/functions/badwords.php');
            include_once('framework/functions/smileys.php');

            echo '<table width="100%" class="tables">
            <tr>
            <td width="15%"><strong>' . $lang['by'] . '</strong></td>
            <td width="85%"><a href="member.php?id=' . (int)$pm_row['id'] . '">' . htmlentities($pm_row['name'], ENT_QUOTES) . '</a></td>
            </tr>
            <tr>
            <td width="15%"><strong>' . $lang['date'] . '</strong></td>
            <td width="85%"><small>' . date('d.m.Y - H:i', strtotime($pm_row['date'])) . ' ' . $lang['o_clock'] . '</small></td>
            </tr>
            <tr>
            <td width="15%" valign="top"><strong>' . $lang['message'] . '</strong></td>
            <td width="85%" valign="top">' . mysql_filter(filter_html(badwords(smileys(stripslashes(nl2br($pm_row['content'])))))) . '</td>
            </tr>
            </table>

            <div class="head_spacer"></div>';
            }

        echo '<div class="clear_long"></div>';

		echo '<h1>' . $lang['to_reply'] . '</h1>
		<form action="read.php?id=' . (int)$_SESSION['id'] . '&id=' . $id . '" method="post" name="content">
        <textarea cols="45" rows="8" name="content" id="content" class="textareas"></textarea>
        <p><input type="submit" name="submit" value="' . $lang['to_reply'] . '" alt="' . $lang['to_reply'] . '" class="buttons"></p>
        </form>';
        }

			}else{

			echo '<p class="false">' . $lang['invalid_id'] . '</p>
			<p><a href="messages.php">' . $lang['back'] . '</a></p>';
			}

	?>

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