3 require "/home/lj/cgi-bin/ljlib.pl";
7 unless ($newsnum =~ /^\d+$/) {
8 die "Need argv[0] = newsnum!\n";
16 #$where = "u.allow_getljnews='Y' AND u.status='A' AND u.statusvis='V'";
18 $where = "u.paidfeatures IN ('early', 'off') AND u.status='A' AND u.statusvis='V' AND u.timeupdate > DATE_SUB(NOW(), INTERVAL 14 DAY)";
20 #$where = "u.status='A' AND u.statusvis='V' AND u.country='US' and u.state IN ('OR', 'WA', 'ID') AND u.timeupdate > DATE_SUB(NOW(), INTERVAL 21 DAY)";
22 #$where = "u.userid=1";
23 #$where = "u.status='A' AND u.timeupdate > DATE_SUB(NOW(), INTERVAL 7 DAY)";
24 #$where = "u.status='A' AND (u.allow_getljnews='Y' OR u.lastn_style NOT IN (1, 2, 3, 4, 5, 20, 6) OR u.friends_style NOT IN (1, 2, 3, 4, 5, 20, 6))";
28 $sth = $dbh->prepare("SELECT u.user FROM user u WHERE $where");
30 if ($dbh->err) { print $dbh->errstr; }
33 push @users, $_->{'user'} while ($_ = $sth->fetchrow_hashref);
35 my ($count) = scalar(@users);
36 print "Count: $count\n";
38 foreach my $user (@users)
43 my $quser = $dbh->quote($user);
44 $sth = $dbh->prepare("SELECT COUNT(*) AS 'sent' FROM news_sent WHERE user=$quser AND newsnum=$newsnum");
46 my ($sent) = $sth->fetchrow_array;
48 print "$user: skipping.\n";
51 $sth = $dbh->prepare("SELECT userid, user, email, name, timeupdate FROM user WHERE user=$quser");
53 $c = $sth->fetchrow_hashref;
56 # my $aa = ®ister_authaction($c->{'userid'}, "nonews");
58 # $c->{'authid'} = $aa->{'aaid'};
59 # $c->{'authcode'} = $aa->{'authcode'};
62 $msg =~ s/\[(\w+?)\]/$c->{$1}/g;
63 open (MAIL
, "|$SENDMAIL");
68 my $quser = $dbh->quote($c->{'user'});
69 my $qemail = $dbh->quote($c->{'email'});
70 $dbh->do("INSERT INTO news_sent (newsnum, user, datesent, email) VALUES ($newsnum, $quser, NOW(), $qemail)");
71 if ($dbh->err) { die $dbh->errstr; }
73 print "mailed $user ($c->{'email'})...\n";