Diff for /register/prgsrc/register.cgi between versions 1.6 and 1.20

version 1.6, 2001/09/11 22:27:12 version 1.20, 2011/05/09 02:22:01
Line 38  use vars qw(%ENV); Line 38  use vars qw(%ENV);
 use CGI qw(:standard);  use CGI qw(:standard);
 use DBI;  use DBI;
 use POSIX qw(locale_h);  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';  $ENV{'LANG'}='ru_RU.KOI8-R';
 my ($SENDMAIL) = "/usr/sbin/sendmail";  my ($SENDMAIL) = "mail";
 my $TO = 'borisv@lk.net, igra@gorlovka.net';  my $TO = 'borisv@lk.net';
 my $FROM = 'borisv@lk.net';  my $FROM = 'borisv@lk.net';
   
 my $date='$Date$';  my $date='$Date$';
 $date =~ s/[^ ]* ([^ ]*) .*/$1/;   $date =~ s/[^ ]* ([^ ]*) .*/$1/; 
   
   
 my $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "")  my $dbh = DBI->connect("DBI:mysql:register", "piataev", "")
     or do {      or do {
         print h1("Временные проблемы") . "База данных временно не          print h1("Временные проблемы") . "База данных временно не
                         работает. Заходите попозже.";                          работает. Заходите попозже.";
         print &Include_virtual("../dimrub/db/reklama.html");          print &Include_virtual("../../dimrub/db/reklama.html");
         print end_html;          print end_html;
         die "Can't connect to DB chgk\n";          die "Can't connect to DB chgk\n";
     };      };
   
 print header;          $dbh->do("set names koi8r");
   
   print header(-charset=>'koi8-r');
   
   
 ##################################################  ##################################################
Line 66  print header; Line 75  print header;
 ##################################################  ##################################################
 print start_html(-"title"=>'Register of Clubs',  print start_html(-"title"=>'Register of Clubs',
                  -author=>'borisv@lk.net',                   -author=>'borisv@lk.net',
                  -background=>"../images/map.jpg");                   -background=>"../../images/map.jpg");
 print &Include_virtual("../dimrub/db/reklama.html");  print &Include_virtual("../../dimrub/db/reklama.html");
 print <<END;  print <<END;
 <table>  <table>
 <tr>  <tr>
 <td background=../images/compass.gif valign=top>  <td background=../../images/compass.gif valign=top>
 END  END
   
 ################################################  ################################################
Line 86  my $self=url(); Line 95  my $self=url();
 # The navigation panel has three special lines  # The navigation panel has three special lines
 ###############################################  ###############################################
 print <<END;  print <<END;
 <dl>  <ul>
 <dt><a href="$self?rid=1&level=1000&clubs=0">Все регионы</a></dt>  <li><a href="$self">Home</a></li>
 <dt><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></dt>  <li><a href="$self?rid=1&level=1000&clubs=0">Все регионы</a></li>
 <dt><a href="$self?addclub=1">Добавить клуб</a></dt>  <li><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></li>
   <li><a href="$self?addclub=1">Добавить клуб</a></li>
   <li><a href="$self?whoiswho=1">Кто есть кто</a></li>
 END  END
   
 #################################################  #################################################
 # And the navpanel itself  # And the navpanel itself
 ##################################################  ##################################################
   
     print ListRegions(dbh=>$dbh,rid=>1,level=>1,tag=>'dt',      print ListRegions(dbh=>$dbh,rid=>1,level=>1,tag=>'li',
                       self=>$self);                        self=>$self);
           
 print <<END;  print <<END;
 </dl>  </ul>
 END  END
   
   
