/** * @brief Function get * seleciona todos os campos do Banco de dados e retorna os valores das colunas ja descriptografado. * @param void * @return object */ public function get() { $i = 0; $result = Dbcommand::select('tb_servicos', array('ALL'), 'ORDER BY SER_ID DESC'); while ($results = Dbcommand::arrays($result)) { $this->service[$i] = new Service(); $this->service[$i]->setId($results['SER_ID']); $this->service[$i]->setId_adm($results['SER_ID_ADM']); foreach ($results as $key => $value) { $results[$key] = Criptography::BASE64($value, 0); } $this->service[$i]->log = $results['SER_LOG']; $this->service[$i]->date_in = $results['SER_DATA']; $this->service[$i]->name = $results['SER_NOME']; $this->service[$i]->about = str_replace('\\r\\n', ' ', $results['SER_SOBRE']); $this->service[$i]->key = $results['SER_CHAVE']; $i++; } $this->size = $i; return $this; }
/** * @brief Function get * seleciona todos os campos do Banco de dados e retorna os valores das colunas ja descriptografado. * @param void * @return void */ public function get() { $i = 0; $result = Dbcommand::select('tb_emails', array('ALL'), 'ORDER BY EM_ID DESC'); while ($results = Dbcommand::arrays($result)) { $this->mail[$i] = new Mail(); $this->mail[$i]->setId($results['EM_ID']); $this->mail[$i]->status = $results['EM_STATUS']; foreach ($results as $key => $value) { $results[$key] = Criptography::BASE64($value, 0); } $this->mail[$i]->date_in = $results['EM_DATA']; $this->mail[$i]->name = $results['EM_NOME']; $this->mail[$i]->mail_job = $results['EM_EMAIL']; $this->mail[$i]->title = $results['EM_ASSUNTO']; $this->mail[$i]->message = str_replace('\\r\\n', ' ', $results['EM_MENSAGEM']); $this->mail[$i]->phone = $results['EM_TEL']; $i++; } $this->size = $i; return $this; }
/** * @brief Function get * seleciona todos os campos do Banco de dados e retorna os valores das colunas ja descriptografado. * @param void * @return object */ public function get() { $i = 0; $name = Criptography::BASE64($this->name, 1); $result = Dbcommand::select('tb_fotos', array('FOTO_NOME_ALBUM' => $name), 'ORDER BY FOTO_ID DESC'); while ($results = Dbcommand::arrays($result)) { $this->photo[$i] = new Photo(); $this->photo[$i]->setId($results['FOTO_ID']); $this->photo[$i]->setId_adm($results['FOTO_ID_ADM']); foreach ($results as $key => $value) { $results[$key] = Criptography::BASE64($value, 0); } $this->photo[$i]->log = $results['FOTO_LOG']; $this->photo[$i]->date_in = $results['FOTO_DATA']; $this->photo[$i]->name = $results['FOTO_NOME']; $this->photo[$i]->albumName = $results['FOTO_NOME_ALBUM']; $this->photo[$i]->url = $results['FOTO_URL']; $i++; } $this->size = $i; return $this; }
$email = $_GET['utilizador']; header("Location: recuperar.php?utilizador=$email&confirmacao=$chave&msg=9"); */ die('<a href="./" class="btn btn-primary">Voltar</a> <p>Senhas diferem uma da outra. Volte e digite seu email novamente para reiniciar a recuperação de senha.</p>'); } } } if (empty($_GET['utilizador']) || empty($_GET['confirmacao'])) { echo die('<a href="./" class="btn btn-primary">Voltar</a> <p>Não é possível alterar a password: dados em falta</p>'); //header("Location: ./"); } @($user = $_GET['utilizador']); @($hash = $_GET['confirmacao']); $results = Dbcommand::select("tb_recuperacao", array("REC_ADM" => $user, 'REC_CONFIRMACAO' => $hash)); if (Dbcommand::count_rows($results) > 0) { //os dados estão corretos: eliminar o pedido e permitir alterar a password Dbcommand::delete("tb_recuperacao", array('REC_ADM' => $user, 'REC_CONFIRMACAO' => $hash)); ?> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-10"> <div class="jumbotron"> <a href="./"><h1>Recuperar de Senha</h1></a> <br/> <?php echo Message::get(); ?> <form action="recuperar.php" method="post">
/** * @brief Function get * pega as informaçoes referentes á contatos da corporacao. * @param void * @return void */ public function get() { $result = Dbcommand::select('tb_empresa', array('ALL'), 'ORDER BY EMP_ID DESC LIMIT 1'); $results = Dbcommand::rows($result); $this->id = $results['EMP_ID']; $this->id_adm = $results['EMP_ID_ADM']; foreach ($results as $key => $value) { $results[$key] = Criptography::BASE64($value, 0); } $this->name = $results['EMP_NOME']; $this->log = $results['EMP_DATA']; $this->adress = $results['EMP_END']; $this->zip = $results['EMP_CEP']; $this->square = $results['EMP_BAIRRO']; $this->city = $results['EMP_CIDADE']; $this->state = $results['EMP_ESTADO']; $this->country = $results['EMP_PAIS']; $this->phone1 = $results['EMP_TEL1']; $this->phone2 = $results['EMP_TEL2']; $this->mail = $results['EMP_EMAIL']; $this->about = str_replace('\\r\\n', ' ', $results['EMP_SOBRE']); return $this; }
/** * @brief Function setRecovery * verifica se é possivel recuperar a senha, verificando se ja foi feito o pedido e se o email ja esta cadastrado; assim depois realiza a recuperação. * @param void * @return mensagem indicador de erro ou sucesso */ public function setRecovery() { $this->mail_job = Dbcommand::post("email"); if (!ValidationData::mail($this->mail_job)) { return "erro_campo"; } else { $this->mail_job = Criptography::BASE64($this->mail_job, 1); $results = Dbcommand::select("tb_administradores", array('ADM_EMAIL' => $this->mail_job)); if (Dbcommand::count_rows($results) == 1) { /* Verifica se o email esta cadastrado */ $chave = sha1(uniqid(mt_rand(), true)); /* Guardar este par de valores na tabela para confirmar mais tarde */ $check = Dbcommand::select("tb_recuperacao", array('REC_ADM' => $this->mail_job)); if (Dbcommand::count_rows($check) > 0) { /* Verifica se o email ja solicitou a recuperacao */ Dbcommand::update("tb_recuperacao", array('REC_CONFIRMACAO' => $chave), array('REC_ADM' => $this->mail_job)); } else { Dbcommand::insert("tb_recuperacao", array('REC_ADM', 'REC_CONFIRMACAO'), array($this->mail_job, $chave)); } /* ==== Setando valores ==== */ $link = $_SERVER['HTTP_HOST'] . "/ej-admin/recuperar/recuperar.php?utilizador={$this->mail_job}&confirmacao={$chave}"; $this->mail_job = Criptography::BASE64($this->mail_job, 0); $this->title = "Recuperação de senha"; $this->message = 'Olá ' . $this->mail_job . ', visite este link para recuperar a senha: ' . $link . '<br><br><br> Solicitação: ' . date("d/m/Y H:i:s", strtotime(date("Y-m-d H:i:s"))); /* ========== ========== */ $mail = new PHPMailer(); /* Classe para enviar emails */ $mail->IsSMTP(); /* Define que a mensagem sera SMTP */ /* Define o remetente */ $mail->From = $this->from; // Seu e-mail $mail->Sender = $this->from; // Seu e-mail $mail->FromName = $this->fromName; // Seu nome /* Define os destinatario(s) */ $mail->AddAddress($this->mail_job); /* Sera para o solicitante */ $mail->IsHTML(true); // Define que o e-mail sera enviado como HTML $mail->CharSet = 'utf-8'; // Charset da mensagem // Define a mensagem (Texto e Assunto) $mail->Subject = $this->title; $mail->Body = $this->message; $sended = $mail->Send(); // Envia o e-mail $mail->ClearAllRecipients(); // Limpa os destinatarios e os anexos if ($sended) { return "sucesso_recuperacao"; } else { return "erro_recuperacao"; } } else { return "erro_email"; } } }
/** * @brief Function login * verifica os dados de entrada e valida caso o usuario esteja cadastrado e ativo. * Assim recebe do banco os dados cadastrado e criptografados do usuario. Ao validar o acesso, é criado uma sessão com 1800s. * @param void * @return mensagem indicador de erro ou sucesso */ public function login() { $this->login = Dbcommand::post("username_user"); $this->password = Dbcommand::post("password_user"); if (!empty($this->login) && !empty($this->password)) { $this->login = Criptography::BASE64($this->login, 1); $result = Dbcommand::select('tb_administradores', array('ADM_LOGIN' => $this->login)); if (Dbcommand::count_rows($result) > 0) { $results = Dbcommand::rows($result); if (Criptography::CheckBcrypt($this->password, $results['ADM_SENHA']) == FALSE) { return "erro_senha"; } else { $this->id = $results['ADM_ID']; $this->status = $results['ADM_STATUS']; if ($this->status != 2) { return "usuario_inativo"; } else { if (!isset($_SESSION)) { session_start(); // seta configurações fuso horario e tempo limite de inatividade em segundos date_default_timezone_set("Brazil/Recife"); $tempolimite = 1800; // (s) /*fim das configurações de fuso horario e limite de inatividade aqui ta o seu script de autenticação no momento em que ele for validado você seta as configurações abaixo. seta as configurações de tempo permitido para inatividade*/ $_SESSION['registro'] = time(); // armazena o momento em que autenticado $_SESSION['limite'] = $tempolimite; // armazena o tempo limite sem atividade // fim das configurações de tempo inativo } $_SESSION['usuario_logado'] = $this->id; $this->log = Criptography::BASE64(date("Y-m-d H:i:s"), 1); Dbcommand::update('tb_administradores', array('ADM_LOG' => $this->log), array('ADM_ID' => $this->id)); return "usuario_logado"; } } } else { return "erro_entrada_usuario"; } } else { return "erro_entrada_usuario"; } }