All mysql_-statments replaced by their corresponding mysqli_-statements
[cacert-devel.git] / scripts / cron / 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 require_once(dirname(__FILE__).'/../../includes/mysql.php');
21 require_once(dirname(__FILE__).'/../../includes/lib/l10n.php');
22 require_once(dirname(__FILE__).'/../../includes/notary.inc.php');
23
24 $query = "select * from `users` where `users`.`verified`=0 and
25 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`users`.`created`)) >= 172800";
26 $res = mysqli_query($_SESSION['mconn'], $query);
27 while($row = mysqli_fetch_assoc($res))
28 {
29 mysqli_query($_SESSION['mconn'], "delete from `email` where `memid`='".$row['id']."'");
30 mysqli_query($_SESSION['mconn'], "delete from `users` where `id`='".$row['id']."'");
31 delete_user_agreement($row['id']);
32 }
33
34 $query = "delete from `domains` where `hash`!='' and
35 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 172800";
36 mysqli_query($_SESSION['mconn'], $query);
37
38 $query = "delete from `email` where `hash`!='' and
39 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 172800";
40 mysqli_query($_SESSION['mconn'], $query);
41
42 $query = "delete from `disputedomain` where `hash`!='' and
43 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 21600";
44 mysqli_query($_SESSION['mconn'], $query);
45
46 $query = "delete from `disputeemail` where `hash`!='' and
47 (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`created`)) >= 21600";
48 mysqli_query($_SESSION['mconn'], $query);
49
50 // the folloing part is presently not used as there is no running programme that uses temporary increase
51 // in case that there is a new one the procedure needs a rework regarding the point claculation
52 /*
53 $query = "select * from `notary` where `expire`!=0 and `expire`<NOW()";
54 $res = mysqli_query($_SESSION['mconn'], $query);
55 while($row = mysqli_fetch_assoc($res))
56 {
57 $query = "select sum(`points`) as `points` from `notary` where `to`='$row[to]' and `expire`=0 group by `to`";
58 $dres = mysqli_query($_SESSION['mconn'], $query);
59 $drow = mysqli_fetch_assoc($dres);
60 if($drow['points'] >= 150)
61 {
62 $query = "update `notary` set `expire`=0, `points`='0' where `to`='$row[to]' and `from`='$row[from]' and `expire`='$row[expire]'";
63 } else {
64 $newpoints = 150 - $drow['points'];
65 $query = "update `notary` set `expire`=0, `points`='0' where `to`='$row[to]' and `from`='$row[from]' and `expire`='$row[expire]'";
66 mysqli_query($_SESSION['mconn'], $query);
67 $query = "insert into `notary` set `expire`=0, `points`='$newpoints', `to`='$row[to]', `from`='$row[from]', `when`=NOW(), `method`='Administrative Increase', `date`=NOW()";
68 }
69
70 $data = mysqli_fetch_assoc(mysqli_query($_SESSION['mconn'], "select * from `users` where `id`='$row[to]'"));
71 $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";
72 sendmail("cacert-board@lists.cacert.org", "[CAcert.org] Temporary Increase Expired.", $body, "website@cacert.org", "", "", "CAcert Website");
73
74 if($data['language'] != "")
75 {
76 L10n::set_translation($data['language']);
77 }
78
79 $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";
80 $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";
81
82 $body .= _("Best regards")."\n";
83 $body .= _("CAcert Support Team");
84
85 sendmail($data['email'], "[CAcert.org] "._("Temporary points increase has expired."), $body, "support@cacert.org", "", "", "CAcert Website");
86
87 mysqli_query($_SESSION['mconn'], $query);
88 fix_assurer_flag($row[to]);
89 }
90 */
91 ?>