function __construct()
 {
     $variables = new Variables();
     $connect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName);
     $result;
     //receinving and striping the variables
     $this->userMatricula = $connect->antiInjection(isset($_POST["tfMatricula"]) ? $_POST["tfMatricula"] : NULL);
     $this->password = $connect->antiInjection(isset($_POST["tfPassword"]) ? $_POST["tfPassword"] : NULL);
     $this->select = $connect->antiInjection(isset($_POST["slSelect"]) ? $_POST["slSelect"] : NULL);
     if (!$connect->start()) {
         echo "Impossible to start connection in Sigin.";
     }
     //encoding to md5 hash
     $this->password = base64_encode($this->password);
     if (!($result = $connect->execute("SELECT * FROM Cadastros c INNER JOIN Folhas f ON c.codigo_fol = f.codigo_fol WHERE c.matricula = '{$this->userMatricula}' AND c.senha = '{$this->password}' AND f.codigo_fol = '{$this->select}'"))) {
         echo "Impossible to execute MySQL query.";
     }
     if ($connect->counterResult($result) > 0) {
         $result = $connect->execute("SELECT * FROM Pessoal WHERE matricula = '{$this->userMatricula}'");
         $row = mysql_fetch_assoc($result);
         $_SESSION["user"] = $this->userMatricula;
         $_SESSION["userPass"] = $this->password;
         $_SESSION["nome"] = $row["nome"];
         $connect->close();
         header("Location: ../index.php?ok=true");
         die;
     }
     $connect->close();
     header("Location: ../index.php?ok=false");
     die;
 }