Line 123  END Line 134  END
 <h1 align=center>  <h1 align=center>
 Журнал "Игра"<br>  Журнал "Игра"<br>
 и<br>  и<br>
 <a href="http:/znatoki/klub/znat.html"><img   <a href="http://internet.chgk.info"><img 
 ismap border=0 src= "http:../images/logo.gif"   ismap border=0 src= "../../images/logo.gif" 
 alt="Интернет Клуб Что? Где? Когда?" width=319 height=27></a>  alt="Интернет Клуб Что? Где? Когда?" width=319 height=27></a>
 <br>ПРЕДСТАВЛЯЮТ<br>  <br>ПРЕДСТАВЛЯЮТ<br>
 Регистр Клубов Интеллектуальных Игр  Регистр Клубов Интеллектуальных Игр
Line 147  END Line 158  END
         $cid =~ s/(\d*)/$1/;          $cid =~ s/(\d*)/$1/;
         print ClubInfo(dbh=>$dbh,cid=>$cid,          print ClubInfo(dbh=>$dbh,cid=>$cid,
                        self=>$self);                         self=>$self);
       } elsif (param('pid')) {
           my $pid = param('pid');
           $pid =~ s/(\d*)/$1/;
           print ListPerson(dbh=>$dbh,pid=>$pid,
                            self=>$self,
                            positions=>1,
                            displayperson=>1);
       } elsif (param('whoiswho')) {
           print PrintWhoIsWho(dbh=>$dbh,
                               self=>$self);
     } elsif (param('addclub')) {      } elsif (param('addclub')) {
         print AddClub();          print AddClub();
     } elsif (param('Submit')) {      } elsif (param('Submit')) {
Line 158  END Line 179  END
 <dt><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></dt>  <dt><a href="$self?rid=1&level=1000&clubs=1">Все клубы</a></dt>
 <dt><a href="$self?addclub=1">Добавить клуб или изменить сведения  <dt><a href="$self?addclub=1">Добавить клуб или изменить сведения
 о клубе</a></dt>  о клубе</a></dt>
   <dt><a href="$self?whoiswho=1">Кто есть кто</a></dt>
 </dl>  </dl>
   <p align=center>
   END
   print &Include_virtual("../../boris/register/regions.html");
   print <<END;
   </p>
 END  END
 }  }
   
 ####################################################################  ####################################################################
 # And the bottom of the page  # And the bottom of the page
 ###################################################################  ###################################################################
       my $sth=$dbh->prepare("select count(*) from Clubs");
       $sth->execute;
       my ($count) = $sth->fetchrow_array;
       $sth->finish;
   
     print "<p align=center>";      print "<p align=center>";
     print "Эту страничку посмотрели ";      print "Всего клубов: $count</p>\n";
     print `/home/piataev/public_html/cgi-bin/counter.sh /znatoki/cgi-bin/register.cgi`;  
     print " раз(а)</p>\n";  
           
     print <<END;      print <<END;
 <hr>  <hr>
 <address>  <address>
 <img width = 60 height = 80 src="../images/owl.gif" alt = "owl">   <img width = 60 height = 80 src="../../images/owl.gif" alt = "owl"> 
 <a href="http://users.lk.net/~borisv">  <a href="http://users.lk.net/~borisv">
 Boris Veytsman</a>, $date  Boris Veytsman</a>
 </address>  </address>
 </body>  </body>
 </html>  </html>
Line 236  SELECT Name FROM Regions WHERE RID=$args Line 265  SELECT Name FROM Regions WHERE RID=$args
   
         # Frist, we print clubs          # Frist, we print clubs
         if ($args{'clubs'}) {          if ($args{'clubs'}) {
               $result .= ListRegionURLs(%args);
             $result .= ListClubs(%args);              $result .= ListClubs(%args);
         }          }
         $sth=$args{'dbh'}->prepare("          $sth=$args{'dbh'}->prepare("
Line 247  SELECT Child FROM RegionRegion WHERE Par Line 277  SELECT Child FROM RegionRegion WHERE Par
                 push @kids,"rid=$kid";                  push @kids,"rid=$kid";
             }              }
             my $clause = join(' OR ', @kids);              my $clause = join(' OR ', @kids);
             $result .= "<dl>\n";              $result .= "<ul>\n";
             $sth=$args{'dbh'}->prepare("              $sth=$args{'dbh'}->prepare("
 SELECT rid FROM Regions WHERE $clause ORDER BY Name");  SELECT rid FROM Regions WHERE $clause ORDER BY Name");
             $sth->execute;              $sth->execute;
