65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
||
/**
|
||
* Careers form endpoint → careers@zettaisystems.com
|
||
*/
|
||
|
||
declare(strict_types=1);
|
||
|
||
require __DIR__ . '/helpers.php';
|
||
|
||
zs_require_post();
|
||
|
||
if (zs_is_honeypot_filled()) {
|
||
zs_json_response(200, ['ok' => true, 'message' => 'Thank you. Your application has been received.']);
|
||
}
|
||
|
||
zs_require_csrf();
|
||
zs_rate_limit('careers');
|
||
|
||
$name = zs_field('name', 120);
|
||
$email = zs_field('email', 160);
|
||
$phone = zs_field('phone', 40);
|
||
$position = zs_field('position', 120);
|
||
$experience = zs_field('experience', 40);
|
||
$message = zs_field('message', 5000);
|
||
|
||
if ($name === '' || $email === '' || $phone === '' || $position === '' || $experience === '') {
|
||
zs_json_response(400, ['ok' => false, 'error' => 'Please fill in all required fields.']);
|
||
}
|
||
if (!zs_valid_email($email)) {
|
||
zs_json_response(400, ['ok' => false, 'error' => 'Please enter a valid email address.']);
|
||
}
|
||
|
||
$attachment = zs_resume_attachment();
|
||
if ($attachment === null) {
|
||
zs_json_response(400, ['ok' => false, 'error' => 'Please attach your resume (PDF or Word).']);
|
||
}
|
||
|
||
$mailSubject = '[Career] ' . $position . ' – ' . $name;
|
||
$body = "New career application from the Zettai Systems website\n";
|
||
$body .= str_repeat('-', 48) . "\n\n";
|
||
$body .= "Name: {$name}\n";
|
||
$body .= "Email: {$email}\n";
|
||
$body .= "Phone: {$phone}\n";
|
||
$body .= "Position: {$position}\n";
|
||
$body .= "Experience: {$experience}\n\n";
|
||
$body .= "Message:\n" . ($message !== '' ? $message : '—') . "\n\n";
|
||
$body .= "Resume attached: {$attachment['name']}\n\n";
|
||
$body .= str_repeat('-', 48) . "\n";
|
||
$body .= 'Submitted: ' . gmdate('Y-m-d H:i:s') . " UTC\n";
|
||
$body .= 'IP: ' . ($_SERVER['REMOTE_ADDR'] ?? 'unknown') . "\n";
|
||
|
||
$sent = zs_send_mail(ZS_CAREERS_TO, $mailSubject, $body, $email, $attachment);
|
||
|
||
if (!$sent) {
|
||
zs_json_response(500, [
|
||
'ok' => false,
|
||
'error' => 'We could not send your application right now. Please email careers@zettaisystems.com or try again later.',
|
||
]);
|
||
}
|
||
|
||
zs_json_response(200, [
|
||
'ok' => true,
|
||
'message' => 'Thank you. Your application has been sent. Our team will review it and follow up if there is a fit.',
|
||
]);
|