@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | public function testConfig(){ |
| 13 | 13 | $this->ret=[]; |
| 14 | - $this->ret['err'] = 0; |
|
| 14 | + $this->ret['err'] = 0; |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | if(!empty(config('irfa.lockout'))){ |
@@ -31,30 +31,30 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | return $this->ret; |
| 33 | 33 | } |
| 34 | - public function testWriteEventFailedLogin($username){ |
|
| 34 | + public function testWriteEventFailedLogin($username){ |
|
| 35 | 35 | |
| 36 | - $this->eventFailedLogin($username); |
|
| 36 | + $this->eventFailedLogin($username); |
|
| 37 | 37 | |
| 38 | - $input = $username; |
|
| 39 | - $dir = config('irfa.lockout.lockout_file_path'); |
|
| 40 | - $path = $dir.md5($input); |
|
| 38 | + $input = $username; |
|
| 39 | + $dir = config('irfa.lockout.lockout_file_path'); |
|
| 40 | + $path = $dir.md5($input); |
|
| 41 | 41 | |
| 42 | - if(File::exists($path)) |
|
| 42 | + if(File::exists($path)) |
|
| 43 | 43 | { |
| 44 | - return true; |
|
| 44 | + return true; |
|
| 45 | 45 | } |
| 46 | - return false; |
|
| 46 | + return false; |
|
| 47 | 47 | } |
| 48 | 48 | public function testWritable($username){ |
| 49 | - $input = $username; |
|
| 50 | - $dir = config('irfa.lockout.lockout_file_path'); |
|
| 51 | - $path = $dir.md5($input); |
|
| 49 | + $input = $username; |
|
| 50 | + $dir = config('irfa.lockout.lockout_file_path'); |
|
| 51 | + $path = $dir.md5($input); |
|
| 52 | 52 | |
| 53 | - if(is_writable($path)) |
|
| 53 | + if(is_writable($path)) |
|
| 54 | 54 | { |
| 55 | - return true; |
|
| 55 | + return true; |
|
| 56 | 56 | } |
| 57 | - return false; |
|
| 57 | + return false; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function testManualLocking($username){ |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | private function confLogging(){ |
| 105 | - if(is_bool(config('irfa.lockout.logging'))){ |
|
| 106 | - $this->ret['logging'] = '<fg=green>OK'; |
|
| 105 | + if(is_bool(config('irfa.lockout.logging'))){ |
|
| 106 | + $this->ret['logging'] = '<fg=green>OK'; |
|
| 107 | 107 | } else{ |
| 108 | 108 | |
| 109 | 109 | $this->ret['err'] +=1; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $this->ret['input_name'] = '<fg=yellow>Must be a String'; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - private function confFilePath(){ |
|
| 123 | + private function confFilePath(){ |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | if(is_writable(config('irfa.lockout.lockout_file_path'))){ |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | if(!empty(config('irfa.lockout.protected_middleware_group'))){ |
| 154 | 154 | $this->ret['protected_middleware_group'] = '<fg=green>OK'; |
| 155 | 155 | } else{ |
| 156 | - $this->ret['err'] +=1; |
|
| 157 | - $this->ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; |
|
| 156 | + $this->ret['err'] +=1; |
|
| 157 | + $this->ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; |
|
| 158 | 158 | } |
| 159 | 159 | } else{ |
| 160 | 160 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | private function confMessage(){ |
| 167 | - if(is_string(config('irfa.lockout.message_name'))){ |
|
| 167 | + if(is_string(config('irfa.lockout.message_name'))){ |
|
| 168 | 168 | $this->ret['message_name'] = '<fg=green>OK'; |
| 169 | 169 | } else{ |
| 170 | 170 | |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | class Testing extends Core { |
| 10 | 10 | private $ret = []; |
| 11 | 11 | |
| 12 | - public function testConfig(){ |
|
| 13 | - $this->ret=[]; |
|
| 12 | + public function testConfig() { |
|
| 13 | + $this->ret = []; |
|
| 14 | 14 | $this->ret['err'] = 0; |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - if(!empty(config('irfa.lockout'))){ |
|
| 17 | + if (!empty(config('irfa.lockout'))) { |
|
| 18 | 18 | $this->confLoginAttemps(); |
| 19 | 19 | $this->confLogging(); |
| 20 | 20 | $this->confInput(); |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | $this->confProtectMiddleware(); |
| 25 | 25 | $this->confMessage(); |
| 26 | 26 | |
| 27 | - } else{ |
|
| 28 | - $this->ret['err'] +=1; |
|
| 27 | + } else { |
|
| 28 | + $this->ret['err'] += 1; |
|
| 29 | 29 | $this->ret['file'] = "<fg=yellow> Could't find config file. Try to run <fg=cyan>php artisan vendor:publish --tag=lockout-account"; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return $this->ret; |
| 33 | 33 | } |
| 34 | - public function testWriteEventFailedLogin($username){ |
|
| 34 | + public function testWriteEventFailedLogin($username) { |
|
| 35 | 35 | |
| 36 | 36 | $this->eventFailedLogin($username); |
| 37 | 37 | |
@@ -39,136 +39,136 @@ discard block |
||
| 39 | 39 | $dir = config('irfa.lockout.lockout_file_path'); |
| 40 | 40 | $path = $dir.md5($input); |
| 41 | 41 | |
| 42 | - if(File::exists($path)) |
|
| 42 | + if (File::exists($path)) |
|
| 43 | 43 | { |
| 44 | 44 | return true; |
| 45 | 45 | } |
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | - public function testWritable($username){ |
|
| 48 | + public function testWritable($username) { |
|
| 49 | 49 | $input = $username; |
| 50 | 50 | $dir = config('irfa.lockout.lockout_file_path'); |
| 51 | 51 | $path = $dir.md5($input); |
| 52 | 52 | |
| 53 | - if(is_writable($path)) |
|
| 53 | + if (is_writable($path)) |
|
| 54 | 54 | { |
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function testManualLocking($username){ |
|
| 60 | + public function testManualLocking($username) { |
|
| 61 | 61 | $input = $username; |
| 62 | 62 | $dir = config('irfa.lockout.lockout_file_path'); |
| 63 | 63 | $path = $dir.md5($input); |
| 64 | 64 | |
| 65 | - if($this->lock_account($username)) |
|
| 65 | + if ($this->lock_account($username)) |
|
| 66 | 66 | { |
| 67 | 67 | return true; |
| 68 | 68 | } |
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | - public function testUnlocking($username){ |
|
| 71 | + public function testUnlocking($username) { |
|
| 72 | 72 | $input = $username; |
| 73 | 73 | $dir = config('irfa.lockout.lockout_file_path'); |
| 74 | 74 | $path = $dir.md5($input); |
| 75 | - $unlock = $this->test_unlock_account($username); |
|
| 76 | - if($unlock) |
|
| 75 | + $unlock = $this->test_unlock_account($username); |
|
| 76 | + if ($unlock) |
|
| 77 | 77 | { |
| 78 | 78 | return true; |
| 79 | 79 | } |
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | - public function testLockLogin($username){ |
|
| 82 | + public function testLockLogin($username) { |
|
| 83 | 83 | $input = $username; |
| 84 | 84 | $dir = config('irfa.lockout.lockout_file_path'); |
| 85 | 85 | $path = $dir.md5($input); |
| 86 | - $unlock = $this->lockLogin($username); |
|
| 87 | - if($unlock) |
|
| 86 | + $unlock = $this->lockLogin($username); |
|
| 87 | + if ($unlock) |
|
| 88 | 88 | { |
| 89 | 89 | return true; |
| 90 | 90 | } |
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | //////Config |
| 94 | - private function confLoginAttemps(){ |
|
| 95 | - if(is_numeric(config('irfa.lockout.login_attemps'))){ |
|
| 94 | + private function confLoginAttemps() { |
|
| 95 | + if (is_numeric(config('irfa.lockout.login_attemps'))) { |
|
| 96 | 96 | $this->ret['login_attemps'] = '<fg=green>OK'; |
| 97 | - } else{ |
|
| 97 | + } else { |
|
| 98 | 98 | |
| 99 | - $this->ret['err'] +=1; |
|
| 100 | - $this->ret['login_attemps'] ='<fg=yellow>Must be a number'; |
|
| 99 | + $this->ret['err'] += 1; |
|
| 100 | + $this->ret['login_attemps'] = '<fg=yellow>Must be a number'; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - private function confLogging(){ |
|
| 105 | - if(is_bool(config('irfa.lockout.logging'))){ |
|
| 104 | + private function confLogging() { |
|
| 105 | + if (is_bool(config('irfa.lockout.logging'))) { |
|
| 106 | 106 | $this->ret['logging'] = '<fg=green>OK'; |
| 107 | - } else{ |
|
| 107 | + } else { |
|
| 108 | 108 | |
| 109 | - $this->ret['err'] +=1; |
|
| 109 | + $this->ret['err'] += 1; |
|
| 110 | 110 | $this->ret['logging'] = '<fg=yellow>Must be a Boolean'; |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - private function confInput(){ |
|
| 113 | + private function confInput() { |
|
| 114 | 114 | |
| 115 | - if(is_string(config('irfa.lockout.input_name'))){ |
|
| 115 | + if (is_string(config('irfa.lockout.input_name'))) { |
|
| 116 | 116 | $this->ret['input_name'] = '<fg=green>OK'; |
| 117 | - } else{ |
|
| 117 | + } else { |
|
| 118 | 118 | |
| 119 | - $this->ret['err'] +=1; |
|
| 119 | + $this->ret['err'] += 1; |
|
| 120 | 120 | $this->ret['input_name'] = '<fg=yellow>Must be a String'; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - private function confFilePath(){ |
|
| 123 | + private function confFilePath() { |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | - if(is_writable(config('irfa.lockout.lockout_file_path'))){ |
|
| 126 | + if (is_writable(config('irfa.lockout.lockout_file_path'))) { |
|
| 127 | 127 | $this->ret['lockout_file_path'] = '<fg=green>OK'; |
| 128 | - } else{ |
|
| 128 | + } else { |
|
| 129 | 129 | $this->ret['lockout_file_path'] = '<fg=yellow>Write Permission Denied in '.config('irfa.lockout.lockout_file_path'); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - private function confRedirectUrl(){ |
|
| 133 | - if(!empty(config('irfa.lockout.redirect_url'))){ |
|
| 132 | + private function confRedirectUrl() { |
|
| 133 | + if (!empty(config('irfa.lockout.redirect_url'))) { |
|
| 134 | 134 | $this->ret['redirect_url'] = '<fg=green>OK'; |
| 135 | - } else{ |
|
| 135 | + } else { |
|
| 136 | 136 | |
| 137 | - $this->ret['err'] +=1; |
|
| 137 | + $this->ret['err'] += 1; |
|
| 138 | 138 | $this->ret['redirect_url'] = '<fg=yellow>Must be provided'; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - private function confProtectActionPath(){ |
|
| 142 | - if(is_array(config('irfa.lockout.protected_action_path'))){ |
|
| 141 | + private function confProtectActionPath() { |
|
| 142 | + if (is_array(config('irfa.lockout.protected_action_path'))) { |
|
| 143 | 143 | $this->ret['protected_action_path'] = '<fg=green>OK'; |
| 144 | - } else{ |
|
| 144 | + } else { |
|
| 145 | 145 | |
| 146 | - $this->ret['err'] +=1; |
|
| 146 | + $this->ret['err'] += 1; |
|
| 147 | 147 | $this->ret['protected_action_path'] = '<fg=yellow>Must be array'; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
| 151 | - private function confProtectMiddleware(){ |
|
| 152 | - if(is_array(config('irfa.lockout.protected_middleware_group'))){ |
|
| 153 | - if(!empty(config('irfa.lockout.protected_middleware_group'))){ |
|
| 151 | + private function confProtectMiddleware() { |
|
| 152 | + if (is_array(config('irfa.lockout.protected_middleware_group'))) { |
|
| 153 | + if (!empty(config('irfa.lockout.protected_middleware_group'))) { |
|
| 154 | 154 | $this->ret['protected_middleware_group'] = '<fg=green>OK'; |
| 155 | - } else{ |
|
| 156 | - $this->ret['err'] +=1; |
|
| 155 | + } else { |
|
| 156 | + $this->ret['err'] += 1; |
|
| 157 | 157 | $this->ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; |
| 158 | 158 | } |
| 159 | - } else{ |
|
| 159 | + } else { |
|
| 160 | 160 | |
| 161 | - $this->ret['err'] +=1; |
|
| 161 | + $this->ret['err'] += 1; |
|
| 162 | 162 | $this->ret['protected_middleware_group'] = '<fg=yellow>Must be array'; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | } |
| 166 | - private function confMessage(){ |
|
| 167 | - if(is_string(config('irfa.lockout.message_name'))){ |
|
| 166 | + private function confMessage() { |
|
| 167 | + if (is_string(config('irfa.lockout.message_name'))) { |
|
| 168 | 168 | $this->ret['message_name'] = '<fg=green>OK'; |
| 169 | - } else{ |
|
| 169 | + } else { |
|
| 170 | 170 | |
| 171 | - $this->ret['err'] +=1; |
|
| 171 | + $this->ret['err'] += 1; |
|
| 172 | 172 | $this->ret['message_name'] = '<fg=yellow>Must be a String'; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -26,36 +26,36 @@ discard block |
||
| 26 | 26 | * @param string $username |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - protected function eventFailedLogin($username=null){ |
|
| 29 | + protected function eventFailedLogin($username = null) { |
|
| 30 | 30 | |
| 31 | - if($username !== null){ |
|
| 31 | + if ($username !== null) { |
|
| 32 | 32 | $this->setPath($username); |
| 33 | 33 | } |
| 34 | - if(!File::exists($this->dir)){ |
|
| 34 | + if (!File::exists($this->dir)) { |
|
| 35 | 35 | File::makeDirectory($this->dir, 0755, true); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if(!File::exists($this->path)) |
|
| 38 | + if (!File::exists($this->path)) |
|
| 39 | 39 | { |
| 40 | 40 | $login_fail = 1; |
| 41 | - } else{ |
|
| 41 | + } else { |
|
| 42 | 42 | |
| 43 | 43 | $get = json_decode(File::get($this->path)); |
| 44 | 44 | $ip_list = $get->ip; |
| 45 | - if(!$this->checkIp($ip_list,$this->ip)){ |
|
| 46 | - array_push($ip_list,$this->ip); |
|
| 45 | + if (!$this->checkIp($ip_list, $this->ip)) { |
|
| 46 | + array_push($ip_list, $this->ip); |
|
| 47 | 47 | } |
| 48 | - if($get->attemps == "lock"){ |
|
| 48 | + if ($get->attemps == "lock") { |
|
| 49 | 49 | $login_fail = "lock"; |
| 50 | - } else{ |
|
| 50 | + } else { |
|
| 51 | 51 | $login_fail = $get->attemps+1; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$this->ip],'last_attemps' => date("Y-m-d H:i:s",time())]; |
|
| 56 | - File::put($this->path,json_encode($content)); |
|
| 57 | - if(File::exists($this->path)){ |
|
| 58 | - chmod($this->path,0755); |
|
| 55 | + $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$this->ip], 'last_attemps' => date("Y-m-d H:i:s", time())]; |
|
| 56 | + File::put($this->path, json_encode($content)); |
|
| 57 | + if (File::exists($this->path)) { |
|
| 58 | + chmod($this->path, 0755); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | } |
@@ -90,17 +90,17 @@ discard block |
||
| 90 | 90 | * @param string $username |
| 91 | 91 | * @return boolean |
| 92 | 92 | */ |
| 93 | - protected function is_locked($username){ |
|
| 93 | + protected function is_locked($username) { |
|
| 94 | 94 | $this->setPath($username); |
| 95 | - if(File::exists($this->path)) |
|
| 95 | + if (File::exists($this->path)) |
|
| 96 | 96 | { |
| 97 | 97 | $get = json_decode(File::get($this->path)); |
| 98 | - if($get->attemps > $this->attemps || $get->attemps == "lock"){ |
|
| 98 | + if ($get->attemps > $this->attemps || $get->attemps == "lock") { |
|
| 99 | 99 | return true; |
| 100 | - } else{ |
|
| 100 | + } else { |
|
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | - } else{ |
|
| 103 | + } else { |
|
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -123,19 +123,19 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return boolean |
| 125 | 125 | */ |
| 126 | - protected function lockLogin($username = null){ |
|
| 126 | + protected function lockLogin($username = null) { |
|
| 127 | 127 | |
| 128 | - if(php_sapi_name() == "cli" AND $username != null){ |
|
| 128 | + if (php_sapi_name() == "cli" AND $username != null) { |
|
| 129 | 129 | $this->setPath($username); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if(File::exists($this->path)) |
|
| 132 | + if (File::exists($this->path)) |
|
| 133 | 133 | { |
| 134 | 134 | $get = json_decode(File::get($this->path)); |
| 135 | - if($get->attemps == "lock"){ |
|
| 135 | + if ($get->attemps == "lock") { |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | - if($get->attemps > $this->attemps){ |
|
| 138 | + if ($get->attemps > $this->attemps) { |
|
| 139 | 139 | // if($matchip){ |
| 140 | 140 | // if($this->checkIp($ip_list,$this->ip)){ |
| 141 | 141 | // return true; |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return boolean |
| 161 | 161 | */ |
| 162 | - private function checkIp($ip_list,$ip){ |
|
| 163 | - if(collect($ip_list)->contains($ip)){ |
|
| 162 | + private function checkIp($ip_list, $ip) { |
|
| 163 | + if (collect($ip_list)->contains($ip)) { |
|
| 164 | 164 | return true; |
| 165 | - } else{ |
|
| 165 | + } else { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @return boolean |
| 175 | 175 | */ |
| 176 | - public function clear_all(){ |
|
| 176 | + public function clear_all() { |
|
| 177 | 177 | $file = new Filesystem(); |
| 178 | - if($file->cleanDirectory($this->path)){ |
|
| 178 | + if ($file->cleanDirectory($this->path)) { |
|
| 179 | 179 | return true; |
| 180 | - } else{ |
|
| 180 | + } else { |
|
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
| 188 | 188 | * @param string $username |
| 189 | 189 | * @return mixed |
| 190 | 190 | */ |
| 191 | - public function unlock_account($username){ |
|
| 191 | + public function unlock_account($username) { |
|
| 192 | 192 | $this->setPath($username); |
| 193 | - if(File::exists($this->path)){ |
|
| 193 | + if (File::exists($this->path)) { |
|
| 194 | 194 | $readf = File::get($this->path); |
| 195 | 195 | File::delete($this->path); |
| 196 | - if(php_sapi_name() == "cli"){ |
|
| 196 | + if (php_sapi_name() == "cli") { |
|
| 197 | 197 | echo Lang::get('lockoutMessage.user_unlock_success')."\n"; |
| 198 | 198 | return $readf; |
| 199 | 199 | |
| 200 | - } else{ |
|
| 200 | + } else { |
|
| 201 | 201 | return true; |
| 202 | 202 | } |
| 203 | - } else{ |
|
| 204 | - if(php_sapi_name() == "cli"){ |
|
| 203 | + } else { |
|
| 204 | + if (php_sapi_name() == "cli") { |
|
| 205 | 205 | echo Lang::get('lockoutMessage.user_lock_404')."\n"; |
| 206 | 206 | return false; |
| 207 | - } else{ |
|
| 207 | + } else { |
|
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -215,21 +215,21 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return mixed |
| 217 | 217 | */ |
| 218 | - public function test_unlock_account($username){ |
|
| 218 | + public function test_unlock_account($username) { |
|
| 219 | 219 | $this->setPath($username); |
| 220 | - if(File::exists($this->path)){ |
|
| 220 | + if (File::exists($this->path)) { |
|
| 221 | 221 | $readf = File::get($this->path); |
| 222 | 222 | File::delete($this->path); |
| 223 | - if(php_sapi_name() == "cli"){ |
|
| 223 | + if (php_sapi_name() == "cli") { |
|
| 224 | 224 | return true; |
| 225 | 225 | |
| 226 | - } else{ |
|
| 226 | + } else { |
|
| 227 | 227 | return true; |
| 228 | 228 | } |
| 229 | - } else{ |
|
| 230 | - if(php_sapi_name() == "cli"){ |
|
| 229 | + } else { |
|
| 230 | + if (php_sapi_name() == "cli") { |
|
| 231 | 231 | return false; |
| 232 | - } else{ |
|
| 232 | + } else { |
|
| 233 | 233 | return false; |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -241,22 +241,22 @@ discard block |
||
| 241 | 241 | * @param string $username |
| 242 | 242 | * @return mixed |
| 243 | 243 | */ |
| 244 | - public function check_account($username){ |
|
| 244 | + public function check_account($username) { |
|
| 245 | 245 | $this->setPath($username); |
| 246 | - if(File::exists($this->path)){ |
|
| 246 | + if (File::exists($this->path)) { |
|
| 247 | 247 | $readf = File::get($this->path); |
| 248 | - if(php_sapi_name() == "cli"){ |
|
| 248 | + if (php_sapi_name() == "cli") { |
|
| 249 | 249 | |
| 250 | 250 | return $readf; |
| 251 | 251 | |
| 252 | - } else{ |
|
| 252 | + } else { |
|
| 253 | 253 | return $readf; |
| 254 | 254 | } |
| 255 | - } else{ |
|
| 256 | - if(php_sapi_name() == "cli"){ |
|
| 255 | + } else { |
|
| 256 | + if (php_sapi_name() == "cli") { |
|
| 257 | 257 | echo Lang::get('lockoutMessage.user_lock_404')."\n"; |
| 258 | 258 | exit(); |
| 259 | - } else{ |
|
| 259 | + } else { |
|
| 260 | 260 | return false; |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -268,31 +268,31 @@ discard block |
||
| 268 | 268 | * @param string $username |
| 269 | 269 | * @return mixed |
| 270 | 270 | */ |
| 271 | - public function lock_account($username){ |
|
| 272 | - $sapi = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web"; |
|
| 271 | + public function lock_account($username) { |
|
| 272 | + $sapi = php_sapi_name() == "cli" ? "lock-via-cli" : "lock-via-web"; |
|
| 273 | 273 | $this->setPath($username); |
| 274 | - try{ |
|
| 275 | - if(!File::exists($this->dir)){ |
|
| 274 | + try { |
|
| 275 | + if (!File::exists($this->dir)) { |
|
| 276 | 276 | File::makeDirectory($this->dir, 0755, true); |
| 277 | 277 | } |
| 278 | 278 | $login_fail = "lock"; |
| 279 | 279 | |
| 280 | - $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => [$sapi],'last_attemps' => date("Y-m-d H:i:s",time())]; |
|
| 281 | - File::put($this->path,json_encode($content)); |
|
| 282 | - if(File::exists($this->path)){ |
|
| 283 | - chmod($this->path,0755); |
|
| 280 | + $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => [$sapi], 'last_attemps' => date("Y-m-d H:i:s", time())]; |
|
| 281 | + File::put($this->path, json_encode($content)); |
|
| 282 | + if (File::exists($this->path)) { |
|
| 283 | + chmod($this->path, 0755); |
|
| 284 | 284 | } |
| 285 | - if(php_sapi_name() == "cli"){ |
|
| 285 | + if (php_sapi_name() == "cli") { |
|
| 286 | 286 | return Lang::get('lockoutMessage.user_lock_success')."\n"; |
| 287 | 287 | |
| 288 | - } else{ |
|
| 288 | + } else { |
|
| 289 | 289 | return true; |
| 290 | 290 | } |
| 291 | - } catch(\Exception $e){ |
|
| 292 | - if(php_sapi_name() == "cli"){ |
|
| 291 | + } catch (\Exception $e) { |
|
| 292 | + if (php_sapi_name() == "cli") { |
|
| 293 | 293 | return "error"; |
| 294 | 294 | |
| 295 | - } else{ |
|
| 295 | + } else { |
|
| 296 | 296 | return false; |
| 297 | 297 | } |
| 298 | 298 | } |