summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2012-05-08 16:44:26 +0200
committerMichael Tänzer <neo@nhng.de>2012-05-08 16:44:26 +0200
commitdbf8bac704968da92b425214d9e79c0507b16985 (patch)
treee63ba1123e097bf20e138bc8044d6d9fac697c48 /scripts
parent7f66d27da25a092be5059a8749723216a0aad339 (diff)
downloadcacert-devel-dbf8bac704968da92b425214d9e79c0507b16985.tar.gz
cacert-devel-dbf8bac704968da92b425214d9e79c0507b16985.tar.xz
cacert-devel-dbf8bac704968da92b425214d9e79c0507b16985.zip
bug 1003: Initial version of reset permissions script
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/resetpermissions.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/resetpermissions.php b/scripts/resetpermissions.php
new file mode 100644
index 0000000..f97ad9d
--- /dev/null
+++ b/scripts/resetpermissions.php
@@ -0,0 +1,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(! $res = mysql_query($query) ) {
+ echo " NOT RESET!!!\n";
+ fwrite(STDERR,
+ "MySQL query for flag $flag failed:\n".
+ "\"$query\"\n".
+ mysql_error()
+ );
+
+ } else {
+ echo " reset.\n";
+ }
+ }
+
+ echo "\n\n";
+} \ No newline at end of file