Annotation of register/prgsrc/register.cgi, revision 1.20

1.1       boris       1: #!/usr/bin/perl
                      2: 
                      3: =pod
                      4: 
                      5: =head1 NAME 
                      6: 
                      7: register.cgi - a universal script for club regiter
                      8: 
                      9: =head1 SYNOPSIS
                     10: 
                     11: register.cgi?[I<options>]
                     12: 
                     13: =head1 DESCRIPTION
                     14: 
                     15: The script draws the hierarchy in the form suitable for WWW
                     16: 
                     17: =head1 AUTHOR
                     18: 
                     19: Boris Veytsman
                     20: 
                     21: =head1 DATE
                     22: 
1.20    ! boris      23: $Date: 2010-03-30 02:55:52 $
1.1       boris      24: 
                     25: =head1 REVISION
                     26: 
1.20    ! boris      27: $Revision: 1.19 $
1.2       boris      28: 
                     29: =cut
                     30: 
                     31: 
                     32: ###################################################
                     33: # Starting up
                     34: ###################################################
                     35: 
                     36:     use strict;
1.6       boris      37: use vars qw(%ENV);
1.2       boris      38: use CGI qw(:standard);
                     39: use DBI;
                     40: use POSIX qw(locale_h);
1.20    ! boris      41: use locale;
1.2       boris      42: 
1.20    ! boris      43: my $thislocale;
        !            44: if ($^O =~ /win/i) {
        !            45:        $thislocale = "Russian_Russia.20866";
        !            46: } else {
        !            47:        $thislocale = "ru_RU.KOI8-R";
        !            48: }
        !            49: POSIX::setlocale( &POSIX::LC_ALL, $thislocale );
1.6       boris      50: $ENV{'LANG'}='ru_RU.KOI8-R';
1.11      boris      51: my ($SENDMAIL) = "mail";
1.20    ! boris      52: my $TO = 'borisv@lk.net';
1.2       boris      53: my $FROM = 'borisv@lk.net';
                     54: 
1.20    ! boris      55: my $date='$Date: 2010-03-30 02:55:52 $';
1.3       boris      56: $date =~ s/[^ ]* ([^ ]*) .*/$1/; 
                     57: 
                     58: 
1.20    ! boris      59: my $dbh = DBI->connect("DBI:mysql:register", "piataev", "")
1.2       boris      60:     or do {
                     61:        print h1("Временные проблемы") . "База данных временно не
                     62:                        работает. Заходите попозже.";
1.16      boris      63:        print &Include_virtual("../../dimrub/db/reklama.html");
1.2       boris      64:        print end_html;
                     65:        die "Can't connect to DB chgk\n";
                     66:     };
                     67: 
1.20    ! boris      68:         $dbh->do("set names koi8r");
        !            69: 
1.10      boris      70: print header(-charset=>'koi8-r');
1.2       boris      71: 
                     72: 
                     73: ##################################################
                     74: # Printing top
                     75: ##################################################
                     76: print start_html(-"title"=>'Register of Clubs',
                     77:                 -author=>'borisv@lk.net',
1.16      boris      78:                 -background=>"../../images/map.jpg");
                     79: print &Include_virtual("../../dimrub/db/reklama.html");
1.2       boris      80: print <<END;
                     81: <table>
                     82: <tr>
1.16      boris      83: <td background=../../images/compass.gif valign=top>
1.2       boris      84: END
                     85: 
                     86: ################################################
                     87: # NAVIGATION PANEL
                     88: ################################################
                     89:     
                     90: my $self=url();
                     91: 
                     92: 
                     93: 
                     94: ###############################################
                     95: # The navigation panel has three special lines
                     96: ###############################################
                     97: print <<END;
1.13      boris      98: <ul>
                     99: <li><a href="$self">Home</a></li>
                    100: <li><a href="$self?rid=1&level=1000&clubs=0">Все регионы</a></li>
                    101: <li><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></li>
                    102: <li><a href="$self?addclub=1">Добавить клуб</a></li>
                    103: <li><a href="$self?whoiswho=1">Кто есть кто</a></li>
1.2       boris     104: END
                    105: 
                    106: #################################################
                    107: # And the navpanel itself
                    108: ##################################################
                    109: 
