cron.php 697 Bytes
<?php

$filename = '/opt/tmp/stfcardid2login.json';
$s = stat($filename);

if ($s === FALSE || (@$s[9]+3600*24) < time()) {
	$apiKey      = trim(file_get_contents('/etc/apikey-voip'));
	$subscribers = json_decode(file_get_contents('http://new.voip.mephi.ru/subscribers.json?limit=65535&renderFilter=subscribers&apiKey='.urlencode($apiKey)), 1)['subscribers'];
	foreach ($subscribers as &$subscriber) {
		if (empty($subscriber['Login']['String']))
			continue;

		foreach ($subscriber['Appointments'] as &$_a) 
			$stfcardid2login[$_a['StfCardId']] = $subscriber['Login']['String'];
	}

	if (count($stfcardid2login) > 1000) {
		file_put_contents($filename, json_encode($stfcardid2login));
	}
}

?>