#!/usr/bin/env php . define('INSTALLDIR', dirname(__DIR__)); define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'e::ay'; $longoptions = ['email=', 'all', 'yes']; $self = basename($_SERVER['PHP_SELF']); $helptext = <<obj->address_type, $e->obj->address, $e->obj->tableName() ); exit(1); } } elseif (have_option('a', 'all')) { $all = true; $ca = new Confirm_address(); $ca->address_type = 'email'; if (!$ca->find()) { echo "confirm_address table contains no lingering email addresses\n"; exit(); } } else { echo "You must provide an email (or --all).\n"; exit(1); } if (!have_option('y', 'yes')) { echo "About to resend confirm_address email to {$ca->N} recipients. Are you sure? [y/N] "; $response = fgets(STDIN); if (strcasecmp(trim($response), 'y') != 0) { echo "Aborting.\n"; exit(); } } function mail_confirm_address(Confirm_address $ca): void { try { $user = User::getByID($ca->user_id); $profile = $user->getProfile(); if ($profile->isSilenced()) { $ca->delete(); return; } if ($user->email === $ca->address) { throw new AlreadyFulfilledException('User already has identical confirmed email address.'); } } catch (AlreadyFulfilledException $e) { echo "\n User already had verified email: " . _ve($ca->address); $ca->delete(); } catch (Exception $e) { echo "\n Failed to get user with ID " . _ve($user_id) . ', deleting confirm_address entry: ' . _ve($e->getMessage()); $ca->delete(); return; } $ca->sendConfirmation(); } require_once INSTALLDIR . '/lib/util/mail.php'; if (!$all) { mail_confirm_address($ca); } else { while ($ca->fetch()) { mail_confirm_address($ca); } } echo "\nDONE.\n";