Модераторы: korob2001, ginnie
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Прикрепление файлов, Прикрепление и отсылка файлов ... 
:(
    Опции темы
keen_
Дата 27.5.2007, 02:37 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 148
Регистрация: 14.9.2006
Где: Москва

Репутация: нет
Всего: -1



Здрасти,  smile  Помогите пожалуйста кто может.

Я использую Matt's FormMail. Вот часть этого скрипта:

Код

#!/usr/bin/perl
##############################################################################
# FormMail                        Version 1.92                               #
# Copyright 1995-2002 Matt Wright [email protected]                    #
# Created 06/09/95                Last Modified 04/21/02                     #
# Matt's Script Archive, Inc.:    http://www.scriptarchive.com/              #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1995-2002 Matthew M. Wright  All Rights Reserved.                #
#                                                                            #
# FormMail may be used and modified free of charge by anyone so long as this #
# copyright notice and the comments above remain intact.  By using this      #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from its use.                                                  #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact. #
##############################################################################
# ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
#                     http://www.securityfocus.com/archive/1/62033           #
##############################################################################
# Define Variables                                                           #
#      Detailed Information Found In README File.                            #

# $mailprog defines the location of your sendmail program on your unix       #
# system. The flags -i and -t should be passed to sendmail in order to       #
# have it ignore single dots on a line and to read message for recipients    #

$mailprog = '/usr/sbin/sendmail -i -t';

# @referers allows forms to be located only on servers which are defined     #
# in this field.  This security fix from the last version which allowed      #
# anyone on any server to use your FormMail script on their web site.        #

@referers = ('mywebsite.com');

# @recipients defines the e-mail addresses or domain names that e-mail can   #
# be sent to.  This must be filled in correctly to prevent SPAM and allow    #
# valid addresses to receive e-mail.  Read the documentation to find out how #
# this variable works!!!  It is EXTREMELY IMPORTANT.                         #
@recipients = &fill_recipients('mywebsite.com');

# ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
# @valid_ENV allows the sysadmin to define what environment variables can    #
# be reported via the env_report directive.  This was implemented to fix     #
# the problem reported at http://www.securityfocus.com/bid/1187              #

@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');

# Done                                                                       #
##############################################################################

# Check Referring URL
&check_url;

# Retrieve Date
&get_date;

# Parse Form Contents
&parse_form;

# Check Required Fields
&check_required;

# Send E-Mail
&send_mail;

# Return HTML Page or Redirect User
&return_html;

# NOTE rev1.91: This function is no longer intended to stop abuse, that      #
#    functionality is now embedded in the checks made on @recipients and the #
#    recipient form field.                                                   #

sub check_url {

    # Localize the check_referer flag which determines if user is valid.     #
    local($check_referer) = 0;

    # If a referring URL was specified, for each valid referer, make sure    #
    # that a valid referring URL was passed to FormMail.                     #

    if ($ENV{'HTTP_REFERER'}) {
        foreach $referer (@referers) {
            if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
                $check_referer = 1;
                last;
            }
        }
    }
    else {
        $check_referer = 1;
    }

    # If the HTTP_REFERER was invalid, send back an error.                   #
    if ($check_referer != 1) { &error('bad_referer') }
}

sub get_date {

    # Define arrays for the day of the week and month of the year.           #
    @days   = ('Sunday','Monday','Tuesday','Wednesday',
               'Thursday','Friday','Saturday');
  



Я хочу добавить возможность прикрепления файлов к письму. Вот код HTML формы на сайте:

Код


<form action="/cgi-bin/vacancy/resume.cgi" method="post" onSubmit="VForm();return document.ReturnValue"><input type=hidden name="recipient" value="[email protected]"><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#cccccc">
<td><table border="0" cellpadding="6" cellspacing="1" width="100%">
<tr bgcolor="#ffffff">
<td>Ваше имя:</td><td><input size="30" type="text" name="realname" maxlength="100"></td>
</tr>
<tr bgcolor="#ffffff">
<td>Ваш электронный адрес:</td><td><input size="30" type="text" name="email" maxlength="100"></td>
</tr>
<tr bgcolor="#ffffff">
<td>Кому:</td><td><select name="subject">
<option value=""> </option>
<option value="Бухгалтерия | Резюме" > Бухгалтерия</option>
<option value="Склад | Резюме" > Склад </option>
<option value="Секретариат | Резюме" > Секретариат </option>
<option value="Юриспруденция | Резюме" > Юриспруденция </option>
<option value="Дизайн | Резюме" > Дизайн </option>
<option value="Информационные технологии | Резюме" > Информационные технологии </option>
<option value="Розничная торговля | Резюме" > Розничная торговля </option>
</select></td>
</tr>
<tr bgcolor="#ffffff" valign="top">
<td>Текст письма:</td><td><textarea cols="37" rows="6" name="Текст письма"></textarea></td>
</tr>
<tr bgcolor="#ffffff">
<td>Прикрепить файл:<br>
(не более 1000 кб)</td><td><input type="file" name="attach"></td>
</tr>
</table></td>
</tr>
</table><br>

<input type="submit" value="&nbsp; Отправить &nbsp;">

</form>



Подскажите пожалуйста какой код добавить в сам скрипт и что поменять/исправить/дополнить в HTML коде формы.

Сразу говорю - я настоящий  smile  чайник.  Плохо понимаю в программировании.  smile Я понимаю, что здесь, возможно уже поднимался подобный вопрос, но я уже 4 часа как не могу найти или разобраться в этом деле. Поэтому обращаюсь к вам.

Сейчас разобрался и понял, что в тэг <form> нужно добавить ENCTYPE="multipart/form-data". Я это сделал, но скрипт меня выругал, сказал, что не заполнено поле recipient, вот: 

Error: Bad/No Recipient
There was no recipient or an invalid recipient specified in the data sent to FormMail. Please make sure you have filled in the recipient form field with an e-mail address that has been configured in @recipients...


Но я заполнил это поле. Когда в форме не стоит ENCTYPE="multipart/form-data", то форма работает.

Спасибо,  smile 
Артур

Это сообщение отредактировал(а) keen_ - 27.5.2007, 04:41
PM MAIL WWW   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Perl: CGI программирование"
korob2001
sharq
  • В этом разделе обсуждаются вопросы относящиеся только к CGI программированию
  • Если ваш вопрос не относится к системному или CGI программированию, задавайте его в общем разделе
  • Если ваш вопрос относится к системному программированию, задавайте его здесь
  • Интерпретатор Perl можно скачать здесь ActiveState, O'REILLY, The source for Perl
  • Справочное руководство "Установка perl-модулей", качать здесь


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, korob2001, sharq.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Perl: разработка для Web | Следующая тема »


 




[ Время генерации скрипта: 0.0390 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.