<?php
@ini_set('display_errors','0'); @ini_set('max_execution_time','30'); @set_time_limit(30);
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
if (session_status() === PHP_SESSION_NONE) session_start();
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/../helpers.php';
require_once __DIR__ . '/../auth.php';
require_once __DIR__ . '/../db_bootstrap.php';
require_once __DIR__ . '/../subscribers_queue_lib.php';
function outr(array $a,int $code=200){ http_response_code($code); echo json_encode($a,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); exit; }
require_login('index.php?login=1');
if (function_exists('require_perm')) @require_perm('can_manage_subscribers');
$conn=ensure_db(true);
try{ outr(['ok'=>true,'run'=>sq_run_worker($conn,1,22)]); }catch(Throwable $e){ sq_log('manual run failed: '.$e->getMessage()); outr(['ok'=>false,'message'=>$e->getMessage()],500); }
