Статьи,обзоры,справочники по PHP


Чего мы не сделали - часть 3


ЛИСТИНГ 4 Файл main.php3 (проверка наличия писем и вывод кнопок)

<html> <body bgcolor="#408080" text="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000"> <BASE TARGET="main"> <a href=mail.php3>New message</a> <?PHP if (isset($mail) && ($mail>=1)):?>| <a href=mail.php3?mail=<?PHP echo $mail;?>> Reply</a>| <a href=del.php3?mail=<?PHP echo $mail;?>target= _top>Delete</a><?PHP endif;?><br><br> <?PHP if(isset($mail) && ($mail>=1)): $imap_stream=imap_open("{127.0.0.1:143}Inbox","$PHP_AUTH_USER", "$PHP_AUTH_PW",OP_READONLY); $inbox=imap_mailboxmsginfo($imap_stream); $body=imap_fetchbody($imap_stream,$mail,1,0); print(nl2br(eregi_replace( "(http|https|ftp)://([-=%_ a-zA-Z0-9./~?:]+)", "<a href=\"\\1://\\2\" target=\"_blank\ ">\\1://\\2</a>", htmlspecialchars($body)))); imap_close($imap_stream); endif; ?> </body> </html>

ЛИСТИНГ 5 Файл mail.php3 (создание письма)

<html> <body bgcolor="#408080" text="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000"> <BASE TARGET="main"> <?PHP if (isset($mail) && ($mail>=1)): $imap_stream=imap_open("{127.0.0.1:143}Inbox","$PHP_AUTH_USER", "$PHP_AUTH_PW",OP_READONLY); $header=imap_header($imap_stream,$mail,300,300,0); endif; ?> <FORM ACTION='send.php3' METHOD='POST'> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%> <TR> <TD class=light WIDTH="150"> <B><b>Your name :</b></B> </TD><TD COLSPAN=2 class=light> <INPUT TYPE="text" NAME="sendername" VALUE="<?PHP echo $sendername;?>" SIZE=60 maxlength=70> </TD></TR> <TR> <TD class=light WIDTH="150"> <B><b>From :</b></B> </TD><TD COLSPAN=2 class=light> <INPUT TYPE="text" NAME="sender" VALUE="<?PHP echo $PHP_AUTH_USER."@host.some_domain.com";?>" SIZE=60 maxlength=70> </TD></TR> <TR> <TD class=light WIDTH="150"> <B><b>Subject :</b></B> </TD><TD COLSPAN=2 class=light> <INPUT TYPE="text" NAME="subject" VALUE="<?PHP if (isset($mail) && ($mail>=1)):?>Re: <?PHP echo eregi_replace("\"",""",$header->Subject); endif;?>" SIZE=60 maxlength=70> </TD></TR> <TR> <TD class=light WIDTH="150"> <B><b>To :</b></B> </TD><TD COLSPAN=2 class=light> <INPUT TYPE="text" NAME="mailto" VALUE="<?PHP if (isset($mail) && ($mail>=1)): echo eregi_replace ("\"",""",$header->fromaddress); endif;?>" SIZE=60 maxlength=70> </TD></TR> <TR> <TD class=light WIDTH="150"> <B>Message body : </TD><TD COLSPAN=2 class=light> <textarea name="text" rows=15 cols=59><?PHP if (isset($mail) && ($mail>=1)): echo "> ".eregi_replace ("\n","\n> ",htmlspecialchars(imap_fetchbody ($imap_stream,$mail,1,0))); endif;?></textarea> <center><input type=submit value="Send"></center><br> </TD></TR> </TABLE> </form> </body> </html> <?PHP if (isset($mail) && ($mail>=1)):imap_close($imap_stream);endif; ?>




- Начало -  - Назад -  - Вперед -