--- register/prgsrc/register.cgi 2001/10/13 23:19:21 1.9 +++ register/prgsrc/register.cgi 2003/09/04 21:09:47 1.17 @@ -20,11 +20,11 @@ Boris Veytsman =head1 DATE -$Date: 2001/10/13 23:19:21 $ +$Date: 2003/09/04 21:09:47 $ =head1 REVISION -$Revision: 1.9 $ +$Revision: 1.17 $ =cut @@ -41,11 +41,11 @@ use POSIX qw(locale_h); setlocale(LC_CTYPE,'russian'); $ENV{'LANG'}='ru_RU.KOI8-R'; -my ($SENDMAIL) = "/usr/sbin/sendmail"; +my ($SENDMAIL) = "mail"; my $TO = 'borisv@lk.net, igra@gorlovka.net, erudit@mail.od.ua'; my $FROM = 'borisv@lk.net'; -my $date='$Date: 2001/10/13 23:19:21 $'; +my $date='$Date: 2003/09/04 21:09:47 $'; $date =~ s/[^ ]* ([^ ]*) .*/$1/; @@ -53,12 +53,12 @@ my $dbh = DBI->connect("DBI:mysql:chgk", or do { print h1("Временные проблемы") . "База данных временно не работает. Заходите попозже."; - print &Include_virtual("../dimrub/db/reklama.html"); + print &Include_virtual("../../dimrub/db/reklama.html"); print end_html; die "Can't connect to DB chgk\n"; }; -print header; +print header(-charset=>'koi8-r'); ################################################## @@ -66,12 +66,12 @@ print header; ################################################## print start_html(-"title"=>'Register of Clubs', -author=>'borisv@lk.net', - -background=>"../images/map.jpg"); -print &Include_virtual("../dimrub/db/reklama.html"); + -background=>"../../images/map.jpg"); +print &Include_virtual("../../dimrub/db/reklama.html"); print < - + END ################################################ @@ -86,23 +86,23 @@ my $self=url(); # The navigation panel has three special lines ############################################### print < -
Home
-
Все регионы
-
Все клубы
-
Добавить клуб
-
Кто есть кто
+ END @@ -125,8 +125,8 @@ END

Журнал "Игра"
и
-Интернет Клуб Что? Где? Когда?
ПРЕДСТАВЛЯЮТ
Регистр Клубов Интеллектуальных Игр @@ -174,7 +174,7 @@ END

END -print &Include_virtual("../boris/register/regions.html"); +print &Include_virtual("../../boris/register/regions.html"); print < END @@ -189,15 +189,12 @@ END $sth->finish; print "

"; - print "Всего клубов: $count
\n"; - print "Эту страничку посмотрели "; - print `/home/piataev/public_html/cgi-bin/counter.sh /znatoki/cgi-bin/register.cgi`; - print " раз(а)

\n"; + print "Всего клубов: $count

\n"; print <
-owl +owl Boris Veytsman, $date
@@ -259,6 +256,7 @@ SELECT Name FROM Regions WHERE RID=$args # Frist, we print clubs if ($args{'clubs'}) { + $result .= ListRegionURLs(%args); $result .= ListClubs(%args); } $sth=$args{'dbh'}->prepare(" @@ -270,7 +268,7 @@ SELECT Child FROM RegionRegion WHERE Par push @kids,"rid=$kid"; } my $clause = join(' OR ', @kids); - $result .= "
\n"; + $result .= "
    \n"; $sth=$args{'dbh'}->prepare(" SELECT rid FROM Regions WHERE $clause ORDER BY Name"); $sth->execute; @@ -278,15 +276,46 @@ SELECT rid FROM Regions WHERE $clause OR $result .= ListRegions( %args,'rid'=>$kid, 'level'=>$args{'level'}-1, - 'tag'=>'dt'); + 'tag'=>'li'); } - $result .= "
\n"; + $result .= "\n"; } } return $result; } ############################################################ +# List the URLs of a given region +########################################################### +sub ListRegionURLs { + my %args = @_; + my $sth; + $sth = $args{'dbh'}->prepare(" +SELECT URL FROM Regions WHERE rid=$args{'rid'} and NOT ISNULL(URL)"); + + $sth->execute; + + if (!$sth->rows) { + return ""; + } + + my $result; + + $result=<
Странички:
+
\n +END + + while (my ($string)=$sth->fetchrow_array) { + $string=htmlize($string); + $result .= p($string); + } + $result .= "
\n"; + return $result; +} + + +############################################################ # List the clubs of a given region or a given association ########################################################### sub ListClubs { @@ -294,7 +323,7 @@ sub ListClubs { my $sth; if ($args{'cid'}) { $sth = $args{'dbh'}->prepare(" -SELECT Child FROM ClubClub WHERE Parent=$args{'cid'}"); +SELECT Child, Status FROM ClubClub WHERE Parent=$args{'cid'}"); } else { $sth = $args{'dbh'}->prepare(" SELECT cid FROM ClubRegion WHERE rid=$args{'rid'}"); @@ -312,27 +341,34 @@ SELECT cid FROM ClubRegion WHERE rid=$ar $result=<Клубы:

-
\n +
    \n END } else { $result=<
    Клубы:
    -
    \n +
      \n END } my @clubs=(); - while (my ($club)=$sth->fetchrow_array) { + my %stat=(); + while (my ($club,$status)=$sth->fetchrow_array) { push @clubs,"cid=$club"; + if ($status) { + $stat{$club}=$status; + } } my $clause = join(' OR ', @clubs); $sth=$args{'dbh'}->prepare(" SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name"); $sth->execute; while (my ($cid,$Name)=$sth->fetchrow_array) { - $result .= dt("$Name\n"); + my $res="$Name\n"; + if (exists $stat{$cid}) { + $res .= " ($stat{$cid})\n"; + } + $result .= li($res); } - $result .= "
\n"; + $result .= "\n"; } @@ -344,7 +380,7 @@ sub ListParents { my $sth; $sth = $args{'dbh'}->prepare(" -SELECT Parent FROM ClubClub WHERE Child=$args{'cid'}"); +SELECT Parent, Status FROM ClubClub WHERE Child=$args{'cid'}"); $sth->execute; @@ -360,15 +396,23 @@ SELECT Parent FROM ClubClub WHERE Child= END my @clubs=(); - while (my ($club)=$sth->fetchrow_array) { + my %stat=(); + while (my ($club,$status)=$sth->fetchrow_array) { push @clubs,"cid=$club"; + if ($status) { + $stat{$club}=$status; + } } my $clause = join(' OR ', @clubs); $sth=$args{'dbh'}->prepare(" SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name"); $sth->execute; while (my ($cid,$Name)=$sth->fetchrow_array) { - $result .= dt("$Name\n"); + my $res = "$Name\n"; + if (exists $stat{$cid}) { + $res .= " ($stat{$cid})\n"; + } + $result .= dt($res); } $result .= "\n"; } @@ -530,7 +574,7 @@ SELECT * FROM People WHERE pid=$args{'pi if (my $string=$person->{'URL'}) { $string = htmlize($string); - push @entries, "Домашнаяя страничка: $string"; + push @entries, "Домашняя страничка: $string"; } if (my $string=$person->{'Phone'}) { @@ -735,11 +779,8 @@ sub AddClub { # Sending the letter with results ##################################################################### sub SendLetter { - open(MAIL,"| $SENDMAIL -t -n"); + open(MAIL,"| $SENDMAIL -s 'Registracionnaya kartochka kluba' $TO"); print MAIL <