ipregistrations.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. class IpregistrationsAction extends ManagedAction
  4. {
  5. protected $needLogin = true;
  6. protected $ipaddress = null;
  7. function title()
  8. {
  9. return sprintf(_('Registrations from IP %s'), $this->ipaddress);
  10. }
  11. protected function doPreparation()
  12. {
  13. if (!$this->scoped->hasRight(Right::SILENCEUSER) && !$this->scoped->hasRole(Profile_role::ADMINISTRATOR)) {
  14. throw new AuthorizationException(_('You are not authorized to view this page.'));
  15. }
  16. $this->ipaddress = $this->trimmed('ipaddress');
  17. $this->profile_ids = Registration_ip::usersByIP($this->ipaddress);
  18. }
  19. public function showContent()
  20. {
  21. $this->elementStart('ul');
  22. $profile = Profile::multiGet('id', $this->profile_ids);
  23. while ($profile->fetch()) {
  24. $this->elementStart('li');
  25. try {
  26. $this->element('a', ['href'=>$profile->getUrl()], $profile->getFancyName());
  27. } catch (InvalidUrlException $e) {
  28. $this->element('span', null, $profile->getFancyName());
  29. }
  30. $this->elementEnd('li');
  31. }
  32. $this->elementEnd('ul');
  33. }
  34. }