1.13      boris     110:     print ListRegions(dbh=>$dbh,rid=>1,level=>1,tag=>'li',
1.2       boris     111:                      self=>$self);
                    112:     
                    113: print <<END;
1.13      boris     114: </ul>
1.2       boris     115: END
                    116: 
                    117: 
                    118: 
                    119:     print <<END;
                    120: </td>
                    121: <td width=100% valign=top>
                    122: END
                    123: 
                    124: 
                    125: ######################################################
                    126: #        MAIN PANEL
                    127: ######################################################
                    128: 
                    129: #
                    130: # First, we introduce ourselves
                    131: #
                    132:     print <<END;
                    133: 
1.4       boris     134: <h1 align=center>
                    135: Журнал "Игра"<br>
                    136: и<br>
1.20    ! boris     137: <a href="http://internet.chgk.info"><img 
1.16      boris     138: ismap border=0 src= "../../images/logo.gif" 
1.2       boris     139: alt="Интернет Клуб Что? Где? Когда?" width=319 height=27></a>
1.4       boris     140: <br>ПРЕДСТАВЛЯЮТ<br>
                    141: Регистр Клубов Интеллектуальных Игр
1.2       boris     142: </h1>
                    143: END
                    144: 
                    145: #
                    146: # Now check the parameters...
                    147: #
                    148:     if (param('rid')) {
                    149:        my $rid = param('rid');
                    150:        $rid =~ s/(\d*)/$1/;
                    151:        print ListRegions(dbh=>$dbh,rid=>$rid,
                    152:                          level=>param('level'),
                    153:                          clubs=>param('clubs'),
                    154:                          tag=>'h2',
                    155:                          self=>$self);
                    156:     } elsif (param('cid')) {
                    157:        my $cid = param('cid');
                    158:        $cid =~ s/(\d*)/$1/;
                    159:        print ClubInfo(dbh=>$dbh,cid=>$cid,
                    160:                       self=>$self);
1.7       boris     161:     } elsif (param('pid')) {
                    162:        my $pid = param('pid');
                    163:        $pid =~ s/(\d*)/$1/;
                    164:         print ListPerson(dbh=>$dbh,pid=>$pid,
                    165:                         self=>$self,
                    166:                          positions=>1,
                    167:                          displayperson=>1);
                    168:     } elsif (param('whoiswho')) {
                    169:         print PrintWhoIsWho(dbh=>$dbh,
                    170:                            self=>$self);
1.2       boris     171:     } elsif (param('addclub')) {
                    172:        print AddClub();
                    173:     } elsif (param('Submit')) {
                    174:        print SendLetter();
1.3       boris     175:     } else {
                    176:        print <<END;
                    177: <dl>
                    178: <dt><a href="$self?rid=1&level=1000&clubs=0">Все регионы</a></dt>
                    179: <dt><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></dt>
                    180: <dt><a href="$self?addclub=1">Добавить клуб или изменить сведения
                    181: о клубе</a></dt>
1.7       boris     182: <dt><a href="$self?whoiswho=1">Кто есть кто</a></dt>
1.3       boris     183: </dl>
1.9       boris     184: <p align=center>
                    185: END
1.16      boris     186: print &Include_virtual("../../boris/register/regions.html");
1.9       boris     187: print <<END;
                    188: </p>
1.3       boris     189: END
1.4       boris     190: }
1.3       boris     191: 
                    192: ####################################################################
                    193: # And the bottom of the page
                    194: ###################################################################
1.8       boris     195:     my $sth=$dbh->prepare("select count(*) from Clubs");
                    196:     $sth->execute;
                    197:     my ($count) = $sth->fetchrow_array;
                    198:     $sth->finish;
1.3       boris     199: 
                    200:     print "<p align=center>";
1.15      boris     201:     print "Всего клубов: $count</p>\n";
1.3       boris     202:     
                    203:     print <<END;
                    204: <hr>
                    205: <address>
1.16      boris     206: <img width = 60 height = 80 src="../../images/owl.gif" alt = "owl"> 
1.3       boris     207: <a href="http://users.lk.net/~borisv">
1.19      boris     208: Boris Veytsman</a>
1.3       boris     209: </address>
                    210: </body>
                    211: </html>
                    212: END
                    213: 
