public function saveLogin(Login $login) { $id = (int) $login->getId(); if ($id > 0) { $requete = $this->dbGateway->prepare("\n\t\tUPDATE backofficeaccess SET user_access = :user, pwd_access = :pwd, role_access = :role WHERE id_access = :id\n\t\t\t") or die(print_r($this->dbGateway->errors_info())); $requete->execute(array('id' => $id, 'user' => $login->getUser(), 'pwd' => $login->getPwd(), 'role' => $login->getRole())); } else { $requete = $this->dbGateway->prepare("INSERT into backofficeaccess(user_access, pwd_access, role_access) \n\t\t\t\t\tvalues(:user, :pwd, :role)") or die(print_r($this->dbGateway->error_info())); $requete->execute(array('user' => $login->getUser(), 'pwd' => $login->getPwd(), 'role' => $login->getRole())); } }
function rote($login, $a) { switch (array_shift($a)) { case 'account': require 'Accounts.php'; $ctr = new Accounts($login); $res = $ctr->process($a, $_GET, $_POST); echo is_string($res) ? $res : json_encode($res); break; case 'utils': require 'Utils.php'; $ctr = new Utils($login); $res = $ctr->process($a, $_GET); echo is_string($res) ? $res : json_encode($res); break; case 'server_url': $out = new stdClass(); $out->success = $_SERVER['SERVER_NAME']; echo json_encode($out); break; case 'LOG': echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 3, '../logs/app_log' . Login::getId() . '.log')); break; case 'ERROR': echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 3, '../logs/app_error' . Login::getId() . '.log')); break; case 'EMAIL': $headers = 'From: admin@front-desk.ca' . "\r\n" . 'Reply-To: admin@front-desk.ca' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 1, '*****@*****.**', $headers)); break; case 'save_file': $file_name = explode('/', $_GET['file_name'])[0]; echo file_put_contents('../data/' . $file_name, file_get_contents("php://input")); break; case 'login': $res = $this->login->process($a, $_GET); echo is_string($res) ? $res : json_encode($res); break; } }
private function getUserId() { return Login::getId(); }
$dataLogin = filter_input_array(INPUT_POST, FILTER_DEFAULT); $get = filter_input(INPUT_GET, 'exe', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if ($lembrarSenha) { $readCode = new Read(); $readCode->ExeRead(DB_PASSWORD_RECOVER, "WHERE pass_code = :code AND ativo = 1", "code={$lembrarSenha}"); if (!$readCode->getResult()) { header("Location: 404.php"); } } if (!empty($dataLogin['AdminLogin'])) { $login->ExeLogin($dataLogin); if (!$login->getResult()) { WSErro($login->getError()[0], $login->getError()[1]); $log->RecordLog("Login: "******"Erro: Login " . $login->getError()[0]); } else { $log->setUserId($login->getId()); $log->RecordLog("Login: "******"Sucesso: Login"); header('Location: painel.php'); } } elseif (!empty($dataLogin['EnviaSenha'])) { $sendEmail = new RecoverEmail(); $sendEmail->Enviar($dataLogin['email']); if ($sendEmail->getResult()) { WSErro($sendEmail->getError()[0], $sendEmail->getError()[1]); $createRecover = new Create(); $createRecover->ExeCreate(DB_PASSWORD_RECOVER, $sendEmail->getCode()); $log->RecordLog("Login: Recuperação de senha: " . $datalogin['email'], "Sucesso: Email enviado"); } else { $log->RecordLog("Login: Recuperação de senha: " . $datalogin['email'], "Erro: email não enviado"); WSErro($sendEmail->getError()[0], $sendEmail->getError()[1]); }