gnu-social/plugins/RegisterThrottle/actions/ipregistrations.php
2016-02-13 01:02:18 +01:00

41 lines
1.2 KiB
PHP

<?php
if (!defined('GNUSOCIAL')) { exit(1); }
class IpregistrationsAction extends ManagedAction
{
protected $needLogin = true;
protected $ipaddress = null;
function title()
{
return sprintf(_('Registrations from IP %s'), $this->ipaddress);
}
protected function doPreparation()
{
if (!$scoped->hasRight(self::VIEWMODLOG) && !$scoped->hasRole(Profile_role::ADMINISTRATOR)) {
throw new AuthorizationException(_('You do not have privileges to see this page'));
}
$this->ipaddress = $this->trimmed('ipaddress');
$this->profile_ids = Registration_ip::usersByIP($this->ipaddress);
}
public function showContent()
{
$this->elementStart('ul');
foreach (Profile::listGet('id', $this->profile_ids) as $profile) {
$this->elementStart('li');
try {
$this->element('a', ['href'=>$profile->getUrl()], $profile->getFancyName());
} catch (InvalidUrlException $e) {
$this->element('span', null, $profile->getFancyName());
}
$this->elementEnd('li');
}
$this->elementEnd('ul');
}
}