<Html>
<head>
<link rel="stylesheet" href="../css/gallery.css" type="text/css" />
<style>
#contain{
width:990px;
height:auto;
border-radius:0px 20px 0px 20px;
padding:5px;
border:1px solid #999999;
-moz-box-shadow: 0 0 5px 5px #888;
-webkit-box-shadow: 0 0 5px 5px#888;
box-shadow: 0 0 10px 10px #888;
}
.isi{
width:320px;
height:320px;
margin:5px;
}
</style>
</head>
<body>
<?php
$ServerName = "{MAILSERVER:PORT/novalidate-cert}INBOX"; // For a IMAP connection (PORT 143)
$UserName = "USERNAME";
$PassWord = "PASSWORD";
if (!$mbox = imap_open($ServerName, $UserName,$PassWord))die("Could not open Mailbox - try again later!");
if ($hdr = imap_check($mbox))
$msgCount = $hdr->Nmsgs;
else
die ("Failed to get mail");
$MN=$msgCount;
?>
<!--<div align="center">
<div id="contain" align="center">
-->
<?php
while($MN>=1)
{
$overview=imap_fetch_overview($mbox,"$MN");
foreach ($overview as $message) {
$msgStruct = imap_fetchstructure($mbox, $message->msgno);
// if it has parts, there are attachments that need reading
if ($msgStruct->parts) {
foreach ($msgStruct->parts as $key => $part) {
switch (strtoupper($part->subtype)) {
case 'GIF': case 'JPEG':case 'PNG':
$fileContent = imap_fetchbody($mbox, $message->msgno, $key + 1);
## Mulai Proses pembuatan width dan height ##
//Membuat gambar dari hasil decode
$img = 'data:image/jpg;base64,' .$fileContent;
//membuat widht dan height baru dengan hasil 25%
$percent = 0.25;
list($width, $height, $type, $attr) = getimagesize($img);
$newwidth = 320;//$width * $percent;
$newheight = 320;//$height * $percent;
## Akhir Proses pembuatan width dan height ##
//menampilkan gambar
//echo '<img src="data:image/jpg;base64,' . $fileContent . '" class="isi" height="'.$newheight.'" width="'.$newwidth.'" />'."";
## Mulai Proses menyimpan file pada folder ##
// encode decode proses
$encode = base64_encode($fileContent);
$img = 'data:image/jpg;base64,' . base64_decode($encode);
//$img = 'data:image/jpeg;base64,'.$fileContent;
// penyesuaian karakter untuk proses penyimpanan
$comma = strpos($img, ',');
$data = base64_decode(substr($img, $comma+1));
//proses pembuatan nama file
//$encode = base64_encode($fileContent);
$vowels = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",);
$str = str_replace($vowels, "", $encode);
if (strlen($str) > 1000){
$trim = substr($str,1000,6);
$name = $trim ."_". $MN ;
}
elseif(strlen($str) > 100) {
$trim = substr($str,100,6);
$name = $trim ."_". $MN ;
}
else {
$trim = substr($str,10,6);
$name = $trim ."_". $MN ;
}
//set rirektory file dan nama file
$myname = '../image/mail_image/'.$name.'.jpg';
//proses simpan hasil penyesuaian karakter
file_put_contents($myname, $data);
## akhir Proses menyimpan file pada folder ##
break;
}
}
}
}
$MN--;
}
?>
<!--</div>
</div>
-->
<?php
## Baca semua email ##
$MN--;
## Baca Email Terakhir ##
//$MN=0;
//redirect ke demo2.php
header("Location: ../demo/demo2.php");
exit;
?>
</body>
</Html>
Tidak ada komentar:
Posting Komentar