Здравствуйте
Помогите решить проблему - есть на сайте форма для отправки сообщений, обрабатывает ее скрипт на perl, но в тексте приходящих с сайта сообщений русские буквы не отображаются, нормально отправляется только латиница. Подскажите, где в скрипте что нужно исправить. к сожалению весь скрипт не влез.
#!/usr/bin/perl
##############################################################################
# FormMail Version 1.92 #
# Copyright 1995-2002 Matt Wright
mattw@scriptarchive.com #
# Created 06/09/95 Last Modified 04/21/02 #
# Matt\'s Script Archive, Inc.:
http://www.scriptarchive.com/ #
##############################################################################
#----------------------------------------------------------------------------#
###############################--ПЕРЕВОД--####################################
# #
# Copyright 2002 Anatoliy Sergeevich #
#
http://HTTP://anatoliy.studio-pegas.com #
# E-MAIL:
anatoliy@studio-pegas.com #
# #
##############################################################################
#----------------------------------------------------------------------------#
# ТУТ НУЖНО ИЗМЕНИТЬ ПАРАМЕТРЫ #
#----------------------------------------------------------------------------#
##############################################################################
# Путь к sendmail
# Обычно это: /usr/sbin/sendmail
# НЕ УДАЛЯЙТЕ "-i -t"
$mailprog = \'/usr/sbin/sendmail -i -t\';
# Эта переменная определяет сервера с которых скрипт будет
# работать. Защищает Вас от несанкционированного доступа к скрипту.
# Если Вы хотите что бы скрипт можно было использовать с других серверов
# надо их здесь указать. ТАК ЖЕ НАДО ОБЯХАТЕЛЬНО УКАЗЫВАТЬ ХОСТ АДРЕС ВАШЕГО E-MAIL ПРОВАЙДЕРА.
# ЕСЛИ У ВАС ТАКОЙ АДРЕС:
email@your.host.com, ТО НАДО ПРОПИСАТЬ ЭТО: your.host.com, ЕСЛИ #
email@mail.ru, то mail.ru
@referers = (\'mail.ru\');
# Done #
##############################################################################
#----------------------------------------------------------------------------#
# ДАЛЕЕ ИЗМЕНЯТЬ СКРИПТ НЕ НУЖНО!!! #
#----------------------------------------------------------------------------#
##############################################################################
# Done #
@recipients = &fill_recipients(@referers);
@valid_ENV = (\'REMOTE_HOST\',\'REMOTE_ADDR\',\'REMOTE_USER\',\'HTTP_USER_AGENT\');
# 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 = (\'Воскресенье\',\'Понедельник\',\'Вторник\',\'Среду\',
\'Четверг\',\'Пятницу\',\'Субботу\');
@months = (\'Января\',\'Февраля\',\'Марта\',\'Апреля\',\'Мая\',\'Июня\',\'Июля\',
\'Августа\',\'Сентября\',\'Октября\',\'Ноября\',\'Декабря\');
# Get the current time and format the hour, minutes and seconds. Add #
# 1900 to the year to get the full 4 digit year. #
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
# Format the date. #
$date = "$days[$wday], $mday $months[$mon] $year года, в $time - по Моск.";
}
sub parse_form {
# Define the configuration associative array. #
%Config = (\'recipient\',\'\', \'subject\',\'\',
\'email\',\'\', \'realname\',\'\',
\'redirect\',\'\', \'bgcolor\',\'\',
\'background\',\'\', \'link_color\',\'\',
\'vlink_color\',\'\', \'text_color\',\'\',
\'alink_color\',\'\', \'title\',\'\',
\'sort\',\'\', \'print_config\',\'\',
\'required\',\'\', \'env_report\',\'\',
\'return_link_title\',\'\', \'return_link_url\',\'\',
\'print_blank_fields\',\'\', \'missing_fields_redirect\',\'\');
# Determine the form\'s REQUEST_METHOD (GET or POST) and split the form #
# fields up into their name-value pairs. If the REQUEST_METHOD was #
# not GET or POST, send an error. #
if ($ENV{\'REQUEST_METHOD\'} eq \'GET\') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{\'QUERY_STRING\'});
}
elsif ($ENV{\'REQUEST_METHOD\'} eq \'POST\') {
# Get the input
read(STDIN, $buffer, $ENV{\'CONTENT_LENGTH\'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
else {
&error(\'request_method\');
}
# For each name-value pair: #
foreach $pair (@pairs) {
# Split the pair up into individual variables. #
local($name, $value) = split(/=/, $pair);
# Decode the form encoding on the name and value variables. #
# v1.92: remove null bytes #
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/\\0//d;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/\\0//d;
# If the field name has been specified in the %Config array, it will #
# return a 1 for defined($Config{$name}}) and we should associate #
# this value with the appropriate configuration variable. If this #
# is not a configuration form field, put it into the associative #
# array %Form, appending the value with a \', \' if there is already a #
# value present. We also save the order of the form fields in the #
# @Field_Order array so we can use this order for the generic sort. #
if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} ne \'\') {
$Form{$name} = "$Form{$name}, $value";
}
else {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}
# The next six lines remove any extra spaces or new lines from the #
# configuration variables, which may have been caused if your editor #
# wraps lines after a certain length or if you used spaces between field #
# names or environment variables. #
$Config{\'required\'} =~ s/(\\s+|\\n)?,(\\s+|\\n)?/,/g;
$Config{\'required\'} =~ s/(\\s+)?\\n+(\\s+)?//g;
$Config{\'env_report\'} =~ s/(\\s+|\\n)?,(\\s+|\\n)?/,/g;
$Config{\'env_report\'} =~ s/(\\s+)?\\n+(\\s+)?//g;
$Config{\'print_config\'} =~ s/(\\s+|\\n)?,(\\s+|\\n)?/,/g;
$Config{\'print_config\'} =~ s/(\\s+)?\\n+(\\s+)?//g;
# Split the configuration variables into individual field names. #
@Required = split(/,/,$Config{\'required\'});
@Env_Report = split(/,/,$Config{\'env_report\'});
@Print_Config = split(/,/,$Config{\'print_config\'});
# ACCESS CONTROL FIX: Only allow ENV variables in @valid_ENV in #
# @Env_Report for security reasons. #
foreach $env_item (@Env_Report) {
foreach $valid_item (@valid_ENV) {
if ( $env_item eq $valid_item ) { push(@temp_array, $env_item) }
}
}
@Env_Report = @temp_array;
}
sub check_required {
# Localize the variables used in this subroutine. #
local($require, @error);
# The following insures that there were no newlines in any fields which #
# will be used in the header. #
if ($Config{\'subject\'} =~ /(\\n|\\r)/m || $Config{\'email\'} =~ /(\\n|\\r)/m ||
$Config{\'realname\'} =~ /(\\n|\\r)/m || $Config{\'recipient\'} =~ /