Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Messages/readpmsg.php
<?php // File: $Id: readpmsg.php,v 1.17 2001/12/04 13:07:45 jgm Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file: Part of phpBB integration
//   Copyright (c) 2001 by
//   Richard Tirtadji AKA King Richard (hide@address.com)
//   Hutdik Hermawan AKA hotFix (hide@address.com)
//   http://www.phpnuke.web.id
// ----------------------------------------------------------------------
// Changelog
// yyyy-mm-dd  username  description
// 2001-11-21  eugeniobaldi    Fixed brosing more than 2 messages 
// ----------------------------------------------------------------------

if (!defined("LOADED_AS_MODULE")) {
         die ("You can't access this file directly...");
     }

$ModName = $GLOBALS['name'];

include 'mainfile.php';
include 'modules/'.$ModName.'/functions.php';

modules_get_language();

global $pntable, $dbconn;

$forumpage = 1;

//FTO : Remove Warning
if (!isset($db)) $db="";

if (!is_user($user)) {
    pnRedirect('user.php');
} else {
    include('header.php');
    $user = base64_decode($user);
    $userdata = explode(":", $user);
    if (!$result = check_user_pw($userdata[1],$userdata[2],$db,$system))
    $userdata = get_userdata($userdata[1], $db);
    $column = &$pntable['priv_msgs_column'];
// FTO the next line doesn't work correctly with Oracle and other database than MySQL
//    $sql = buildSimpleQuery ('priv_msgs', array ('msg_id', 'msg_image', 'subject', 'from_userid', 'to_userid', 'msg_time', 'msg_text', 'read_msg'), "$column[to_userid]=$userdata[uid]", '', 1, $start);
// FTO Use msgid to find message
    $sql = buildSimpleQuery ('priv_msgs', array ('msg_id', 'msg_image', 'subject', 'from_userid', 'to_userid', 'msg_time', 'msg_text', 'read_msg'), "$column[msg_id]=$msgid");
    $resultID = $dbconn->Execute($sql);
    if($dbconn->ErrorNo()<>0) {
        error_log("DB Error: " . $dbconn->ErrorMsg());
        echo $dbconn->ErrorMsg() . "<br>";
        forumerror(0005);
    }
//ADODBtag MoveNext ->fet_chrow(DB_FETCHMODE_ASSOC

    $myrow = $resultID->GetRowAssoc(false);

//FTO Remove Record count    $resultID->MoveNext();

    // Turn this time string into a UNIX timestamp for use with GetUserTime
    $myrow['msg_time'] = mktime( substr($myrow['msg_time'], 11, 2),     // hour
                                        substr($myrow['msg_time'], 14, 2),    // minute
                                        '0',                                // second
                                        substr($myrow['msg_time'], 5, 2),     // month
                                        substr($myrow['msg_time'], 8, 2),     // day
                                    substr($myrow['msg_time'], 0, 4));    // year

    $column = &$pntable['priv_msgs_column'];

//FTO Test it update necessary

    if ($myrow['msg_id'] != '1')
    {
      $sql = "UPDATE $pntable[priv_msgs]
            SET $column[read_msg]='1' 
            WHERE $column[msg_id]=$myrow[msg_id]";
      $result = $dbconn->Execute($sql);
      if($dbconn->ErrorNo()<>0) {
        error_log("DB Error: " . $dbconn->ErrorMsg());
        echo $dbconn->ErrorMsg() . "<br>";
        forumerror(0005);
        }
    }

    OpenTable();
    echo "<center><font class=\"pn-pagetitle\">"._PRIVATEMESSAGE."</font>
           <br>
	   <br>
	    <font class=\"pn-normal\">
	    <b>
	     <a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=index\">"._INDEX."</a>
	    </b></font>
	  </center>";
    CloseTable();
    echo "<br>"
    ."<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" valign=\"top\" width=\"100%\"><tr><td>"
    ."<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\">"
    ."<tr bgcolor=\"$bgcolor2\" align=\"left\">"
    ."<td width=\"20%\"><font class=\"pn-sub\"><b>"._FROM."</b></font></td>"
//FTO Use quote for index
    ."<td width=\"80%\"><font class=\"pn-sub\"><b>".$myrow['subject']."</b></font></td>"
    ."</tr>";

//FTO Do not use record count
//    if ($resultID->PO_Record Count() == 0) {
    if ($resultID->EOF) {
        echo "<td bgcolor=\"$bgcolor3\" colspan=\"2\" align=\"center\"><font class=\"pn-normal\">"._DONTHAVEMESSAGES."</font>
          </td></tr>\n";
    } else {
//FTO
    $resultID->MoveNext();
    echo "<tr bgcolor=\"$bgcolor3\" align=\"left\">\n";
    $posterdata = get_userdata_from_id($myrow['from_userid'], $db);
    echo "<td valign=\"top\"><font class=\"pn-normal\"><b>$posterdata[uname]</b></font><br><br>\n";
    if ($posterdata['user_from'] != "") {
        echo "<font class=\"pn-normal\">"._FROM.": $posterdata[user_from]</font><br><br>\n";
    }
    if ($posterdata['user_avatar'] != "")
//FTO use quotes fro index name (remove warning)
    echo "<img src='images/avatar/$posterdata[user_avatar]' alt=\"\">\n"
        ."</td><td><font class=\"pn-sub\">"._SENT.": ".ml_ftime(_DATETIMEBRIEF, GetUserTime($myrow['msg_time']))."</font>&nbsp;&nbsp;&nbsp"
        ."<hr noshade>\n";
    echo "<font class=\"pn-normal\">\n";
    $message = stripslashes($myrow['msg_text']);
//FTO use quotes fro index name (remove warning)
    $message = eregi_replace("\[addsig]", "<br>-----------------<br>" . pn_bbencode($posterdata['user_sig']), $message);
    echo $message . "</font><br>"
        ."<hr noshade>\n"
        ."&nbsp;&nbsp<a href=\"user.php?op=userinfo&amp;uname=$posterdata[uname]\"><img src=\"images/global/profile.gif\" border=\"0\" alt=\"\"></a><font class=\"pn-sub\">"._PROFILE."</font>\n";
    if($posterdata['femail'] != 0)
        echo "&nbsp;&nbsp;<a href=\"mailto:$posterdata[femail]\"><IMG SRC=\"images/global/email.gif\" border=\"0\" alt=\"\"></a><font class=\"pn-sub\">"._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/global/www_icon.gif\" border=0 Alt=\"\"></a><font class=\"pn-sub\">www</font>\n";
    }
    if($posterdata['user_icq'] != '')
        echo "&nbsp;&nbsp;<a href=\"http://wwp.mirabilis.com/$posterdata[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/global/aim.gif\" border=\"0\" Alt=\"\"></a><font class=\"pn-sub\">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/global/yim.gif\" border=\"0\" Alt=\"\"></a>";
    if($posterdata["user_msnm"] != '')
            echo "&nbsp;<a href=\"bb_profile.php?userid=$posterdata[uid]\"><img src=\"images/global/msnm.gif\" border=\"0\" Alt=\"\"></a>";
    echo "</td></tr>"
        ."<tr bgcolor=\"$bgcolor1\" align=\"RIGHT\"><td width=20% COLSPAN=2 align=RIGHT><font class=\"pn-normal\">";

//FTO Get pPrevious and next msg id
    $prevmsgid=-1;
    $nextmsgid=-1;
    $nextmsgprev=false;
    $nextmsgnext=false;
    $prevmsgprev=false;
    $prevmsgnext=false;

   //FTO Get previous msg ID
   if ($msgprev)
       {
        $sql = buildSimpleQuery ('priv_msgs', array ('msg_id'), "$column[msg_id]>$msgid AND $column[to_userid]=$userdata[uid]", "$column[msg_id]", 2);
        $result = $dbconn->Execute($sql);
        if($dbconn->ErrorNo()<>0) {
           error_log("DB Error: " . $dbconn->ErrorMsg());
           echo $dbconn->ErrorMsg() . "<br>";
           forumerror(0005);
        }

        if (!$result->EOF)
            {
             // FTO If previous then next exist
             $prevmsgnext=true;

             $myresultrow = $result->GetRowAssoc(false);
             $prevmsgid   = $myresultrow['msg_id'];

             // Check if prev of prev...
             $result->MoveNext();
             if ($result->EOF) $prevmsgprev=false; else $prevmsgprev=true;

            }
        else $prevmsgprev=false;

        echo "<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=readpmsg&amp;msgid=$prevmsgid&amp;msgnext=$prevmsgnext&amp;msgprev=$prevmsgprev\">"._PREVIOUSMESSAGE."</a> | ";
       }
       else         echo ""._PREVIOUSMESSAGE." | ";


   //FTO Get next msg ID
    if ($msgnext)
       {
        $sql = buildSimpleQuery ('priv_msgs', array ('msg_id'), "$column[msg_id]<$msgid AND $column[to_userid]=$userdata[uid]","$column[msg_id] DESC");
        $result = $dbconn->Execute($sql);

        if($dbconn->ErrorNo()<>0) {
           error_log("DB Error: " . $dbconn->ErrorMsg());
           echo $dbconn->ErrorMsg() . "<br>";
           forumerror(0005);
        }
        
        if (!$result->EOF)
            {
             // FTO If next then previous exist
             $nextmsgprev=true;

             $myresultrow = $result->GetRowAssoc(false);
             $nextmsgid=$myresultrow['msg_id'];
             // Check if next of next...
             $result->MoveNext();
             if ($result->EOF) $nextmsgnext=false; else $nextmsgnext=true;

            }
        else $nextmsgnext=false;
        echo "<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=readpmsg&amp;msgid=$nextmsgid&amp;msgnext=$nextmsgnext&amp;msgprev=$nextmsgprev\">"._NEXTMESSAGE."</a></font>";
       }
   else         echo ""._NEXTMESSAGE."</font>";
   

// FTO previous method to navigate
//    $previous = $start-1;
//    $next = $start+1;


//FTO    if ($previous >= 0) {
//        echo "<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=readpmsg&amp;start=$previous&amp;total_messages=$total_messages\">"._PREVIOUSMESSAGE."</a> | ";
//    } else {
//        echo ""._PREVIOUSMESSAGE." | ";
//    }
//FTO    if ($next < $total_messages) {
//        echo "<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=readpmsg&amp;start=$next&amp;total_messages=$total_messages\">"._NEXTMESSAGE."</a></font>";

//    } else {
//        echo ""._NEXTMESSAGE."</font>";
//    }

    echo "</td></tr>"
        ."<tr bgcolor=\"$bgcolor2\" align=\"left\"><td width=\"20%\" COLSPAN=\"2\" align=\"left\">"
        ."<font class=\"pn-normal\">"
        ."<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=replypmsg&amp;reply=1&amp;msg_id=$myrow[msg_id]\"><img src=\"images/global/reply.gif\" border=\"0\" alt=\"\"></a>\n"
        ."&nbsp;<a href=\"modules.php?op=modload&amp;name=$ModName&amp;file=replypmsg&amp;delete=1&amp;msg_id=$myrow[msg_id]\"><img src=\"images/global/delete.gif\" border=0 alt=\"\"></a>\n";
    }
    echo "</font></td></tr></table></td></tr></table>";
}
include('footer.php');

?>
Return current item: ProNuke. Postnuke To Oracle