bug 827 restriced yellow marker <2006-09-1
[cacert-devel.git] / scripts / removedead.php
1 #!/usr/bin/php -q
2 <? /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2008 CAcert Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 include_once("/home/cacert/www/includes/mysql.php");
21
22 $query = "select * from `users` where `users`.`verified`=0 and
23 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`users`.`created`)) >= 172800";
24 $res = mysql_query($query);
25 while($row = mysql_fetch_assoc($res))
26 {
27 mysql_query("delete from `email` where `memid`='".$row['id']."'");
28 mysql_query("delete from `users` where `id`='".$row['id']."'");
29 }
30
31 $query = "delete from `domains` where `hash`!='' and
32 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 172800";
33 mysql_query($query);
34
35 $query = "delete from `email` where `hash`!='' and
36 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 172800";
37 mysql_query($query);
38
39 $query = "delete from `disputedomain` where `hash`!='' and
40 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 21600";
41 mysql_query($query);
42
43 $query = "delete from `disputeemail` where `hash`!='' and
44 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 21600";
45 mysql_query($query);
46
47 $query = "select * from `notary` where `expire`!=0 and `expire`<NOW()";
48 $res = mysql_query($query);
49 while($row = mysql_fetch_assoc($res))
50 {
51 $query = "select sum(`points`) as `points` from `notary` where `to`='$row[to]' and `expire`=0 group by `to`";
52 $dres = mysql_query($query);
53 $drow = mysql_fetch_assoc($dres);
54 if($drow['points'] >= 150)
55 {
56 $query = "update `notary` set `expire`=0, `points`='0' where `to`='$row[to]' and `from`='$row[from]' and `expire`='$row[expire]'";
57 } else {
58 $newpoints = 150 - $drow['points'];
59 $query = "update `notary` set `expire`=0, `points`='0' where `to`='$row[to]' and `from`='$row[from]' and `expire`='$row[expire]'";
60 mysql_query($query);
61 $query = "insert into `notary` set `expire`=0, `points`='$newpoints', `to`='$row[to]', `from`='$row[from]', `when`=NOW(), `method`='Administrative Increase', `date`=NOW()";
62 }
63
64 $data = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$row[to]'"));
65 $body = sprintf("%s %s (%s) had a temporary increase, but this has just expired and they have been reduced to 150 points.", $data['fname'], $data['lname'], $data['email'])."\n\n";
66 sendmail("cacert-board@lists.cacert.org", "[CAcert.org] Temporary Increase Expired.", $body, "website@cacert.org", "", "", "CAcert Website");
67
68 if($data['language'] != "")
69 {
70 $userlang = $data['language'];
71 putenv("LANG=".$userlang);
72 setlocale(LC_ALL, $userlang);
73 }
74
75 $body = _("You are receiving this email because you had a temporary increase to 200 points. This has since expired and you have been reduced to 150 points.")."\n\n";
76 $body = _("If you needed more time or any other extenuating circumstances you should contact us immediately so this situation can be dealt with immediately.")."\n\n";
77
78 $body .= _("Best regards")."\n";
79 $body .= _("CAcert Support Team");
80
81 sendmail($data['email'], "[CAcert.org] "._("Temporary points increase has expired."), $body, "support@cacert.org", "", "", "CAcert Website");
82
83 mysql_query($query);
84 fix_assurer_flag($row[to]);
85 }
86 ?>