From: Evan Prodromou Date: Tue, 26 Apr 2011 21:48:01 +0000 (-0400) Subject: move domain status network scripts X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32cb8b130493e93ed42fcf1c4e9216d41ff74fc8;p=quix0rs-gnu-social.git move domain status network scripts --- diff --git a/plugins/DomainStatusNetwork/scripts/proposesite.php b/plugins/DomainStatusNetwork/scripts/proposesite.php new file mode 100644 index 0000000000..345128d20c --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/proposesite.php @@ -0,0 +1,94 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$helptext = << +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"; +} diff --git a/plugins/DomainStatusNetwork/scripts/registeremailuser.php b/plugins/DomainStatusNetwork/scripts/registeremailuser.php new file mode 100644 index 0000000000..a8c942d3dd --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/registeremailuser.php @@ -0,0 +1,49 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$helptext = << + +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"; diff --git a/plugins/DomainStatusNetwork/scripts/sitefordomain.php b/plugins/DomainStatusNetwork/scripts/sitefordomain.php new file mode 100644 index 0000000000..80fa6375e0 --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/sitefordomain.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$helptext = << +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"; + } +} diff --git a/plugins/EmailRegistration/scripts/proposesite.php b/plugins/EmailRegistration/scripts/proposesite.php deleted file mode 100644 index 345128d20c..0000000000 --- a/plugins/EmailRegistration/scripts/proposesite.php +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); - -$helptext = << -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"; -} diff --git a/plugins/EmailRegistration/scripts/registeremailuser.php b/plugins/EmailRegistration/scripts/registeremailuser.php deleted file mode 100644 index a8c942d3dd..0000000000 --- a/plugins/EmailRegistration/scripts/registeremailuser.php +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); - -$helptext = << - -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"; diff --git a/plugins/EmailRegistration/scripts/sitefordomain.php b/plugins/EmailRegistration/scripts/sitefordomain.php deleted file mode 100644 index 80fa6375e0..0000000000 --- a/plugins/EmailRegistration/scripts/sitefordomain.php +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); - -$helptext = << -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"; - } -}