dron
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору <?php ### World Wide Contact PHP by WorldWideCreations.com ### ### You can use this script freely in any way you wish. The only restriction is that you may ### NOT redistribute this script in any way. ### ### This script will accept data from your contact form and email it to you. It will even accept ### a file. Files are zipped before they are sent. ### ### Use the test form that comes with this script as a guide. There are three required fields: ### ### subject, from and message are required. You can add other fields to your form and they will ### be included in the mailing. ### ### If you are going to provide a file upload box, the file form field MUST be named FILE (case sensitive). ### ### Please see the form.htm file for a DEMO. ### ### Define the thank_you variable below as the page where you will send users after they submit the form. ### ### Define the mail_to variable as the email address you want the form sent to. ### ### Define the subject_prefix variable with text that will come before the users entered subject. ### ### Upload form.htm, thanks.htm, zip.lib.php, and contact.php to your server. ### ### Make sure your contact form POSTS to contact.php. Example: ### ### <form method="POST" action="http://www.stolbikoff.ru/cgi-bin/mail/contact.php" ENCTYPE="multipart/form-data"> ### ### Do NOT remove the ENCTYPE="multipart/form-data" part of the form tag or file uploads will not work. $thank_you = "http://www.stolbikoff.ru/2/thanks.htm"; $mail_to = 'fordron@mail.ru'; $subject_prefix = "Contact Form: "; ### No more editing required if (isset($_POST['SUBJECT'])) { $subject = $_POST['SUBJECT']; } else { $subject = $_POST['subject']; } if (isset($_POST['FROM'])) { $from = $_POST['FROM']; } else { $from = $_POST['from']; } if (isset($_POST['MESSAGE'])) { $message = $_POST['MESSAGE']; } else { $message = $_POST['message']; } foreach ($_POST as $key => $value) { if (strtolower($key) != 'subject' and strtolower($key) != 'message' and strtolower($key) != 'from' and strtolower($key) != 'file') { $message .= "\n\n$key: $value"; } } $from = ereg_replace("(\r|\n)","",$from); if( !preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $from)) { die("Invalid Email Address!"); } $subject = ereg_replace("(\r|\n)","",$subject); $mulmail = new multipartmail($mail_to, $from, $subject_prefix . $subject); if (is_uploaded_file($_FILES['FILE']['tmp_name'])) { $filename = $_FILES['FILE']['name']; include("zip.lib.php"); $ziper = new zipfile(); $ziper->addFile(fread(fopen($_FILES['FILE']['tmp_name'], "r"), $_FILES['FILE']['size']), $filename); $cid = $mulmail->addattachment($ziper->file(), "application/zip", $filename . '.zip'); } $mulmail->addmessage($message . "\n"); $mulmail->sendmail(); header("location: " . $thank_you); ## Class provided free from http://us3.php.net/function.mail by krisdover at hotmail dot com. ## Modified by World Wide Creations due to incompatibilities and to fit into this script. class multipartmail{ var $header; var $parts; var $message; var $subject; var $to_address; var $boundary; function multipartmail($dest, $src, $sub){ $this->to_address = $dest; $this->subject = $sub; $this->parts = array(""); $this->boundary = "------------" . md5(uniqid(time())); $this->header = "From: $src\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/related;\n" . " boundary=\"" . $this->boundary . "\"\r\n" . "X-Mailer: PHP/" . phpversion(); } function addmessage($msg = "", $ctype = "text/plain"){ $this->parts[0] = "Content-Type: $ctype; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: 7bit\r\n" . "\n" . $msg; //chunk_split($msg, 68, "\n"); } function addattachment($data, $ctype, $fname){ $i = count($this->parts); $content_id = "part$i." . sprintf("%09d", crc32($fname)) . strrchr($this->to_address, "@"); $this->parts[$i] = "Content-Type: $ctype; name=\"$fname\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-ID: <$content_id>\r\n" . "Content-Disposition: inline;\n" . " filename=\"$fname\"\r\n" . "\n" . chunk_split( base64_encode($data), 68, "\n"); return $content_id; } function buildmessage(){ $this->message = "This is a multipart message in mime format.\n"; $cnt = count($this->parts); for($i=0; $i<$cnt; $i++){ $this->message .= "--" . $this->boundary . "\n" . $this->parts[$i]; } } /* to get the message body as a string */ function getmessage(){ $this->buildmessage(); return $this->message; } function sendmail(){ $this->buildmessage(); mail($this->to_address, $this->subject, $this->message, $this->header); } } ?> Файл form.htm: <form method="post" action="http://www.stolbikoff.ru/cgi-bin/mail/contact.php" ENCTYPE="multipart/form-data"> Ваше имя: <input type=text name=subject><P> Ваш e-mail: <input type=text name=from><P> Some Other Field: <input type=text name=other><P> Сообщение:<P><textarea name=message></textarea><P> <input type=submit value=Submit> </form>
1) не нужно выкладывать такие длинные листинги в открытом виде 2) что значит "не понимает"? /Cheery/ | Всего записей: 413 | Зарегистр. 20-07-2001 | Отправлено: 16:19 15-11-2006 | Исправлено: Cheery, 17:38 15-11-2006 |
|