--- register/prgsrc/register.cgi 2001/09/17 02:57:51 1.7 +++ register/prgsrc/register.cgi 2011/05/09 02:22:01 1.20 @@ -20,11 +20,11 @@ Boris Veytsman =head1 DATE -$Date: 2001/09/17 02:57:51 $ +$Date: 2011/05/09 02:22:01 $ =head1 REVISION -$Revision: 1.7 $ +$Revision: 1.20 $ =cut @@ -38,27 +38,36 @@ use vars qw(%ENV); use CGI qw(:standard); use DBI; use POSIX qw(locale_h); +use locale; -setlocale(LC_CTYPE,'russian'); +my $thislocale; +if ($^O =~ /win/i) { + $thislocale = "Russian_Russia.20866"; +} else { + $thislocale = "ru_RU.KOI8-R"; +} +POSIX::setlocale( &POSIX::LC_ALL, $thislocale ); $ENV{'LANG'}='ru_RU.KOI8-R'; -my ($SENDMAIL) = "/usr/sbin/sendmail"; -my $TO = 'borisv@lk.net, igra@gorlovka.net, erudit@mail.od.ua'; +my ($SENDMAIL) = "mail"; +my $TO = 'borisv@lk.net'; my $FROM = 'borisv@lk.net'; -my $date='$Date: 2001/09/17 02:57:51 $'; +my $date='$Date: 2011/05/09 02:22:01 $'; $date =~ s/[^ ]* ([^ ]*) .*/$1/; -my $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "") +my $dbh = DBI->connect("DBI:mysql:register", "piataev", "") 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; + $dbh->do("set names koi8r"); + +print header(-charset=>'koi8-r'); ################################################## @@ -66,12 +75,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,22 +95,23 @@ my $self=url(); # The navigation panel has three special lines ############################################### print < -
Все регионы
-
Все клубы
-
Добавить клуб
-
Кто есть кто
+ END @@ -124,8 +134,8 @@ END

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

+END +print &Include_virtual("../../boris/register/regions.html"); +print < END } #################################################################### # And the bottom of the page ################################################################### + my $sth=$dbh->prepare("select count(*) from Clubs"); + $sth->execute; + my ($count) = $sth->fetchrow_array; + $sth->finish; print "

"; - 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 +Boris Veytsman
@@ -248,6 +265,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(" @@ -259,7 +277,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; @@ -267,15 +285,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 { @@ -283,7 +332,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'}"); @@ -301,27 +350,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"; } @@ -333,7 +389,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; @@ -349,15 +405,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"; } @@ -474,7 +538,7 @@ sub htmlize { sub ListPeople { my %args = @_; my $sth = $args{'dbh'}->prepare(" -SELECT pid,Position FROM ClubPeople WHERE cid=$args{'cid'} ORDER BY Weight DESC"); +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"); $sth->execute; if (!$sth->rows) { @@ -519,7 +583,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'}) { @@ -684,23 +748,23 @@ sub AddClub { -size=> 60)])), ); - $result .= h3("Дополнительные вопросы"); - $result .= table( +# $result .= h3("Дополнительные вопросы"); +# $result .= table( - Tr(td(["Что вам больше всего нравится в журнале 'Игра'?", - textarea(-name=>'IgraA', - -rows=>5, - -columns=>60)])), - Tr(td(["Что вам больше всего не нравится в журнале 'Игра'?", - textarea(-name=>'IgraB', - -rows=>5, - -columns=>60)])), - Tr(td(["Что бы вы хотели увидеть в журнале 'Игра' - то -чего нет в настоящее время?", - textarea(-name=>'IgraC', - -rows=>5, - -columns=>60)])), - ); +# Tr(td(["Что вам больше всего нравится в журнале 'Игра'?", +# textarea(-name=>'IgraA', +# -rows=>5, +# -columns=>60)])), +# Tr(td(["Что вам больше всего не нравится в журнале 'Игра'?", +# textarea(-name=>'IgraB', +# -rows=>5, +# -columns=>60)])), +# Tr(td(["Что бы вы хотели увидеть в журнале 'Игра' - то +# чего нет в настоящее время?", +# textarea(-name=>'IgraC', +# -rows=>5, +# -columns=>60)])), +# ); $result .= h3("Кто регистрировал"); $result .= table( @@ -724,11 +788,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 <