summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-07 10:50:05 -0800
committerBrion Vibber <brion@pobox.com>2010-12-07 10:50:05 -0800
commit9df856e667a12cd217576263efbc72fff12692d9 (patch)
treedc8d588e8b01d1ec788c78d6aec10a9b9d26bec6 /scripts
parent01f32e3998b8d031d2a39e2d0506253142b6632e (diff)
parent4b4b763255ad3b2bff8f18da2bd3927b52a54e55 (diff)
Merge branch '0.9.x' into merge
Conflicts: README actions/hostmeta.php classes/File_redirection.php lib/common.php lib/designsettings.php lib/router.php lib/util.php lib/xmppmanager.php plugins/OStatus/OStatusPlugin.php
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/clear_jabber.php92
-rwxr-xr-xscripts/delete_status_network.sh39
-rwxr-xr-xscripts/deletegroup.php71
-rw-r--r--scripts/flushrouter.php33
-rw-r--r--scripts/restoreuser.php2
5 files changed, 228 insertions, 9 deletions
diff --git a/scripts/clear_jabber.php b/scripts/clear_jabber.php
new file mode 100755
index 000000000..5ec53caf0
--- /dev/null
+++ b/scripts/clear_jabber.php
@@ -0,0 +1,92 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$shortoptions = 'i::n::y';
+$longoptions = array('id=', 'nickname=', 'yes', 'all', 'dry-run');
+
+$helptext = <<<END_OF_DELETEUSER_HELP
+clear_jabber.php [options]
+Deletes a user's confirmed Jabber/XMPP address from the database.
+
+ -i --id ID of the user
+ -n --nickname nickname of the user
+ --all all users with confirmed Jabber addresses
+ --dry-run Don't actually delete info.
+
+END_OF_DELETEUSER_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+ $user = User::staticGet('id', $id);
+ if (empty($user)) {
+ print "Can't find user with ID $id\n";
+ exit(1);
+ }
+} else if (have_option('n', 'nickname')) {
+ $nickname = get_option_value('n', 'nickname');
+ $user = User::staticGet('nickname', $nickname);
+ if (empty($user)) {
+ print "Can't find user with nickname '$nickname'\n";
+ exit(1);
+ }
+} else if (have_option('all')) {
+ $user = new User();
+ $user->whereAdd("jabber != ''");
+ $user->find(true);
+ if ($user->N == 0) {
+ print "No users with registered Jabber addresses in database.\n";
+ exit(1);
+ }
+} else {
+ print "You must provide either an ID or a nickname.\n";
+ print "\n";
+ print $helptext;
+ exit(1);
+}
+
+function clear_jabber($id)
+{
+ $user = User::staticGet('id', $id);
+ if ($user && $user->jabber) {
+ echo "clearing user $id's user.jabber, was: $user->jabber";
+ if (have_option('dry-run')) {
+ echo " (SKIPPING)";
+ } else {
+ $original = clone($user);
+ $user->jabber = null;
+ $result = $user->updateKeys($original);
+ }
+ echo "\n";
+ } else if (!$user) {
+ echo "Missing user for $id\n";
+ } else {
+ echo "Cleared jabber already for $id\n";
+ }
+}
+
+do {
+ clear_jabber($user->id);
+} while ($user->fetch());
+
+print "DONE.\n";
diff --git a/scripts/delete_status_network.sh b/scripts/delete_status_network.sh
index 3a8ebdcfd..4e91cd639 100755
--- a/scripts/delete_status_network.sh
+++ b/scripts/delete_status_network.sh
@@ -4,22 +4,45 @@
set -e
-source /etc/statusnet/setup.cfg
+source /etc/statusnet/setup.cfg || (echo "Failed to read /etc/statusnet/setup.cfg"; exit -1)
export nickname=$1
+if [ "x" == "x$nickname" ]
+then
+ echo "Usage: delete_status_network.sh <site-nickname>"
+ exit 1
+fi
export database=$nickname$DBBASE
-# Create the db
+# Pull the status_network record so we know which DB server to drop from...
+TARGET_DBHOST=`mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB --batch --skip-column-names -e \
+ "select dbhost from status_network where nickname='$nickname'"`
-mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS -f drop $database
+if [ "x" == "x$TARGET_DBHOST" ]
+then
+ echo "Aborting: Could not find status_network record for site $nickname"
+ exit 1
+fi
-mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
+# Drop the database
+echo "Dropping $database from $TARGET_DBHOST..."
+mysqladmin -h $TARGET_DBHOST -u $ADMIN --password=$ADMINPASS -f drop $database || exit 1
-delete from status_network where nickname = '$nickname';
-
-ENDOFCOMMANDS
+# Remove the status_network entry
+echo "Removing status_network entry for $nickname..."
+mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB -e \
+ "delete from status_network where nickname = '$nickname'" || exit 1
+# Remove uploaded file areas
for top in $AVATARBASE $FILEBASE $BACKGROUNDBASE; do
- rm -Rf $top/$nickname
+ if [ "x" == "x$top" ]
+ then
+ echo "Skipping deletion due to broken config"
+ else
+ echo "Deleting $top/$nickname"
+ rm -Rf "$top/$nickname"
+ fi
done
+
+echo "Done."
diff --git a/scripts/deletegroup.php b/scripts/deletegroup.php
new file mode 100755
index 000000000..5a1ac109f
--- /dev/null
+++ b/scripts/deletegroup.php
@@ -0,0 +1,71 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$shortoptions = 'i::n::y';
+$longoptions = array('id=', 'nickname=', 'yes');
+
+$helptext = <<<END_OF_DELETEGROUP_HELP
+deletegroup.php [options]
+deletes a group from the database
+
+ -i --id ID of the group
+ -n --nickname nickname of the group
+ -y --yes do not wait for confirmation
+
+END_OF_DELETEGROUP_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+ $group = User_group::staticGet('id', $id);
+ if (empty($group)) {
+ print "Can't find group with ID $id\n";
+ exit(1);
+ }
+} else if (have_option('n', 'nickname')) {
+ $nickname = get_option_value('n', 'nickname');
+ $local = Local_group::staticGet('nickname', $nickname);
+ if (empty($local)) {
+ print "Can't find group with nickname '$nickname'\n";
+ exit(1);
+ }
+ $group = User_group::staticGet('id', $local->group_id);
+} else {
+ print "You must provide either an ID or a nickname.\n";
+ print "\n";
+ print $helptext;
+ exit(1);
+}
+
+if (!have_option('y', 'yes')) {
+ print "About to PERMANENTLY delete group '{$group->nickname}' ({$group->id}). Are you sure? [y/N] ";
+ $response = fgets(STDIN);
+ if (strtolower(trim($response)) != 'y') {
+ print "Aborting.\n";
+ exit(0);
+ }
+}
+
+print "Deleting...";
+$group->delete();
+print "DONE.\n";
diff --git a/scripts/flushrouter.php b/scripts/flushrouter.php
new file mode 100644
index 000000000..79493eae4
--- /dev/null
+++ b/scripts/flushrouter.php
@@ -0,0 +1,33 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$helptext = <<<END_OF_FLUSHROUTER_HELP
+flushrouter.php -s<sitename>
+Flush the url router from cache.
+
+END_OF_FLUSHROUTER_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+Cache::delete(Router::cacheKey());
+
+print "OK.\n"; \ No newline at end of file
diff --git a/scripts/restoreuser.php b/scripts/restoreuser.php
index 8327c796c..b37e9db74 100644
--- a/scripts/restoreuser.php
+++ b/scripts/restoreuser.php
@@ -219,7 +219,7 @@ function postNote($user, $activity)
$rendered = purify($sourceContent);
$content = html_entity_decode(strip_tags($rendered), ENT_QUOTES, 'UTF-8');
- $shortened = common_shorten_links($content);
+ $shortened = $user->shortenLinks($content);
$options = array('is_local' => Notice::LOCAL_PUBLIC,
'uri' => $sourceUri,