<?php
$max_age_seconds = 300;
$heartbeat_file = 'cron/encrypt_heartbeat.log';

$last_run_time = 0;
if (file_exists($heartbeat_file)) {
  $last_run = file_get_contents($heartbeat_file);
  $last_run_time = is_numeric($last_run) ? (int)$last_run : 0;
}


if (time() - $last_run_time >= $max_age_seconds) {

	$result = $conn->prepare("SELECT id FROM encrypt_log WHERE status = 'pending'");
	$result->execute();
	if ($result->rowCount()){
		include('cron/encrypt.php');
		print "<meta http-equiv='refresh' content='30'>";
	}
}