<?$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $tiempoinicial = $mtime; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chequear cuenta de correo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="imap_css.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<h1 class="titulo"> Webmail BETA </h1>
<?
$imap = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", "user", "pass") or
die("No Se Pudo Conectar Al Servidor:" . imap_last_error());
// Detalles generales de todos los mensajes del usuario.
// Ordenamos los mensajes arriba los más nuevos y abajo los más antiguos
// Informacion del mailbox
echo "<div class='estadisticas'>";
if ($check) {
echo "Fecha: " . $check->Date . "<br/>" ; echo "Total Mensajes: $check->Nmsgs | Sin Leer: $check->Unread | Recientes: $check->Recent | Eliminados: $check->Deleted <br/>";
echo "Tamaño buzón: " . $check->Size . "<br/><br/>" ;
} else {
}
echo "</div>";
// MOSTRAMOS EL MENSAJE
echo "-------------------------------------------------------<br />";
if (isset($_GET['num'])){ $num_mensaje=$_GET['num'];
echo "Mostrando cuerpo del mensaje #$num_mensaje<br/>";
$cont=0;
foreach ($resultados as $detalles) {
$cont = $cont + 1;
if ($cont == $num_mensaje){
$asunto=$detalles->subject;
echo "<p class='asunto'>$asunto</p>";}
}
$section = 1;
echo nl2br(strip_tags($mensaje,'<p>')); // Util para los mensajes HTML, los transforma en texto plano
}else{
echo "Mensaje no encontrado<br/>";
}
echo "<br />-------------------------------------------------------<br />";
?>
<table class='tabla1'>
<thead>
<tr>
<th scope="col" title="Mensaje">Msj</th>
<th scope="col" title="Remitente">Remitente</th>
<th scope="col" title="Asunto">Asunto</th>
<th scope="col" title="Tamaño">Tamaño</th>
<th scope="col" title="Fecha">Fecha</th>
<th scope="col" title="Leido">Leido</th>
<th scope="col" title="Adjunto">ADJ</th>
</tr>
</thead>
<?
foreach ($resultados as $detalles) {
echo "<tr>";
// Ponemos 'Sin asunto' en caso que no tenga.
if ($detalles->subject == ''){$subject='Sin asunto';}
else{
//Evita asuntos tipo =?ISO-8859-1?Q?B=F8lla?=
}
/* OBTENER EL FROM DEL MENSAJE */
$from = $header->from;
foreach ($from as $id => $object) {
$fromname = $object->personal;
$fromaddress = $object->mailbox . "@" . $object->host;
} /* FIN DEL FROM */
echo "<td><b>#$detalles->msgno</b></td>";
echo "<td><b>$fromaddress</b></td>";
echo "<td><a href='leer_correo.php?num=$detalles->msgno'><b>$subject</b></a></td>";
$tamanyo=$detalles->size;
$size=round($tamanyo/1024,2); // Pasamos a KB if ($tamanyo<100000){
echo "<td><b> $size KB</b></td>";
}
else{
$size=round($size/1024,2); // Pasamos a MB echo "<td><b> $size MB</b></td>";
}
echo "<td><b>$fecha</b></td>";
if($detalles->seen == "0") {
echo "<td><b>Sin leer</b></td>";
$cont = $cont + 1;
} else {
echo "<td>Leido</td>";
}
/* ========== TRATAR ADJUNTOS ================== */
$mid=$detalles->msgno;
$parts = $struct->parts;
$i = 0;
if (!$parts) { /* Simple message, only 1 piece */
$attachment = array(); /* No attachments */ //$content = imap_body($imap, $mid);
} else { /* Complicated message, multiple parts */
$endwhile = false;
$stack = array(); /* Stack while parsing message */ $content = ""; /* Content of message */
$attachment = array(); /* Attachments */
while (!$endwhile) {
if (!$parts[$i]) {
$parts = $stack[count($stack)-1]["p"]; $i = $stack[count($stack)-1]["i"] + 1; } else {
$endwhile = true;
}
}
if (!$endwhile) {
/* Create message part first (example '1.2.3') */
$partstring = "";
foreach ($stack as $s) {
$partstring .= ($s["i"]+1) . ".";
}
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "ATTACHMENT") { /* Attachment */ $attachment[] = array("filename" => $parts[$i]->parameters[0]->value, } //elseif (strtoupper($parts[$i]->subtype) == "PLAIN") { /* Message */
//$content .= imap_fetchbody($imap, $mid, $partstring);
//}
}
if ($parts[$i]->parts) {
$stack[] = array("p" => $parts, "i" => $i); $parts = $parts[$i]->parts;
$i = 0;
} else {
$i++;
}
} /* while */
} /* complicated message */
// echo "Analyzed message $mid, result: <br />";
// echo "Contenido: $content<br /><br />";
$num_adjuntos=count($attachment); //echo "Numero de adjuntos: $num_adjuntos <br /><br />";
if ($num_adjuntos>0){
echo "<td>Si</td>";
for ($i=0;$i<$num_adjuntos;$i++){
$nombre=$attachment[$i]['filename'];
//echo "Nombre del fichero: $nombre <br />";
}
}else{
echo "<td>No</td>";
}
/* ========== FIN ADJUNTO ================== */
echo "</tr>";
} // fin foreach resultados
echo "</table>";
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $tiempofinal = $mtime; $tiempototal = ($tiempofinal - $tiempoinicial); echo "La página fue creada en ".$tiempototal." segundos"; ?>
<div id="footer"> <p>Tratamiento de correo via IMAP - BETA 1.5</p></div>
</body>
</html>