Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index() {
- $this->load->view('layout/html_header.php'); //Def
- $this->load->view('layout/page_header.php'); //Def
- $this->load->library('form_validation');
- $this->load->view('home.php');
- $this->load->view('layout/page_footer.php'); //Def
- $this->load->view('layout/html_footer.php'); //Def
- }
- public function login() {
- $this->load->view('layout/html_header.php'); //Def
- $this->load->view('layout/page_header.php'); //Def
- $this->load->library('form_validation');
- $this->form_validation->set_rules('user', 'seu usuário', 'required');
- $this->form_validation->set_rules('pass', 'sua senha', 'required');
- $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
- $this->form_validation->set_message('required', 'Preencha %s corretamente.');
- $this->form_validation->set_message('checkPass', 'Os dados de login inseridos estão incorretos.');
- if ($this->form_validation->run() == false) {
- $this->load->view('home');
- } else {
- $userip = $_SERVER['REMOTE_ADDR'];
- $query = $this->db->get_where('hackjump', array('ip' => $userip));
- $rows = $query->num_rows();
- if ($rows != 0) {
- $gpass = false;
- } else {
- $gpass = true;
- }
- if (!$gpass) {
- $row = $query->row(1);
- $tries = $row->tries;
- $time = $row->time;
- if ($tries == 3) {
- $mustTime = $time + 7200;
- if ($time > $mustTime) {
- $this->db->delete('hackjump', array('ip' => $userip));
- $gpass = true;
- } else {
- $gpass = false;
- }
- } else {
- $gpass = true;
- }
- }
- if ($gpass) {
- $user = $this->input->post('user');
- $pass = md5($this->input->post('pass'));
- $query = $this->db->get_where('users', array('name' => $user, 'pass' => $pass));
- if ($query->num_rows()) {
- //PASSOU!
- $this->load->view('fhome');
- echo "PASSOU!";
- } else {
- $query = $this->db->get_where('hackjump', array('ip' => $userip));
- $rows = $query->num_rows();
- if ($rows != 0) {
- $row = $query->row(1);
- $gtime = $row->time;
- $btime = $gtime + 7200;
- $tries = $row->tries;
- $ntries = $tries + 1;
- $attTime = time();
- if ($attTime > $btime) {
- $this->db->delete('hackjump', array('ip' => $userip));
- $this->db->insert('hackjump', array('ip' => $userip, 'time' => $attTime, 'tries' => '1'));
- } else {
- $this->db->update('hackjump', array('tries' => $ntries, 'time' => $attTime), array('ip' => $userip));
- }
- } else {
- $attTime = time();
- $this->db->insert('hackjump', array('ip' => $userip, 'time' => $attTime, 'tries' => '1'));
- }
- $data['passError'] = "Nome de usuário ou senha incorretos.<br />Se você errar o login 3 vezes o seu IP ficará bloqueado por 2 horas.";
- $this->load->view('home', $data);
- }
- } else {
- $data['passError'] = "Você errou o login 3 vezes.<br />O seu IP está bloqueado por enquanto, tente novamente mais tarde ou contate o webmaster.";
- $this->load->view('home', $data);
- }
- }
- $this->load->view('layout/page_footer.php'); //Def
- $this->load->view('layout/html_footer.php'); //Def
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement