Skip to content

Commit

Permalink
Merge pull request #2329 from juliolobo/Captcha-no-cadastrar-do-Mine
Browse files Browse the repository at this point in the history
Adicionando verificação captcha no formulário de cadastro de cliente …
  • Loading branch information
willph authored Feb 12, 2024
2 parents 8be5724 + ee4434f commit 3248b4f
Show file tree
Hide file tree
Showing 9 changed files with 422 additions and 15 deletions.
2 changes: 1 addition & 1 deletion application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
| $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = ['url', 'audit', 'date', 'dd', 'validation', 'general'];
$autoload['helper'] = ['url', 'audit', 'date', 'dd', 'validation', 'general', 'captcha'];


/*
Expand Down
33 changes: 32 additions & 1 deletion application/controllers/Mine.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,8 @@ public function cadastrar()

if ($this->form_validation->run('clientes') == false) {
$this->data['custom_error'] = (validation_errors() ? '<div class="form_error">' . validation_errors() . '</div>' : false);
} elseif (strtolower($this->input->post('captcha')) != strtolower($this->session->userdata('captchaWord'))) {
$this->session->set_flashdata('error', 'Os caracteres da imagem não foram preenchidos corretamente ou o tempo máximo para preenchimento foi ultrapassado!');
} else {
$data = [
'nomeCliente' => set_value('nomeCliente'),
Expand Down Expand Up @@ -834,7 +836,36 @@ public function cadastrar()
$this->session->set_flashdata('error', 'Falha ao realizar cadastro!');
}
}
$data = '';

$arrFont = ['ZXX_Noise.otf', 'karabine.ttf', 'capture.ttf', 'captcha.ttf'];
shuffle($arrFont);

$vals = [
'img_path' => './assets/captcha-images/',
'img_url' => base_url().'assets/captcha-images/',
'font_path' => './assets/font/'.$arrFont[0],
'img_width' => 150,
'img_height' => 45,
'expiration' => 7200,
'word_length' => 6,
'font_size' => 20,
'img_id' => 'Imageid',
'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'colors' => [
'background' => [255, 255, 255],
'border' => [255, 255, 255],
'text' => [0, 0, 0],
'grid' => [255, 40, 40],
]
];

$cap = create_captcha($vals);
$this->session->set_userdata('captchaWord', $cap['word']);

$data = [
'captchaImage' => $cap['image']
];

$this->load->view('conecte/cadastrar', $data);
}

Expand Down
Loading

0 comments on commit 3248b4f

Please sign in to comment.