redirect_to_random
This commit is contained in:
parent
a8040ae815
commit
68493c4401
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user