home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / webmail / readmail.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  7.0 KB  |  180 lines

  1. <?php
  2.  
  3. /*************************************************************************/
  4.  #  Mailbox 0.9.2a   by Sivaprasad R.L (http://netlogger.net)             #
  5.  #  eMailBox 0.9.3   by Don Grabowski  (http://ecomjunk.com)              #
  6.  #          --  A pop3 client addon for phpnuked websites --              #
  7.  #                                                                        #
  8.  # This program is distributed in the hope that it will be useful,        #
  9.  # but WITHOUT ANY WARRANTY; without even the implied warranty of         #
  10.  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
  11.  # GNU General Public License for more details.                           #
  12.  #                                                                        #
  13.  # You should have received a copy of the GNU General Public License      #
  14.  # along with this program; if not, write to the Free Software            #
  15.  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              #
  16.  #                                                                        #
  17.  #             Copyright (C) by Sivaprasad R.L                            #
  18.  #            Script completed by Ecomjunk.com 2001                       #
  19. /*************************************************************************/
  20.  
  21. if (!eregi("modules.php", $PHP_SELF)) {
  22.     die ("You can't access this file directly...");
  23. }
  24.  
  25. require_once("mainfile.php");
  26. $module_name = basename(dirname(__FILE__));
  27. get_lang($module_name);
  28.  
  29. parse_str(base64_decode($pop3_cookie));
  30. require ("modules/$module_name/pop3.php");
  31. require ("modules/$module_name/decodemessage.php");
  32. include ("header.php");
  33. include ("modules/$module_name/mailheader.php");
  34. include ("modules/$module_name/class.rc4crypt.php");
  35.  
  36. if(!isset($id)) {
  37.     echo "Error: Invalid Parameter<br>";
  38.     include ("modules/$module_name/mailfooter.php");
  39.     exit();
  40. }
  41.  
  42. $query = "Select * from $prefix"._popsettings." where id = $id";
  43. if(($res = sql_query($query, $dbi)) && (sql_num_rows($res, $dbi) > 0)) {
  44.     $row = sql_fetch_array($res, $dbi);
  45.     $uid = $row[uid];
  46.     $auser = base64_decode($user);
  47.     $userdata = explode(":", $auser);
  48.     $userid = $userdata[0];
  49.     if ($uid != $userid) {
  50.     echo "<center><h2>Error: Permission denied</center>";
  51.     include ("modules/$module_name/mailfooter.php");
  52.     exit();
  53.     }
  54.     $server = $row[popserver];
  55.     $port = $row[port];
  56.     $username = $row[uname];
  57.     $rc4 = new rc4crypt();
  58.     $password = $rc4->endecrypt($username,$row[passwd],"de");
  59. } else {
  60.     echo "Error: POP Server not set properly<br>";
  61.     include ("modules/$module_name/mailfooter.php");
  62.     exit();
  63. }
  64.  
  65. $ms = $msgid;
  66. set_time_limit(0);
  67. $pop3=new POP3($server,$username,$password);
  68. $pop3->Open();
  69. $message = $pop3->GetMessage($ms) ;
  70. $s = $pop3->Stats() ;
  71. $body = $message["body"];
  72. $header = $message["header"];
  73. $full = $message["full"];
  74. $pop3->Close();
  75. $d = new DecodeMessage;
  76. $d->InitMessage($full);
  77. $from_address = chop($d->Headers("From"));
  78. $to_address = chop($d->Headers("To"));
  79. $subject = $d->Headers("Subject");
  80. $cc = chop($d->Headers("Cc"));
  81. $replyto = chop($d->Headers("Reply-To:"));
  82. $result = sql_query("select account from ".$prefix."_popsettings where id='$id'", $dbi);
  83. list($account) = sql_fetch_row($result, $dbi);
  84. title(""._MAILBOX." ($account)");
  85. OpenTable();
  86. echo "<table border=\"0\" width=\"100%\">
  87.     <tr>
  88.     <td align=\"left\" bgcolor=\"$bgcolor2\"><b>"._FROM.":</b></td>
  89.     <td>".htmlspecialchars($from_address)."</td>
  90.     </tr>
  91.     <tr>
  92.     <td align=\"left\" bgcolor=\"$bgcolor2\"><b>"._TO.":</b></td>
  93.     <td>".htmlspecialchars($to_address)."</td>
  94.     </tr>";
  95.  
  96. if ($cc != "") {
  97.     echo "<tr>
  98.     <td align=\"left\" bgcolor=\"$bgcolor2\"><b>Cc:</b></td>
  99.         <td>".htmlspecialchars($cc)."</td>
  100.         </tr>";
  101. }
  102.  
  103. echo "<tr>
  104.     <td align=\"left\" bgcolor=\"$bgcolor2\"><b>"._SUBJECT.":</b></td>
  105.     <td>".htmlspecialchars($subject)."</td>
  106.     </tr><tr>
  107.     <td align=\"left\" bgcolor=\"$bgcolor2\"><b>"._DATE.":</b></td>
  108.     <td>".htmlspecialchars($d->Headers("Date")) ."</td>
  109.     </tr><tr>
  110.     <td colspan=2>
  111.     <table border=0 width=100% cellspacing=0><tr><td bgcolor=$bgcolor2>
  112.     <table border=0 width=100% cellspacing=5 cellpadding=0><tr><td bgcolor=\"$bgcolor2\">
  113.     <form action=\"modules.php?name=$module_name&file=inbox\" method=\"post\">
  114.     <input type=hidden name=\"id\" value=\"$id\">
  115.     <input type=hidden name=\"op\" value=\"delete\">
  116.     <input type=hidden name=\"msgid\" value=\"$msgid\">
  117.     <input type=submit value=\""._DELETE."\">";
  118. if ($email_send == 1) {
  119.     echo "</form>
  120.     </td><td bgcolor=\"$bgcolor2\">
  121.     <form action=modules.php?name=$module_name&file=compose method=\"post\">
  122.     <input type=hidden name=to value=\"".htmlspecialchars($from_address)."\">
  123.     <input type=hidden name=subject value=\"".htmlspecialchars($subject)."\">
  124.     <input type=hidden name=body value=\"".htmlspecialchars($content)."\">
  125.     <input type=hidden name=op value=\"reply\">
  126.     <input type=submit value=\""._REPLY."\">
  127.     </form>
  128.     </td><td bgcolor=\"$bgcolor2\" width=\"100%\">
  129.     <form action=\"modules.php?name=$module_name&file=compose\" method=\"post\">
  130.     <input type=hidden name=\"to\" value=\"".htmlspecialchars($from_address)."\">
  131.     <input type=hidden name=\"subject\" value=\"".htmlspecialchars($subject)."\">
  132.     <input type=hidden name=\"body\" value=\"".htmlspecialchars($content)."\">
  133.     <input type=hidden name=\"op\" value=\"forward\">
  134.     <input type=submit value=\""._FORWARD."\">
  135.     </form>";
  136. }
  137. echo "</td></tr></table></tr></td></table></td></tr><tr><td colspan=2 bgcolor=\"$bgcolor2\">";
  138. OpenTable();
  139. $message = $d->Result();
  140. $rtext = "";
  141.  
  142. for ($j=0;$j<count($message);$j++) {
  143.     for ($i=0;$i<count($message[$j]);$i++) {
  144.     if (chop($message[$j][$i]["attachments"]) != '') {
  145.         $att_txt .= " <a href=\"".$d->attachment_path."/".$message[$j][$i]["attachments"]."\">".$message[$j][$i]["attachments"]."</a>";
  146.     }
  147.     }
  148.     for ($i=0;$i<count($message[$j]);$i++) {
  149.     if (eregi("text/html", $message[$j][$i]["body"]["type"])) {
  150.         $res = quoted_printable_decode($message[$j][$i]["body"]["body"]);
  151.             $res = ereg_replace("(=\n)", "", $res);
  152.             $res = eregi_replace("(<body)", "<xbody", $res);
  153.             $res = eregi_replace("(<meta)", "<xmeta", $res);
  154.         echo "<br>";
  155.         echo $res;
  156.     } else {
  157.             echo nl2br(htmlspecialchars($message[$j][$i]["body"]["body"]))."<br>";
  158.     }
  159.     $content = $rtext .= strip_tags($message[$j][$i]["body"]["body"]);
  160.     }
  161. }
  162. CloseTable();
  163. echo "</td></tr></table>";
  164.  
  165. if ($attachments_view == 1) {
  166.     if($att_txt) {
  167.     echo "<table align=\"center\" border=\"0\" width=\"100%\"><tr bgcolor=\"$bgcolor2\"><td>
  168.             <b> "._ATTACHMENTS.": </b></td><td width=\"100%\"> $att_txt</td></tr></table>";
  169.     }
  170. }
  171.  
  172. if ($attach_nv == 1) {
  173.     echo "<table align=\"center\" border=\"0\" width=\"100%\"><tr bgcolor=\"$bgcolor2\"><td align=\"center\">"
  174.         .""._ATTACHSECURITY."</td></tr></table>";
  175. }
  176.  
  177. CloseTable();
  178. include ("modules/$module_name/mailfooter.php");
  179.  
  180. ?>