[1174] | 1 | <?php
|
---|
[3232] | 2 | $GLOBALS['phpgw_info'] = array();
|
---|
| 3 | $GLOBALS['phpgw_info']['flags'] = array('noheader' => True,'nonavbar' => True,'currentapp' => 'admin');
|
---|
| 4 | include('../header.inc.php');
|
---|
[1174] | 5 | require_once('classes/CertificadoB.php');
|
---|
[3232] | 6 | $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
---|
[1174] | 7 | // pega caminho completo do arquivo de CAS..
|
---|
[3232] | 8 | $path3 =$GLOBALS['CAs'];
|
---|
[1174] | 9 | // se não pude acessar o arquivo com certificados retornar .....
|
---|
[3232] | 10 | if(!is_file($path3))
|
---|
| 11 | {
|
---|
| 12 | $xml .= '<certificados><cert><item>' . $path3 . '</item><nome>Path para pasta com certificados esta invalida</nome><validade></validade></cert></certificados>';
|
---|
| 13 | Header('Content-type: application/xml; charset=utf-8');
|
---|
| 14 | echo $xml;
|
---|
| 15 | exit();
|
---|
| 16 | }
|
---|
[1174] | 17 | $todos_certificados = ler_certificados_CAS($path3);
|
---|
| 18 | $CB = new CertificadoB();
|
---|
[3232] | 19 | //$_POST['id'] = 'A';
|
---|
| 20 | if($_POST['id'])
|
---|
| 21 | {
|
---|
| 22 | if($_POST['id'] != 'A')
|
---|
| 23 | {
|
---|
| 24 | // id indica o certificado solicitado ....
|
---|
| 25 | $aux = explode('-',$_POST['id']);
|
---|
| 26 | if(count($aux) > 1)
|
---|
| 27 | {
|
---|
| 28 | $id =$aux[0];
|
---|
| 29 | $id = $id -1;
|
---|
| 30 | }
|
---|
| 31 | else
|
---|
| 32 | {
|
---|
| 33 | $id = 0;
|
---|
| 34 | }
|
---|
| 35 | // Pega o certificado solicitado ...
|
---|
| 36 | $certificado = $todos_certificados[$id];
|
---|
| 37 | // Vai parsear, e gerar o xml ...
|
---|
| 38 | $CB -> certificado($certificado);
|
---|
| 39 | // Pega o xml com os dados do certificado ..
|
---|
| 40 | $xml .= $CB -> dados_xml;
|
---|
| 41 | }
|
---|
| 42 | else
|
---|
| 43 | {
|
---|
| 44 | // Requisitado todo o conteudo do arquivo de CAs ..
|
---|
| 45 | $item = 1;
|
---|
| 46 | $processados = array();
|
---|
| 47 | $xml .= "<certificados>";
|
---|
| 48 | //$xml .= '<cert><item>0</item><nome>Parametro xxxxxxxxxx xxxxxxxxxxxxxxxxxxxx invalido.</nome><validade> asdad </validade></cert>';
|
---|
| 49 |
|
---|
| 50 | foreach($todos_certificados as $certificado)
|
---|
| 51 | {
|
---|
| 52 | $CB -> certificado($certificado);
|
---|
| 53 | $df = $CB -> dados['FIM_VALIDADE'];
|
---|
| 54 | $xml .= '<cert>';
|
---|
| 55 | $xml .= '<item>' . $item++ . '</item>';
|
---|
| 56 | $xml .= ' <nome>' . $CB->dados['SUBJECT']['CN'] . '</nome>';
|
---|
| 57 | if($processados[$CB->dados['SUBJECT']['CN']])
|
---|
| 58 | {
|
---|
| 59 | $alerta = '<font color="#FF0000"><b>DUPLICADO (veja o item ' . $processados[$CB->dados['SUBJECT']['CN']] . ' acima) </b></font>';
|
---|
| 60 | }
|
---|
| 61 | else
|
---|
| 62 | {
|
---|
| 63 | $alerta = '';
|
---|
| 64 | $processados[$CB->dados['SUBJECT']['CN']] = $item-1;
|
---|
| 65 | }
|
---|
| 66 | $xml .= '<validade> ' . $alerta . ' Valido ate ' . substr($df,0,4) . '/' . substr($df,4,2) .
|
---|
| 67 | '/' .
|
---|
| 68 | substr($df,6,2) .
|
---|
| 69 | ' - ' .
|
---|
| 70 | substr($df,8,2) .
|
---|
| 71 | ':' .
|
---|
| 72 | substr($df,10,2) .
|
---|
| 73 | ':' .
|
---|
| 74 | substr($df,12,2) .
|
---|
| 75 | ' GMT' . '</validade>';
|
---|
| 76 | $xml .= '</cert>';
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | $xml .= "</certificados>";
|
---|
| 81 |
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
[1174] | 84 | else
|
---|
[3232] | 85 | {
|
---|
| 86 | $xml .= '<certificados><cert><item>99</item><nome>Parametro invalido.</nome><validade> </validade></cert></certificados>';
|
---|
| 87 | }
|
---|
[1174] | 88 | # Fecha o processamento de geracao do xml com um CABEÇALHO
|
---|
[3232] | 89 | Header('Content-type: application/xml; charset=utf-8');
|
---|
[1174] | 90 | echo $xml;
|
---|
| 91 | ?>
|
---|
| 92 |
|
---|
| 93 | |
---|