<?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: mailbox.php,v 1.8.2.5 2004/08/15 12:57:27 kirilt Exp $



/*************************************************************************/
 #  Mailbox 0.9.2a   by Sivaprasad R.L (http://netlogger.net)              #
 #                                                                        #
 #          --  A pop3 client addon for phpnuked websites --              #
 #                                                                        #
 # 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.                           #
 #                                                                        #
 # You should have received a copy of the GNU General Public License      #
 # along with this program; if not, write to the Free Software            #
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              #
 #                                                                        #
 #             Copyright (C) by Sivaprasad R.L                            #
 #                                                                        #
/*************************************************************************/


if( ! _MPN_USER ) { FunctionLibrary :: redirectRequest( 'user.php' ); exit; }

$index = 2;

if (isset($pop3_cookie))
{
    parse_str(base64_decode($pop3_cookie));
}

require("pop3.inc.php");
include "header.php";
include "mailheader.php";
include "class.rc4crypt.php";

$query = 'SELECT * FROM ' . $mpnTables['popsettings'] . ' WHERE uid = ' . (int)$GLOBALS['uinf']['uid'];
$res = mysql_query($query);

if (mysql_num_rows($res) < 1) {
    echo "<br><BR><table width=95% border=1 bordercolor=$bgcolor1 align=center>
          <tr><Td bgcolor=$bgcolor1 width=10%>" . translate("Welcome") . "</td><td>&nbsp;</td></tr>
          <tr><td colspan=2><br>";
    echo translate("Please click on <a href=settings.php>settings</a> to configure your mailbox.");
    echo "<br><br>";
    echo translate("By setting up new accounts, you can download mails from as many servers (pop3) as you want without ever logging in to each of them manually. ");
    echo translate("Checking email is now made a lot easier for you. ");
    echo translate("Click <a href=emailhelp.php>here</a>, for help in setting up new accounts.");
    echo "</td></tr>
          </table>";
    include "mailfooter.php";
    return;
}
?>

<script language="javascript">
function mailbox(num)
{
    formname = 'inbox' + num;
    window.document.forms[formname].submit();
}
</script>

<?php

    echo "<br><br><table border=0 bgcolor=\"$bgcolor3\" align=center width=80% CELLPADDING=3 CELLSPACING=1>" .
         "<tr bgcolor=\"$bgcolor2\"><td>" . translate("Account") . "</td><td>" . translate("Number of mails") . "</td><td>" . translate("Size") . "</td></tr>";

$count = 0;
while ($row = mysql_fetch_array($res)) {
    $count++;
    $server = $row["popserver"];
    $port = $row["port"];
    $username = $row["uname"];

    $rc4 = new rc4crypt();
    $password = $rc4->encrypt($username, $row["passwd"]);
    $account = $row["account"];
    $serverid = $row["id"];



    $pop3 = new POP3($server, $username, $password);
    $pop3->Open();
    $stats = $pop3->Stats();

    $mailsum = $stats["message"];
    $mailmem = round($stats["size"] / 1024) . "K";

    echo "<tr bgcolor=\"$bgcolor1\">
            <td align=left>
            <A href=\"inbox.php?id=$serverid\">$account</a></td>
            <td align=left>$mailsum</td>
            <td align=left>$mailmem Kbytes</td>
          </tr>";
    $pop3->Close();
}
echo "</table><br><br>";

include "mailfooter.php";
?>
