[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/yahrzeit/old/ -> yahrload (source)

   1  #!/usr/local/bin/perl
   2  
   3  #
   4  #  Produce Yahrzeit List
   5  #  
   6  
   7  require "getopts.pl";
   8  require "fmtsub";
   9  
  10  while (<DATA>) {
  11      push (@tmpl1,$_);
  12  } 
  13  
  14  use DBI;
  15  
  16  #
  17  #   Connect to database
  18  #
  19  $driver = "mysql";
  20  $dsn = "DBI:$driver:database=yidata;host=192.168.64.2;port=3306";
  21  $dbh = DBI->connect($dsn, "yiadmin", "yipass");
  22  $drh = DBI->install_driver("mysql");
  23  
  24  
  25  
  26  
  27  while (<>) {
  28      last if /^###/;
  29      if (/:end:/) {
  30          if($have_data) { 
  31              &fmt("",\@mydata);
  32              $yy=0;
  33              ($yd,$ym)=split(/[ \t]+/,$key{"yahrhebdate"},2);
  34              if($ym =~ /\s*(\d+)$/) { $yy =$1; }
  35              $ym =~ s/\s*(\d+)$//;
  36              $tmo=$mo=0;
  37              $t=$key{relation};
  38              $relationname = $key{relationname};
  39              $relation = $key{relation};
  40              $membername = $key{membername};
  41              $hebd = $key{yahrhebdate};
  42  
  43              $relationname =~ s/(["'])/\\\1/g;
  44  
  45  #
  46  #  check if address on file
  47  #
  48  
  49        @names=split(/[\s]/, $membername);
  50              $last= pop(@names);
  51  
  52              $sth = $dbh->prepare( $sqlstmt = "SELECT serial from identity 
  53                           where name_last like \'$last%\'" );
  54              $serial= $rows=0;
  55              if ($sth->execute ) {
  56                  while (my $ref = $sth->fetchrow_arrayref) {
  57                      $rows++;
  58                      $serial =$$ref[0];
  59                  }
  60                  $serial = 0 if ($rows != 1 ) ;
  61              }
  62  
  63  #
  64  #  add to database
  65  #
  66              $sth = $dbh->prepare( $sqlstmt = "INSERT INTO yz 
  67                    (serial, 
  68                       y_notify_name, 
  69                       y_rel, 
  70                       y_rel_name, 
  71                       y_heb_dy, 
  72                       y_dt_mo, 
  73                       y_dt_yr) 
  74                  VALUES 
  75                    ($serial, 
  76                       \'$membername\', 
  77                       \'$relation\', 
  78                       \'$relationname\', 
  79                       $yd, 
  80                       \'$ym\', 
  81                       $yy)");
  82              $sqlstmt =~ s/    / /g;
  83              $sth->execute;
  84              }
  85  
  86              $have_data=0;
  87              @mydata = ();
  88              next;
  89  
  90          } elsif (/:begin:/) { next; 
  91          } else {
  92              push (@mydata,$_);
  93              $have_data=1;
  94          }
  95  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7