Ir para conteúdo
Fórum Script Brasil
  • 0

(ajuda) Erro em php


laante

Pergunta

Ola galera sou novo aqui no forum, me deram uma source só que esta com erro alguém pode me ajudar, não sei nd em php 

se vocês corrigirem os errors e me mandarem ficaria feliz,  obrigado!!

 

 

<html>
<head>
<title>SUS||DARONCODE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://fuckchecker.com.br/free/path/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="https://fuckchecker.com.br/free/path/css/animate.css" rel="stylesheet" type="text/css">
<link href="https://fuckchecker.com.br/free/path/css/explicitchk.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="path/css/font-awesome.min.css">
</head>
<body>
<center>
<h2>CONSULTAS</h2>
<form action="" method="post"> 
<input class="form-control"  style="width: 326px; text-align: center;"  name="enviarcpf" > <br>
<input type="submit" class="btn btn-success" name="pesquisar" value="Consultar">
</form> 	
</html>    	
</body>

</html>
<?php
function getStr($string,$start,$end){
    $str = explode($start,$string);
    $str = explode($end,$str[1]);
    return $str[0];
}


$cookies = rand(1000000,1000000);
$cnes = "cnes"; // CNES
$logincad = "usuario"; // USUARIO
$senhacad = "senha"; // SENHA
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/login/actionArmazenarXS.form");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies.".txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest"));
curl_setopt($ch, CURLOPT_REFERER, "https://cadastro.saude.gov.br/cadsusweb/login/actionArmazenarXS.form");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cnes=$cnes&usuario=$logincad&senha=$senhacad");
$neylog1 = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/j_security_check");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies.".txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate, br');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "j_username=$cnes.$logincad&cnes=$cnes&usuario=$logincad&j_password=$senhacad");
$neylog2 = curl_exec($ch);



 if(isset($_POST['enviarcpf']))
 {
     $cpf= $_POST['enviarcpf'];
     $cpf=trim($cpf);

     if($cpf <> '')
     {
     curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/restrito/consultar/pesquisar.form");
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies . ".txt");
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate, br');
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "usuario=%7B%22idCorporativo%22%3Anull%2C%22idLocal%22%3Anull%2C%22desabilitarDataQuality%22%3Afalse%2C%22obsDesabilitarDataQuality%22%3Anull%2C%22numeroProtocoloPrecadastro%22%3Anull%2C%22protocoloPrimeiroAcesso%22%3Anull%2C%22protocolo%22%3Anull%2C%22solicitarAcessoPortal%22%3Afalse%2C%22encontradoReceita%22%3Anull%2C%22cpf%22%3Anull%2C%22numeroCns%22%3A%22%22%2C%22nome%22%3A%22%22%2C%22nomeSocial%22%3A%22%22%2C%22nomeMae%22%3A%22%22%2C%22nomePai%22%3A%22%22%2C%22sexo%22%3Anull%2C%22sexoDescricao%22%3Anull%2C%22racaCor%22%3Anull%2C%22racaCorDescricao%22%3Anull%2C%22dataObito%22%3Anull%2C%22dataOperacaoObito%22%3Anull%2C%22motivoDeclaracaoObito%22%3Anull%2C%22cnesOperador%22%3Anull%2C%22tipoSanguineo%22%3Anull%2C%22etniaIndigena%22%3Anull%2C%22etniaIndigenaDescricao%22%3Anull%2C%22dataNascimento%22%3A%22%22%2C%22nacionalidade%22%3Anull%2C%22paisNascimentoCodigo%22%3Anull%2C%22paisNascimento%22%3Anull%2C%22municipioNascimentoCodigo%22%3A%22%22%2C%22municipioNascimento%22%3A%22%22%2C%22dataNaturalizacao%22%3Anull%2C%22portariaNaturalizacao%22%3Anull%2C%22dataEntradaBrasil%22%3Anull%2C%22emailPrincipal%22%3Anull%2C%22emailAlternativo%22%3Anull%2C%22emailPrincipalValidado%22%3Anull%2C%22emailAlternativoValidado%22%3Anull%2C%22telefone%22%3A%5B%5D%2C%22nomade%22%3Afalse%2C%22enderecoCodigo%22%3Anull%2C%22paisResidenciaCodigo%22%3Anull%2C%22paisResidenciaDescricao%22%3Anull%2C%22enderecoMunicipio%22%3Anull%2C%22enderecoMunicipioCodigo%22%3Anull%2C%22enderecoTipoLogradouro%22%3Anull%2C%22enderecoTipoLogradouroCodigo%22%3Anull%2C%22enderecoLogradouro%22%3Anull%2C%22enderecoNumero%22%3Anull%2C%22enderecoComplemento%22%3Anull%2C%22enderecoBairroCodigo%22%3Anull%2C%22enderecoBairro%22%3Anull%2C%22enderecoCep%22%3Anull%2C%22emailPrincipalCodigo%22%3Anull%2C%22emailAlternativoCodigo%22%3Anull%2C%22dnv%22%3Anull%2C%22numeroInscricaoSocialCodigo%22%3Anull%2C%22numeroInscricaoSocial%22%3Anull%2C%22rgCodigo%22%3Anull%2C%22rgNumero%22%3Anull%2C%22rgOrgaoEmissor%22%3Anull%2C%22rgOrgaoEmissorDescricao%22%3Anull%2C%22rgUf%22%3Anull%2C%22rgDataEmissao%22%3Anull%2C%22tituloEleitorCodigo%22%3Anull%2C%22tituloEleitorNumero%22%3Anull%2C%22tituloEleitorZona%22%3Anull%2C%22tituloEleitorSecao%22%3Anull%2C%22certidao%22%3A%5B%5D%2C%22ctpsCodigo%22%3Anull%2C%22ctpsNumero%22%3Anull%2C%22ctpsSerie%22%3Anull%2C%22ctpsDataEmissao%22%3Anull%2C%22cnhNumero%22%3Anull%2C%22cnhDataEmissao%22%3Anull%2C%22cnhUf%22%3Anull%2C%22passaporteCodigo%22%3Anull%2C%22passaporteNumero%22%3Anull%2C%22passaportePaisCodigo%22%3Anull%2C%22passaportePais%22%3Anull%2C%22passaporteDataValidade%22%3Anull%2C%22passaporteDataEmissao%22%3Anull%2C%22fotografia%22%3A%5B%5D%2C%22situacao%22%3A%22Ativo%22%2C%22dataAlteracao%22%3Anull%2C%22spanSituacao%22%3Anull%2C%22motivoCancelamento%22%3Anull%2C%22spanVip%22%3Anull%2C%22vipDescricao%22%3Anull%2C%22spanProtecao%22%3Anull%2C%22protecaoDescricao%22%3Anull%2C%22motivoNaoHigienizado%22%3Anull%2C%22vivo%22%3Anull%2C%22cartoesAgregados%22%3A%5B%5D%2C%22tipoDocumento%22%3A%22CPF%22%2C%22numeroDocumento%22%3A%22" . $cpf . "%22%7D&byPassHigienizacao=false&tpPesquisa=identica");
     $saida = curl_exec($ch);
        $cns= getStr($saida,'"numeroCns": "','"');

         curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/restrito/consultar/visualizar.form");
         curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies . ".txt");
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate, br');
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "cns=$cns");
         $saida2 = curl_exec($ch);


         $nome= getStr($saida2,'"nome": "','"');
         $nomeMae= getStr($saida2,'"nomeMae": "','"');
         $nomePai = getStr($saida2,'"nomePai": "','"');
         $sexo = getStr($saida2,'"sexo": "','"');
         $datanascimendo = getStr($saida2,'"dataNascimento": "','"');
         $dataobito = getStr($saida2,'"dataObito": "','"');
         $paisNascimento = getStr($saida2,'"paisNascimento": "','"');
         $municipioNascimento = getStr($saida2,'"municipioNascimento": "','"');
         $sexo = getStr($saida2,'"sexo": "','"');
         $vivo = getStr($saida2,'"vivo":',',');
         $cpf = getStr($saida2,'"cpf": "','"');
         $rgnumero = getStr($saida2,'"rgNumero": "','"');

         $pais = getStr($saida2,'"paisResidenciaDescricao": "','"');
         $estado = getStr($saida2,'"enderecoMunicipio": "','"');
         $numerocasa = getStr($saida2,'"enderecoNumero": "','"');
         $endereco = getStr($saida2,'"enderecoLogradouro": "','"');
         $bairro = getStr($saida2,'"enderecoBairro": "','"');
         $cep = getStr($saida2,'"enderecoCep": "','"');
         $ddd = getStr($saida2,'"ddd":',',');
         $telefone = getStr($saida2,'"numero": "','"');



