]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add DomainStatusNetwork plugin
authorEvan Prodromou <evan@status.net>
Tue, 26 Apr 2011 20:51:05 +0000 (16:51 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 26 Apr 2011 20:51:05 +0000 (16:51 -0400)
plugins/DomainStatusNetwork/scripts/#installbyemail.php# [new file with mode: 0644]
plugins/DomainStatusNetwork/scripts/installbyemail.php [new file with mode: 0644]
plugins/DomainStatusNetwork/scripts/proposesite.php [new file with mode: 0644]
plugins/DomainStatusNetwork/scripts/registeremailuser.php [new file with mode: 0644]
plugins/DomainStatusNetwork/scripts/sitefordomain.php [new file with mode: 0644]

diff --git a/plugins/DomainStatusNetwork/scripts/#installbyemail.php# b/plugins/DomainStatusNetwork/scripts/#installbyemail.php#
new file mode 100644 (file)
index 0000000..cca726e
--- /dev/null
@@ -0,0 +1,117 @@
+#!/usr/bin/env php
+<?php
+/**
+ * StatusNet - the 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/>.
+ *
+ * @category Installation
+ * @package  Installation
+ *
+ * @author   Brion Vibber <brion@status.net>
+ * @author   Evan Prodromou <evan@status.net>
+ * @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 <email-address>";
+    }
+
+    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('/<a[^>+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
+                                 '\2 &lt;\1&gt;',
+                                 $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 (file)
index 0000000..e352dfc
--- /dev/null
@@ -0,0 +1,117 @@
+#!/usr/bin/env php
+<?php
+/**
+ * StatusNet - the 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/>.
+ *
+ * @category Installation
+ * @package  Installation
+ *
+ * @author   Brion Vibber <brion@status.net>
+ * @author   Evan Prodromou <evan@status.net>
+ * @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 <email-address>";
+    }
+
+    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('/<a[^>+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
+                                 '\2 &lt;\1&gt;',
+                                 $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 (file)
index 0000000..0b0f35b
--- /dev/null
@@ -0,0 +1,85 @@
+#!/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];
+
+
+$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 (file)
index 0000000..a8c942d
--- /dev/null
@@ -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";
diff --git a/plugins/DomainStatusNetwork/scripts/sitefordomain.php b/plugins/DomainStatusNetwork/scripts/sitefordomain.php
new file mode 100644 (file)
index 0000000..80fa637
--- /dev/null
@@ -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";
+    }
+}