gestione gare pubbliche
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

57 righe
2.3 KiB

<?
if (!empty($elabora_coda)) {
$current_time = (int) date('H');
if($current_time >= 5) {
alertManager::printCliInfo("Aggiornamento Indici SPID");
if (empty(getQueueLog("0","updateSpid"))) {
$indexes = SpidSA::getIndexs("tuttogare-pa");
if (!empty($indexes)) {
$found = [];
$updateStato = $pdo->prepare("UPDATE b_enti SET indice_spid = :index, spid = 'S' WHERE codice_spid = :codice");
foreach($indexes AS $index) {
$updateStato->bindValue(":index",$index["index"]);
$updateStato->bindValue(":codice",$index["codice"]);
$updateStato->execute();
$found[] = (int) $index["codice"];
}
}
// if (!empty($found)) {
// $enti = $pdo->go("UPDATE b_enti SET indice_spid = NULL, spid = 'N' WHERE spid <> 'W' AND codice_spid NOT IN (" . implode(",",$found) . ")");
// }
$idp_list_url = 'https://registry.spid.gov.it/assets/data/idp.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $idp_list_url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
echo "Contacting $idp_list_url" . PHP_EOL;
$json = curl_exec($ch);
curl_close($ch);
$idps = json_decode($json);
foreach ($idps->data as $idp) {
$metadata_url = $idp->metadata_url;
$ipa_entity_code = $idp->ipa_entity_code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $metadata_url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
echo "Contacting $metadata_url" . PHP_EOL;
$xml = curl_exec($ch);
if ($xml !== false) {
// operation completed successfully
$file = "{$spidIDPFolder}{$ipa_entity_code}.xml";
file_put_contents($file, $xml);
}
curl_close($ch);
}
writeQueueLog("0","updateSpid");
} else {
alertManager::printCliWarning("Già eseguito");
}
}
}
?>