bug 827 restriced yellow marker <2006-09-1
[cacert-devel.git] / scripts / addpoints.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 // This script seems to add points for assurances that didn't received their points automatically before.
21
22 include_once("../includes/mysql.php");
23
24 $query = "select * from `notary` group by `from`";
25 $res = mysql_query($query);
26 while($row = mysql_fetch_assoc($res))
27 {
28 $query = "select *,sum(`points`) as `points` from `users`, `notary` where `users`.`id`=`notary`.`to` and `users`.`id`='".$row['from']."' group by `notary`.`to`";
29 $drow = mysql_fetch_assoc(mysql_query($query));
30 if($drow['points'] < 100 || $drow['points'] >= 150)
31 continue;
32 $query = "select * from `notary` where `from`='".$drow['id']."' and `to`='".$drow['id']."'";
33 $num = mysql_num_rows(mysql_query($query));
34 $query = "select * from `notary` where `from`='".$drow['id']."' and `to`!='".$drow['id']."'";
35 $newnum = mysql_num_rows(mysql_query($query));
36 if($num < $newnum)
37 {
38 echo $drow['fname']." ".$drow['lname']." <".$drow['email']."> (memid: ".$drow['id']." points: ".$drow['points']." - num: $num newnum: $newnum)\n";
39 for($i = $newnum; $i > $num; $i--)
40 {
41 $newpoints = 2;
42 if($drow['points'] + 1>= 150)
43 break;
44 if($drow['points'] + 2 > 150)
45 $newpoints = 1;
46 $query = "insert into `notary` set `from`='".$drow['id']."', `to`='".$drow['id']."',
47 `points`='$newpoints', `method`='Administrative Increase', `date`=NOW()";
48 mysql_query($query);
49 $drow['points'] += $newpoints;
50 fix_assurer_flag($drow['id']);
51 }
52 }
53 }
54 ?>