home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / compose.php < prev    next >
Encoding:
PHP Script  |  2003-03-16  |  22.6 KB  |  649 lines

  1. <?php
  2. /////////////////////////////////////////////////////////
  3. //    
  4. //    source/compose.php
  5. //
  6. //    (C)Copyright 2000-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
  7. //
  8. //        This file is part of IlohaMail.
  9. //        IlohaMail is free software released under the GPL 
  10. //        license.  See enclosed file COPYING for details,
  11. //        or see http://www.fsf.org/copyleft/gpl.html
  12. //
  13. /////////////////////////////////////////////////////////
  14.  
  15. /********************************************************
  16.  
  17.     AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
  18.     FILE:  source/compose.php
  19.     PURPOSE:
  20.         1.  Provide interface for creating messages
  21.         2.  Provide interface for uploading attachments
  22.         3.  Form MIME format (RFC822) compliant messages
  23.         4.  Send message
  24.         5.  Save to "sent items" folder if so specified
  25.     PRE-CONDITIONS:
  26.         $user - Session ID for session validation and user preference retreaval
  27.     POST-CONDITIONS:
  28.         Displays standard message composition interface by default
  29.         If "upload" button pressed, displays all inputted text and attachment info
  30.         If "send" button pressed, sends, files, and displays status
  31.     COMMENTS:
  32.     
  33. ********************************************************/
  34.  
  35. include("../include/super2global.inc");
  36. include("../include/header_main.inc");
  37. include("../lang/".$my_prefs["lang"]."compose.inc");
  38. include("../lang/".$my_prefs["lang"]."dates.inc");
  39. include("../include/icl.inc");
  40. include("../include/version.inc");
  41. include("../conf/defaults.inc");
  42. /******* Init values *******/
  43. if (!isset($attachments)) $attachments=0;
  44.  
  45. if (isset($change_contacts)) $show_contacts = $new_show_contacts;
  46. if (isset($change_show_cc)) $show_cc = $new_show_cc;
  47.  
  48. //Handle ddresses submitted from contacts list 
  49. //(in contacts window)
  50. if (is_array($contact_to)) $to .= (empty($to)?"":", ").urldecode(implode(", ", $contact_to));
  51. if (is_array($contact_cc)) $cc .= (empty($cc)?"":", ").urldecode(implode(", ", $contact_cc));
  52. if (is_array($contact_bcc)) $bcc .= (empty($bcc)?"":", ").urldecode(implode(", ", $contact_bcc));
  53. //(in compose window)
  54. if ((isset($to_a)) && (is_array($to_a))){
  55.     reset($to_a);
  56.     while ( list($key, $val) = each($to_a)) $$to_a_field .= ($$to_a_field!=""?", ":"").stripslashes($val);
  57. }
  58.  
  59. //generate authenticated email address
  60. if (empty($init_from_address)){
  61.     $sender_addr = $loginID.( strpos($loginID, "@")>0 ? "":"@".$host );
  62. }else{
  63.     $sender_addr = str_replace("%u", $loginID, str_replace("%h", $host, $init_from_address));
  64. }
  65.  
  66. /***
  67.     generate user's name
  68. ***/
  69. $from_name = (empty($my_prefs["user_name"])?"":"\"".LangEncodeSubject($my_prefs["user_name"], $my_charset)."\" ");
  70.  
  71. if ($TRUST_USER_ADDRESS){
  72.     //Honor User Address
  73.     //If email address is specified in prefs, use that in the "From"
  74.     //field, and set the Sender field to an authenticated address
  75.     $from_addr = (empty($my_prefs["email_address"]) ? $sender_addr : $my_prefs["email_address"] );
  76.     $from = $from_name."<".$from_addr.">";
  77.     $reply_to = "";
  78. }else{
  79.     //Default
  80.     //Set "From" to authenticated user address
  81.     //Set "Reply-To" to user specified address (if any)
  82.     $from_addr = $sender_addr;
  83.     $from = $from_name."<".$sender_addr.">";
  84.     if (!empty($my_prefs["email_address"])) $reply_to = $from_name."<".$my_prefs["email_address"].">";
  85.     else $reply_to = "";
  86. }
  87. $original_from = $from;
  88.  
  89. /***
  90.     CHECK UPLOADS DIR
  91. ***/
  92. $uploadDir = $UPLOAD_DIR.ereg_replace("[\\/]", "", $loginID.".".$host);
  93. if (!is_dir($uploadDir)) $error .= "Invalid uploads dir<br>";
  94.  
  95. /****
  96.     SEND
  97. ****/
  98. if (isset($send)){
  99.     $conn = iil_Connect($host, $loginID, $password, $AUTH_MODE);
  100.     if (!$conn)
  101.         echo "failed";
  102.     else{
  103.         //echo "Composing...<br>\n"; flush();
  104.         
  105.         $error = "";
  106.         
  107.         /**** Check for subject ***/
  108.         $no_subject = false;
  109.         if ((strlen($subject)==0)&&(!$confirm_no_subject)){
  110.             $error .= $composeErrors[0]."<br>\n";
  111.             $no_subject = true;
  112.         }
  113.         
  114.         /**** Check "from" ***/
  115.         if (strlen($from)<7) $error .= $composeErrors[1]."<br>\n";
  116.         
  117.         /**** Check for recepient ***/
  118.         $to = stripslashes($to);
  119.         if ((strcasecmp($to, "self")==0) || (strcasecmp($to, "me")==0)) $to=$my_prefs["email_address"];
  120.         if ((strlen($to) < 7) || (strpos($to, "@")===false))
  121.             $error .= $composeErrors[2]."<br>\n";
  122.             
  123.         /**** Anti-Spam *****/
  124.         $as_ok = true;
  125.         //echo "lastSend: $lastSend <br> numSent: $numSent <br>\n";
  126.         //echo "$max_rcpt_message $max_rcpt_session $min_send_interval <br>";
  127.         if ((isset($max_rcpt_message)) && ((isset($max_rcpt_session))) && (isset($min_send_interval))){
  128.             $num_recepients = substr_count($to.$cc.$bcc, "@");
  129.             if ($num_recepients > $max_rcpt_message) $as_ok = false;
  130.             if (($num_recepients + $numSent) > $max_rcpt_session) $as_ok = false;
  131.             if ((time() - $lastSend) < $min_send_interval) $as_ok = false;
  132.         }else{
  133.             echo "Bypassing anti-spam<br>\n";
  134.         }
  135.         if (!$as_ok){
  136.             $as_error = $composeErrors[5];
  137.             $as_error = str_replace("%1", $max_rcpt_message, $as_error);
  138.             $as_error = str_replace("%2", $max_rcpt_session, $as_error);
  139.             $as_error = str_replace("%3", $min_send_interval, $as_error);
  140.             $error .= $as_error;
  141.         }
  142.         /**********************/
  143.  
  144.         if ($error){
  145.             //echo "<font color=\"red\">".$error."</font><br><br>\n";
  146.         }else{
  147.             //echo "<p>Sending....";
  148.             //flush();
  149.             
  150.             $num_parts=0;
  151.     
  152.             /*** Initialize header ***/
  153.             $headerx = "Date: ".TZDate($my_prefs["timezone"])."\n";
  154.             $headerx.= "X-Mailer: IlohaMail/".$version." (On: ".$_SERVER["SERVER_NAME"].")\n";
  155.             if (!empty($replyto_messageID)) $headerx.= "In-Reply-To: <".$replyto_messageID.">\n";
  156.         
  157.             /****  Attach Sig ****/
  158.                 
  159.             if ($attach_sig==1) $message.="\n\n".$my_prefs["signature1"];
  160.                 
  161.             /****  Attach Tag-line ***/
  162.             
  163.             if ($userLevel < $TAG_LEVEL){
  164.                 $message .= "\n\n".$TAG_LINE;
  165.             }
  166.  
  167.             /****  Encode  ****/
  168.             $subject=stripslashes($subject);
  169.             $message=stripslashes($message);
  170.             $subject=LangEncodeSubject($subject, $my_charset);
  171.             $part[0]=LangEncodeMessage($message, $my_charset);
  172.  
  173.             /***********************/
  174.                 
  175.             /****  Pre-process addresses */
  176.             $from = stripslashes($from);
  177.             $to = stripslashes($to);
  178.                 
  179.             $to = LangEncodeAddressList($to, $my_charset);
  180.             $from = LangEncodeAddressList($from, $my_charset);
  181.                     
  182.             if (!empty($cc)){
  183.                 $cc= stripslashes($cc);
  184.                 $cc = LangEncodeAddressList($cc, $my_charset);
  185.             }
  186.             if (!empty($bcc)){
  187.                 $bcc = stripslashes($bcc);
  188.                 $bcc = LangEncodeAddressList($bcc, $my_charset);
  189.             }
  190.             /***********************/
  191.  
  192.                     
  193.             /****  Add Recipients *********/
  194.             //$headerx.="Return-Path: ".$sender_addr."\n";
  195.             $headerx.="From: ".$from."\n";
  196.             //$headerx.="Sender: ".$sender_addr."\n";
  197.             $headerx.="Bounce-To: ".$from."\n";
  198.             $headerx.="Errors-To: ".$from."\n";
  199.             if (!empty($reply_to)) $headerx.="Reply-To: ".stripslashes($reply_to)."\n";
  200.             if ($cc){
  201.                 $headerx.="CC: ". stripslashes($cc)."\n";
  202.             }
  203.             if ($bcc){
  204.                 $headerx.="BCC: ".stripslashes($bcc)."\n";
  205.             }
  206.             /************************/
  207.                 
  208.             /****  Prepare attachments *****/
  209.             echo "Attachments: $attachments <br>\n";
  210.             if (is_dir($uploadDir)){
  211.                 //open directory
  212.                 if ($handle = opendir($uploadDir)) {
  213.                     //loop through files
  214.                     while (false !== ($file = readdir($handle))) {
  215.                         if (($file != "." && $file != "..") && ($attach[$file]==1)) {
  216.                             //split up file name
  217.                             $file_parts = explode(".", $file);
  218.                             
  219.                             //put together full path
  220.                             $path = $uploadDir."/".$file;
  221.  
  222.                             //read data
  223.                             $fp=fopen($path,"r");
  224.                             $a_data=fread($fp,filesize($path));
  225.                             fclose($fp);
  226.     
  227.                             //if data is good...
  228.                             if ($a_data!=""){
  229.                                 echo "Attachment $i is good <br>\n";
  230.                                 $num_parts++;
  231.                                     
  232.                                 //get name and type
  233.                                 $a_name=base64_decode($file_parts[1]);
  234.                                 $a_type=strtolower(base64_decode($file_parts[2]));
  235.                                 if ($a_type=="") $a_type="application/octet-stream";                                
  236.                                 
  237.                                 //stick it in conent array
  238.                                 $part[$num_parts]["type"]="Content-Type: ".$a_type."; name=\"".$a_name."\"\n";
  239.                                 $part[$num_parts]["disposition"]="Content-Disposition: attachment; filename=\"".$a_name."\"\n";
  240.                                 $part[$num_parts]["encoding"]="Content-Transfer-Encoding: base64\n";
  241.                                 $part[$num_parts]["data"]=myWordWrap(base64_encode($a_data),76);
  242.                             }
  243.  
  244.  
  245.                             //delete file
  246.                             unlink($path);
  247.                         }
  248.                     }
  249.                     closedir($handle); 
  250.                 }
  251.             }
  252.  
  253.             
  254.             /**** Put together MIME message *****/
  255.             echo "Num parts: $num_parts <br>\n";
  256.             if ($num_parts==0){
  257.                 $headerx.=$part[0]["type"];
  258.                 if (!empty($part[0]["encoding"])) $headerx.=$part[0]["encoding"];
  259.                 $body=$part[0]["data"];
  260.             }else{
  261.                 $boundary="RWP_PART_".$loginID.time();
  262.                 $headerx.="MIME-Version: 1.0 \n";
  263.                 $headerx.="Content-Type: multipart/mixed; boundary=\"$boundary\"\n"; 
  264.                     
  265.                 $body="This message is in MIME format.\n";
  266.                 for ($i=0;$i<=$num_parts;$i++){
  267.                     $body.="\n--".$boundary."\n";
  268.                     if ($part[$i]["type"]!="") $body.=$part[$i]["type"];
  269.                     if ($part[$i]["encoding"]!="") $body.=$part[$i]["encoding"];
  270.                     if ($part[$i]["disposition"]!="") $body.=$part[$i]["disposition"];
  271.                     $body.="\n";
  272.                     $body.=$part[$i]["data"]."\n";
  273.                 }
  274.                 $body.="\n--".$boundary."--";
  275.             }
  276.  
  277.  
  278.             /**** Send message *****/
  279.             echo "Sending...<br>";
  280.             if (mail($to,$subject,$body,$headerx, "-f$from_addr")){
  281.                 echo "Sent.<br>"; flush();
  282.                 $error = "";
  283.                 //save in send folder
  284.                 $append_str="To: ".$to."\n".(!empty($subject)?"Subject: ".$subject:"")."\n".$headerx."\n\n".$body;
  285.                 if ($my_prefs["save_sent"]==1){
  286.                     $append_str="To: ".$to."\n"."Subject: ".$subject."\n".$headerx."\n\n".$body;
  287.                     if (!iil_C_Append($conn, $my_prefs["sent_box_name"], $append_str)){
  288.                         $error .= "Couldn't save in ".$my_prefs["sent_box_name"].":".$conn->error."<br>\n";
  289.                     }else{
  290.                         echo "Saved in ".$my_prefs["sent_box_name"]."<br>\n";
  291.                     }
  292.                 }
  293.                 //echo nl2br($append_str);
  294.                 
  295.                 //if replying, flag original message
  296.                 if (isset($in_reply_to)) $reply_id = $in_reply_to;
  297.                 else if (isset($forward_of)) $reply_id = $forward_of;
  298.                 if (isset($reply_id)){
  299.                     $pos = strrpos($reply_id, ":");
  300.                     $reply_num = substr($reply_id, $pos+1);
  301.                     $reply_folder = substr($reply_id, 0, $pos);
  302.                     
  303.                     if (iil_C_Flag($conn, $reply_folder, $reply_num, "ANSWERED") < 1){
  304.                         $error .= "Flagging failed:".$conn->error."<br>\n";
  305.                     }
  306.                 }
  307.                 
  308.                 //update spam-prevention related records
  309.                 include("../include/as_update.inc");
  310.  
  311.                 //close window
  312.                 if ((empty($error))&&($my_prefs["closeAfterSend"]==1)){
  313.                     echo "<p>Message successfully sent.";
  314.                     echo "<script type=\"text/javascript\"><!--\nwindow.close();\n--></script>";
  315.                     echo "<br><br>"; flush();
  316.                 }else{
  317.                     echo $error;
  318.                 }
  319.             }else{
  320.                 echo "<p><font color=\"red\">Send FAILED</font>";
  321.             }
  322.  
  323.             iil_Close($conn); 
  324.             exit;
  325.         }
  326.     iil_Close($conn);
  327.     }
  328. }
  329.  
  330.  
  331. /****
  332.     HANDLE UPLOADED FILE
  333. ****/
  334. if (isset($upload)){
  335.     if (($userfile)&&($userfile!="none")){
  336.         $i=$attachments;
  337.         $newfile = base64_encode($userfile_name).".".base64_encode($userfile_type).".".base64_encode($userfile_size);
  338.         $newpath=$uploadDir."/".$user.".".$newfile;
  339.         if (!move_uploaded_file($userfile, $newpath)){
  340.             echo $userfile_name." : ".$composeErrors[3];
  341.         }
  342.     }else{
  343.         echo $composeErrors[4];
  344.     }
  345. }
  346.  
  347.  
  348. /****
  349.     FETCH LIST OF UPLOADED FILES
  350. ****/
  351. if (is_dir($uploadDir)){
  352.     //open directory
  353.     if ($handle = opendir($uploadDir)) {
  354.         //loop through files
  355.         while (false !== ($file = readdir($handle))) {
  356.             if ($file != "." && $file != "..") {
  357.                 //split up file name
  358.                 $file_parts = explode(".", $file);
  359.                 
  360.                 //make sure first part is session ID, and add to list
  361.                 if (strcmp($file_parts[0], $user)==0) $uploaded_files[] = $file;
  362.             } 
  363.         }
  364.         closedir($handle); 
  365.     }
  366. }    
  367.  
  368.  
  369. /****
  370.     REPLYING OR FORWARDING
  371. ****/
  372. if ((isset($replyto)) || (isset($forward))){
  373.     // if REPLY, or FORWARD
  374.     if ((isset($folder))&&(isset($id))){
  375.         include_once("../include/mime.inc");
  376.         
  377.         $conn = iil_Connect($host, $loginID, $password, $AUTH_MODE);
  378.         $header=iil_C_FetchHeader($conn, $folder, $id);
  379.         $structure_str=iil_C_FetchStructureString($conn, $folder, $id);
  380.         $structure=iml_GetRawStructureArray($structure_str);
  381.         
  382.         $subject=LangDecodeSubject($header->subject, $my_prefs["charset"]);
  383.         $lookfor=(isset($replyto)?"Re:":"Fwd:");
  384.         $pos = strpos ($subject, $lookfor);
  385.         if ($pos===false) {
  386.             $pos = strpos ($subject, strtoupper($lookfor));
  387.             if ($pos===false) {
  388.                 $subject=$lookfor." ".$subject;
  389.             }
  390.         }
  391.         
  392.         //get messageID
  393.         $replyto_messageID = $header->messageID;
  394.         
  395.         //get "from";
  396.         $from = $header->from;
  397.         //replace to "reply-to" if specified
  398.         if ($replyto){
  399.             $to = $from;
  400.             if (!empty($header->replyto)) $to = $header->replyto;
  401.         }
  402.         if ($replyto_all){
  403.             if (!empty($header->to)) $to .= (empty($to)?"":", ").$header->to;
  404.             if (!empty($header->cc)) $cc .= (empty($cc)?"":", ").$header->cc;
  405.         }
  406.         
  407.         //mime decode "to," "cc," and "from" fields
  408.         if (isset($to)){
  409.             $to_a = LangParseAddressList($to);
  410.             $to = "";
  411.             while ( list($k, $v) = each($to_a) ){
  412.             
  413.                 //remove user's own address from "to" list
  414.                 if ((stristr($to_a[$k]["address"], $from_addr) === false) and
  415.                      (stristr($to_a[$k]["address"], $loginID."@".$host) === false) and
  416.                     (stristr($to_a[$k]["address"], $my_prefs["email_address"])===false)){
  417.                     $to .= (empty($to)?"":", ")."\"".LangDecodeSubject($to_a[$k]["name"], $my_prefs["charset"])."\" <".$to_a[$k]["address"].">";
  418.                 }
  419.             }
  420.         }
  421.         if (isset($cc)){
  422.             $cc_a = LangParseAddressList($cc);
  423.             $cc = "";
  424.             while ( list($k, $v) = each($cc_a) ){
  425.                 //remove user's own address from "cc" list
  426.                 if ((stristr($cc_a[$k]["address"], $from_addr) === false) and
  427.                      (stristr($cc_a[$k]["address"], $loginID."@".$host) === false) and
  428.                     (stristr($to_a[$k]["address"], $my_prefs["email_address"])===false)){
  429.                     $cc .= (empty($cc)?"":", ")."\"".LangDecodeSubject($cc_a[$k]["name"], $my_prefs["charset"])."\" <".$cc_a[$k]["address"].">";
  430.                 }
  431.             }
  432.         }
  433.         $from_a = LangParseAddressList($from);
  434.         $from = "\"".LangDecodeSubject($from_a[0]["name"], $my_prefs["charset"])."\" <".$from_a[0]["address"].">";
  435.         
  436.         //format headers for reply/forward
  437.         if (isset($replyto)){
  438.             $message_head = $composeStrings[9];
  439.             $message_head = str_replace("%d", LangFormatDate($header->timestamp, $lang_datetime["prevyears"]), $message_head);
  440.             $message_head = str_replace("%s", $from, $message_head);
  441.         }else if (isset($forward)){
  442.             if ($show_header){
  443.                 $message_head = iil_C_FetchPartHeader($conn, $folder, $id, 0);
  444.             }else{
  445.                 $message_head = $composeStrings[10];
  446.                 $message_head .= $composeHStrings[5].": ".ShowDate2($header->date,"","short")."\n";
  447.                 $message_head .= $composeHStrings[1].": ". LangDecodeSubject($from, $my_prefs["charset"])."\n";
  448.                 $message_head .= $composeHStrings[0].": ".LangDecodeSubject($header->subject, $my_prefs["charset"])."\n\n";
  449.             }
  450.         }
  451.         if (!empty($message_head)) $message_head = "\n".$message_head."\n";
  452.         
  453.         //get message
  454.         if (!empty($part)) $part.=".1";
  455.         else{
  456.             $part = iml_GetFirstTextPart($structure, "");
  457.         }
  458.         
  459.         $message=iil_C_FetchPartBody($conn, $folder, $id, $part);
  460.         if (empty($message)){
  461.             $part = 0;
  462.             $message = iil_C_FetchPartBody($conn, $folder, $id, $part);
  463.         }
  464.         
  465.         //decode message if necessary
  466.         $encoding=iml_GetPartEncodingCode($structure, $part);        
  467.         if ($encoding==3) $message = base64_decode($message);
  468.         else if ($encoding==4){
  469.             if ($encoding == 3 ) $message = base64_decode($message);
  470.             else if ($encoding == 4) $message = quoted_printable_decode($message);                    
  471.             //$message = str_replace("=\n", "\n", $message);
  472.             //$message = quoted_printable_decode(str_replace("=\r\n", "\n", $message));
  473.         }
  474.         
  475.         //add quote marks
  476.         $message = str_replace("\r", "", $message);
  477.         $charset=iml_GetPartCharset($structure, $part);
  478.         $message=LangConvert($message, $my_prefs["charset"], $charset);
  479.         if (isset($replyto)) $message=">".str_replace("\n","\n>",$message);
  480.         $message = "\n".LangConvert($message_head, $my_prefs["charset"]).$message;
  481.  
  482.         iil_Close($conn);            
  483.     }
  484. }
  485. ?>
  486. <FORM ENCTYPE="multipart/form-data" ACTION="compose.php" METHOD=POST>
  487.     <input type="hidden" name="user" value="<?php echo $user?>">
  488.     <input type="hidden" name="show_contacts" value="<?php echo $show_contacts?>">
  489.     <input type="hidden" name="show_cc" value="<?php echo $show_cc?>">
  490.     <?php
  491.         if ($no_subject) echo '<input type="hidden" name="confirm_no_subject" value="1">';
  492.     
  493.         if ($replyto){
  494.             $in_reply_to = $folder.":".$id;
  495.             echo "<input type=\"hidden\" name=\"in_reply_to\" value=\"$in_reply_to\">\n";
  496.             echo "<input type=\"hidden\" name=\"replyto_messageID\" value=\"$replyto_messageID\">\n";
  497.         }else if ($forward){
  498.             $forward_of = $folder.":".$id;
  499.             echo "<input type=\"hidden\" name=\"forward_of\" value=\"$forward_of\">\n";
  500.         }
  501.     ?>
  502.         <table border="0" width="100%">
  503.     <tr>
  504.         <td valign="bottom" align="left">
  505.             <font size=+1><b><?php echo $composeStrings[0]; ?></b></font>
  506.                
  507.             <font size="-1">[<a href="" onClick="window.close();"><?php echo $composeStrings[11]?></a>]</font>
  508.         </td>
  509.         <td valign="bottom" align="right">
  510.                                 </td>
  511.     </tr>
  512.     </table>
  513.         <?php
  514.     if (!empty($error)) echo '<br><font color="red">'.$error.'</font>';
  515.     ?>
  516.         <p><?php echo $composeHStrings[0]?>:<input type=text name="subject" value="<?php echo htmlspecialchars(stripslashes($subject))?>" size="60">
  517.     <input type=submit name=send value="<?php echo  $composeStrings[1]?>">
  518.     <?php
  519.     
  520.         $to = htmlspecialchars($to);
  521.         $cc = htmlspecialchars($cc);
  522.         $bcc = htmlspecialchars($bcc);
  523.     
  524.         // format sender's email address (i.e. "from" string)
  525.         $email_address = htmlspecialchars($original_from);
  526.         echo "<table>";
  527.         echo "<tr><td align=right>".$composeHStrings[1].":</td><td>".LangDecodeSubject($email_address, $my_prefs["charset"])."</td></tr>\n";
  528.   
  529.         if (($show_contacts) || ($my_prefs["showContacts"])){
  530.             echo "<tr><td align=right valign=top>";
  531.             echo "<select name=\"to_a_field\">\n";
  532.             echo "<option value=\"to\">".$composeHStrings[2].":\n";
  533.             echo "<option value=\"cc\">".$composeHStrings[3].":\n";
  534.             echo "<option value=\"bcc\">".$composeHStrings[4].":\n";
  535.             echo "</select>\n";
  536.             echo"</td><td>";
  537.         
  538.             // display "select" box with contacts
  539.             include("../include/read_contacts.inc");
  540.             if ((is_array($contacts)) && (count($contacts) > 0)){
  541.                 echo "<select name=\"to_a[]\" MULTIPLE SIZE=5>\n";
  542.                 while ( list($key, $foobar) = each($contacts) ){
  543.                     $contact = $contacts[$key];
  544.                     if (!empty($contact["email"])){
  545.                         $line = "\"".$contact["name"]."\" <".$contact["email"].">";
  546.                         echo "<option>".htmlspecialchars($line)."\n";
  547.                     }
  548.                     if (!empty($contact["email2"])){
  549.                         $line = "\"".$contact["name"]."\" <".$contact["email2"].">";
  550.                         echo "<option>".htmlspecialchars($line)."\n";
  551.                     }
  552.                 }
  553.                 echo "</select>"; 
  554.                 echo "<input type=\"submit\" name=\"add_contacts\" value=\"".$composeStrings[8]."\"><br>\n";
  555.             }
  556.             echo "</td></tr>\n";
  557.             $contacts_shown = true;
  558.         }else{
  559.             $contacts_shown = false;
  560.         }
  561.         
  562.         // display to box
  563.         if (strlen($to) < 60)
  564.             echo "<tr><td align=right>".$composeHStrings[2].":</td><td><input type=text name=\"to\" value=\"".stripslashes($to)."\" size=60></td></tr>\n";
  565.         else
  566.             echo "<tr><td align=right>".$composeHStrings[2].":</td><td><textarea name=\"to\" cols=\"60\" rows=\"3\">".stripslashes($to)."</textarea></td></tr>\n";
  567.  
  568.         if ((!empty($cc)) || ($my_prefs["showCC"]==1) || ($show_cc)){
  569.             // display cc box
  570.             if (strlen($cc) < 60)
  571.                 echo "<tr><td align=right>".$composeHStrings[3].":</td><td><input type=text name=\"cc\" value=\"".stripslashes($cc)."\" size=60></td></tr>\n";
  572.             else
  573.                 echo "<tr><td align=right>".$composeHStrings[3].":</td><td><textarea name=\"cc\" cols=\"60\" rows=\"3\">".stripslashes($cc)."</textarea></td></tr>\n";
  574.             $cc_field_shown = true;
  575.         }else{
  576.             $cc_field_shown = false;
  577.         }
  578.         
  579.         if ((!empty($bcc)) || ($my_prefs["showCC"]==1) || ($show_cc)){
  580.             // display bcc box
  581.             if (strlen($bcc) < 60)
  582.                 echo "<tr><td align=right>".$composeHStrings[4].":</td><td><input type=text name=\"bcc\" value=\"".stripslashes($bcc)."\" size=60></td></tr>\n";
  583.             else
  584.                 echo "<tr><td align=right>".$composeHStrings[4].":</td><td><textarea name=\"bcc\" cols=\"60\" rows=\"3\">".stripslashes($bcc)."</textarea></td></tr>\n";
  585.             $bcc_field_shown = true;
  586.         }else{
  587.             $bcc_field_shown = false;
  588.         }
  589.         
  590.         
  591.         //show attachments
  592.         echo "<tr>";
  593.         echo "<td align=\"right\" valign=\"top\">".$composeStrings[4].":</td>";
  594.         echo "<td valign=\"top\">";
  595.         if ((is_array($uploaded_files)) && (count($uploaded_files)>0)){
  596.             echo "<table>";
  597.             reset($uploaded_files);
  598.             while ( list($k,$file) = each($uploaded_files) ){
  599.                 $file_parts = explode(".", $file);
  600.                 echo "<tr><td valign=\"bottom\"><input type=\"checkbox\" name=\"attach[$file]\" value=\"1\" ".($attach[$file]==1?"CHECKED":"")."></td>";
  601.                 echo "<td valign=\"bottom\" bgcolor=\"".$my_colors["main_hilite"]."\">".base64_decode($file_parts[1])." </td>";
  602.                 echo "<td valign=\"bottom\" bgcolor=\"".$my_colors["main_hilite"]."\" class=\"small\">".base64_decode($file_parts[3])."bytes </td>";
  603.                 echo "<td valign=\"bottom\" bgcolor=\"".$my_colors["main_hilite"]."\" class=\"small\">(".base64_decode($file_parts[2]).")</td>";
  604.                 echo "</td></tr>\n";
  605.             }
  606.             echo "</table>";
  607.         }
  608.         echo '<input type="hidden" name="MAX_FILE_SIZE" value="2000000">';
  609.         echo "<INPUT NAME=\"userfile\" TYPE=\"file\">";
  610.         echo '<INPUT TYPE="submit" NAME="upload" VALUE="'.$composeStrings[2].'">';
  611.         echo "</td></tr>\n";
  612.         
  613.         echo "<tr><td></td><td>";
  614.         if (!$contacts_shown){
  615.             //"show contacts" button
  616.             echo "<input type=\"hidden\" name=\"new_show_contacts\" value=1>\n";
  617.             echo "<input type=\"submit\" name=\"change_contacts\" value=\"".$composeStrings[5]."\">\n";
  618.         }else{
  619.             //"hide contacts" button, if not specified in prefs
  620.             if ($my_prefs["showContacts"]!=1){
  621.                 echo "<input type=\"hidden\" name=\"new_show_contacts\" value=0>\n";
  622.                 echo "<input type=\"submit\" name=\"change_contacts\" value=\"".$composeStrings[6]."\">\n";
  623.             }
  624.         }
  625.         
  626.         if ((!$cc_field_shown) || (!$bcc_field_shown)){
  627.             //"show cc/bcc field" button
  628.             include("../lang/".$my_prefs["lang"]."prefs.inc");
  629.             echo '<input type="hidden" name="new_show_cc" value="1">';
  630.             echo '<input type="submit" name="change_show_cc" value="'.$prefsStrings["6.2"].'">';
  631.         }else{
  632.             echo '<input type="hidden" name="new_show_cc" value="'.$show_cc.'">';
  633.         }
  634.         echo "</td></tr>\n";
  635.         echo "</table>";
  636.     ?>
  637.     <br><?php echo $composeStrings[7]?><br>
  638.     <TEXTAREA NAME=message ROWS=20 COLS=77 WRAP=virtual><?php echo htmlspecialchars(stripslashes($message)); ?></TEXTAREA>
  639.     <br><input type=checkbox name="attach_sig" value=1 <?php echo ($my_prefs["show_sig1"]==1?"CHECKED":""); ?> ><?php echo $composeStrings[3]."\n"; ?>
  640.     <?php
  641.  
  642.     ?>
  643.     <input type="hidden" name="attachments" value="<?php echo $attachments; ?>">
  644.  
  645. </form>
  646. <?php
  647. ?>
  648. </BODY></HTML>
  649.