#!/usr/bin/env php . */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'd'; $longoptions = array('delete'); $helptext = << Set the tag for site . With -d, delete the tag. END_OF_SETTAG_HELP; require_once INSTALLDIR.'/scripts/commandline.inc'; if (count($args) != 2) { show_help(); exit(1); } $nickname = $args[0]; $tag = strtolower($args[1]); $sn = Status_network::memGet('nickname', $nickname); if (empty($sn)) { print "No such site.\n"; exit(-1); } $tags = $sn->getTags(); $i = array_search($tag, $tags); if ($i !== false) { if (have_option('d', 'delete')) { // Delete unset($tags[$i]); $orig = clone($sn); $sn->tags = implode('|', $tags); $result = $sn->update($orig); if (!$result) { print "Couldn't update.\n"; exit(-1); } } else { print "Already set.\n"; exit(-1); } } else { if (have_option('d', 'delete')) { // Delete print "No such tag.\n"; exit(-1); } else { $tags[] = $tag; $orig = clone($sn); $sn->tags = implode('|', $tags); $result = $sn->update($orig); if (!$result) { print "Couldn't update.\n"; exit(-1); } } }