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 // Abort if called from a web server
23 define('INSTALLDIR', dirname(__DIR__));
24 define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
26 $shortoptions = 't:w:';
27 $longoptions = array('tagged=', 'not-tagged=');
29 $helptext = <<<ENDOFHELP
30 allsites.php - list all sites configured for multi-site use
31 USAGE: allsites.php [OPTIONS]
33 -t --tagged=tagname List only sites with this tag
34 -w --not-tagged=tagname List only sites without this tag
38 require_once INSTALLDIR.'/scripts/commandline.inc';
40 function print_all_sites() {
42 $sn = new Status_network();
45 while ($sn->fetch()) {
46 print "$sn->nickname\n";
52 function print_tagged_sites($tag) {
54 $sn = new Status_network();
56 $sn->query('select status_network.nickname '.
57 'from status_network join status_network_tag '.
58 'on status_network.site_id = status_network_tag.site_id '.
59 'where status_network_tag.tag = "' . $tag . '"');
61 while ($sn->fetch()) {
62 print "$sn->nickname\n";
68 function print_untagged_sites($tag) {
70 $sn = new Status_network();
72 $sn->query('select status_network.nickname '.
73 'from status_network '.
75 '(select tag from status_network_tag '.
76 'where site_id = status_network.site_id '.
77 'and tag = "'.$tag.'")');
79 while ($sn->fetch()) {
80 print "$sn->nickname\n";
86 if (have_option('t', 'tagged')) {
87 $tag = get_option_value('t', 'tagged');
88 print_tagged_sites($tag);
89 } else if (have_option('w', 'not-tagged')) {
90 $tag = get_option_value('w', 'not-tagged');
91 print_untagged_sites($tag);