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', realpath(dirname(__FILE__) . '/..'));
25 $shortoptions = 't:w:';
26 $longoptions = array('tagged=', 'not-tagged=');
28 $helptext = <<<ENDOFHELP
29 allsites.php - list all sites configured for multi-site use
30 USAGE: allsites.php [OPTIONS]
32 -t --tagged=tagname List only sites with this tag
33 -w --not-tagged=tagname List only sites without this tag
37 require_once INSTALLDIR.'/scripts/commandline.inc.php';
39 function print_all_sites() {
41 $sn = new Status_network();
44 while ($sn->fetch()) {
45 print "$sn->nickname\n";
51 function print_tagged_sites($tag) {
53 $sn = new Status_network();
55 $sn->query('select status_network.nickname '.
56 'from status_network join status_network_tag '.
57 'on status_network.site_id = status_network_tag.site_id '.
58 'where status_network_tag.tag = "' . $tag . '"');
60 while ($sn->fetch()) {
61 print "$sn->nickname\n";
67 function print_untagged_sites($tag) {
69 $sn = new Status_network();
71 $sn->query('select status_network.nickname '.
72 'from status_network '.
74 '(select tag from status_network_tag '.
75 'where site_id = status_network.site_id '.
76 'and tag = "'.$tag.'")');
78 while ($sn->fetch()) {
79 print "$sn->nickname\n";
85 if (have_option('t', 'tagged')) {
86 $tag = get_option_value('t', 'tagged');
87 print_tagged_sites($tag);
88 } else if (have_option('w', 'not-tagged')) {
89 $tag = get_option_value('w', 'not-tagged');
90 print_untagged_sites($tag);