<?php require_once __DIR__.'/../includes/functions.php';
$start=date('Y-m-d H:i:s');
try{
 q('UPDATE mj_listings SET status="expired" WHERE expires_at IS NOT NULL AND expires_at<NOW() AND status="active"');
 q('INSERT INTO mj_cron_logs(job_name,status,message,started_at,ended_at) VALUES("daily","success","Daily maintenance completed",?,NOW())',[$start]);
 echo "OK\n";
}catch(Throwable $e){ q('INSERT INTO mj_cron_logs(job_name,status,message,started_at,ended_at) VALUES("daily","failed",?, ?,NOW())',[$e->getMessage(),$start]); echo "FAILED: ".$e->getMessage(); }
