Skip to content

Commit

Permalink
Fix PHP fatal error if an exception occurs when spid_handle is called…
Browse files Browse the repository at this point in the history
… not the first time
  • Loading branch information
Zhigalin committed Oct 9, 2023
1 parent 5eb7586 commit d57cc7b
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions wp-spid-italia.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,28 @@ function spid_handle() {
echo '<br><br><pre><small style="color:darkred;">La configurazione SPID ha generato un errore</small></pre>';
}

function spid_errors( $errorMsg2 ){
$xmlString = isset($_GET['SAMLResponse']) ? gzinflate(base64_decode($_GET['SAMLResponse'])) : base64_decode($_POST['SAMLResponse']);
$xmlResp = new \DOMDocument();
$xmlResp->loadXML($xmlString);
if ( $xmlResp->textContent ) {
switch ( $xmlResp->textContent ) {
case stripos( $xmlResp->textContent, 'nr19') !== false:
return '<b>SPID errore 19</b> - Ripetuta sottomissione di credenziali errate';
case stripos( $xmlResp->textContent, 'nr20') !== false:
return '<b>SPID errore 20</b> - Utente privo di credenziali compatibili con il livello richiesto dal fornitore del servizio';
case stripos( $xmlResp->textContent, 'nr21') !== false:
return '<b>SPID errore 21</b> - Timeout';
case stripos( $xmlResp->textContent, 'nr22') !== false:
return '<b>SPID errore 22</b> - Utente nega il consenso all\'invio di dati al SP in caso di sessione vigente';
case stripos( $xmlResp->textContent, 'nr23') !== false:
return '<b>SPID errore 23</b> - Credenziali sospese o revocate';
case stripos( $xmlResp->textContent, 'nr25') !== false:
return '<b>SPID errore 25</b> - Processo di autenticazione annullato dall\'utente';
default:
return 'Si è verificato un errore durante l\'accesso SPID. Contattare l\'amministratore per maggiori informazioni.';
if( !function_exists('spid_errors') ) {
function spid_errors( $errorMsg2 ){
$xmlString = isset($_GET['SAMLResponse']) ? gzinflate(base64_decode($_GET['SAMLResponse'])) : base64_decode($_POST['SAMLResponse']);
$xmlResp = new \DOMDocument();
$xmlResp->loadXML($xmlString);
if ( $xmlResp->textContent ) {
switch ( $xmlResp->textContent ) {
case stripos( $xmlResp->textContent, 'nr19') !== false:
return '<b>SPID errore 19</b> - Ripetuta sottomissione di credenziali errate';
case stripos( $xmlResp->textContent, 'nr20') !== false:
return '<b>SPID errore 20</b> - Utente privo di credenziali compatibili con il livello richiesto dal fornitore del servizio';
case stripos( $xmlResp->textContent, 'nr21') !== false:
return '<b>SPID errore 21</b> - Timeout';
case stripos( $xmlResp->textContent, 'nr22') !== false:
return '<b>SPID errore 22</b> - Utente nega il consenso all\'invio di dati al SP in caso di sessione vigente';
case stripos( $xmlResp->textContent, 'nr23') !== false:
return '<b>SPID errore 23</b> - Credenziali sospese o revocate';
case stripos( $xmlResp->textContent, 'nr25') !== false:
return '<b>SPID errore 25</b> - Processo di autenticazione annullato dall\'utente';
default:
return 'Si è verificato un errore durante l\'accesso SPID. Contattare l\'amministratore per maggiori informazioni.';
}
}
}
}
Expand Down Expand Up @@ -457,4 +459,4 @@ function spid_option($name) {
return false;
}

?>
?>

0 comments on commit d57cc7b

Please sign in to comment.