Ejemplo n.º 1
0
 /**
  * @brief Function setContact
  *      seta as informaoes de contato nas suas variaveis do banco de dados.
  * @param id_adm do usuario logado
  * @return mensagem indicador de erro ou sucesso
  */
 public function setContact($id_adm)
 {
     $this->id_adm = $id_adm;
     $this->adress = Dbcommand::post("adress_corporation");
     $this->zip = Dbcommand::post("zip_corporation");
     $this->square = Dbcommand::post("square_corporation");
     $this->city = Dbcommand::post("city_corporation");
     $this->state = Dbcommand::post("state_corporation");
     $this->country = Dbcommand::post("country_corporation");
     $this->phone1 = Dbcommand::post("phone1_corporation");
     $this->phone2 = Dbcommand::post("phone2_corporation");
     $this->mail = Dbcommand::post("mail_corporation");
     if (empty($this->adress) || empty($this->square) || empty($this->city) || empty($this->state) || empty($this->country)) {
         return "erro_campos";
     } elseif (!ValidationData::cep($this->zip) || !ValidationData::mail($this->mail) || !ValidationData::phone($this->phone1) || !ValidationData::phone($this->phone2) || !ValidationData::text($this->square) || !ValidationData::text($this->city) || !ValidationData::text($this->state) || !ValidationData::text($this->country) || !ValidationData::text($this->adress)) {
         return "erro_campo";
     } else {
         $this->adress = Criptography::BASE64($this->adress, 1);
         $this->city = Criptography::BASE64($this->city, 1);
         $this->country = Criptography::BASE64($this->country, 1);
         $this->mail = Criptography::BASE64($this->mail, 1);
         $this->square = Criptography::BASE64($this->square, 1);
         $this->phone1 = Criptography::BASE64($this->phone1, 1);
         $this->phone2 = Criptography::BASE64($this->phone2, 1);
         $this->state = Criptography::BASE64($this->state, 1);
         $this->zip = Criptography::BASE64($this->zip, 1);
         $this->log = Criptography::BASE64(date("Y-m-d H:i:s"), 1);
         Dbcommand::update('tb_empresa', array('EMP_ID_ADM' => $this->id_adm, 'EMP_DATA' => $this->log, 'EMP_END' => $this->adress, 'EMP_CEP' => $this->zip, 'EMP_BAIRRO' => $this->square, 'EMP_CIDADE' => $this->city, 'EMP_ESTADO' => $this->state, 'EMP_PAIS' => $this->country, 'EMP_TEL1' => $this->phone1, 'EMP_TEL2' => $this->phone2, 'EMP_EMAIL' => $this->mail), array('EMP_ID' => $this->id));
         return "sucesso_alterar_dados";
     }
 }
Ejemplo n.º 2
0
 /**
  * @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";
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @brief Function set
  *      insere no Banco de dados todos os valores já criptgrofado checando se o texto nao esta vazio.
  * @param void
  * @return mensagem indicador de erro ou sucesso
  */
 public function set()
 {
     $this->name = Dbcommand::post("name_user");
     $this->login = Dbcommand::post("username_user");
     $this->mail_job = Dbcommand::post("mail_job_user");
     $this->password = Dbcommand::post("password1_user");
     if (empty($this->password) || $this->password !== Dbcommand::post('password2_user')) {
         return "erro_senha";
     } else {
         $this->password = Criptography::Bcrypt($this->password);
     }
     if (!ValidationData::username($this->login) || !ValidationData::mail($this->mail_job) || !ValidationData::name($this->name)) {
         return "erro_campo";
     }
     $this->login = Criptography::BASE64($this->login, 1);
     $result = Dbcommand::select('tb_administradores', array('ADM_LOGIN' => $this->login));
     if (Dbcommand::count_rows($result) > 0) {
         return "campos_cadastrados";
     } else {
         $mail = new Mail();
         // Envia notificacao para o usuario informando que a conta foi ativada
         $mail->name = Dbcommand::post("username_user");
         $mail->mail_job = $this->mail_job;
         $mail->setSave();
         $this->name = Criptography::BASE64($this->name, 1);
         $this->mail_job = Criptography::BASE64($this->mail_job, 1);
         $this->date_in = Criptography::BASE64(date("Y-m-d H:i:s"), 1);
         Dbcommand::insert('tb_administradores', array('ADM_DATA', 'ADM_NOME', 'ADM_SENHA', 'ADM_LOGIN', 'ADM_EMAIL', 'ADM_STATUS'), array($this->date_in, $this->name, $this->password, $this->login, $this->mail_job, $this->status));
         return "sucesso_cadastro";
     }
 }