From feb97cfc2288169fbf8f1f47393c9735c017eeb6 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 2 Mar 2016 15:48:18 +0100 Subject: [PATCH] Resend confirm_address stuff, please read its NOTE first --- scripts/resend_confirm_address.php | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 scripts/resend_confirm_address.php diff --git a/scripts/resend_confirm_address.php b/scripts/resend_confirm_address.php new file mode 100755 index 0000000000..1d7cb55ca5 --- /dev/null +++ b/scripts/resend_confirm_address.php @@ -0,0 +1,91 @@ +#!/usr/bin/env php +address_type = 'email'; + if (!$ca->find()) { + print "confirm_address table contains no lingering email addresses\n"; + exit(0); + } +} else { + print "You must provide an email (or --all).\n"; + exit(1); +} + +if (!have_option('y', 'yes')) { + print "About to resend confirm_address email to {$ca->N} recipients. Are you sure? [y/N] "; + $response = fgets(STDIN); + if (strtolower(trim($response)) != 'y') { + print "Aborting.\n"; + exit(0); + } +} + +function mailConfirmAddress(Confirm_address $ca) +{ + try { + $user = User::getByID($ca->user_id); + if ($user->email === $ca->address) { + throw new AlreadyFulfilledException('User already has identical confirmed email address.'); + } + } catch (AlreadyFulfilledException $e) { + print "\n User already had verified email: "._ve($ca->address); + $ca->delete(); + } catch (Exception $e) { + print "\n Failed to get user with ID "._ve($user_id).', deleting confirm_address entry: '._ve($e->getMessage()); + $ca->delete(); + return; + } + mail_confirm_address($user, $ca->code, $user->getNickname(), $ca->address); +} + +require_once(INSTALLDIR . '/lib/mail.php'); + +if (!$all) { + mailConfirmAddress($ca); +} else { + while ($ca->fetch()) { + mailConfirmAddress($ca); + } +} + +print "\nDONE.\n"; -- 2.39.5