<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: readpmsg.php,v 1.12.2.15 2004/04/18 12:45:44 ajvwaay Exp $




/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)            */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* =========================                                            */
/* Part of phpBB integration                                            */
/* Copyright (c) 2001 by                                                */
/*    Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)         */
/*    Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)                 */
/* http://www.phpnuke.web.id                                            */
/*                                                                      */
/* 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.       */
/************************************************************************/

if ( ! _MPN_USER ) { $_SERVER['F_LIB'] -> redirectRequest( 'user.php' ); }

$index = 2;

@( include_once __ROOT__ . 'core_ForumEntry.php' )
  OR goBack( translate( 'Include Error' ) );

$order = ( ! isset( $_REQUEST['order'] ) ) ? ( 'DESC' ) : ( $_REQUEST['order'] );
$start = ( ! isset( $_REQUEST['start'] ) ) ? ( 0 ) : ( $_REQUEST['start'] );

$sql = 'SELECT *
        FROM ' . $mpnTables['priv_msgs'] . '
        WHERE to_userid = ' . $GLOBALS['uinf']['uid'] . '
        ORDER BY msg_id ' . $order . '
        LIMIT ' . $start . ',1';

@( $result = mysql_query( $sql ) )
  OR goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );

$myrow = @mysql_fetch_array( $result );
$chkresult = ( ! empty( $myrow ) && is_array( $myrow ) );

if ( $chkresult )
{
    $posterdata = getPosterData( $myrow['msg_id'], $myrow['from_userid'] );

    if ( $posterdata['uid'] < -1 || ! is_array( $posterdata ) )
    {
        if ( _MPN_ADMIN )
        {
             $myrow['msg_text'] .= getAdminWarning( $myrow['from_userid'] );
        }

        if ( ! _UM_SHOW_DELETED_USERS_CONTENT_ && ! _MPN_ADMIN )
        {
            unset( $myrow, $posterdata );
            $chkresult = (bool)FALSE;
        }
    }
}

if ( $chkresult )
{

    $sql = "UPDATE ".$mpnTables['priv_msgs']." SET read_msg='1' WHERE msg_id='" . $myrow['msg_id'] . "'";

    $result = mysql_query($sql);

    if (!$result)
    {
        echo mysql_error() . "<br>";
        forumerror('0005');
    }
}

@( include_once __ROOT__ . 'header.php' )
  OR goBack( translate( 'Include Error' ) );

echo '<h1>' . translate ( 'Viewing Private Message' ) . '</h1>' . "\n";
echo '<h2><i>' . $myrow["subject"] . '</i><br />' . "\n";
echo translate( 'From' ) . ' : <i>' . $posterdata['uname'] . '</i></h2>' . "\n";

echo '<table class="simpleborders" summary="reading private message"><tr>' . "\n";

