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>
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* CLI: export leads as CSV for staff follow-up.
|
|
*
|
|
* php api/cron/export-leads.php [--since=YYYY-MM-DD] > leads.csv
|
|
*
|
|
* Contains personal data — store the output securely and delete when done.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
if (PHP_SAPI !== 'cli') {
|
|
http_response_code(404);
|
|
exit;
|
|
}
|
|
require_once dirname(__DIR__) . '/lib/bootstrap.php';
|
|
|
|
$since = null;
|
|
foreach ($argv as $arg) {
|
|
if (str_starts_with($arg, '--since=')) {
|
|
$since = substr($arg, 8);
|
|
}
|
|
}
|
|
$sql = 'SELECT submission_id, created_at, first_name, last_name, email, phone_e164, campus_id, visit_date, service_time, adults, children, child_age_ranges, questions, email_consent, sms_consent, consent_version, consent_at, variant, attribution, mailchimp_status, sms_status FROM leads';
|
|
$params = [];
|
|
if ($since) {
|
|
$sql .= ' WHERE created_at >= ?';
|
|
$params[] = $since;
|
|
}
|
|
$sql .= ' ORDER BY created_at ASC';
|
|
$st = Db::pdo()->prepare($sql);
|
|
$st->execute($params);
|
|
$out = fopen('php://stdout', 'w');
|
|
$first = true;
|
|
while ($row = $st->fetch()) {
|
|
if ($first) {
|
|
fputcsv($out, array_keys($row));
|
|
$first = false;
|
|
}
|
|
fputcsv($out, $row);
|
|
}
|