redirect_to_random

This commit is contained in:
Synox 2018-02-23 22:21:05 +01:00
parent a8040ae815
commit 68493c4401
2 changed files with 16 additions and 14 deletions

View File

@ -39,18 +39,6 @@ function error($status, $text) {
function redirect_to_random(array $domains) {
$wordLength = rand(3, 8);
$container = new PronounceableWord_DependencyInjectionContainer();
$generator = $container->getGenerator();
$word = $generator->generateWordOfGivenLength($wordLength);
$nr = rand(51, 91);
$name = $word . $nr;
$domain = $domains[array_rand($domains)];
header("location: ?$name@$domain");
}
/** /**
* deletes messages older than X days. * deletes messages older than X days.
*/ */

View File

@ -7,10 +7,24 @@ abstract class Page {
function if_invalid_redirect_to_random(User $user, array $config_domains) { function if_invalid_redirect_to_random(User $user, array $config_domains) {
if ($user->isInvalid()) { if ($user->isInvalid()) {
redirect_to_random($config_domains); $this->redirect_to_random($config_domains);
exit(); exit();
} }
} }
function redirect_to_random(array $domains) {
$wordLength = rand(3, 8);
$container = new PronounceableWord_DependencyInjectionContainer();
$generator = $container->getGenerator();
$word = $generator->generateWordOfGivenLength($wordLength);
$nr = rand(51, 91);
$name = $word . $nr;
$domain = $domains[array_rand($domains)];
header("location: ?$name@$domain");
}
} }
class RedirectToAddressPage extends Page { class RedirectToAddressPage extends Page {
@ -80,7 +94,7 @@ class RedirectToRandomAddressPage extends Page {
} }
function invoke(ImapClient $imapClient) { function invoke(ImapClient $imapClient) {
redirect_to_random($this->config_domains); $this->redirect_to_random($this->config_domains);
} }
} }