Files
visit.waterschurch.org/public/api/cron/retry-integrations.php
T
Waters ChurchandClaude Fable 5.1 78cd0cc550 Plan Your Visit landing page for visit.waterschurch.org
Next.js 16 static export + PHP 8 API for cPanel/Apache hosting.

- Location-aware campus finder (IP estimate, optional precise location, ZIP search)
- Three-step Plan Your Visit form with separate email/SMS consent
- PHP API: validation, anti-spam, rate limiting, SQLite lead store,
  Mailchimp and Sinch Engage adapters, idempotent retries via cron
- Attribution capture (utm_*, gclid/gbraid/wbraid, fbclid, ttclid, twclid) and
  consent-aware analytics hooks
- Vitest and PHP test suites, cPanel deployment script and docs

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-22 13:22:26 -04:00

30 lines
1.1 KiB
PHP

<?php
/**
* Cron: retry failed Mailchimp / Sinch deliveries and purge expired leads.
*
* cPanel → Cron Jobs → every 5 minutes:
* VISIT_PRIVATE_DIR=/home/USER/visit-private /usr/local/bin/php /home/USER/visit.waterschurch.org/api/cron/retry-integrations.php >> /home/USER/visit-private/logs/cron.log 2>&1
*
* CLI only — web requests are refused by the .htaccess in this folder AND by the guard below.
*/
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
}
require_once dirname(__DIR__) . '/lib/bootstrap.php';
require_once dirname(__DIR__) . '/lib/LeadProcessor.php';
$lock = fopen(Config::dataDir() . '/retry.lock', 'c');
if (!$lock || !flock($lock, LOCK_EX | LOCK_NB)) {
fwrite(STDOUT, gmdate('c') . " retry: another run is in progress\n");
exit(0);
}
$result = LeadProcessor::retryDue(Config::int('RETRY_BATCH_SIZE', 25));
$purged = LeadProcessor::purgeExpired();
fwrite(STDOUT, sprintf("%s retry: checked=%d processed=%d purged=%d mode=%s\n", gmdate('c'), $result['checked'], $result['processed'], $purged, Config::mode()));
flock($lock, LOCK_UN);