Exemple #2
0
 function __construct()
 {
     $variables = new Variables();
     $connect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName);
     $result;
     //receinving and striping the variables
     $this->userName = $connect->antiInjection(isset($_POST["tfUserName"]) ? $_POST["tfUserName"] : NULL);
     $this->password = $connect->antiInjection(isset($_POST["tfPassword"]) ? $_POST["tfPassword"] : NULL);
     if (!$connect->start()) {
         echo "Impossible to star connection in Sigin.";
     }
     //encoding to md5 hash
     $this->password = md5($this->password);
     if (!($result = $connect->execute("SELECT * FROM Administradores WHERE usuario = '{$this->userName}' and senha = '{$this->password}'"))) {
         echo "Impossible to execute MySQL query.";
     }
     if ($connect->counterResult($result) > 0) {
         $_SESSION["usuario"] = $this->userName;
         $_SESSION["senha"] = $this->password;
         $row = mysql_fetch_assoc($result);
         $_SESSION["nivel"] = $row["id_nivel"];
         //$connect->close();
         switch ($_SESSION["nivel"]) {
             case 1:
                 header("Location: ../importDocuments.php");
                 break;
             case 2:
                 header("Location: ../makeRegister.php");
                 break;
         }
         die;
     }
     //$connect->close();
     header("Location: ../admin.php?login=false");
     die;
 }
 function execute()
 {
     $toFix = false;
     $archiveDBFname = $this->path;
     $variables = new Variables();
     $MySQLconnect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName);
     if (!($DFBconnect = dbase_open($archiveDBFname, 0))) {
         //only reading
         return false;
     }
     //Connection to DBF error
     //get number of rows of dbf table
     $numRows = dbase_numrecords($DFBconnect);
     //get number of files of dbf table
     $numFields = dbase_numfields($DFBconnect);
     //the DBF registers begins with 1
     for ($x = 1; $x <= $numRows; $x++) {
         $DBFrow = dbase_get_record($DFBconnect, $x);
         //Get DBF archive rows
         $this->DB[$x - 1] = $DBFrow;
     }
     /*$host_ftp = "localhost";
     		$user_ftp = "root";
     		$pass_ftp = "";
     		
     		// Faz a conexão com o Servidor
     		$ftp_con = ftp_connect($host_ftp);
     		// Efetua o login com o usuário e senha informados
     		$ftp_log = ftp_login($ftp_con,$user_ftp,$pass_ftp);
     		
     		// Deleta o arquivo informado
     		if(!ftp_delete($ftp_con, $archiveDBFname))
     			die("ERRO CRITICO FTP!");
     		
     		// Encerramos a conexão de FTP previamente estabelecida
     		ftp_close($ftp_con);*/
     /*echo(decoct(777)."<br/>");
     		$temp = stat($archiveDBFname);
     		echo(octdec($temp["mode"])."<br/>");
     		echo(octdec(fileperms($archiveDBFname)));
     		if(!unlink($archiveDBFname))
     			die("ERRO CRITICO!");
     			
     		die("OK");*/
     //unlink($archiveDBFname)
     if (!$MySQLconnect->start()) {
         echo "Impossible to star connection in Handler.";
     }
     if (strlen($this->folhaType) > 0) {
         $row = mysql_fetch_assoc($MySQLconnect->execute("SELECT codigo_fol FROM Folhas where nome='{$this->folhaType}'"));
         $code = $row["codigo_fol"];
     }
     for ($x = 0; $x < $numRows; $x++) {
         switch ($this->tableId) {
             case "dcr":
                 $aux = array("INSERT INTO Cargos (cargo, descricao_cargo , tipo, vencimento) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . $this->DB[$x][2] . "', " . $this->DB[$x][3] . ")");
                 break;
             case "dlt":
                 $aux = array("INSERT INTO Lotacoes (lotacao, descricao_lotacao , secretaria) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][2])) . "')");
                 break;
             case "especial":
                 $aux = array("INSERT INTO Especialidades (codigo_esp, descricao_especialidade , cargo) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . $this->DB[$x][2] . "')");
                 break;
             case "eventos":
                 $aux = array("INSERT INTO Eventos (codigo_eve, descricao_evento, IRRF, IPMT, FAL, FIXO, TEMP, valor_eve, GRAT, FGTS, desconto, nivel_eve, INSS) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "',  '" . $this->DB[$x][2] . "',  '" . $this->DB[$x][3] . "',  '" . $this->DB[$x][4] . "',  '" . $this->DB[$x][5] . "',  '" . $this->DB[$x][6] . "',  " . $this->DB[$x][7] . ",  '" . $this->DB[$x][8] . "',  '" . $this->DB[$x][9] . "',  " . $this->DB[$x][10] . ", '" . $this->DB[$x][11] . "', '" . $this->DB[$x][12] . "')");
                 break;
             case "cadastro":
                 $date = explode("-", $_SESSION["day"]);
                 $query = "SELECT * FROM Cadastros WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code;
                 $result = $MySQLconnect->execute($query);
                 $cont = $MySQLconnect->counterResult($result);
                 if ($code == 1) {
                     if ($cont > 0) {
                         $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][28] . "', descontar='" . $this->DB[$x][29] . "', receber='" . $this->DB[$x][30] . "', funcao='" . $this->DB[$x][31] . "', maior_360='" . $this->DB[$x][33] . "', prof_40h='" . $this->DB[$x][34] . "', vlt_ver='" . $this->DB[$x][35] . "', val_niv=" . $this->valueFormater($this->DB[$x][36]) . ", data_FGTS='" . $this->dateFormater($this->DB[$x][37]) . "', permanente='" . $this->DB[$x][38] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][39]) . ", vencimento=" . $this->valueFormater($this->DB[$x][40]) . ", flag='" . $this->DB[$x][41] . "', entrada='" . $this->DB[$x][42] . "', liquido=" . $this->valueFormater($this->DB[$x][45]) . ", sobregrat='" . $this->DB[$x][46] . "', assistencia='" . $this->DB[$x][47] . "', medico='" . $this->DB[$x][48] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][43] . "',  numero='" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . "");
                     } else {
                         $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][34] . "', '" . $this->DB[$x][35] . "', " . $this->valueFormater($this->DB[$x][36]) . ", '" . $this->dateFormater($this->DB[$x][37]) . "', '" . $this->DB[$x][38] . "', " . $this->valueFormater($this->DB[$x][39]) . ", " . $this->valueFormater($this->DB[$x][40]) . ", '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', " . $this->valueFormater($this->DB[$x][45]) . ", '" . $this->DB[$x][46] . "', '" . $this->DB[$x][47] . "', '" . $this->DB[$x][48] . "', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  '" . $this->dateFormater($this->DB[$x][17]) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][43] . "',  '" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "', " . $code . ")");
                     }
                 } else {
                     if ($code == 2) {
                         if ($cont > 0) {
                             $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][10] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][11] . "', dep_imp_re='" . $this->DB[$x][13] . "', hora_sem='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', instrucao='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', data_afastamento='" . $this->dateFormater($this->DB[$x][20]) . "', sindical='" . $this->DB[$x][21] . "', dp_sal_fam='" . $this->DB[$x][22] . "', hora_ponto='" . $this->DB[$x][23] . "', vale_transporte='" . $this->DB[$x][24] . "', data_promocao='" . $this->dateFormater($this->DB[$x][26]) . "', tipo='" . $this->DB[$x][29] . "', situacao='" . $this->DB[$x][30] . "', descontar='" . $this->DB[$x][31] . "', receber='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', funcao='" . $this->DB[$x][33] . "', maior_360='" . $this->DB[$x][35] . "', prof_40h='" . $this->DB[$x][36] . "', vlt_ver='" . $this->DB[$x][37] . "', val_niv=0, data_FGTS='" . $this->dateFormater($this->DB[$x][38]) . "', permanente='" . $this->DB[$x][40] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][39]) . ", vencimento=0, flag='" . $this->DB[$x][41] . "', entrada='" . $this->DB[$x][42] . "', liquido=" . $this->valueFormater($this->DB[$x][45]) . ", sobregrat='" . $this->DB[$x][8] . "', assistencia='" . $this->DB[$x][9] . "', medico='" . $this->DB[$x][46] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][14] . "', CPF='" . $this->DB[$x][17] . "', PIS_PASEP='" . $this->DB[$x][18] . "',  data_nascimento='" . $this->dateFormater($this->DB[$x][19]) . "', ultimo_nome='" . $this->DB[$x][34] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . $this->DB[$x][27] . "', orgao_expedidor='" . $this->DB[$x][28] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][43] . "',  numero='" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . "");
                         } else {
                             $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][10] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', '" . $this->dateFormater($this->DB[$x][20]) . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->DB[$x][23] . "', '" . $this->DB[$x][24] . "', '" . $this->dateFormater($this->DB[$x][26]) . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][35] . "', '" . $this->DB[$x][36] . "', '" . $this->DB[$x][37] . "', 0, '" . $this->dateFormater($this->DB[$x][38]) . "', '" . $this->DB[$x][40] . "', " . $this->valueFormater($this->DB[$x][39]) . ", 0, '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', " . $this->valueFormater($this->DB[$x][45]) . ", '" . $this->DB[$x][8] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][46] . "', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][14] . "', '" . $this->DB[$x][17] . "', '" . $this->DB[$x][18] . "',  '" . $this->dateFormater($this->DB[$x][19]) . "', '" . $this->DB[$x][34] . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][43] . "',  '" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "', " . $code . ")");
                         }
                     } else {
                         if ($code == 3) {
                             if ($cont > 0) {
                                 $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][30] . "', descontar='" . $this->DB[$x][31] . "', receber='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', funcao='" . $this->DB[$x][33] . "', maior_360='" . $this->DB[$x][35] . "', prof_40h='" . $this->DB[$x][36] . "', vlt_ver='" . $this->DB[$x][37] . "', 0, data_FGTS='" . $this->dateFormater($this->DB[$x][44]) . "', permanente='" . $this->DB[$x][41] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][42]) . ", 0, 'z', 'z', liquido=" . $this->valueFormater($this->DB[$x][40]) . ", sobregrat='" . $this->DB[$x][43] . "', assistencia='" . $this->DB[$x][45] . "', 'z', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . $this->DB[$x][34] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][38] . "',  numero='" . $this->DB[$x][39] . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . "");
                             } else {
                                 $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][35] . "', '" . $this->DB[$x][36] . "', '" . $this->DB[$x][37] . "', 0, '" . $this->dateFormater($this->DB[$x][44]) . "', '" . $this->DB[$x][41] . "', " . $this->valueFormater($this->DB[$x][42]) . ", 0, 'z', 'z', " . $this->valueFormater($this->DB[$x][40]) . ", '" . $this->DB[$x][43] . "', '" . $this->DB[$x][45] . "', 'z', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  '" . $this->dateFormater($this->DB[$x][17]) . "', '" . $this->DB[$x][34] . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][38] . "',  '" . $this->DB[$x][39] . "', " . $code . ")");
                             }
                         } else {
                             if ($code == 4) {
                                 if ($cont > 0) {
                                     $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][28] . "', descontar='" . $this->DB[$x][29] . "', receber='" . $this->DB[$x][30] . "', funcao='" . $this->DB[$x][31] . "', maior_360='" . $this->DB[$x][33] . "', prof_40h='" . $this->DB[$x][34] . "', vlt_ver='" . $this->DB[$x][35] . "', 0, data_FGTS='" . $this->dateFormater($this->DB[$x][36]) . "', permanente='z', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][44]) . ", vencimento=0, flag='z', entrada='" . $this->DB[$x][37] . "', liquido=" . $this->valueFormater($this->DB[$x][38]) . ", sobregrat='" . $this->DB[$x][41] . "', assistencia='" . $this->DB[$x][42] . "', medico='z', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][39] . "',  numero='" . $this->DB[$x][40] . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . "");
                                 } else {
                                     $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][34] . "', '" . $this->DB[$x][35] . "', 0, '" . $this->dateFormater($this->DB[$x][36]) . "', 'z', " . $this->valueFormater($this->DB[$x][44]) . ", 0, 'z', '" . $this->DB[$x][37] . "', " . $this->valueFormater($this->DB[$x][38]) . ", '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', 'z', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "',  '" . $this->dateFormater($this->DB[$x][17]) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][39] . "',  '" . $this->DB[$x][40] . "', " . $code . ")");
                                 }
                             }
                         }
                     }
                 }
                 break;
             case "calculo":
                 $date = explode("-", $_SESSION["day"]);
                 $query = "SELECT * FROM Calculos WHERE matricula='" . $this->DB[$x][0] . "' AND fol_codigo=" . $code . " AND data BETWEEN '" . $date[2] . "-" . $date[1] . "-01' and '" . $date[2] . "-" . $date[1] . "-31' AND eve_codigo='" . $this->DB[$x][1] . "' AND valor='" . $this->valueFormater($this->DB[$x][2]) . "'";
                 $result = $MySQLconnect->execute($query);
                 if ($MySQLconnect->counterResult($result) > 0) {
                     $aux = array("UPDATE Calculos SET valor=" . $this->valueFormater($this->DB[$x][2]) . " WHERE matricula='" . $this->DB[$x][0] . "' AND fol_codigo=" . $code . " AND eve_codigo='" . $this->DB[$x][1] . "' AND data BETWEEN '" . $date[2] . "-" . $date[1] . "-01' and '" . $date[2] . "-" . $date[1] . "-31'");
                 } else {
                     $aux = array("INSERT INTO Calculos (valor, fol_codigo, eve_codigo, matricula, data) VALUES (" . $this->valueFormater($this->DB[$x][2]) . ", " . $code . ", '" . $this->DB[$x][1] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->dateFormater2($_SESSION["day"]) . "')");
                 }
                 break;
         }
         /*foreach($aux as $query){
         			echo $query."<br>";
         		}*/
         foreach ($aux as $query) {
             if (!$MySQLconnect->execute($query)) {
                 /*echo $query."<br>";
                 		die();*/
                 $toFix = true;
                 $this->DB[$x][$numFields] = "true";
             } else {
                 $this->DB[$x][$numFields] = "false";
             }
         }
     }
     //$MySQLconnect->close();
     dbase_close($DFBconnect);
     unlink($archiveDBFname);
     if ($toFix and $this->tableId != "cadastro" and $this->tableId != "calculo") {
         $this->fixProblems($numFields, $numRows);
     } else {
         header("Location: ../importDocuments.php?upl=true&tab={$this->tableId}");
     }
 }