echo'<div class="alert alert-success" style="width: 532px;"role="alert">';
        echo " <br><b> NOME:</b> $nome<br>";
        echo " <b>NOME DA MÃE:</b> $nomeMae<br>";
         echo " <b>NOME DO PAI:</b> $nomePai<br>";
          echo " <b>SEXO:</b> $sexo<br>";
          echo " <b>DATA DE NASCIMENTO:</b> $datanascimendo<br>";
         echo " <b>DATA DE OBITO:</b> $dataObito<br>";
         echo " <b>PAIS:</b> $paisNascimento<br>";
         echo " <b>MUNICIPIO DE NASCIMENTO:</b> $municipioNascimento<br>";
    
         echo " <b>CPF:</b> $cpf<br>";
         echo " <b>RG:</b> $rgnumero<br>";
        
         
         echo " <b>PAIS:</b> $pais<br>";
         echo " <b>ESTADO:</b> $estado <br>";
         echo " <b>NUMERO DA CASA:</b> $numerocasa <br>";
         echo " <b>ENDEREÇO:</b> $endereco<br>";
         echo " <b>BAIRRO:</b> $bairro <br>";
         echo " <b>CEP:</b> $cep<br>";
         echo " <b>TELEFONE:</b> ($ddd) $telefone <br></div>";




     }


 }


