summaryrefslogtreecommitdiff
path: root/scripts/resetpermissions.php
blob: 055e36ab2b7ee8eade1f9cc09d55f1afa9666b1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/php -q
<?php
/*
LibreSSL - CAcert web application
Copyright (C) 2004-2012  CAcert Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

require_once(dirname(__FILE__).'/../includes/mysql.php');

$flags = array('board', 'tverify');

foreach ($flags as $flag) {
	echo "Resetting $flag flag:\n";
	$query = "select `id`, `fname`, `lname`, `email` from `users`
			where `$flag` = 1";
	if(! $res = mysql_query($query) ) {
		fwrite(STDERR,
				"MySQL query for flag $flag failed:\n".
				"\"$query\"\n".
				mysql_error()
		);
	
		continue;
	}
	
	while ($row = mysql_fetch_assoc($res)) {
		echo "$row[fname] $row[lname] $row[email]";
		
		$update = "update `users` set `$flag` = 0 where `id` = $row[id]";
		if(! $res2 = mysql_query($update) ) {
			echo " NOT RESET!!!\n";
			fwrite(STDERR,
					"MySQL query for $flag flag reset on user $row[id] failed:\n".
					"\"$update\"\n".
					mysql_error()
			);
			
		} else {
			echo " reset.\n";
		}
	}
	
	echo "\n\n";
}