- /**
- * Check whether the given nickname is potentially usable, or if it's
- * excluded by any blacklists on this system.
- *
- * WARNING: INPUT IS NOT VALIDATED OR NORMALIZED. NON-NORMALIZED INPUT
- * OR INVALID INPUT MAY LEAD TO FALSE RESULTS.
- *
- * @param string $nickname
- * @return boolean true if clear, false if blacklisted
- */
- static function allowed_nickname($nickname)
- {
- // XXX: should already be validated for size, content, etc.
- $blacklist = common_config('nickname', 'blacklist');
-
- //all directory and file names should be blacklisted
- $d = dir(INSTALLDIR);
- while (false !== ($entry = $d->read())) {
- $blacklist[]=$entry;
- }
- $d->close();
-
- //all top level names in the router should be blacklisted
- $router = Router::get();
- foreach(array_keys($router->m->getPaths()) as $path){
- if(preg_match('/^\/(.*?)[\/\?]/',$path,$matches)){
- $blacklist[]=$matches[1];
- }
- }
- return !in_array($nickname, $blacklist);
- }
-