<?php
/**
 * Cron entry point.
 *
 * Runs every cron job that is currently due (it delegates to
 * pjBaseCron::pjActionRun, which checks each active job's next_run).
 *
 * Schedule it from your server every few minutes, e.g. crontab:
 *     star/5 * * * * php /path/to/cron.php            (command-line)
 * or as a web cron / uptime pinger hitting:
 *     https://your-domain/path/cron.php               (URL)
 *
 * (Replace "star" above with an asterisk.)
 */

// Tell the front controller which controller/action to dispatch.
$_GET['controller'] = 'pjBaseCron';
$_GET['action']     = 'pjActionRun';
$_REQUEST['controller'] = 'pjBaseCron';
$_REQUEST['action']     = 'pjActionRun';

// When run from the command line there is no HTTP request, so provide the
// few request variables the bootstrap expects.
if (PHP_SAPI === 'cli') {
    if (empty($_SERVER['HTTP_HOST']))   { $_SERVER['HTTP_HOST']   = 'localhost'; }
    if (empty($_SERVER['PHP_SELF']))    { $_SERVER['PHP_SELF']    = '/cron.php'; }
    if (empty($_SERVER['SCRIPT_NAME'])) { $_SERVER['SCRIPT_NAME'] = '/cron.php'; }
    if (empty($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = '/cron.php'; }
    if (empty($_SERVER['REQUEST_METHOD'])) { $_SERVER['REQUEST_METHOD'] = 'GET'; }
}

// Boot the application and dispatch (index.php reads $_GET['controller']).
require dirname(__FILE__) . '/index.php';
