diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/checkschema.php | 30 | ||||
-rw-r--r-- | scripts/createsim.php | 2 | ||||
-rw-r--r-- | scripts/deleteuser.php | 68 | ||||
-rwxr-xr-x | scripts/getvaliddaemons.php | 34 | ||||
-rwxr-xr-x | scripts/maildaemon.php | 9 | ||||
-rwxr-xr-x | scripts/pluginqueuehandler.php | 58 | ||||
-rw-r--r-- | scripts/showtable.php | 41 | ||||
-rwxr-xr-x | scripts/startdaemons.sh | 2 | ||||
-rwxr-xr-x | scripts/xmppdaemon.php | 11 |
9 files changed, 236 insertions, 19 deletions
diff --git a/scripts/checkschema.php b/scripts/checkschema.php new file mode 100644 index 000000000..bf52abe15 --- /dev/null +++ b/scripts/checkschema.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +<?php +/* + * StatusNet - a distributed open-source microblogging tool + * Copyright (C) 2008, 2009, 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_CHECKSCHEMA_HELP +Gives plugins a chance to update the database schema. + +END_OF_CHECKSCHEMA_HELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +Event::handle('CheckSchema'); diff --git a/scripts/createsim.php b/scripts/createsim.php index 71ed3bf72..1266a9700 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -101,7 +101,7 @@ function newSub($i) $to = User::staticGet('nickname', $tunic); - if (empty($from)) { + if (empty($to)) { throw new Exception("Can't find user '$tunic'."); } diff --git a/scripts/deleteuser.php b/scripts/deleteuser.php new file mode 100644 index 000000000..52389123c --- /dev/null +++ b/scripts/deleteuser.php @@ -0,0 +1,68 @@ +#!/usr/bin/env php +<?php +/* + * StatusNet - a distributed open-source microblogging tool + * Copyright (C) 2008, 2009, 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_DELETEUSER_HELP +deleteuser.php [options] +deletes a user from the database + + -i --id ID of the user + -n --nickname nickname of the user + -y --yes do not wait for confirmation + +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 { + print "You must provide either an ID or a nickname.\n"; + exit(1); +} + +if (!have_option('y', 'yes')) { + print "About to PERMANENTLY delete user '{$user->nickname}' ({$user->id}). Are you sure? [y/N] "; + $response = fgets(STDIN); + if (strtolower(trim($response)) != 'y') { + print "Aborting.\n"; + exit(0); + } +} + +print "Deleting..."; +$user->delete(); +print "DONE.\n"; diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 8f48e8e6f..6dd019712 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -35,20 +35,36 @@ ENDOFHELP; require_once INSTALLDIR.'/scripts/commandline.inc'; +$daemons = array(); + +$daemons[] = INSTALLDIR.'/scripts/pluginqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; + if(common_config('xmpp','enabled')) { - echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php "; - echo "xmppconfirmhandler.php "; + $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; + $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php'; } + if(common_config('twitterbridge','enabled')) { - echo "twitterstatusfetcher.php "; + $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php'; } -echo "ombqueuehandler.php "; + if (common_config('twitter', 'enabled')) { - echo "twitterqueuehandler.php "; - echo "synctwitterfriends.php "; + $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php'; } -echo "facebookqueuehandler.php "; -echo "pingqueuehandler.php "; + if (common_config('sms', 'enabled')) { - echo "smsqueuehandler.php "; + $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php'; +} + +if (Event::handle('GetValidDaemons', array(&$daemons))) { + foreach ($daemons as $daemon) { + print $daemon . ' '; + } + print "\n"; } diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php index 5705cfd50..586bef624 100755 --- a/scripts/maildaemon.php +++ b/scripts/maildaemon.php @@ -260,10 +260,11 @@ class MailerDaemon function add_notice($user, $msg, $fileRecords) { - $notice = Notice::saveNew($user->id, $msg, 'mail'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - return $notice; + try { + $notice = Notice::saveNew($user->id, $msg, 'mail'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + return $e->getMessage(); } foreach($fileRecords as $fileRecord){ $this->attachFile($notice, $fileRecord); diff --git a/scripts/pluginqueuehandler.php b/scripts/pluginqueuehandler.php new file mode 100755 index 000000000..ae807db6a --- /dev/null +++ b/scripts/pluginqueuehandler.php @@ -0,0 +1,58 @@ +#!/usr/bin/env php +<?php +/* + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, 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::'; +$longoptions = array('id::'); + +$helptext = <<<END_OF_OMB_HELP +Daemon script for letting plugins handle stuff at queue time + + -i --id Identity (default none) + +END_OF_OMB_HELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once INSTALLDIR . '/lib/queuehandler.php'; + +class PluginQueueHandler extends QueueHandler +{ + + function transport() + { + return 'plugin'; + } + + function handle_notice($notice) + { + Event::handle('HandleQueuedNotice', array(&$notice)); + return true; + } +} + +if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); +} else { + $id = null; +} + +$handler = new PluginQueueHandler($id); +$handler->runOnce(); diff --git a/scripts/showtable.php b/scripts/showtable.php new file mode 100644 index 000000000..eb18a98e2 --- /dev/null +++ b/scripts/showtable.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +<?php +/* + * StatusNet - a distributed open-source microblogging tool + * Copyright (C) 2008, 2009, 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_SHOWTABLE_HELP +showtable.php <tablename> +Shows the structure of a table + +END_OF_SHOWTABLE_HELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +if (count($args) != 1) { + show_help(); +} + +$name = $args[0]; + +$schema = Schema::get(); + +$td = $schema->getTableDef($name); + +print_r($td); diff --git a/scripts/startdaemons.sh b/scripts/startdaemons.sh index 298162673..5fb75414d 100755 --- a/scripts/startdaemons.sh +++ b/scripts/startdaemons.sh @@ -40,7 +40,7 @@ DAEMONS=`php $DIR/getvaliddaemons.php $ARGSG` for f in $DAEMONS; do printf "Starting $f..."; - php $DIR/$f $ARGSD + php $f $ARGSD printf "DONE.\n" done diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 1b1aec3e6..b2efc07c3 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -323,12 +323,15 @@ class XMPPDaemon extends Daemon mb_strlen($content_shortened))); return; } - $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - $this->from_site($user->jabber, $notice); + + try { + $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + $this->from_site($user->jabber, $e->getMessage()); return; } + common_broadcast_notice($notice); $this->log(LOG_INFO, 'Added notice ' . $notice->id . ' from user ' . $user->nickname); |