public function banip()
 {
     if (!$this->session->has('quantity-login')) {
         $this->session->set('quantity-login', 1);
     } else {
         $quantity_login = (int) $this->session->get('quantity-login');
         $this->session->set('quantity-login', $quantity_login + 1);
     }
     if ((int) $this->session->get('quantity-login') >= 5) {
         $ip = $this->request->getClientAddress();
         $find_ip = Ipclient::findFirst(array('conditions' => "ipaddress = '{$ip}' AND type_deny = 2"));
         if ($find_ip) {
             $find_ip->deny = 1;
             $find_ip->date_deny = date('Y-m-d H:i:s');
             $find_ip->type_deny = 2;
             $find_ip->save();
         } else {
             $ipDeny = new Ipclient();
             $ipDeny->ipaddress = $ip;
             $ipDeny->deny = 1;
             $ipDeny->date_deny = date('Y-m-d H:i:s');
             $ipDeny->type_deny = 2;
             $ipDeny->create();
         }
     }
     return (int) $this->session->get('quantity-login');
 }
 public function updateAction()
 {
     if ($this->request->ispost()) {
         if ($this->request->isAjax()) {
             $id = $this->request->getPost('id', 'int');
             $action = $this->request->getPost('action', 'int');
             if ($id && $action) {
                 $ipFind = Ipclient::findFirstById($id);
                 if ($ipFind) {
                     if ((int) $action === 1) {
                         $ipFind->deny = 1;
                         $ipFind->date_deny = date('Y-m-d H:i:s');
                         $ipFind->save();
                         $this->sendAjax(1);
                     } else {
                         $ipFind->deny = 2;
                         $ipFind->date_deny = '';
                         $ipFind->save();
                         $this->sendAjax(2);
                     }
                 }
             }
         }
     }
 }
 public function checkDeny($ip)
 {
     if (!$this->session->has('ip-client-access-admin')) {
         $ip_deny = Ipclient::findFirst("deny = 1 AND type_deny = 2 AND ipaddress = '{$ip}'");
         if ($ip_deny) {
             $this->session->set('ip-client-access-admin', $ip);
             header("HTTP/1.1 403 Forbidden", true);
             die("<html>\n                        <head>\n                            <title>Error 403 - Banned</title>\n                        </head>\n                        <body>\n                            <center>\n                                <h1>Error 403 - Forbidden</h1>\n                                Hello user, you have been banned from accessing our site. If you feel this ban was a mistake, please contact the website administrator to have it removed.<br />\n                                Xin chào bạn, bạn đã bị cấm truy cập vào trang web của chúng tôi. Nếu bạn cảm thấy lệnh cấm này là một sai lầm, xin vui lòng liên hệ với người quản trị trang web để loại bỏ lệnh cấm.<br />\n                                <em>Contact Email: <a href='mailto:" . $this->info['email'] . "?Subject=Please%20Unban%20My%20IP:%20{$ip}' target='_top'>" . $this->info['email'] . "</a></em><br />\n                                <em>IP Address: '{$ip}'</em>\n                            </center>\n                        </body>\n                    </html>");
         }
     } else {
         $ip = $this->session->get('ip-client-access-admin');
         header("HTTP/1.1 403 Forbidden", true);
         die("<html>\n                    <head>\n                        <title>Error 403 - Banned</title>\n                    </head>\n                    <body>\n                        <center>\n                            <h1>Error 403 - Forbidden</h1>\n                            Hello user, you have been banned from accessing our site. If you feel this ban was a mistake, please contact the website administrator to have it removed.<br />\n                            Xin chào bạn, bạn đã bị cấm truy cập vào trang web của chúng tôi. Nếu bạn cảm thấy lệnh cấm này là một sai lầm, xin vui lòng liên hệ với người quản trị trang web để loại bỏ lệnh cấm.<br />\n                            <em>Contact Email: <a href='mailto:" . $this->info['email'] . "?Subject=Please%20Unban%20My%20IP:%20{$ip}' target='_top'>" . $this->info['email'] . "</a></em><br />\n                            <em>IP Address: '{$ip}'</em>\n                        </center>\n                    </body>\n                </html>");
     }
 }