1.2       boris     214: 
                    215:     print <<END;
                    216: </td>
                    217: </tr>
                    218: </table>
                    219: END
                    220: 
                    221: print end_html;
                    222: 
                    223: exit 0;
                    224: 
                    225: ###################################################
                    226: # Parsing included file
                    227: ##################################################
                    228: sub Include_virtual {
                    229:     my ($fn, $output) = (@_, '');
                    230:     
                    231:     open F , $fn
                    232:        or return; #die "Can't open the file $fn: $!\n";
                    233:     
                    234:     while (<F>) {
                    235:        if (/<!--#include/o) {
                    236:            s/<!--#include virtual="\/(.*)" -->/&Include_virtual($1)/e;
                    237:        }
                    238:        if (/<!--#exec/o) {
                    239:            s/<!--#exec.*cmd\s*=\s*"([^"]*)".*-->/`$1`/e;
                    240:        }
                    241:        $output .= $_;
                    242:     }
                    243:     return $output;
                    244: }
                    245: 
                    246: 
                    247: 
                    248: #############################################################
                    249: # Listing the given region and optionally its children
                    250: #############################################################
                    251: 
                    252: 
                    253: sub ListRegions {
                    254:     my %args = @_;
                    255:     my $sth = $args{'dbh'}->prepare("
                    256: SELECT Name FROM Regions WHERE RID=$args{'rid'}");
                    257:     $sth->execute;
                    258:     if (!$sth->rows) {
                    259:        return "";
                    260:     }
                    261:     my ($name)=$sth->fetchrow_array;
1.4       boris     262:     $name="<a href=\"$self?rid=$args{'rid'}&level=100&clubs=1\">$name</a>";
1.2       boris     263:     my $result="<$args{'tag'}>$name</$args{'tag'}>\n";
                    264:     if ($args{'level'}>0) { # Print children
                    265: 
                    266:        # Frist, we print clubs
                    267:        if ($args{'clubs'}) {
1.10      boris     268:            $result .= ListRegionURLs(%args);
1.2       boris     269:            $result .= ListClubs(%args);
                    270:        }
                    271:        $sth=$args{'dbh'}->prepare("
                    272: SELECT Child FROM RegionRegion WHERE Parent=$args{'rid'}");
                    273:        $sth->execute;
                    274:        if ($sth->rows) {
                    275:            my @kids=();
                    276:            while (my ($kid)=$sth->fetchrow_array) {
                    277:                push @kids,"rid=$kid";
                    278:            }
                    279:            my $clause = join(' OR ', @kids);
1.13      boris     280:            $result .= "<ul>\n";
1.2       boris     281:            $sth=$args{'dbh'}->prepare("
                    282: SELECT rid FROM Regions WHERE $clause ORDER BY Name");
                    283:            $sth->execute;
                    284:            while (my ($kid)=$sth->fetchrow_array) {
                    285:                $result .= ListRegions(
                    286:                                       %args,'rid'=>$kid,
                    287:                                       'level'=>$args{'level'}-1,
1.13      boris     288:                                       'tag'=>'li');
1.2       boris     289:            }
1.13      boris     290:            $result .= "</ul>\n";
1.2       boris     291:        }
                    292:     }
                    293:     return $result;
                    294: }
                    295: 
                    296: ############################################################
1.10      boris     297: # List the URLs of a given region
                    298: ###########################################################
                    299: sub ListRegionURLs {
                    300:     my %args = @_;
                    301:     my $sth;
                    302:     $sth = $args{'dbh'}->prepare("
                    303: SELECT URL FROM Regions WHERE rid=$args{'rid'} and NOT ISNULL(URL)");
                    304: 
                    305:     $sth->execute;
                    306:        
                    307:     if (!$sth->rows) {
                    308:        return "";
                    309:     }
                    310:     
                    311:     my $result;
                    312:        
                    313:     $result=<<END;
                    314: <dl><dt>Странички:</dt>
                    315: <dd><dl>\n
                    316: END
                    317:     
                    318:     while (my ($string)=$sth->fetchrow_array) {
                    319:        $string=htmlize($string);
                    320:        $result .= p($string);
                    321:     }
                    322:     $result .= "</dl></dd></dl>\n";
                    323:     return $result;
                    324: }
                    325: 
                    326: 
                    327: ############################################################
1.4       boris     328: # List the clubs of a given region or a given association
1.2       boris     329: ###########################################################
                    330: sub ListClubs {
                    331:     my %args = @_;
                    332:     my $sth;
                    333:     if ($args{'cid'}) {
                    334:        $sth = $args{'dbh'}->prepare("
1.17      boris     335: SELECT Child, Status FROM ClubClub WHERE Parent=$args{'cid'}");
1.2       boris     336:     } else {
                    337:        $sth = $args{'dbh'}->prepare("
                    338: SELECT cid FROM ClubRegion WHERE rid=$args{'rid'}");
                    339:     }
                    340: 
                    341:     $sth->execute;
                    342:        
                    343:     if (!$sth->rows) {
                    344:        return "";
                    345:     }
                    346:     
                    347:     my $result;
                    348:        
                    349:     if ($args{'cid'}) {
                    350: 
                    351:        $result=<<END;
                    352: <h3>Клубы:</h3>
1.13      boris     353: <ul>\n
1.2       boris     354: END
                    355:      } else {
                    356:  
                    357:         $result=<<END;
1.13      boris     358: <ul>\n
1.2       boris     359: END
                    360:     }
                    361:     my @clubs=();
1.17      boris     362:     my %stat=();
                    363:     while (my ($club,$status)=$sth->fetchrow_array) {
1.2       boris     364:        push @clubs,"cid=$club";
1.17      boris     365:        if ($status) {
                    366:            $stat{$club}=$status;
                    367:        }
1.2       boris     368:     }
                    369:     my $clause = join(' OR ', @clubs);
                    370:     $sth=$args{'dbh'}->prepare("
                    371: SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");
                    372:     $sth->execute;
                    373:     while (my ($cid,$Name)=$sth->fetchrow_array) {
1.17      boris     374:        my $res="<a href=\"$self?cid=$cid\">$Name</a>\n";
                    375:        if (exists $stat{$cid}) {
                    376:            $res .= " ($stat{$cid})\n";
                    377:        }
                    378:        $result .= li($res);
1.2       boris     379:     }
1.13      boris     380:     $result .= "</ul>\n";
1.2       boris     381: }
                    382: 
1.4       boris     383: 
                    384: ############################################################
                    385: # List the association a given club belongs to
                    386: ###########################################################
                    387: sub ListParents {
                    388:     my %args = @_;
                    389:     my $sth;
                    390: 
                    391:     $sth = $args{'dbh'}->prepare("
1.17      boris     392: SELECT Parent, Status FROM ClubClub WHERE Child=$args{'cid'}");
1.4       boris     393: 
                    394:     $sth->execute;
                    395:        
                    396:     if (!$sth->rows) {
                    397:        return "";
                    398:     }
                    399:     
                    400:     my $result;
                    401:        
                    402:     $result=<<END;
                    403: <h3>Коллективный член ассоциаций:</h3>
1.7       boris     404: <dl>\n
1.4       boris     405: END
                    406: 
                    407:     my @clubs=();
1.17      boris     408:     my %stat=();
                    409:     while (my ($club,$status)=$sth->fetchrow_array) {
1.4       boris     410:        push @clubs,"cid=$club";
1.17      boris     411:        if ($status) {
                    412:            $stat{$club}=$status;
                    413:        }
1.4       boris     414:     }
                    415:     my $clause = join(' OR ', @clubs);
                    416:     $sth=$args{'dbh'}->prepare("
                    417: SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");
                    418:     $sth->execute;
                    419:     while (my ($cid,$Name)=$sth->fetchrow_array) {
1.17      boris     420:        my $res = "<a href=\"$self?cid=$cid\">$Name</a>\n";
                    421:        if (exists $stat{$cid}) {
                    422:            $res .= " ($stat{$cid})\n";
                    423:        }
                    424:        $result .= dt($res);
1.4       boris     425:     }
                    426:     $result .= "</dl></dd></dl>\n";
                    427: }
                    428: 
1.2       boris     429: #############################################################
                    430: # The longest subroutine in the list...
                    431: #############################################################
                    432: sub ClubInfo {
                    433:     my %args = @_;
                    434:     my $sth = $args{'dbh'}->prepare("
                    435: SELECT * FROM Clubs WHERE cid=$args{'cid'}");
                    436:     $sth->execute;
                    437: 
                    438:     if (!$sth->rows) {
                    439:        return "";
                    440:     }
                    441:     
                    442:     my $result="";
                    443:     my $club=$sth->fetchrow_hashref;
                    444:     $result .= h2($club->{'Name'});
                    445: 
                    446:     if (my $string=$club->{'Address'}) {
                    447:        $string =~ s/\n/<br>\n/g;
                    448:        $result .= h3('Адрес')."\n".p($string);
                    449:     }
                    450: 
                    451:     if (my $string=$club->{'URL'}) {
                    452:        $string = htmlize($string);
                    453:        $result .= h3('Домашняя страничка')."\n".p($string);
                    454:     }
                    455: 
                    456:     if (my $string=$club->{'Phone'}) {
                    457:        $result .= h3('Телефон')."\n".p($string);
                    458:     }
                    459: 
                    460:     if (my $string=$club->{'Fax'}) {
                    461:        $result .= h3('Факс')."\n".p($string);
                    462:     }
                    463: 
                    464:     if (my $string=$club->{'Email'}) {
                    465:        $string = htmlize($string,'mailto:');
                    466:        $result .= h3('E-mail')."\n".p($string);
                    467:     }
                    468: 
                    469: 
                    470:     $result .= ListPeople(%args); 
                    471: 
1.4       boris     472:     $result .= ListParents(%args);
                    473: 
1.2       boris     474:     $result .= ListClubs(%args); 
                    475: 
1.4       boris     476: 
1.2       boris     477:     if (my $string=$club->{'DoB'}) {
                    478:        $result .= h3('История создания клуба')."\n".p($string);
                    479:     }
                    480: 
                    481:     if (my $string=$club->{'Sponsor'}) {
                    482:        $result .= h3('Спонсор')."\n".p($string);
                    483:     }
                    484: 
                    485:     if (my $string=$club->{'Meetings'}) {
                    486:        $result .= h3('Форма деятельности клуба')."\n".p($string);
                    487:     }
                    488: 
                    489:     if (my $string=$club->{'AdultTeams'}) {
                    490:        $result .= h3('Взрослые команды')."\n".p($string);
                    491:     
                    492:     }
                    493: 
                    494:     if (my $string=$club->{'KidTeams'}) {
                    495:        $result .= h3('Детские команды')."\n".p($string);
                    496:     
                    497:     }
                    498: 
                    499:     if (my $string=$club->{'ForeignFests'}) {
                    500:        $result .= h3('Иногородние фестивали, традиционно посещаемые командами клуба')."\n".p($string);
                    501:     
                    502:     }
                    503: 
                    504:     if (my $string=$club->{'Braglist'}) {
                    505:        $result .= h3('Высшие достижения команд клуба')."\n".p($string);
                    506:     
                    507:     }
                    508: 
                    509:     if (my $string=$club->{'OwnFests'}) {
                    510:        $result .= h3('Фестивали, организуемые клубом')."\n".p($string);
                    511:     
                    512:     }
                    513: 
                    514: 
                    515:     return $result;
                    516: 
                    517: }
                    518: 
                    519: 
                    520: ##############################################################
                    521: # Adding a href=... The second optional argument may be 
                    522: # 'mailto:'
                    523: ##############################################################
                    524: 
                    525: sub htmlize {
                    526:     my($string,$proto)=@_;
                    527:     $string =~ s/^\s+//;
                    528:     $string =~ s/\s+$//;
                    529:     my @entities = split /\s+/, $string;
                    530:     my @hrefs=map {"<a href=\"$proto$_\">$_</a>"} @entities;
                    531:     return join(", ",@hrefs);
                    532: }
                    533: 
                    534: 
                    535: ##############################################################
                    536: # List the bosses....
                    537: ##############################################################
                    538: sub ListPeople {
                    539:     my %args = @_;
                    540:     my $sth = $args{'dbh'}->prepare("
1.18      boris     541: SELECT a.pid,a.Position FROM ClubPeople=a,People=b WHERE a.cid=$args{'cid'} and a.pid=b.pid ORDER BY a.Weight Desc, b.Name");
1.2       boris     542:     $sth->execute;
                    543: 
                    544:     if (!$sth->rows) {
                    545:        return "";
                    546:     }
                    547: 
                    548:     my $result=h3('Руководство');
                    549:     while (my($pid,$Position)=$sth->fetchrow_array) {
                    550:        $result .= h4($Position);
                    551:        $result .= ListPerson(%args,pid=>$pid);
                    552:     }
                    553:     return $result;
                    554: }
                    555: 
                    556: ##############################################################
                    557: # Listing one person
                    558: #############################################################
                    559: sub ListPerson {
                    560:     my %args=@_;
                    561:     my $sth = $args{'dbh'}->prepare("
                    562: SELECT * FROM People WHERE pid=$args{'pid'}");
                    563:     $sth->execute;
                    564: 
                    565:     if (!$sth->rows) {
                    566:        return "";
                    567:     }
                    568: 
1.7       boris     569:     my $result="";
1.2       boris     570:     my @entries=();
                    571:     my $person=$sth->fetchrow_hashref;
                    572:     if (my $string = $person->{'Name'}) {
1.7       boris     573:        if ($args{'displayperson'}) {
                    574:            $result=h2($string);
                    575:        } else {
                    576:            push @entries, 
                    577:            "<a href=\"$args{'self'}?pid=$args{'pid'}\">$string</a>";
                    578:         }
1.2       boris     579:     }
                    580:     if (my $string=$person->{'Address'}) {
                    581:        push @entries, "Адрес: $string";
                    582:     }
                    583: 
                    584:     if (my $string=$person->{'URL'}) {
                    585:        $string = htmlize($string);
1.14      boris     586:        push @entries, "Домашняя страничка: $string";
1.2       boris     587:     }
                    588: 
                    589:     if (my $string=$person->{'Phone'}) {
                    590:        push @entries, "Телефон: $string";
                    591:     }
                    592: 
                    593:     if (my $string=$person->{'Fax'}) {
                    594:        push @entries, "Факс: $string";
                    595:     }
                    596: 
                    597:     if (my $string=$person->{'Email'}) {
                    598:        $string = htmlize($string,'mailto:');
                    599:        push @entries, "E-mail: $string";
                    600:     }
                    601: 
1.7       boris     602:     $result.=p(join('; ',@entries).".");
                    603:     if ($args{'positions'}) {
                    604:        my $sth=$dbh->prepare("SELECT cid,Position FROM ClubPeople
                    605: WHERE pid=$args{'pid'} ORDER by Weight");
                    606:        $sth->execute;
                    607:        $result .= "<dl>\n";
                    608:        while (my ($cid,$Position)=$sth->fetchrow_array) {
                    609:            my $sth1=$dbh->prepare("Select Name from Clubs where
                    610: cid=$cid");
                    611:            $sth1->execute;
                    612:            my ($Name)=$sth1->fetchrow_array;
                    613:            $sth1->finish;
                    614:            $result .= "<dd><strong>$Position,</strong> ";
                    615:            $result .= "<a href=\"$args{self}?cid=$cid\">$Name</a></dd>\n";
                    616:        }
                    617:        $sth->finish;
                    618:        $result .= "</dl>\n";
                    619:     }
                    620:     return $result;
1.2       boris     621: 
                    622: }
                    623: 
                    624: 
                    625: #########################################################
                    626: # Adding club
                    627: #########################################################
                    628: sub AddClub {
                    629:     my $result=h2("Добавить клуб или изменить информацию о клубе");
                    630:     
1.3       boris     631: 
1.2       boris     632:     $result .= start_form;
1.3       boris     633: 
                    634:     $result .= h3("Контактная информация");
                    635:     $result .= p("Адрес, телефон, email и т.д. ниже -- НЕ адреса руководства
                    636: клуба (их Вы введёте ниже), 
                    637: а официальные адреса самого клуба. Если отдельного адреса,
                    638: телефона, и т.д. у клуба нет, просто оставьте
                    639: поля пустыми");
1.2       boris     640:     $result .= table(Tr(td(["Название клуба",
                    641:                            textfield(-name=>'Name',
                    642:                                   -size=>60)])),
1.3       boris     643:                     Tr(td(["Официальный адрес клуба",
1.2       boris     644:                            textarea(-name=>'Address',
                    645:                                     -rows=>5,
                    646:                                     -columns=>60)])),
1.3       boris     647:                     Tr(td(["Страничка клуба",
1.2       boris     648:                            textfield(-name=>'URL',
                    649:                                     -size=>60)])),
1.3       boris     650:                     Tr(td(["Телефон клуба",
1.2       boris     651:                            textfield(-name=>'Phone',
                    652:                                     -size=>60)])),
1.3       boris     653:                     Tr(td(["Факс клуба",
1.2       boris     654:                            textfield(-name=>'Fax',
                    655:                                     -size=>60)])),
1.3       boris     656:                     Tr(td(["E-mail клуба",
1.2       boris     657:                            textfield(-name=>'Email',
                    658:                                     -size=>60)])),
1.3       boris     659:                     );
                    660:     $result .= h3("Руководство клуба");
                    661:     $result .= p("Адреса и телефоны ниже будут опубликованы. Если Вы не хотите
                    662: афишировать чьи-то адреса и телефоны, просто оставьте соответствующие поля
                    663: пустыми");
                    664:     $result .= "<ol>\n";
                    665:     for(my $i=1;$i<=5;$i++) {
                    666:        $result .=li;
                    667:        $result .= table(
                    668:                         
                    669:                         Tr(td(["Должность",
                    670:                                textfield(-name=>"Position$i",
                    671:                                          -size=>50)])),
                    672:                         Tr(td(["ФИО",
                    673:                                textfield(-name=>"Name$i",
                    674:                                          -size=>50)])),
                    675:                         Tr(td(["Адрес",
                    676:                                textarea(-name=>"Address$i",
                    677:                                         -columns=>50,
                    678:                                         -rows=>5)])),
                    679:                         Tr(td(["Телефон",
                    680:                                textfield(-name=>"Phone$i",
                    681:                                          -size=>50)])),
                    682:                         Tr(td(["Факс",
                    683:                                textfield(-name=>"Fax$i",
                    684:                                          -size=>50)])),
                    685:                         Tr(td(["Email",
                    686:                                textfield(-name=>"Email$i",
                    687:                                          -size=>50)])),
                    688:                         Tr(td(["Домашняя страничка",
                    689:                                textfield(-name=>"URL$i",
                    690:                                          -size=>50)])),
                    691:                         );
                    692:     }
                    693:     $result .= "</ol>\n";
                    694:     $result .= h3("Ассоциации и объединения");
                    695:     $result .= table(
1.2       boris     696:                     Tr(td(["Ассоциации, членом котрых является клуб",
                    697:                            textarea(-name=>'Parents',
                    698:                                     -rows=>5,
                    699:                                     -columns=>60)])),
                    700:                     Tr(td(["Для ассоциаций: коллективные члены ассоциации",
                    701:                            textarea(-name=>'Members',
                    702:                                     -rows=>5,
                    703:                                     -columns=>60)])),
1.3       boris     704:                     );
                    705:     $result .= h3("Жизнь клуба");
                    706:     $result .= table(
1.2       boris     707:                     Tr(td(["История создания клуба",
                    708:                            textarea(-name=>'DoB',
                    709:                                     -rows=>5,
                    710:                                     -columns=>60)])),
                    711:                     Tr(td(["Основной спонсор клуба",
                    712:                            textarea(-name=>'Sponsor',
                    713:                                     -rows=>5,
                    714:                                     -columns=>60)])),
                    715:                     Tr(td(["Основные формы деятельности клуба",
                    716:                            textarea(-name=>'Meetings',
                    717:                                     -rows=>5,
                    718:                                     -columns=>60)])),
                    719:                     Tr(td(["Взрослые команды",
                    720:                            textarea(-name=>'AdultTeams',
                    721:                                     -rows=>5,
                    722:                                     -columns=>60)])),
                    723:                     Tr(td(["Детские команды",
                    724:                            textarea(-name=>'KidTeams',
                    725:                                     -rows=>5,
                    726:                                     -columns=>60)])),
                    727:                     Tr(td(["Иногородние фестивали, на которые ездят команды клуба",
                    728:                            textarea(-name=>'ForeignFests',
                    729:                                     -rows=>5,
                    730:                                     -columns=>60)])),
                    731:                     Tr(td(["Высшие достижения команд клуба",
                    732:                            textarea(-name=>'Braglist',
                    733:                                     -rows=>5,
                    734:                                     -columns=>60)])),
                    735:                     Tr(td(["Фестивали, которые организовывает клуб",
                    736:                            textarea(-name=>'OwnFests',
                    737:                                     -rows=>5,
                    738:                                     -columns=>60)])),
1.3       boris     739:                     );
                    740: 
                    741:     $result .= h3("География клуба (для будущей карты)");
                    742:     $result .= table(
                    743:                     Tr(td(["Долгота",
                    744:                            textfield(-name=>"Longitude",
                    745:                                      -size=> 60)])),
                    746:                     Tr(td(["Широта",
                    747:                            textfield(-name=>"Latitude",
                    748:                                      -size=> 60)])),
                    749:                     );
                    750: 
1.20    ! boris     751: #     $result .= h3("Дополнительные вопросы");
        !           752: #     $result .= table(
1.3       boris     753: 
1.20    ! boris     754: #                   Tr(td(["Что вам больше всего нравится в журнале 'Игра'?",
        !           755: #                          textarea(-name=>'IgraA',
        !           756: #                                   -rows=>5,
        !           757: #                                   -columns=>60)])),
        !           758: #                   Tr(td(["Что вам больше всего не нравится в журнале 'Игра'?",
        !           759: #                          textarea(-name=>'IgraB',
        !           760: #                                   -rows=>5,
        !           761: #                                   -columns=>60)])),
        !           762: #                   Tr(td(["Что бы вы хотели увидеть в журнале 'Игра' - то 
        !           763: # чего нет в настоящее время?",
        !           764: #                          textarea(-name=>'IgraC',
        !           765: #                                   -rows=>5,
        !           766: #                                   -columns=>60)])),
        !           767: #                   );
1.5       boris     768: 
                    769:     $result .= h3("Кто регистрировал");
                    770:     $result .= table(
                    771:                     Tr(td(["Имя",
                    772:                            textfield(-name=>'RegistrarName',
                    773:                                     -size=>60)])),
                    774:                     Tr(td(["Email",
                    775:                            textfield(-name=>'RegistrarEmail',
                    776:                                     -size=>60)])),
1.2       boris     777:                     );
1.3       boris     778: 
                    779:     $result .= p("Нажав кнопку 'Submit', Вы отправите Вашу регистрационную 
1.4       boris     780: карточку службе поддержки регистра. Пожалуйста, подождите несколько дней, пока
                    781: Ваша информация будет обработана и попадёт в регистр");
1.2       boris     782:     $result .= submit(-name=>'Submit');
                    783:     $result .= end_form;
                    784:     return $result;
                    785: }
                    786: 
                    787: ###################################################################
                    788: # Sending the letter with results
                    789: #####################################################################
                    790: sub SendLetter {
1.11      boris     791:    open(MAIL,"| $SENDMAIL -s 'Registracionnaya kartochka kluba' $TO");
1.3       boris     792:     print MAIL <<END;
1.2       boris     793: MIME-Version: 1.0
                    794: Content-type: text/plain; charset=koi8-r
                    795: 
                    796: END
1.3       boris     797:     foreach my $key (param) {
                    798:        my $value = param($key);
                    799:        if ($value =~ /^\s*$/) {
                    800:            next;
                    801:        }
1.20    ! boris     802:        $value =~ s/'/\\'/g;
        !           803:        print MAIL "$key=\'$value\'\n\n";
1.3       boris     804:     }
                    805:            
1.2       boris     806: 
1.4       boris     807:    close MAIL;
                    808:    return p("Спасибо за регистрацию. Ваши данные приняты и после ".
                    809:            "обработки будут внесены в базу данных");
1.2       boris     810: }
1.1       boris     811: 
1.7       boris     812: ###############################################################
                    813: # Printing Who is Who list
                    814: ###############################################################
                    815: sub PrintWhoIsWho {
                    816:     my %args =@_;
                    817:     my $result = h2("Кто есть кто");
                    818:     $result .= "\n<dl>\n";
                    819:     my $sth = $dbh->prepare("SELECT pid,Name FROM People ORDER BY Name");  
                    820:     $sth->execute;
                    821:     while (my($pid,$Name)=$sth->fetchrow_array) {
                    822:        $result .= dd("<a href=\"$args{'self'}?pid=$pid\">$Name</a>");
                    823:        $result .= "\n";
                    824:     }
                    825:     $sth->finish;
                    826:     $result .= "</dl>\n";
                    827:     return $result;
                    828: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>