if ( ! $chkresult )
{
    echo "<TD BGCOLOR=\"$bgcolor3\" colspan=2 ALIGN=\"CENTER\">" . translate("You don't have any private messages") . "</TD></TR> ";
}
else
{
    $msg_time = getDisplayTime( $myrow['msg_time'], 'forumdatestring2' );

    echo "<TR BGCOLOR=\"$bgcolor3\" ALIGN=\"LEFT\">\n";

   // $posterdata = getPosterData( NULL, $myrow['from_userid'] );

    echo "<TD WIDTH='20%' valign='top'><b>" . $posterdata["uname"] . "</b><br>\n";
    $posts = $posterdata["posts"];

    echo "<br><font size=-2>" . translate("Posts:") . " $posts<br>\n";
    echo translate("From:") . $posterdata["user_from"] . "<br></FONT><br>\n";
    if ($posterdata["user_avatar"] != '')
            echo "<img src='images/forum/avatar/" . $posterdata["user_avatar"] . "' Alt=\"\">\n";
    echo "</TD><TD><img src=\"images/forum/subject/" . $myrow["msg_image"] . "\" Alt=\"\">&nbsp;<font size=-1>". translate("Sent:")." $msg_time";
    echo "<HR></font><b>" . $myrow["subject"] . "</b><br><br>\n";

    $message = stripslashes( $myrow["msg_text"] );

    $_SERVER['SAN'] -> formatPost( $message, $posterdata['user_sig'] );

    echo "<div class='bbcode_msg'>$message</div>\n";
    echo "<br /><br />";

    echo "<HR>\n";
    echo "&nbsp;&nbsp<a href=\"user.$phpEx?op=userinfo&uname=" . $posterdata["uname"] . "\"><img src=\"images/forum/icons/profile.gif\" border=0 Alt=\"\"></a><FONT SIZE=1>" . translate("Profile") . "</FONT>\n";
    if($posterdata["femail"] != 0)
            echo "&nbsp;&nbsp;<a href=\"mailto:" . $posterdata["femail"] . "\"><IMG SRC=\"images/forum/icons/email.gif\" BORDER=0 Alt=\"\"></a><FONT SIZE=1>" . translate("Email") . "</FONT>\n";
    if($posterdata["url"] != '') {
            if(strstr("http://", $posterdata["url"]))
                    $posterdata["url"] = "http://" . $posterdata["url"];
            echo "&nbsp;&nbsp;<a href=\"" . $posterdata["url"] . "\" TARGET=\"_blank\"><IMG SRC=\"images/forum/icons/www_icon.gif\" BORDER=0 Alt=\"\"></a><FONT SIZE=1>www</FONT>\n";
    }
    if($posterdata["user_icq"] != '')
            echo "&nbsp;&nbsp;<a href=\"http://wwp.mirabilis.com/" . $posterdata["user_icq"] . "\" TARGET=\"_blank\"><IMG SRC=\"http://wwp.icq.com/scripts/online.dll?icq=" . $posterdata["user_icq"] . "&img=5\" BORDER=0\" Alt=\"\"></a>";

    if($posterdata["user_aim"] != '')
                 echo "&nbsp;<a href=\"aim:goim?screenname=" . $posterdata["user_aim"] . "&message=Hi+" . $posterdata["user_aim"] . ".+Are+you+there?\"><img src=\"images/forum/icons/aim.gif\" border=\"0\" Alt=\"\"></a><FONT SIZE=1>aim</FONT>";

       if($posterdata["user_yim"] != '')
                 echo "&nbsp;<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=" . $posterdata["user_yim"] . "&.src=pg\"><img src=\"images/forum/icons/yim.gif\" border=\"0\" Alt=\"\"></a>";

       if($posterdata["user_msnm"] != '')
                 echo "&nbsp;<a href=\"bb_profile.$phpEx?userid=" . $posterdata["uid"] . "\"><img src=\"images/forum/icons/msnm.gif\" border=\"0\" Alt=\"\"></a>";

    echo "</TD></TR>";
    echo "<TR BGCOLOR=\"$bgcolor1\" ALIGN=\"RIGHT\"><TD width='20%' COLSPAN=2 ALIGN=RIGHT><FONT COLOR=\"$textcolor2\" SIZE=1>";

    $previous = $start-1;
    $next = $start+1;

    if ($previous >= 0) echo "<a href='readpmsg.$phpEx?start=$previous&total_messages=$total_messages&order=$order'>" . translate("Previous Messages") . "</a> | ";
    else echo translate("Previous Messages") . " | ";
    if ($next < $total_messages) echo "<a href='readpmsg.$phpEx?start=$next&total_messages=$total_messages&order=$order'>" . translate("Next Messages") . "</a></FONT>";
    else echo translate("Next Messages") . "</FONT>";

    echo "</TD></TR>";
    //echo "<TR BGCOLOR=\"$bgcolor2\" ALIGN=\"LEFT\"><TD width='20%' COLSPAN=2 ALIGN=LEFT>";
    echo "<tr><td class='center' colspan='2'>\n";

    echo '<p class="row center"><br />' . "\n";

    echo "<span class=\"button\"><a href=\"replypmsg.php?reply=1&amp;msg_id=" . $myrow["msg_id"] . "\" title=\"" . translate( 'Reply' ) . "\">" . translate( 'Reply' ) . "</a></span>";

    echo "<span class=\"button\"><a href=\"replypmsg.php?reply=1&amp;qmsg=1&amp;msg_id=" . $myrow["msg_id"] . "\" title=\"" . translate( 'Quote &amp; Reply' ) . "\">" . translate( 'Quote &amp; Reply' ) . "</a></span>";

    echo "<span class=\"button\"><a href=\"replypmsg.php?delete=1&amp;msg_id=" . $myrow["msg_id"] . "\" title=\"" . translate( 'Delete' ) . "\">" . translate( 'Delete' ) . "</a></span>";

    echo '</p><br /><br />' . "\n";

    echo getForumNav();
}

echo "</td></tr></table>";

@( include_once __ROOT__ . 'footer.php' )
  OR goBack( translate( 'Include Error' ) );

?>
