| "Нужно использовать функции PHP для соеденения по протоколу IMAP" - это-то я итак знаю, но все равно спасибо:) Конкретнее кто-нибудь может ответить? вот, например, как переделать этот скрипт под мою задачу:
<?
$msgno="10"; //message number
$user_cook="Anil"; //pictures stored in this name
$user ="myuser"; //email username
$pass="mypassword" //password
$imaps=imap_open("{217.197.114.134:110/pop3}INBOX", "$user", "$pass");
$body=imap_body ($imaps,$msgno);
$headMess=imap_fetchstructure($imaps,$msgno);
for($is = 1 ; $is <= count($headMess->parts) ; $is++) {
$newBody = imap_fetchbody($imaps,$msgno,$is);
}
$finalBody = imap_fetchbody($imaps,$msgno,(count($headMess->parts)));
//*********************************************
// getting the boundary for the inline message
$bodyPcs=preg_split("/\n/",$body);
for($j=0;$j<(count($bodyPcs));$j++){
$bodyPcs[$j] = preg_replace("/\n/","",$bodyPcs[$j]);
if(preg_match("/Content-Type: multipart\/related/",$bodyPcs[$j])){
$boundary = $bodyPcs[($j+1)];
$BlFlag=1;
}
}
if($BlFlag!=1){
for($j1=0;$j1<(count($bodyPcs));$j1++){
$findBoundary = preg_replace("/\n/","",$bodyPcs[$j1]);
$findBoundary = preg_replace("/\r/","",$bodyPcs[$j1]);
if($findBoundary != "") {$boundary = $bodyPcs[$j1];break;}
}
}
$boundary=preg_replace("/^.*?\"/","",$boundary);
$boundary=preg_replace("/\"/","",$boundary);
// the end of the inline boundary
//**********************************************
$HtmlPart=preg_split("/$boundary/",$finalBody);
$MyPart=$HtmlPart[1];
$MyPart=preg_replace("/-+/","",$MyPart);
$MyPart=preg_replace("/\>/",">\n",$MyPart);
unset($HtmlPart);
//*********************************************
//getting the blocks
$matchs=preg_split("/\n/",$finalBody);
for($k=0;$k<=count($matchs);$k++){
$Line=$matchs[$k];
if(preg_match("/\=-+/",$Line)){
$Line=preg_replace("/\=.*\n/","",$Line);
}
if(preg_match("/$boundary/",$Line)){$Pcs +=1 ;}
if(!preg_match("/^\-/",$Line))
$PcsLine[$Pcs] .= $Line;
}
// end of blocks
//********************************************
//*********************************************
//Making the Pictures into an array
$ImageCount=0;
for($i=0;$i<count($PcsLine);$i++){
$ImageLine=$PcsLine[$i];
if(preg_match("/Content-Type\: image.*/",$ImageLine)){
$ImageBody[$ImageCount]=preg_replace("/.*filename\=.*\"/","",$ImageLine);
$cleanBody=split("-",$ImageBody[$ImageCount]);
$ImageBody[$ImageCount] = $cleanBody[0];
$ImageCount +=1;
}
}
// End of picture creation
//***********************************************
//**********************************************
//Printing the Picture
for($i=0;$i<$ImageCount;$i++){
$files="";
$files=base64_decode($ImageBody[$i]);
$filename="Anil$i.gif";
$fp=fopen("$filename","w+");
$fd=fputs($fp,$files);
fclose($fp);
//print"file $filename created <br>";
}
// Printing ends here
//*********************************************
// Putting Images in the correct places
$Myparts=$MyPart;
for($is=0;$is<$ImageCount;$is++){
$ij=$is+1;
$FileName="$user_cook$is.gif\"";
$Myparts=preg_replace("/cid\:part$ij.*\"/","$FileName",$Myparts);
}
// ends here
//***************************************************
//**************************************************
//The final result
$Myparts=preg_replace("/Content.*/","",$Myparts);
print $Myparts;
//Ends here
//*************************************************
// check if this message has an attachment
$msg_struct = imap_fetchstructure($imaps, $msgno);
$subtype = $msg_struct->subtype;
$atch_body = "";
if($subtype == MIXED || $subtype == ALTERNATIVE ||
$subtype == REPORT || $subtype == RELATED) {
// if any attachments build our attachment array
$atch_cnt = 0;
for($i = 1 ; $i < count($msg_struct->parts) ; $i++) {
$atch_part = $msg_struct->parts[$i];
$atch_param = $atch_part->parameters;
$atch_subtype = $atch_part->subtype;
$atch_type = $atch_part->type;
$atch_desc = $atch_part->description;
$atch_disposition = $atch_part->disposition;
$atch_encoding = $atch_part->encoding;
$msg_attachments[$atch_cnt]["size"] = convert_size($atch_part->bytes);
if($atch_type == 2) { // message
if($atch_subtype == RFC822) {
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_RFC822_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_RFC822_DESC'];
} else if($atch_subtype == DELIVERY-STATUS) {
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_REPORT_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_REPORT_DESC'];
}
$atch_cnt++;
continue;
}
if($atch_disposition == INLINE) {
if($atch_type == 5) // if it is an IMAGE
$atch_body = "<img src=\"$BASE_HREF/$BSX_LAUNCHER?RequestID=READMSG&mbox=" . urlencode($mbox) . "&ID=$ID&part=$i\"><br>\n";
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_INLINE_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_INLINE_DESC'];
if(!$BASILIX_SHOWINLINE || $atch_type != 5)
$atch_cnt++;
continue;
}
for($j = 0 ; $j < count($atch_param) ; $j++) {
$atch_param_attr = $atch_param[$j]->attribute;
$atch_param_val = $atch_param[$j]->value;
if($atch_param_attr == NAME) {
$msg_attachments[$atch_cnt]["filename"] = $atch_param_val;
$msg_attachments[$atch_cnt]["desc"] = $atch_desc;
break;
}
if($atch_subtype == HTML) {
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_HTML_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_HTML_DESC'];
} else if($atch_subtype == PLAIN) {
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_PLAIN_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_PLAIN_DESC'];
} else if($atch_subtype == ENRICHED) {
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_ENRICHED_FILE'];
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_ENRICHED_DESC'];
}
}
if($msg_attachments[$atch_cnt]["filename"] == "")
$msg_attachments[$atch_cnt]["filename"] = $lng['READMSG_UNKNOWN_FILE'];
if($msg_attachments[$atch_cnt]["desc"] == "")
$msg_attachments[$atch_cnt]["desc"] = $lng['READMSG_UNKNOWN_DESC'];
$atch_cnt++;
}
}
for($i = 0 ; $i < $atch_cnt ; $i++) {
$ac = $i + 1;
print $msg_attachments[$i]["desc"];
}
unset ($bodyPcs);
unset($matchs);
unset($ImagesBody);
unset($PcsLine);
?>
Здесь выводится окно для авторизации, но мне нужно чтобы сразу содержимое на страницу показывал. Как затолкать авторизацию уже внутрь скрипта? И ещё проблемка: в данном скрипте вылезает ошибка в 5-й (imap_open("{217.197.114.134:110/pop3}INBOX", "$user", "$pass");) строке.... :( Помогите, плиз. | |