22 lines
760 B
PHP
22 lines
760 B
PHP
<?php
|
|
/**
|
|
* cron_auth.php — Secret-based auth for cron endpoints called by Node.js scheduler.
|
|
* No session required. Validates x-cron-secret header against NODE_EMIT_SECRET.
|
|
* Sets up $pdo1, $pdo2, and $answer identical to db_auth.php.
|
|
*/
|
|
ini_set('display_errors', 0);
|
|
ini_set('log_errors', 1);
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
require_once __DIR__ . '/../../config.php';
|
|
require_once __DIR__ . '/../../dbconn.php';
|
|
|
|
$secret = $_SERVER['HTTP_X_CRON_SECRET'] ?? '';
|
|
if (!defined('NODE_EMIT_SECRET') || $secret !== NODE_EMIT_SECRET) {
|
|
http_response_code(403);
|
|
exit(json_encode(['success' => 0, 'message' => 'Forbidden']));
|
|
}
|
|
|
|
$data = json_decode(file_get_contents('php://input'), true) ?? [];
|
|
$answer = ['success' => 0];
|