function sphinx_iterate_sites($callback) { if (sphinx_use_network()) { // @fixme this should use, like, some kind of config Status_network::setupDB('localhost', 'statusnet', 'statuspass', 'statusnet'); $sn = new Status_network(); if (!$sn->find()) { die("Confused... no sites in status_network table or lookup failed.\n"); } while ($sn->fetch()) { $callback($sn); } } else { if (preg_match('!^(mysqli?|pgsql)://(.*?):(.*?)@(.*?)/(.*?)$!', common_config('db', 'database'), $matches)) { list(, $dbtype, $dbuser, $dbpass, $dbhost, $dbname) = $matches; $sn = (object) array('sitename' => common_config('site', 'name'), 'dbhost' => $dbhost, 'dbuser' => $dbuser, 'dbpass' => $dbpass, 'dbname' => $dbname); $callback($sn); } else { print "Unrecognized database configuration string in config.php\n"; exit(1); } } }
function saveStatusNetwork() { Status_network::setupDB($this->sitehost, $this->rootname, $this->rootpass, $this->sitedb, array()); $sn = new Status_network(); $sn->nickname = $this->nickname; $sn->dbhost = $this->host; $sn->dbuser = $this->username; $sn->dbpass = $this->password; $sn->dbname = $this->database; $sn->sitename = $this->sitename; $result = $sn->insert(); if (!$result) { throw new ServerException("Could not create status_network: " . print_r($sn, true)); } // Re-fetch; stupid auto-increment integer isn't working $sn = Status_network::staticGet('nickname', $sn->nickname); if (empty($sn)) { throw new ServerException("Created {$this->nickname} status_network and could not find it again."); } // Set default tags $tags = $this->tags; // Add domain tag $tags[] = 'domain=' . $this->domain; $sn->setTags($tags); $this->sn = $sn; }