$cadastrar = isset($_GET["cadastrar"]) ? $_GET["cadastrar"] : NULL; if ($cadastrar == "sim") { foreach ($_POST as $nomeCampo => $valor) { $comando = "\$" . $nomeCampo . "= antiSQL(isset(\$_POST['{$nomeCampo}']) ? '" . $valor . "' : NULL);"; eval($comando); } include_once $toRoot . "utils/ConectarMySQL.class.php"; include_once $toRoot . "beans/Empresa.class.php"; include_once $toRoot . "beans/Funcionario.class.php"; include_once $toRoot . "beans/Log.class.php"; include_once $toRoot . "dao/DAOEmpresa.class.php"; include_once $toRoot . "dao/DAOFuncionario.class.php"; include_once $toRoot . "dao/DAOLog.class.php"; $conexao = new ConectarMySql($toRoot); $empresa = new Empresa($tfNomEmp); $daoEmpresa = new DAOEmpresa($empresa, $conexao); $daoEmpresa->cadastrar(); $empresa = $daoEmpresa->getAtual(); $log = new Log(3, 7, $tfNomEmp . " cadastrado!"); $daoLog = new DAOLog($log, $conexao); $daoLog->cadastrar(); $funcionario = new Funcionario($empresa->codigo, $_SESSION["codigo"]); $daoFuncionario = new DAOFuncionario($funcionario, $conexao); $daoFuncionario->cadastrar(); $log->alvCodigo = 6; $log->descricao = "Empresa cadastrado!"; $daoLog->setLog($log); $daoLog->cadastrar(); $conexao->fechar(); $cadastrar = true; }
<?php session_start(); $nivelAcesso = "../../:2:3:4"; include_once "../../utils/controladorAcesso.php"; include_once "../../utils/funcoes.php"; $desc = antiSQL(isset($_POST["tfEmpDesc"]) ? $_POST["tfEmpDesc"] : NULL); if ($desc != NULL) { include_once "../../utils/ConectarMySQL.class.php"; $conexao = new ConectarMySQL(); include_once "../../dao/DAOEmpresa.class.php"; $dao = new DAOEmpresa($desc, "../../", $conexao); include_once "../../dao/DAOLog.class.php"; $log = new DAOLog($_SESSION["pessoa"], 3, $_SESSION["nivel"], $_SESSION["codigo"], 2, "valor=\\'" . $desc . "\\'", "../../", $conexao); if ($dao->cadastrar() && $log->cadastrar()) { $conexao->commit(); } else { $conexao->rollback(); } header("Location: cadEmpresa.php?cad=ok"); die; } $cad = antiSQL(isset($_GET["cad"]) ? $_GET["cad"] : NULL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!--