Line 255  SELECT rid FROM Regions WHERE $clause OR Line 285  SELECT rid FROM Regions WHERE $clause OR
                 $result .= ListRegions(                  $result .= ListRegions(
                                        %args,'rid'=>$kid,                                         %args,'rid'=>$kid,
                                        'level'=>$args{'level'}-1,                                         'level'=>$args{'level'}-1,
                                        'tag'=>'dt');                                         'tag'=>'li');
             }              }
             $result .= "</dl>\n";              $result .= "</ul>\n";
         }          }
     }      }
     return $result;      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=<<END;
   <dl><dt>Странички:</dt>
   <dd><dl>\n
   END
       
       while (my ($string)=$sth->fetchrow_array) {
           $string=htmlize($string);
           $result .= p($string);
       }
       $result .= "</dl></dd></dl>\n";
       return $result;
   }
   
   
   ############################################################
 # List the clubs of a given region or a given association  # List the clubs of a given region or a given association
 ###########################################################  ###########################################################
 sub ListClubs {  sub ListClubs {
Line 271  sub ListClubs { Line 332  sub ListClubs {
     my $sth;      my $sth;
     if ($args{'cid'}) {      if ($args{'cid'}) {
         $sth = $args{'dbh'}->prepare("          $sth = $args{'dbh'}->prepare("
 SELECT Child FROM ClubClub WHERE Parent=$args{'cid'}");  SELECT Child, Status FROM ClubClub WHERE Parent=$args{'cid'}");
     } else {      } else {
         $sth = $args{'dbh'}->prepare("          $sth = $args{'dbh'}->prepare("
 SELECT cid FROM ClubRegion WHERE rid=$args{'rid'}");  SELECT cid FROM ClubRegion WHERE rid=$args{'rid'}");
Line 289  SELECT cid FROM ClubRegion WHERE rid=$ar Line 350  SELECT cid FROM ClubRegion WHERE rid=$ar
   
         $result=<<END;          $result=<<END;
 <h3>Клубы:</h3>  <h3>Клубы:</h3>
 <dd><dl>\n  <ul>\n
 END  END
      } else {       } else {
     
          $result=<<END;           $result=<<END;
 <dl><dt>Клубы:</dt>  <ul>\n
 <dd><dl>\n  
 END  END
     }      }
     my @clubs=();      my @clubs=();
     while (my ($club)=$sth->fetchrow_array) {      my %stat=();
       while (my ($club,$status)=$sth->fetchrow_array) {
         push @clubs,"cid=$club";          push @clubs,"cid=$club";
           if ($status) {
               $stat{$club}=$status;
           }
     }      }
     my $clause = join(' OR ', @clubs);      my $clause = join(' OR ', @clubs);
     $sth=$args{'dbh'}->prepare("      $sth=$args{'dbh'}->prepare("
 SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");  SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");
     $sth->execute;      $sth->execute;
     while (my ($cid,$Name)=$sth->fetchrow_array) {      while (my ($cid,$Name)=$sth->fetchrow_array) {
         $result .= dt("<a href=\"$self?cid=$cid\">$Name</a>\n");          my $res="<a href=\"$self?cid=$cid\">$Name</a>\n";
           if (exists $stat{$cid}) {
               $res .= " ($stat{$cid})\n";
           }
           $result .= li($res);
     }      }
     $result .= "</dl></dd></dl>\n";      $result .= "</ul>\n";
 }  }
   
   
Line 321  sub ListParents { Line 389  sub ListParents {
     my $sth;      my $sth;
   
     $sth = $args{'dbh'}->prepare("      $sth = $args{'dbh'}->prepare("
 SELECT Parent FROM ClubClub WHERE Child=$args{'cid'}");  SELECT Parent, Status FROM ClubClub WHERE Child=$args{'cid'}");
   
     $sth->execute;      $sth->execute;
                   
Line 333  SELECT Parent FROM ClubClub WHERE Child= Line 401  SELECT Parent FROM ClubClub WHERE Child=
                   
     $result=<<END;      $result=<<END;
 <h3>Коллективный член ассоциаций:</h3>  <h3>Коллективный член ассоциаций:</h3>
 <dd><dl>\n  <dl>\n
 END  END
   
     my @clubs=();      my @clubs=();
     while (my ($club)=$sth->fetchrow_array) {      my %stat=();
       while (my ($club,$status)=$sth->fetchrow_array) {
         push @clubs,"cid=$club";          push @clubs,"cid=$club";
           if ($status) {
               $stat{$club}=$status;
           }
     }      }
     my $clause = join(' OR ', @clubs);      my $clause = join(' OR ', @clubs);
     $sth=$args{'dbh'}->prepare("      $sth=$args{'dbh'}->prepare("
 SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");  SELECT cid, Name FROM Clubs WHERE $clause ORDER BY Name");
     $sth->execute;      $sth->execute;
     while (my ($cid,$Name)=$sth->fetchrow_array) {      while (my ($cid,$Name)=$sth->fetchrow_array) {
         $result .= dt("<a href=\"$self?cid=$cid\">$Name</a>\n");          my $res = "<a href=\"$self?cid=$cid\">$Name</a>\n";
           if (exists $stat{$cid}) {
               $res .= " ($stat{$cid})\n";
           }
           $result .= dt($res);
     }      }
     $result .= "</dl></dd></dl>\n";      $result .= "</dl></dd></dl>\n";
 }  }
Line 462  sub htmlize { Line 538  sub htmlize {
 sub ListPeople {  sub ListPeople {
     my %args = @_;      my %args = @_;
     my $sth = $args{'dbh'}->prepare("      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;      $sth->execute;
   
     if (!$sth->rows) {      if (!$sth->rows) {
Line 490  SELECT * FROM People WHERE pid=$args{'pi Line 566  SELECT * FROM People WHERE pid=$args{'pi
         return "";          return "";
     }      }
   
       my $result="";
     my @entries=();      my @entries=();
     my $person=$sth->fetchrow_hashref;      my $person=$sth->fetchrow_hashref;
     if (my $string = $person->{'Name'}) {      if (my $string = $person->{'Name'}) {
         push @entries, $string;          if ($args{'displayperson'}) {
               $result=h2($string);
           } else {
               push @entries, 
               "<a href=\"$args{'self'}?pid=$args{'pid'}\">$string</a>";
           }
     }      }
     if (my $string=$person->{'Address'}) {      if (my $string=$person->{'Address'}) {
         push @entries, "Адрес: $string";          push @entries, "Адрес: $string";
Line 501  SELECT * FROM People WHERE pid=$args{'pi Line 583  SELECT * FROM People WHERE pid=$args{'pi
   
     if (my $string=$person->{'URL'}) {      if (my $string=$person->{'URL'}) {
         $string = htmlize($string);          $string = htmlize($string);
         push @entries, "Домашнаяя страничка: $string";          push @entries, "Домашняя страничка: $string";
     }      }
   
     if (my $string=$person->{'Phone'}) {      if (my $string=$person->{'Phone'}) {
Line 517  SELECT * FROM People WHERE pid=$args{'pi Line 599  SELECT * FROM People WHERE pid=$args{'pi
         push @entries, "E-mail: $string";          push @entries, "E-mail: $string";
     }      }
   
     return p(join('; ',@entries).".");      $result.=p(join('; ',@entries).".");
       if ($args{'positions'}) {
           my $sth=$dbh->prepare("SELECT cid,Position FROM ClubPeople
   WHERE pid=$args{'pid'} ORDER by Weight");
           $sth->execute;
           $result .= "<dl>\n";
           while (my ($cid,$Position)=$sth->fetchrow_array) {
               my $sth1=$dbh->prepare("Select Name from Clubs where
   cid=$cid");
               $sth1->execute;
               my ($Name)=$sth1->fetchrow_array;
               $sth1->finish;
               $result .= "<dd><strong>$Position,</strong> ";
               $result .= "<a href=\"$args{self}?cid=$cid\">$Name</a></dd>\n";
           }
           $sth->finish;
           $result .= "</dl>\n";
       }
       return $result;
   
 }  }
   
Line 648  sub AddClub { Line 748  sub AddClub {
                                       -size=> 60)])),                                        -size=> 60)])),
                      );                       );
   
     $result .= h3("Дополнительные вопросы");  #     $result .= h3("Дополнительные вопросы");
     $result .= table(  #     $result .= table(
   
                      Tr(td(["Что вам больше всего нравится в журнале 'Игра'?",  #                    Tr(td(["Что вам больше всего нравится в журнале 'Игра'?",
                             textarea(-name=>'IgraA',  #                           textarea(-name=>'IgraA',
                                      -rows=>5,  #                                    -rows=>5,
                                      -columns=>60)])),  #                                    -columns=>60)])),
                      Tr(td(["Что вам больше всего не нравится в журнале 'Игра'?",  #                    Tr(td(["Что вам больше всего не нравится в журнале 'Игра'?",
                             textarea(-name=>'IgraB',  #                           textarea(-name=>'IgraB',
                                      -rows=>5,  #                                    -rows=>5,
                                      -columns=>60)])),  #                                    -columns=>60)])),
                      Tr(td(["Что бы вы хотели увидеть в журнале 'Игра' - то   #                    Tr(td(["Что бы вы хотели увидеть в журнале 'Игра' - то 
 чего нет в настоящее время?",  # чего нет в настоящее время?",
                             textarea(-name=>'IgraC',  #                           textarea(-name=>'IgraC',
                                      -rows=>5,  #                                    -rows=>5,
                                      -columns=>60)])),  #                                    -columns=>60)])),
                      );  #                    );
   
     $result .= h3("Кто регистрировал");      $result .= h3("Кто регистрировал");
     $result .= table(      $result .= table(
Line 688  sub AddClub { Line 788  sub AddClub {
 # Sending the letter with results  # Sending the letter with results
 #####################################################################  #####################################################################
 sub SendLetter {  sub SendLetter {
    open(MAIL,"| $SENDMAIL -t -n");     open(MAIL,"| $SENDMAIL -s 'Registracionnaya kartochka kluba' $TO");
     print MAIL <<END;      print MAIL <<END;
 To: $TO  
 From: $FROM  
 Subject: Registracionnaya kartochka kluba  
 MIME-Version: 1.0  MIME-Version: 1.0
 Content-type: text/plain; charset=koi8-r  Content-type: text/plain; charset=koi8-r
   
Line 702  END Line 799  END
         if ($value =~ /^\s*$/) {          if ($value =~ /^\s*$/) {
             next;              next;
         }          }
         print MAIL "$key=$value\n\n";          $value =~ s/'/\\'/g;
           print MAIL "$key=\'$value\'\n\n";
     }      }
                           
   
Line 711  END Line 809  END
             "обработки будут внесены в базу данных");              "обработки будут внесены в базу данных");
 }  }
   
   ###############################################################
   # Printing Who is Who list
   ###############################################################
   sub PrintWhoIsWho {
       my %args =@_;
       my $result = h2("Кто есть кто");
       $result .= "\n<dl>\n";
       my $sth = $dbh->prepare("SELECT pid,Name FROM People ORDER BY Name");  
       $sth->execute;
       while (my($pid,$Name)=$sth->fetchrow_array) {
           $result .= dd("<a href=\"$args{'self'}?pid=$pid\">$Name</a>");
           $result .= "\n";
       }
       $sth->finish;
       $result .= "</dl>\n";
       return $result;
   }

Removed from v.1.6  
changed lines
  Added in v.1.20


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