| 1 |
296 |
ahitrov |
<%args> |
| 2 |
|
|
|
| 3 |
|
|
$voting => undef |
| 4 |
|
|
$quest => undef |
| 5 |
|
|
$filled => undef |
| 6 |
|
|
|
| 7 |
|
|
</%args> |
| 8 |
|
|
<%init> |
| 9 |
|
|
return unless ref $voting; |
| 10 |
|
|
|
| 11 |
|
|
my $CP = 'UTF8'; |
| 12 |
|
|
my $to = $voting->email; |
| 13 |
|
|
my $error; |
| 14 |
|
|
my $errstr; |
| 15 |
|
|
my $testresult; |
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
$testresult = 1; |
| 19 |
|
|
foreach ( 1 .. $quest->{question_amount} ) { |
| 20 |
|
|
my $index = 'r'.$_; |
| 21 |
|
|
if ( !exists $ARGS{$index} ) { |
| 22 |
|
|
$testresult = 0; |
| 23 |
|
|
} elsif ( exists $ARGS{$index} && $ARGS{$index} != $quest->{questions}->[$_-1]->{right} ) { |
| 24 |
|
|
$testresult = 0; |
| 25 |
|
|
} |
| 26 |
|
|
} |
| 27 |
|
|
|
| 28 |
|
|
if ( $testresult ) { |
| 29 |
|
|
$CP = 'ISO' if Convert::Cyrillic::cstocs('ISO', 'UTF8', $filled) eq 'Ответить'; |
| 30 |
|
|
$CP = 'KOI8' if Convert::Cyrillic::cstocs('KOI8', 'UTF8', $filled) eq 'Ответить'; |
| 31 |
|
|
$CP = 'WIN' if Convert::Cyrillic::cstocs('WIN', 'UTF8', $filled) eq 'Ответить'; |
| 32 |
|
|
my $name = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{freefield_1}); |
| 33 |
|
|
my $body = "Пользователь $name правильно ответил на вопросы.<br>\n"; |
| 34 |
|
|
$body .= "Переданы данные:<br>\n"; |
| 35 |
|
|
foreach my $j ( 1 .. $quest->{freefields_amount} ) { |
| 36 |
|
|
$body .= " ".$quest->{freefields}->[$j-1].":\t".$ARGS{"freefield_".$j}."<br>\n"; |
| 37 |
|
|
} |
| 38 |
|
|
$body .= "-----------------------------------<br>\n"; |
| 39 |
|
|
$body .= "Робот ".$request->{project_profile}->name; |
| 40 |
|
|
my %email; |
| 41 |
|
|
$email{subject} = 'Анкета на конкурс '.$request->{project}; |
| 42 |
|
|
$email{from_name} = Convert::Cyrillic::cstocs($CP, 'UTF8', $name); |
| 43 |
|
|
$email{to_name} = 'Жюри'; |
| 44 |
|
|
$email{body} = $body; |
| 45 |
|
|
$email{from} = 'admin@rambler-co.ru'; |
| 46 |
|
|
$email{to} = $to; |
| 47 |
|
|
|
| 48 |
|
|
# $voting->res(int($voting->res)+1); |
| 49 |
|
|
# $voting->store; |
| 50 |
|
|
|
| 51 |
|
|
warn 'Все зашибись!!!'; |
| 52 |
|
|
unless ($error) { |
| 53 |
|
|
$m->comp ('/subs/sendmail.msn', email => \%email); |
| 54 |
|
|
} |
| 55 |
|
|
} else { |
| 56 |
|
|
warn 'Не пролезло'; |
| 57 |
|
|
} |
| 58 |
|
|
</%init> |