if(isset($_POST['enviarnome']))
{
    $nome= $_POST['enviarnome'];
    $nome=trim($nome);

    if($$nome<> '') {
curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/restrito/consultar/pesquisar.form");
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies . ".txt");
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate, br');
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "usuario=%7B%22idCorporativo%22%3Anull%2C%22idLocal%22%3Anull%2C%22desabilitarDataQuality%22%3Afalse%2C%22obsDesabilitarDataQuality%22%3Anull%2C%22numeroProtocoloPrecadastro%22%3Anull%2C%22protocoloPrimeiroAcesso%22%3Anull%2C%22protocolo%22%3Anull%2C%22solicitarAcessoPortal%22%3Afalse%2C%22encontradoReceita%22%3Anull%2C%22cpf%22%3Anull%2C%22numeroCns%22%3A%22%22%2C%22nome%22%3A%22%22%2C%22nomeSocial%22%3A%22%22%2C%22nomeMae%22%3A%22%22%2C%22nomePai%22%3A%22%22%2C%22sexo%22%3Anull%2C%22sexoDescricao%22%3Anull%2C%22racaCor%22%3Anull%2C%22racaCorDescricao%22%3Anull%2C%22dataObito%22%3Anull%2C%22dataOperacaoObito%22%3Anull%2C%22motivoDeclaracaoObito%22%3Anull%2C%22cnesOperador%22%3Anull%2C%22tipoSanguineo%22%3Anull%2C%22etniaIndigena%22%3Anull%2C%22etniaIndigenaDescricao%22%3Anull%2C%22dataNascimento%22%3A%22%22%2C%22nacionalidade%22%3Anull%2C%22paisNascimentoCodigo%22%3Anull%2C%22paisNascimento%22%3Anull%2C%22municipioNascimentoCodigo%22%3A%22%22%2C%22municipioNascimento%22%3A%22%22%2C%22dataNaturalizacao%22%3Anull%2C%22portariaNaturalizacao%22%3Anull%2C%22dataEntradaBrasil%22%3Anull%2C%22emailPrincipal%22%3Anull%2C%22emailAlternativo%22%3Anull%2C%22emailPrincipalValidado%22%3Anull%2C%22emailAlternativoValidado%22%3Anull%2C%22telefone%22%3A%5B%5D%2C%22nomade%22%3Afalse%2C%22enderecoCodigo%22%3Anull%2C%22paisResidenciaCodigo%22%3Anull%2C%22paisResidenciaDescricao%22%3Anull%2C%22enderecoMunicipio%22%3Anull%2C%22enderecoMunicipioCodigo%22%3Anull%2C%22enderecoTipoLogradouro%22%3Anull%2C%22enderecoTipoLogradouroCodigo%22%3Anull%2C%22enderecoLogradouro%22%3Anull%2C%22enderecoNumero%22%3Anull%2C%22enderecoComplemento%22%3Anull%2C%22enderecoBairroCodigo%22%3Anull%2C%22enderecoBairro%22%3Anull%2C%22enderecoCep%22%3Anull%2C%22emailPrincipalCodigo%22%3Anull%2C%22emailAlternativoCodigo%22%3Anull%2C%22dnv%22%3Anull%2C%22numeroInscricaoSocialCodigo%22%3Anull%2C%22numeroInscricaoSocial%22%3Anull%2C%22rgCodigo%22%3Anull%2C%22rgNumero%22%3Anull%2C%22rgOrgaoEmissor%22%3Anull%2C%22rgOrgaoEmissorDescricao%22%3Anull%2C%22rgUf%22%3Anull%2C%22rgDataEmissao%22%3Anull%2C%22tituloEleitorCodigo%22%3Anull%2C%22tituloEleitorNumero%22%3Anull%2C%22tituloEleitorZona%22%3Anull%2C%22tituloEleitorSecao%22%3Anull%2C%22certidao%22%3A%5B%5D%2C%22ctpsCodigo%22%3Anull%2C%22ctpsNumero%22%3Anull%2C%22ctpsSerie%22%3Anull%2C%22ctpsDataEmissao%22%3Anull%2C%22cnhNumero%22%3Anull%2C%22cnhDataEmissao%22%3Anull%2C%22cnhUf%22%3Anull%2C%22passaporteCodigo%22%3Anull%2C%22passaporteNumero%22%3Anull%2C%22passaportePaisCodigo%22%3Anull%2C%22passaportePais%22%3Anull%2C%22passaporteDataValidade%22%3Anull%2C%22passaporteDataEmissao%22%3Anull%2C%22fotografia%22%3A%5B%5D%2C%22situacao%22%3A%22Ativo%22%2C%22dataAlteracao%22%3Anull%2C%22spanSituacao%22%3Anull%2C%22motivoCancelamento%22%3Anull%2C%22spanVip%22%3Anull%2C%22vipDescricao%22%3Anull%2C%22spanProtecao%22%3Anull%2C%22protecaoDescricao%22%3Anull%2C%22motivoNaoHigienizado%22%3Anull%2C%22vivo%22%3Anull%2C%22cartoesAgregados%22%3A%5B%5D%2C%22tipoDocumento%22%3A%22CPF%22%2C%22numeroDocumento%22%3A%22" . $cpf . "%22%7D&byPassHigienizacao=false&tpPesquisa=identica");
      $saida = curl_exec($ch);
   
         $cns= getStr($saida,'"numeroCns": "','"');

         curl_setopt($ch, CURLOPT_URL, "https://cadastro.saude.gov.br/cadsusweb/restrito/consultar/visualizar.form");
         curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies . ".txt");
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate, br');
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "cns=$cns");
         $saida2 = curl_exec($ch);


         $nome= getStr($saida2,'"nome": "','"');
         $nomeMae= getStr($saida2,'"nomeMae": "','"');
         $nomePai = getStr($saida2,'"nomePai": "','"');
         $sexo = getStr($saida2,'"sexo": "','"');
         $datanascimendo = getStr($saida2,'"dataNascimento": "','"');
         $paisNascimento = getStr($saida2,'"paisNascimento": "','"');
         $municipioNascimento = getStr($saida2,'"municipioNascimento": "','"');
         $sexo = getStr($saida2,'"sexo": "','"');
         $vivo = getStr($saida2,'"vivo":',',');
     
         $pais = getStr($saida2,'"paisResidenciaDescricao": "','"');
         $estado = getStr($saida2,'"enderecoMunicipio": "','"');
         $telefone = getStr($saida2,'"numero": "','"');




        echo "NOME: $nome<br>";
        echo "NOME DA MÃE: $nomeMae<br>";
         echo "NOME DO PAI: $nomePai<br>";
          echo "SEXO: $sexo<br>";
          echo "DATA DE NASCIMENTO: $datanascimendo<br>";
         echo "PAIS: $paisNascimento<br>";
         echo "MUNICIPIO DE NASCIMENTO: $municipioNascimento<br>";
         echo "$vivo<br>";



        echo "TELEFONE: $telefone <br><center></div>";
    }

    }


   ?>

 

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0
1 hora atrás, Beraldo disse:

Qual é o erro? Descreva o problema

Aqui nós vamos orientar você a corrigir o script. Não entregaremos código pronto. 

Se quiser aprender PHP, estamos aqui pra ajudar. Se quiser apenas o código pronto, contrate um profissional

 

Erro Undefined offset !! pode me ajudar ? 

 

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,5k
×
×
  • Criar Novo...