diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/console.php | 21 | ||||
-rwxr-xr-x | scripts/useremail.php | 77 | ||||
-rwxr-xr-x | scripts/xmppdaemon.php | 20 |
3 files changed, 91 insertions, 27 deletions
diff --git a/scripts/console.php b/scripts/console.php index 210d2b6b2..329caf472 100755 --- a/scripts/console.php +++ b/scripts/console.php @@ -73,7 +73,7 @@ function read_input_line($prompt) */ function readline_emulation($prompt) { - if(file_exists(trim(shell_exec('which bash')))) { + if(CONSOLE_INTERACTIVE && file_exists(trim(shell_exec('which bash')))) { $encPrompt = escapeshellarg($prompt); $command = "read -er -p $encPrompt && echo \"\$REPLY\""; $encCommand = escapeshellarg($command); @@ -103,7 +103,9 @@ function readline_emulation($prompt) if (feof(STDIN)) { return false; } - print $prompt; + if (CONSOLE_INTERACTIVE) { + print $prompt; + } return fgets(STDIN); } @@ -123,13 +125,16 @@ function console_help() print "Type ctrl+D or enter 'exit' to exit.\n"; } - -print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n"; -$prompt = common_config('site', 'name') . '> '; +if (CONSOLE_INTERACTIVE) { + print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n"; + $prompt = common_config('site', 'name') . '> '; +} while (!feof(STDIN)) { $line = read_input_line($prompt); if ($line === false) { - print "\n"; + if (CONSOLE_INTERACTIVE) { + print "\n"; + } break; } elseif ($line !== '') { try { @@ -154,5 +159,7 @@ while (!feof(STDIN)) { print get_class($e) . ": " . $e->getMessage() . "\n"; } } - print "\n"; + if (CONSOLE_INTERACTIVE) { + print "\n"; + } } diff --git a/scripts/useremail.php b/scripts/useremail.php new file mode 100755 index 000000000..6676a87c8 --- /dev/null +++ b/scripts/useremail.php @@ -0,0 +1,77 @@ +#!/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:e:'; +$longoptions = array('id=', 'nickname=', 'email='); + +$helptext = <<<END_OF_USEREMAIL_HELP +useremail.php [options] +Queries a user's registered email address, or queries the users with a given registered email. + + -i --id id of the user to query + -n --nickname nickname of the user to query + -e --email email address to query + +END_OF_USEREMAIL_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); + } +} + +if (!empty($user)) { + if (empty($user->email)) { + print "No email registered for user '$user->nickname'\n"; + } else { + print "$user->email\n"; + } + exit(0); +} + +if (have_option('e', 'email')) { + $user = new User(); + $user->email = get_option_value('e', 'email'); + $user->find(false); + if (!$user->fetch()) { + print "No users with email $user->email\n"; + exit(0); + } + do { + print "$user->id $user->nickname\n"; + } while ($user->fetch()); +} else { + print "You must provide either an ID, email, or a nickname.\n"; + exit(1); +} diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index e52e2a6af..20105b602 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -195,17 +195,6 @@ class XMPPDaemon extends Daemon } else if ($this->is_otr($pl['body'])) { $this->log(LOG_INFO, 'Ignoring OTR from ' . $from); return; - } else if ($this->is_direct($pl['body'])) { - $this->log(LOG_INFO, 'Got a direct message ' . $from); - - preg_match_all('/d[\ ]*([a-z0-9]{1,64})/', $pl['body'], $to); - - $to = preg_replace('/^d([\ ])*/', '', $to[0][0]); - $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']); - - $this->log(LOG_INFO, 'Direct message from '. $user->nickname . ' to ' . $to); - - $this->add_direct($user, $body, $to, $from); } else { $this->log(LOG_INFO, 'Posting a notice from ' . $user->nickname); @@ -284,15 +273,6 @@ class XMPPDaemon extends Daemon } } - function is_direct($txt) - { - if (strtolower(substr($txt, 0, 2))=='d ') { - return true; - } else { - return false; - } - } - function from_site($address, $msg) { $text = '['.common_config('site', 'name') . '] ' . $msg; |