diff --git a/plugins/DomainStatusNetwork/scripts/#installbyemail.php# b/plugins/DomainStatusNetwork/scripts/#installbyemail.php# new file mode 100644 index 0000000000..cca726e6a0 --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/#installbyemail.php# @@ -0,0 +1,117 @@ +#!/usr/bin/env php +. + * + * @category Installation + * @package Installation + * + * @author Brion Vibber + * @author Evan Prodromou + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @version 1.0.0 + * @link http://status.net + */ + +if (php_sapi_name() !== 'cli') { + exit(1); +} + +define('INSTALLDIR', dirname(dirname(__FILE__))); +set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib'); + +require_once INSTALLDIR . '/lib/installer.php'; + +class EmailMultihomeInstaller extends Installer +{ + protected $address; + + function __construct($address) + { + $this->address = $address; + } + + /** + * Go for it! + * @return boolean success + */ + function main() + { + if (!$this->checkPrereqs()) { + return false; + } + if ($this->prepare()) { + return $this->handle(); + } else { + $this->showHelp(); + return false; + } + } + + /** + * Get our input parameters... + * @return boolean success + */ + + function prepare() + { + + } + + function handle() + { + return $this->doInstall(); + } + + function showHelp() + { + print "USAGE: installbyemail.php "; + } + + function warning($message, $submessage='') + { + print $this->html2text($message) . "\n"; + if ($submessage != '') { + print " " . $this->html2text($submessage) . "\n"; + } + print "\n"; + } + + function updateStatus($status, $error=false) + { + if ($this->verbose || $error) { + if ($error) { + print "ERROR: "; + } + print $this->html2text($status); + print "\n"; + } + } + + private function html2text($html) + { + // break out any links for text legibility + $breakout = preg_replace('/+]\bhref="(.*)"[^>]*>(.*)<\/a>/', + '\2 <\1>', + $html); + return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8'); + } +} + +$installer = new EmailMultihomeInstaller(); +$ok = $installer->main($argv[1]); +exit($ok ? 0 : 1); diff --git a/plugins/DomainStatusNetwork/scripts/installbyemail.php b/plugins/DomainStatusNetwork/scripts/installbyemail.php new file mode 100644 index 0000000000..e352dfc0b7 --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/installbyemail.php @@ -0,0 +1,117 @@ +#!/usr/bin/env php +. + * + * @category Installation + * @package Installation + * + * @author Brion Vibber + * @author Evan Prodromou + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @version 1.0.0 + * @link http://status.net + */ + +if (php_sapi_name() !== 'cli') { + exit(1); +} + +define('INSTALLDIR', dirname(dirname(__FILE__))); +set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib'); + +require_once INSTALLDIR . '/lib/installer.php'; + +class EmailMultihomeInstaller extends Installer +{ + protected $address; + + function __construct($address) + { + $this->address = $address; + } + + /** + * Go for it! + * @return boolean success + */ + function main() + { + if (!$this->checkPrereqs()) { + return false; + } + if ($this->prepare()) { + return $this->handle(); + } else { + $this->showHelp(); + return false; + } + } + + /** + * Get our input parameters... + * @return boolean success + */ + + function prepare() + { + + } + + function handle() + { + return $this->doInstall(); + } + + function showHelp() + { + print "USAGE: installbyemail.php "; + } + + function warning($message, $submessage='') + { + print $this->html2text($message) . "\n"; + if ($submessage != '') { + print " " . $this->html2text($submessage) . "\n"; + } + print "\n"; + } + + function updateStatus($status, $error=false) + { + if ($this->verbose || $error) { + if ($error) { + print "ERROR: "; + } + print $this->html2text($status); + print "\n"; + } + } + + private function html2text($html) + { + // break out any links for text legibility + $breakout = preg_replace('/+]\bhref="(.*)"[^>]*>(.*)<\/a>/', + '\2 <\1>', + $html); + return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8'); + } +} + +$installer = new EmailMultihomeInstaller(); +$ok = $installer->main($argv[1]); +exit($ok ? 0 : 1); diff --git a/plugins/DomainStatusNetwork/scripts/proposesite.php b/plugins/DomainStatusNetwork/scripts/proposesite.php new file mode 100644 index 0000000000..0b0f35b76a --- /dev/null +++ b/plugins/DomainStatusNetwork/scripts/proposesite.php @@ -0,0 +1,85 @@ +#!/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]; + + +$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"; + } +}