2016-07-10 15:32:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . '../vendor/autoload.php';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bootstrap environment, configs and database
|
|
|
|
*/
|
2016-07-11 20:29:44 +00:00
|
|
|
$env = BootstrapHelper::bootEnvironment();
|
2016-07-10 15:32:38 +00:00
|
|
|
$config = Config::$CONFIG;
|
2016-07-11 20:29:44 +00:00
|
|
|
$db = BootstrapHelper::bootDatabase();
|
|
|
|
$translator = BootstrapHelper::bootTranslator();
|
|
|
|
$logger = BootstrapHelper::bootLogger();
|
2016-07-10 15:32:38 +00:00
|
|
|
|
|
|
|
// handle all users awaiting verification and notify them
|
|
|
|
$users = UserAwaitingVerification::all();
|
|
|
|
$now = Carbon::now();
|
|
|
|
$now->modify('+' . getenv('verification_cleanup_time'));
|
|
|
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
$createdAt = DateHelper::convertToCarbon($user->created_at);
|
|
|
|
|
|
|
|
if (!empty($createdAt)) {
|
|
|
|
if ($createdAt->lt($now)) {
|
|
|
|
$mailer = new PHPMailer();
|
|
|
|
$mailer->CharSet = 'UTF-8';
|
|
|
|
$mailer->ContentType = 'text/plain';
|
|
|
|
$mailer->isSMTP();
|
|
|
|
$mailer->SMTPSecure = getenv('mail_secure');
|
|
|
|
$mailer->SMTPAuth = getenv('mail_auth');
|
|
|
|
|
|
|
|
$mailer->Host = getenv('mail_host');
|
|
|
|
$mailer->Port = getenv('mail_port');
|
|
|
|
$mailer->Username = getenv('mail_username');
|
|
|
|
$mailer->Password = getenv('mail_password');
|
|
|
|
$mailer->From = getenv('mail_from');
|
|
|
|
$mailer->FromName = getenv('mail_from_name');
|
|
|
|
|
|
|
|
$mailer->addAddress($user->email);
|
|
|
|
|
|
|
|
$mailer->Subject = $translator->trans('cleanup.mail.subject', ['%server%' => getenv('site_xmpp_server_displayname')]);
|
|
|
|
$mailer->Body = $translator->trans('cleanup.mail.body', ['%username%' => $user->username, '%server%' => getenv('site_xmpp_server_displayname')]);
|
|
|
|
$mailer->send();
|
|
|
|
|
|
|
|
$logger->info($translator->trans('log.verification.cleanup', ['%username%' => $user->username]));
|
|
|
|
$user->delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|