Example #1
0
 * returns as soon as a download is finished
 * or wait 10 seconds if no download is queued.
 */
if (!function_exists("curl_init")) {
    error_log("php-curl not installed or not enabled, exit.\n");
    exit(1);
}
require_once __DIR__ . '/../../../common.php';
require_once __DIR__ . '/../libs/cron.php';
require_once __DIR__ . '/../libs/api.php';
$cron = new Cron();
$api = new Api();
$api->log_caller = "cron-calling-daemon";
while (true) {
    // We search for the list of crontasks to launch (date/time selector is done there)
    $list = $cron->cronTasksList();
    $urllist = array();
    foreach ($list as $onecron) {
        if (substr($onecron["url"], 0, 7) == "http://" || substr($onecron["url"], 0, 8) == "https://") {
            if (strpos($onecron["url"], "?") !== false) {
                $onecron["url"] .= "&action=transcoder_cron&app_key=" . $onecron['clientkey'];
            } else {
                $onecron["url"] .= "?action=transcoder_cron&app_key=" . $onecron['clientkey'];
            }
            $urllist[] = array("url" => $onecron["url"], "uid" => $onecron["uid"]);
        }
    }
    if (empty($urllist)) {
        // nothing to do :
        sleep(60);
        // Let's try again in a minute