Location: PHPKode > scripts > crackerMail > crackermail/default.php
<?php

$page = "default";
$pageShow = $_GET['p'];

$userid = $_GET['user'];

include('config.php'); //arrays for mailbox info
include('icons.php'); //values for icons
include('text_funcs.php');

$user = $mailbox[$userid][0];
$server = $mailbox[$userid][1];
$port = $mailbox[$userid][2];
$type = $mailbox[$userid][3];
$password = $mailbox[$userid][4];
$title = $mailbox[$userid][5];
$name = $mailbox[$userid][6];
$reply = $mailbox[$userid][7];

$mbox_open = "{" . $server . ":" . $port . "/" . $type . "}INBOX";

// execute if POST var delMsg contains data (i.e. there are msgs to be deleted)
if ($_POST['delMsg']) {

	$mbox = @imap_open($mbox_open, $user, $password);

	$delMsg = explode("=||=",$_POST['delMsg']);
	if (count($delMsg) > 1) {
		foreach($delMsg as $key => $val) {
			$data = explode("|=|", $val);
			if (verifyMsgDel($mbox, $data[0], $data[1]) == 1) {
				imap_delete($mbox, $data[0]);
			}
		}
	} else {
		$data = explode("|=|", $delMsg[0]);
		if (verifyMsgDel($mbox, $data[0], $data[1]) == 1) {
			imap_delete($mbox, $data[0]);
		}
	}
	imap_expunge($mbox);

	imap_close($mbox);
}

// open mailbox and get msgs
$mbox = @imap_open($mbox_open, $user, $password);

if ($mbox) {

	$mbox_info = imap_mailboxmsginfo($mbox);

	include("pagination.php"); //message list pagination

	if ($totalMsg > 0) {

		for ($msgno = $fromMsg; $msgno > $toMsg; $msgno--) {

			if ($header_info = getHeaders($mbox, $msgno)) {

				$fromName[$msgno] = $header_info['fromName'];
				$from[$msgno] = $header_info['fromName'] . " &lt;<a class='msg' href='compose_msg.php?user=" . $userid . "&to=" . $header_info['fromAddr'] . "&p=" . $pageShow . "'>" . $header_info['fromAddr'] . "</a>&gt;";
				$to[$msgno] = $header_info['to'];
				if (!$header_info['subject']) {
					$subject[$msgno] = "{none}";
				}
				else {
					$subject[$msgno] = $header_info['subject'];
				}
				$dateInt[$msgno] =  $header_info['date'];
				$date[$msgno] =  date("D n/j/Y G:i", $header_info['date']);

			}

			$txtDelMsg[$msgno] = "<" . htmlspecialchars($header_info['fromAddr']) . ">: '" . html_entity_decode($subject[$msgno]) . "'";

			//get structure
			$structure = imap_fetchstructure($mbox, $msgno);

			// if multipart, parse
			if ((is_array($structure->parts)) || (!$structure->parts)) {
				$sections = parse($structure);
				$attachments = get_attachments($sections);
			} else {
				unset($sections);
				unset($attachments);
			}

			// if attachments exist
			if (is_array($attachments)) {
				$attach[$msgno] = "<img src='images/att.gif' title='";
				for ($x = 0; $x < sizeof($attachments)-1; $x++) {
					$attach[$msgno] .= $attachments[$x]["name"] . ", ";
				}
				$attach[$msgno] .= $attachments[sizeof($attachments)-1]["name"] . "'>";
			}
		}

		$errNo = 0;

	}

	else {

		$errNo = 1; // error re: no messages

	}
	
	imap_close($mbox);

}

else {

	$errNo = 2; // error re: cannot connect

}

include('header.php');

?>

<!-- Start Page Content -->

<div class="mailbox"><?php echo $title ?></div>

<table width="100%">
	<tr>
		<td>
			<a class="std" href="javascript:window.location.href='<?php echo $_SERVER['PHP_SELF'] ?>?<?php echo $_SERVER['QUERY_STRING'] ?>'"><?php echo $get ?></a>
			&nbsp;|&nbsp;<a class="std" href="compose_msg.php?user=<?php echo $userid ?>&p=<?php echo $pageShow ?>"><?php echo $write ?></a>
			&nbsp;|&nbsp;<a class="std" href="javascript:addressBook('edit',<?php echo $userid ?>,0)"><?php echo $addr ?></a>

<?php

if ($mbox_info->Nmsgs > 0) {

?>

			&nbsp;|&nbsp;<a class="std" href="javascript:delChecked('delMsg')"><?php echo $del ?></a>

<?php

}

?>

			&nbsp;|&nbsp;<a class="std" href="index.php"><?php echo $mail ?></a>
		</td>

<?php if (count($mailbox) > 1) { ?>

		<td class="std" align="right">
			<select id="newMailbox" class="std" onchange="window.location.href='default.php?user='+document.getElementById('newMailbox').value+'&p=1'">
				<option>Select Mailbox ... </option>
<?php
	for ($i = 0; $i < count($mailbox); $i++) {
		if ($i != $userid) {
			echo "				<option value=\"" . $i . "\">" . $mailbox[$i][5] . "</option>\n";
		}
	}
?>
			</select>
		</td>
<?php } ?>
	</tr>
	<tr>
		<td class="std" colspan="2" style="font-size:0.75em;text-align:right"><?php echo $pMsg ?></td>
	</tr>
</table>

<form name="sort_form">
	<input type="hidden" name="sort_field" value="<?php echo $sortField ?>">
	<input type="hidden" name="sort_dir" value="<?php echo $sortDirection ?>">
</form>

<form name="delForm" action="default.php?user=<?php echo $userid ?>&p=<?php echo $pageShow ?>" method="post"> 

<table id="tblData" width="100%">
	<thead>
		<tr>
			<td class="hdr1" width="20" title="Check All">
<?php
if (!$errNo) {
	echo "			<input type=\"hidden\" name=\"msgs\">\n";
	echo "			<input type=\"hidden\" name=\"delMsg\">\n";
	echo "			<input type=\"checkbox\" name=\"checkAll\" title=\"Check All\" onclick=\"chkAll(this,this.form,'delMsg')\">\n";
}
else {
	echo "			&nbsp;\n";
}
?>
			</td>
			<td class="hdr1" width="11" align="center" title="Attachments">&nbsp;</td>
			<td id="from_hdr" class="hdr1" width="40%" title="Click to sort by Name" style="cursor:default" onclick="sortColumn('from')">From</td>
			<td id="subject_hdr" class="hdr1" width="40%" title="Click to sort by Subject" style="cursor:default" onclick="sortColumn('subject')">Subject</td>
			<td id="date_hdr" class="hdr1" width="16%"  title="Click to sort by Date" style="cursor:default" onclick="sortColumn('date')">Received</td>
		</tr>
	</thead>
<?php

if ($errNo == 1) {

?>

	<tr>
		<td class="std" colspan="5"><strong>No messages found.</strong></td>
	</tr>

<?php
	
}

else if ($errNo == 2) {

?>

	<tr>
		<td class="std" colspan="5"><strong>Cannot connect to <?php echo $mbox_open ?></strong></td>
	</tr>

<?php

}

?>

</table>

</form>

<!-- End Page Content -->

</body>

</html>
Return current item: crackerMail