home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / webmail / inbox.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  6.4 KB  |  158 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. include ("header.php");
  30. parse_str(base64_decode($pop3_cookie));
  31. require ("modules/$module_name/pop3.php");
  32. require ("modules/$module_name/decodemessage.php");
  33. include ("modules/$module_name/mailheader.php");
  34. include ("modules/$module_name/class.rc4crypt.php");
  35.  
  36. getServer($id);
  37. set_time_limit(0);
  38. $pop3=new POP3($server,$username,$password);
  39. $pop3->Open();
  40.  
  41. if($op == "delete") {
  42.     global $msgid;
  43.     if(is_array($msgid)) {
  44.     foreach($msgid as $mid) {
  45.         $pop3->DeleteMessage($mid);
  46.     }
  47.     } else {
  48.     $pop3->DeleteMessage($msgid);
  49.     }
  50.     $pop3->Close();
  51.     $pop3->Open();
  52. }
  53.  
  54. $s = $pop3->Stats() ;
  55. $mailsum = $s["message"];
  56. global $start,$numshow;
  57. if (!isset($start)) $upperlimit = $mailsum; else $upperlimit = $start;
  58. $lowerlimit = $upperlimit - $numshow;
  59. if ($lowerlimit < 0) $lowerlimit = 0;
  60. $showstart =  $mailsum - $upperlimit + 1;
  61. $showend = $mailsum - $lowerlimit;
  62. echo "<form action=modules.php?name=$module_name&file=inbox method=post>
  63.     <input type=hidden name=id value=$id>
  64.     <input type=hidden name=op value='delete'>";
  65. OpenTable();
  66. $result = sql_query("select account from ".$prefix."_popsettings where id='$id' AND uid='$cookie[0]'", $dbi);
  67. list($account) = sql_fetch_row($result, $dbi);
  68. echo "<center><b>$account: "._EMAILINBOX."</b></center><br><br>";
  69. echo "<table border=\"0\" width=100%>"
  70.     ."<tr>"
  71.     ."<td width=\"4%\" bgcolor=\"$bgcolor2\"> </td>"
  72.     ."<td width=\"25%\" bgcolor=\"$bgcolor2\"><b>"._FROM."</b></td>"
  73.     ."<td width=\"51%\" bgcolor=\"$bgcolor2\"><b>"._SUBJECT."</b></font></td>"
  74.     ."<td width=\"6%\" bgcolor=\"$bgcolor2\"><b>"._SIZE."</b></font></td>"
  75.     ."<td width=\"14%\" bgcolor=\"$bgcolor2\"><b>"._DATE."</b></font></td>"
  76.     ."</tr>";
  77. for ($i=$upperlimit;$i>$lowerlimit;$i--) {
  78.     $list = $pop3->ListMessage($i);
  79.     echo "<tr><td bgcolor=\"$bgcolor1\" height=\"24\" align=\"center\"><input type=\"checkbox\" name=\"msgid[]\" value=\"$i\"></td>";
  80.     if ($attachments_view == 0) {
  81.     if ($list["has_attachment"]) {
  82.             $att_exists = "&attach_nv=1";
  83.     } else {
  84.         $att_exists = "";
  85.     }
  86.     }
  87.     echo "<td bgcolor=\"$bgcolor1\" height=\"24\"><a href=\"modules.php?name=$module_name&file=readmail&id=$id&msgid=$i$att_exists\">";
  88.     $sender = ($list["sender"]["name"]) ? $list["sender"]["name"] : $list["sender"]["email"];
  89.     echo htmlspecialchars(substr($sender,0,30));
  90.     echo "</a>";
  91.     echo (strlen($sender) > 30) ? "..." : "";
  92.     echo "</a></font></td>";
  93.     echo "<td bgcolor=\"$bgcolor1\"><a href=\"modules.php?name=$module_name&file=readmail&id=$id&msgid=$i$att_exists\">";
  94.     echo chop($list["subject"]) ? htmlspecialchars($list["subject"]) : ""._NOSUBJECT."";
  95.     echo "</td><td bgcolor=\"$bgcolor1\">";
  96.     echo round($list["size"]/1024)."Kb";
  97.     echo $list["has_attachment"] ? "<img src=\"$imgpath/clip.gif\" border=\"0\">" : "";
  98.     echo "</td><td bgcolor=\"$bgcolor1\">";
  99.     echo htmlspecialchars($list["date"]);
  100.     echo "</font></td></tr>";
  101. }
  102. echo "</table>";
  103. navbuttons();
  104. echo "</form>";
  105. $pop3->Close();
  106. CloseTable();
  107. include ("modules/$module_name/mailfooter.php");
  108.  
  109. function getServer($id) {
  110.     global $user, $server, $port, $username, $password, $numshow, $prefix, $module_name, $dbi;
  111.     if(!isset($id)) {
  112.     echo "Error: Invalid Parameter<br>";
  113.     include ("modules/$module_name/mailfooter.php");
  114.     exit();
  115.     }
  116.     $query = "Select * from $prefix"._popsettings." where id = $id";
  117.     if(($res = sql_query($query, $dbi)) && (sql_num_rows($res, $dbi) > 0)) {
  118.     $row = sql_fetch_array($res, $dbi);
  119.     $uid = $row[uid];
  120.     $auser = base64_decode($user);
  121.     $userdata = explode(":", $auser);
  122.     $userid = $userdata[0];
  123.     if($uid != $userid) {
  124.         echo "<center><h2>Error: Permission Denied</center>";
  125.         exit();
  126.     }
  127.     $server = $row[popserver];
  128.     $port = $row[port];
  129.     $username = $row[uname];
  130.     $rc4 = new rc4crypt();
  131.     $password = $rc4->endecrypt($username,$row[passwd],"de");
  132.     $numshow = $row[numshow];
  133.     } else {
  134.     echo "Error: POP Server not set properly<br>";
  135.     exit();
  136.     }
  137. }
  138.  
  139. function navbuttons() {
  140.     global $id, $showstart, $showend, $mailsum, $upperlimit, $lowerlimit, $numshow, $module_name;
  141.     echo "<br>"
  142.         ."<table border=\"0\" width=\"100%\">"
  143.         ."<tr><td width=\"15%\">"
  144.     ."<input type=\"submit\" value=\""._DELETESELECTED."\"></td></tr></table>"
  145.     ."<table border=\"0\" width=\"100%\" align=\"center\">"
  146.         ."<td width=\"70%\" align=\"center\">"._SHOWING." ($showstart - $showend) "._OF." $mailsum "._EMAILS."</td>";
  147.     if ($upperlimit != $mailsum) {
  148.     $ul = $upperlimit + $numshow;
  149.         if ($ul > $mailsum) $ul = $mailsum;
  150.     echo "<td width=\"7%\"><a href=\"modules.php?name=$module_name&file=inbox&id=$id&start=$ul\">"._PREVIOUS."</a></td>";
  151.     }
  152.     if ($lowerlimit > 0) {
  153.     echo "<td width=\"7%\"><a href=\"modules.php?name=$module_name&file=inbox&id=$id&start=$lowerlimit\">"._NEXT."</a></td>";
  154.     }
  155.     echo "</tr></table>";
  156. }
  157.  
  158. ?>