move domain status network scripts

This commit is contained in:
Evan Prodromou
2011-04-26 17:48:01 -04:00
parent 6576dbdf43
commit 32cb8b1304
3 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env php
<?php
/*
* StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
* Script to print out current version of the software
*
* 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_SITEFORDOMAIN_HELP
sitefordomain.php [options] <email address|domain>
Prints site information for the domain given
END_OF_SITEFORDOMAIN_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
require_once INSTALLDIR.'/plugins/EmailRegistration/extlib/effectiveTLDs.inc.php';
require_once INSTALLDIR.'/plugins/EmailRegistration/extlib/regDomain.inc.php';
function nicknameAvailable($nickname)
{
$sn = Status_network::staticGet('nickname', $nickname);
return !empty($sn);
}
function nicknameForDomain($domain)
{
global $tldTree;
$registered = getRegisteredDomain($domain, $tldTree);
$parts = explode('.', $registered);
$base = $parts[0];
if (nicknameAvailable($base)) {
return $base;
}
$domainish = str_replace('.', '-', $registered);
if (nicknameAvailable($domainish)) {
return $domainish;
}
$i = 1;
// We don't need to keep doing this forever
while ($i < 1024) {
$candidate = $domainish.'-'.$i;
if (nicknameAvailable($candidate)) {
return $candidate;
}
}
return null;
}
$raw = $args[0];
$parts = explode('@', $raw);
if (count($parts) == 1) {
$domain = $parts[0];
} else {
$domain = $parts[1];
}
$domain = strtolower(trim($domain));
$nickname = nicknameForDomain($domain);
if (empty($nickname)) {
throw ClientException("No candidate found.");
} else {
print $nickname;
print "\n";
}

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env php
<?php
/*
* StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2011, 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_REGISTEREMAILUSER_HELP
registeremailuser.php [options] <email address>
Options:
-e --email Send a confirmation message to the email address
register a new user by email address.
END_OF_REGISTEREMAILUSER_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
if (count($args) == 0) {
show_help();
}
$email = $args[0];
$confirm = EmailRegistrationPlugin::registerEmail($email);
if (have_option('e', 'email')) {
EmailRegistrationPlugin::sendConfirmEmail($confirm);
}
$confirmUrl = common_local_url('register', array('code' => $confirm->code));
print $confirmUrl."\n";

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env php
<?php
/*
* StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
* Script to print out current version of the software
*
* 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_SITEFORDOMAIN_HELP
sitefordomain.php [options] <email address|domain>
Prints site information for the domain given
END_OF_SITEFORDOMAIN_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
$raw = $args[0];
$parts = explode('@', $raw);
if (count($parts) == 1) {
$domain = $parts[0];
} else {
$domain = $parts[1];
}
$domain = strtolower(trim($domain));
$snt = Status_network_tag::withTag('domain='.$domain);
while ($snt->fetch()) {
$sn = Status_network::staticGet('site_id', $snt->site_id);
if (!empty($sn)) {
print $sn->nickname."\n";
}
}