Yes, I'm pretty sure I have the edits like you suggested...
<?
######################################
#Coded By Jijo Last Update Date[Jan/19/06]
#http://phpclasses.org
#####################################
##########################################################
###################### Class readattachment ###############
class readattachment
{
function getdecodevalue($message,$coding)
{
if ($coding == 0)
{
$message = imap_8bit($message);
}
elseif ($coding == 1)
{
$message = imap_8bit($message);
}
elseif ($coding == 2)
{
$message = imap_binary($message);
}
elseif ($coding == 3)
{
$message=imap_base64($message);
}
elseif ($coding == 4)
{
$message = imap_qprint($message);
}
elseif ($coding == 5)
{
$message = imap_base64($message);
}
return $message;
}
function getdata($host,$login,$password,$filepath,$album,$folder)
{
$mbox = imap_open ($host, $login, $password) or die("can't connect: " . imap_last_error());
$message = array();
$message["attachment"]["type"][0] = "text";
$message["attachment"]["type"][1] = "multipart";
$message["attachment"]["type"][2] = "message";
//$message["attachment"]["type"][3] = "application";
$message["attachment"]["type"][4] = "audio";
$message["attachment"]["type"][5] = "image";
$message["attachment"]["type"][6] = "video";
$message["attachment"]["type"][7] = "other";
for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++)
{
$headerinfo = imap_header($mbox, $jk);
$subject = $headerinfo->Subject;
$matches = array();
if (preg_match('/^=\?[^?]*\?B\?(.*)\?=/m', $subject, $matches))
$subject = base64_decode($matches[1]);
$structure = imap_fetchstructure($mbox, $jk , FT_UID);
$parts = $structure->parts;
$fpos=2;
for($i = 1; $i < count($parts); $i++)
{
$message["pid"][$i] = ($i);
$part = $parts[$i];
if(TRUE)
{
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext=$part->subtype;
if ($part->ifdparameters)
foreach($part->dparameters as $dparam)
if (strtolower($dparam->attribute) == 'filename') $filename = $dparam->value;
if (empty($filename))
if ($part->ifparameters)
foreach($part->parameters as $param)
if (strtolower($param->attribute) == 'name') $filename = $param->value;
if (empty($filename)) $filename = 'nfn' . rand() . '.' . strtolower($part->subtype);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$jk,$fpos);
$fp=fopen($filepath . $filename,w);
$data=$this->getdecodevalue($mege,$part->type);
fputs($fp,$data);
fclose($fp);
add_picture($album, $folder, $filename, 0, $subject);
$fpos+=1;
}
}
imap_delete($mbox,$jk);
}
imap_expunge($mbox);
imap_close($mbox);
}
}
?>