4 * StatusNet - the distributed open-source microblogging tool
5 * Copyright (C) 2009, StatusNet, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
25 $helptext = <<<END_OF_REGISTERBYEMAIL_HELP
26 USAGE: registerbyemail.php
27 Registers a new user by email address and sends a confirmation email
29 -e email Email to register
31 END_OF_REGISTERBYEMAIL_HELP;
33 require_once INSTALLDIR.'/scripts/commandline.inc';
35 $email = get_option_value('e', 'email');
37 $parts = explode('@', $email);
38 $nickname = common_nicknamize($parts[0]);
40 $user = User::staticGet('nickname', $nickname);
43 $confirm = new Confirm_address();
45 $confirm->user_id = $user->id;
46 $confirm->address_type = 'email';
48 if ($confirm->find(true)) {
49 $url = common_local_url('confirmfirstemail',
50 array('code' => $confirm->code));
54 print "User not waiting for confirmation.\n";
60 $user = User::register(array('nickname' => $nickname,
63 $confirm = new Confirm_address();
64 $confirm->code = common_confirmation_code(128);
65 $confirm->user_id = $user->id;
66 $confirm->address = $email;
67 $confirm->address_type = 'email';
71 $url = common_local_url('confirmfirstemail',
72 array('code' => $confirm->code));
76 mail_confirm_address($user,