include_once "../beans/Variables.class.php";
require_once "../utils/Connect.class.php";
$variables = new Variables();
$connect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName);
$oldPass = $connect->antiInjection(isset($_POST["tfOldPass"]) ? $_POST["tfOldPass"] : NULL);
$newPass1 = $connect->antiInjection(isset($_POST["tfNewPass1"]) ? $_POST["tfNewPass1"] : NULL);
$newPass2 = $connect->antiInjection(isset($_POST["tfNewPass2"]) ? $_POST["tfNewPass2"] : NULL);
if (strcmp($newPass1, $newPass2) == 0) {
    $newPass1 = base64_encode($newPass1);
    $oldPass = base64_encode($oldPass);
} else {
    $connect->close();
    header("Location: ../index.php?pass=false");
    die;
}
if (!$connect->start()) {
    echo "Impossible to star connection in Sigin.";
}
if (!($result = $connect->execute("SELECT * FROM Cadastros WHERE matricula = '" . $_SESSION["user"] . "' AND senha = '" . $oldPass . "'"))) {
    echo "Impossible to execute MySQL query.";
}
if ($connect->counterResult($result) > 0) {
    $connect->execute("UPDATE Cadastros SET senha='" . $newPass1 . "' WHERE matricula = '" . $_SESSION["user"] . "'");
    $_SESSION["userPass"] = $newPass1;
    $connect->close();
    header("Location: ../index.php?pass=true");
    die;
}
$connect->close();
header("Location: ../index.php?pass=false");
die;