Merge remote-tracking branch 'origin/bug-1213' into release
[cacert-devel.git] / scripts / consistence.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 include_once("../includes/mysql.php");
20
21
22 if(0)
23 {
24 $query = "select locations.id from locations, regions where locations.regid=regions.id and locations.ccid!=regions.ccid;";
25 $res = mysql_query($query);
26 while($row = mysql_fetch_assoc($res))
27 {
28 $query = "update users set `assurer`='1' where `id`='${row['uid']}'";
29 echo "inconsistence in location ".$row['locations.id']."\n";
30 //mysql_query($query);
31 }
32 }
33
34 if(0)
35 {
36 $query = "select id from locations where regid<1 or ccid<1;";
37 $res = mysql_query($query);
38 while($row = mysql_fetch_assoc($res))
39 {
40 //$query = "update users set `assurer`='1' where `id`='${row['uid']}'";
41 echo "inconsistence in location ".$row['id']."\n";
42 //mysql_query($query);
43 }
44 }
45 if(1)
46 {
47 $query = "select users.id, locations.regid from users inner join locations on users.locid=locations.id where users.regid!=locations.regid or users.ccid!=locations.ccid;";
48 $res = mysql_query($query);
49 echo mysql_error();
50 while($row = mysql_fetch_assoc($res))
51 {
52 echo "inconsistence in user #".$row['id']."\n";
53 $query = "update users set regid=".$row['regid']." where `id`=".$row['id'].";";
54
55 echo "query: $query\n";
56 if($row['regid']=="1182") mysql_query($query);
57 }
58 }
59
60 exit();
61
62 mysql_query("update `locations` set `acount`=0");
63 $query = "SELECT `users`.`locid` AS `locid`, count(*) AS `total` FROM `users`
64 WHERE users.assurer='1' AND `users`.`locid` != 0 and users.listme=1
65 GROUP BY `users`.`locid`";
66 $res = mysql_query($query);
67 while($row = mysql_fetch_assoc($res))
68 {
69 $query = "update `locations` set `acount`='${row['total']}' where `id`='${row['locid']}'";
70 echo $query."\n";
71 mysql_query($query);
72 }
73
74
75 mysql_query("update `regions` set `acount`=0");
76 $query = "SELECT `users`.`regid` AS `regid`, count(*) AS `total` FROM `users`
77 WHERE users.assurer='1' AND `users`.`regid` != 0 and users.listme=1
78 GROUP BY `users`.`regid`";
79 $res = mysql_query($query);
80 while($row = mysql_fetch_assoc($res))
81 {
82 $query = "update `regions` set `acount`='${row['total']}' where `id`='${row['regid']}'";
83 echo $query."\n";
84 mysql_query($query);
85 }
86
87
88
89
90 mysql_query("update `countries` set `acount`=0");
91 $query = "SELECT `users`.`ccid` AS `ccid`, count(*) AS `total` FROM `users`
92 WHERE users.assurer='1' AND `users`.`ccid` != 0 and users.listme=1
93 GROUP BY `users`.`ccid`";
94 $res = mysql_query($query);
95 while($row = mysql_fetch_assoc($res))
96 {
97 $query = "update `countries` set `acount`='${row['total']}' where `id`='${row['ccid']}'";
98 echo $query."\n";
99 mysql_query($query);
100 }
101
102
103
104
105 ?>