Passed
Push — master ( 5bb679...8d229b )
by IRFA
04:04 queued 11s
created
src/Console/Commands/LockInfoPackage.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
     $conf = config('irfa.lockout');
57 57
 
58 58
         $this->line('<fg=default>-------------------------------------------------------------------------------');
59
-         $this->line('<fg=yellow>Commands');
60
-          $table = new Table($this->output);
59
+            $this->line('<fg=yellow>Commands');
60
+            $table = new Table($this->output);
61 61
             $table->setRows([
62 62
                 ['<fg=cyan>php artisan lockout:lock {username}','<fg=default>locking account'],
63 63
                 ['<fg=cyan>php artisan lockout:unlock {username}','<fg=default>unlocking account'],
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
                 ['<fg=cyan>php artisan lockout:is-locked {username}','<fg=default>checking account (return boolean)'],
66 66
                 ['<fg=cyan>php artisan lockout:clear','<fg=default>unlocking all account']]
67 67
             );
68
-          $table->render();
69
-         $this->line('<fg=default>-------------------------------------------------------------------------------');
68
+            $table->render();
69
+            $this->line('<fg=default>-------------------------------------------------------------------------------');
70 70
         $this->line('<fg=yellow>Configuration');
71 71
     foreach($conf as $key => $val){
72 72
         if(is_array($val)){
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             $row[] = ['<fg=default>'.$key,' <fg=cyan>'.$vl];
80 80
         }
81 81
         // dd($row);
82
-          $table = new Table($this->output);
82
+            $table = new Table($this->output);
83 83
             $table->setRows($row);
84 84
                         $table->render();
85 85
     }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $this->informasi();
42 42
     }
43 43
 
44
-    private function informasi(){
44
+    private function informasi() {
45 45
             $this->line(" _____      __             _                _               _   
46 46
 |_   _|    / _|           | |              | |             | |  
47 47
   | | _ __| |_ __ _ ______| |     ___   ___| | _____  _   _| |_ 
@@ -59,24 +59,24 @@  discard block
 block discarded – undo
59 59
          $this->line('<fg=yellow>Commands');
60 60
           $table = new Table($this->output);
61 61
             $table->setRows([
62
-                ['<fg=cyan>php artisan lockout:lock {username}','<fg=default>locking account'],
63
-                ['<fg=cyan>php artisan lockout:unlock {username}','<fg=default>unlocking account'],
64
-                ['<fg=cyan>php artisan lockout:check {username}','<fg=default>checking account with details'],
65
-                ['<fg=cyan>php artisan lockout:is-locked {username}','<fg=default>checking account (return boolean)'],
66
-                ['<fg=cyan>php artisan lockout:clear','<fg=default>unlocking all account']]
62
+                ['<fg=cyan>php artisan lockout:lock {username}', '<fg=default>locking account'],
63
+                ['<fg=cyan>php artisan lockout:unlock {username}', '<fg=default>unlocking account'],
64
+                ['<fg=cyan>php artisan lockout:check {username}', '<fg=default>checking account with details'],
65
+                ['<fg=cyan>php artisan lockout:is-locked {username}', '<fg=default>checking account (return boolean)'],
66
+                ['<fg=cyan>php artisan lockout:clear', '<fg=default>unlocking all account']]
67 67
             );
68 68
           $table->render();
69 69
          $this->line('<fg=default>-------------------------------------------------------------------------------');
70 70
         $this->line('<fg=yellow>Configuration');
71
-    foreach($conf as $key => $val){
72
-        if(is_array($val)){
73
-            foreach($val as $v){
71
+    foreach ($conf as $key => $val) {
72
+        if (is_array($val)) {
73
+            foreach ($val as $v) {
74 74
                 $vl .= $v.", ";
75 75
             }
76
-        } else{
76
+        } else {
77 77
                 $vl = $val;
78 78
             }
79
-            $row[] = ['<fg=default>'.$key,' <fg=cyan>'.$vl];
79
+            $row[] = ['<fg=default>'.$key, ' <fg=cyan>'.$vl];
80 80
         }
81 81
         // dd($row);
82 82
           $table = new Table($this->output);
Please login to merge, or discard this patch.
src/Console/Commands/CheckLockedCommands.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@
 block discarded – undo
45 45
             if($lock){
46 46
                 $table->setRows([
47 47
                         ['<fg=yellow>'.$username.' is locked',]]);
48
-                 $table->render();
48
+                    $table->render();
49 49
                 $this->line('<fg=default>Run <fg=cyan>php artisan lockout:unlock '.$username.'<fg=default> to unlock account.'); 
50 50
             } else{
51
-                 $table->setRows([
51
+                    $table->setRows([
52 52
                         ['<fg=green>'.$username.' is unlocked',]]);
53
-                  $table->render();
54
-                         $this->line('<fg=default>Run <fg=cyan>php artisan lockout:lock '.$username.'<fg=default> to lock account.');  
53
+                    $table->render();
54
+                            $this->line('<fg=default>Run <fg=cyan>php artisan lockout:lock '.$username.'<fg=default> to lock account.');  
55 55
             }   
56 56
                        
57 57
                 // $this->line('<fg=yellow>Valid input is  lock, unlock, and attemps.');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace Irfa\Lockout\Console\Commands;
4 4
 
5 5
 use Illuminate\Console\Command;
6
-use Irfa\Lockout\Func\Core,Lockout;
6
+use Irfa\Lockout\Func\Core, Lockout;
7 7
 use Symfony\Component\Console\Helper\Table;
8 8
 
9 9
 class CheckLockedCommands extends Command
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
         $username = $this->argument('username');
43 43
         $lock = Lockout::isLocked($username);
44 44
             $table = new Table($this->output);
45
-            if($lock){
45
+            if ($lock) {
46 46
                 $table->setRows([
47
-                        ['<fg=yellow>'.$username.' is locked',]]);
47
+                        ['<fg=yellow>'.$username.' is locked', ]]);
48 48
                  $table->render();
49 49
                 $this->line('<fg=default>Run <fg=cyan>php artisan lockout:unlock '.$username.'<fg=default> to unlock account.'); 
50
-            } else{
50
+            } else {
51 51
                  $table->setRows([
52
-                        ['<fg=green>'.$username.' is unlocked',]]);
52
+                        ['<fg=green>'.$username.' is unlocked', ]]);
53 53
                   $table->render();
54 54
                          $this->line('<fg=default>Run <fg=cyan>php artisan lockout:lock '.$username.'<fg=default> to lock account.');  
55 55
             }   
Please login to merge, or discard this patch.
src/Func/Core.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
40 40
             File::put($path,json_encode($content));
41 41
             if(File::exists($path)){
42
-              chmod($path,0750);
42
+                chmod($path,0750);
43 43
             }
44 44
           
45 45
     }
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
         $path = $dir.md5($username);
60 60
         if(File::exists($path))
61 61
         {
62
-           $get = json_decode(File::get($path));
63
-           if($get->attemps > $attemps || $get->attemps == "lock"){
64
-              return true;
65
-           } else{
66
-              return false;
67
-           }
62
+            $get = json_decode(File::get($path));
63
+            if($get->attemps > $attemps || $get->attemps == "lock"){
64
+                return true;
65
+            } else{
66
+                return false;
67
+            }
68 68
         } else{
69 69
             return false;
70 70
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
190 190
                 File::put($path,json_encode($content));
191 191
                 if(File::exists($path)){
192
-                  chmod($path,0750);
192
+                    chmod($path,0750);
193 193
                 }
194 194
                 if(php_sapi_name() == "cli"){
195 195
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -2,206 +2,206 @@
 block discarded – undo
2 2
 namespace  Irfa\Lockout\Func;
3 3
 
4 4
 use Log;
5
-use Illuminate\Support\Facades\Request,File,Lang,Session;
5
+use Illuminate\Support\Facades\Request, File, Lang, Session;
6 6
 use Illuminate\Filesystem\Filesystem;
7 7
 use Symfony\Component\Console\Helper\Table;
8 8
 
9 9
 class Core
10 10
 {
11
-    protected function eventFailedLogin(){
11
+    protected function eventFailedLogin() {
12 12
         $ip = Request::ip();
13 13
         $input = Request::input(config('irfa.lockout.input_name'));
14
-        $matchip= config('irfa.lockout.match_ip') == true ? $ip :null;
14
+        $matchip = config('irfa.lockout.match_ip') == true ? $ip : null;
15 15
         $dir = config('irfa.lockout.lockout_file_path');
16 16
         $path = $dir.md5($input);
17 17
 
18
-        if(!File::exists($dir)){
18
+        if (!File::exists($dir)) {
19 19
                 File::makeDirectory($dir, 0750, true);
20 20
         }
21 21
 
22
-        if(!File::exists($path))
22
+        if (!File::exists($path))
23 23
         {
24 24
             $login_fail = 1;
25
-        } else{
25
+        } else {
26 26
 
27 27
             $get = json_decode(File::get($path));
28 28
             $ip_list = $get->ip;
29
-            if(!$this->checkIp($ip_list,$ip)){
30
-                array_push($ip_list,$ip);
29
+            if (!$this->checkIp($ip_list, $ip)) {
30
+                array_push($ip_list, $ip);
31 31
             }
32
-            if($get->attemps == "lock"){
32
+            if ($get->attemps == "lock") {
33 33
                 $login_fail = "lock";
34
-            } else{
34
+            } else {
35 35
                 $login_fail = $get->attemps+1;
36 36
             }
37 37
         }
38 38
         
39
-            $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
40
-            File::put($path,json_encode($content));
41
-            if(File::exists($path)){
42
-              chmod($path,0750);
39
+            $content = ['username' => $input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
40
+            File::put($path, json_encode($content));
41
+            if (File::exists($path)) {
42
+              chmod($path, 0750);
43 43
             }
44 44
           
45 45
     }
46
-    protected function eventCleanLockoutAccount(){
46
+    protected function eventCleanLockoutAccount() {
47 47
         $input = Request::input(config('irfa.lockout.input_name'));
48 48
         $this->unlock_account($input);
49 49
           
50 50
     }
51
-    protected function logging($middleware="WEB"){
52
-        if(config('irfa.lockout.logging')){
51
+    protected function logging($middleware = "WEB") {
52
+        if (config('irfa.lockout.logging')) {
53 53
                     Log::notice($middleware." | Login attemps fail | "."username : ".Request::input(config('irfa.lockout.input_name'))." | ipAddress : ".Request::ip()." | userAgent : ".$_SERVER['HTTP_USER_AGENT'].PHP_EOL);
54 54
             }
55 55
     }
56
-    protected function is_locked($username){
56
+    protected function is_locked($username) {
57 57
         $dir = config('irfa.lockout.lockout_file_path');
58 58
         $attemps = config('irfa.lockout.login_attemps');
59 59
         $path = $dir.md5($username);
60
-        if(File::exists($path))
60
+        if (File::exists($path))
61 61
         {
62 62
            $get = json_decode(File::get($path));
63
-           if($get->attemps > $attemps || $get->attemps == "lock"){
63
+           if ($get->attemps > $attemps || $get->attemps == "lock") {
64 64
               return true;
65
-           } else{
65
+           } else {
66 66
               return false;
67 67
            }
68
-        } else{
68
+        } else {
69 69
             return false;
70 70
         }
71 71
     }
72 72
 
73
-    protected function showMessage(){
74
-        if(Session::has(config('irfa.lockout.message_name'))){
73
+    protected function showMessage() {
74
+        if (Session::has(config('irfa.lockout.message_name'))) {
75 75
             return Session::get(config('irfa.lockout.message_name'));
76 76
         }
77 77
 
78 78
         return null;
79 79
     }
80
-    protected function lockLogin(){
80
+    protected function lockLogin() {
81 81
         $ip = Request::ip();
82 82
         $input = Request::input(config('irfa.lockout.input_name'));
83
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
83
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
84 84
         $dir = config('irfa.lockout.lockout_file_path');
85 85
         $attemps = config('irfa.lockout.login_attemps');
86 86
         $path = $dir.md5($input);
87
-        if(File::exists($path))
87
+        if (File::exists($path))
88 88
         {
89 89
                 $get = json_decode(File::get($path));
90 90
             // dd($get->attemps.">".$attemps);
91
-                if($get->attemps == "lock"){
91
+                if ($get->attemps == "lock") {
92 92
                 return true;
93 93
                 }
94
-                if($get->attemps > $attemps){
95
-                    if($matchip){
96
-                    if($this->checkIp($ip_list,$ip)){
94
+                if ($get->attemps > $attemps) {
95
+                    if ($matchip) {
96
+                    if ($this->checkIp($ip_list, $ip)) {
97 97
                         return true;
98
-                    } else{
98
+                    } else {
99 99
                         return false;
100 100
                     }
101
-                    } else{
101
+                    } else {
102 102
                     return true;
103 103
                     }
104
-                } else{
104
+                } else {
105 105
                 return false;
106 106
                 }
107
-        } else{
107
+        } else {
108 108
             return false;
109 109
             }
110 110
     }
111
-    private function checkIp($ip_list,$ip){
112
-        if(collect($ip_list)->contains($ip)){
111
+    private function checkIp($ip_list, $ip) {
112
+        if (collect($ip_list)->contains($ip)) {
113 113
             return true;
114
-        } else{
114
+        } else {
115 115
             return false;
116 116
         }
117 117
 
118 118
     }
119
-    public function clear_all(){
119
+    public function clear_all() {
120 120
         $file = new Filesystem();
121
-        if($file->cleanDirectory(config('irfa.lockout.lockout_file_path'))){
121
+        if ($file->cleanDirectory(config('irfa.lockout.lockout_file_path'))) {
122 122
         return true;
123
-        } else{
123
+        } else {
124 124
         return false;
125 125
         }
126 126
     }
127
-    public function unlock_account($username){
127
+    public function unlock_account($username) {
128 128
         $ip = Request::ip();
129
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
129
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
130 130
         $dir = config('irfa.lockout.lockout_file_path');
131 131
         $attemps = config('irfa.lockout.attemps');
132 132
         $path = $dir.md5($username);
133 133
 
134
-        if(File::exists($path)){
134
+        if (File::exists($path)) {
135 135
             $readf = File::get($path);
136 136
                 File::delete($path);
137
-            if(php_sapi_name() == "cli"){
137
+            if (php_sapi_name() == "cli") {
138 138
                 echo Lang::get('lockoutMessage.user_unlock_success')."\n";
139 139
                 return $readf;
140 140
               
141
-            } else{
141
+            } else {
142 142
                 return true;
143 143
             }
144
-        } else{
145
-            if(php_sapi_name() == "cli"){
144
+        } else {
145
+            if (php_sapi_name() == "cli") {
146 146
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
147 147
                 exit();
148
-            } else{
148
+            } else {
149 149
                 return false;
150 150
             }
151 151
         }
152 152
         }
153
-        public function check_account($username){
153
+        public function check_account($username) {
154 154
         $dir = config('irfa.lockout.lockout_file_path');
155 155
         $path = $dir.md5($username);
156 156
 
157
-        if(File::exists($path)){
157
+        if (File::exists($path)) {
158 158
             $readf = File::get($path);
159
-            if(php_sapi_name() == "cli"){
159
+            if (php_sapi_name() == "cli") {
160 160
               
161 161
                 return $readf;
162 162
               
163
-            } else{
163
+            } else {
164 164
                 return $readf;
165 165
             }
166
-        } else{
167
-            if(php_sapi_name() == "cli"){
166
+        } else {
167
+            if (php_sapi_name() == "cli") {
168 168
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
169 169
                 exit();
170
-            } else{
170
+            } else {
171 171
                 return false;
172 172
             }
173 173
         }
174 174
         }
175 175
 
176
-        public function lock_account($username){
177
-        $ip = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web";
176
+        public function lock_account($username) {
177
+        $ip = php_sapi_name() == "cli" ? "lock-via-cli" : "lock-via-web";
178 178
         $input = $username;
179
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
179
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
180 180
         $dir = config('irfa.lockout.lockout_file_path');
181 181
         $attemps = config('irfa.lockout.login_attemps');
182 182
         $path = $dir.md5($username);
183
-        try{
184
-            if(!File::exists($dir)){
183
+        try {
184
+            if (!File::exists($dir)) {
185 185
                 File::makeDirectory($dir, 0750, true);
186 186
             }
187 187
                 $login_fail = "lock";
188 188
           
189
-                $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
190
-                File::put($path,json_encode($content));
191
-                if(File::exists($path)){
192
-                  chmod($path,0750);
189
+                $content = ['username' => $input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
190
+                File::put($path, json_encode($content));
191
+                if (File::exists($path)) {
192
+                  chmod($path, 0750);
193 193
                 }
194
-                if(php_sapi_name() == "cli"){
194
+                if (php_sapi_name() == "cli") {
195 195
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
196 196
                   
197
-                } else{
197
+                } else {
198 198
                 return true;
199 199
                 }
200
-            } catch(Exception $e){
201
-                if(php_sapi_name() == "cli"){
200
+            } catch (Exception $e) {
201
+                if (php_sapi_name() == "cli") {
202 202
                 return "error";
203 203
                   
204
-                } else{
204
+                } else {
205 205
                 return false;
206 206
                 }
207 207
             }
Please login to merge, or discard this patch.
src/Func/Lockout.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         }
17 17
         return true;
18 18
     }
19
-  	public function isLocked($username){
20
-  		return $this->is_locked($username);
21
-  	}
19
+        public function isLocked($username){
20
+            return $this->is_locked($username);
21
+        }
22 22
     public function message(){
23 23
         return $this->showMessage();
24 24
     }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -6,58 +6,58 @@
 block discarded – undo
6 6
 
7 7
 class Lockout extends Core {
8 8
 	
9
-    public function unlock($username){
10
-        if(is_array($username)){
11
-            foreach($username as $key){
9
+    public function unlock($username) {
10
+        if (is_array($username)) {
11
+            foreach ($username as $key) {
12 12
                 $this->_unlock($key);
13 13
             }
14
-        } else{
14
+        } else {
15 15
             $this->_unlock($username);
16 16
         }
17 17
         return true;
18 18
     }
19
-  	public function isLocked($username){
19
+  	public function isLocked($username) {
20 20
   		return $this->is_locked($username);
21 21
   	}
22
-    public function message(){
22
+    public function message() {
23 23
         return $this->showMessage();
24 24
     }
25
-    public function lock($username){
26
-        if(is_array($username)){
27
-            foreach($username as $key){
25
+    public function lock($username) {
26
+        if (is_array($username)) {
27
+            foreach ($username as $key) {
28 28
                     $this->_lock($key);
29 29
             }
30
-        } else{
30
+        } else {
31 31
                 $this->_lock($username);
32 32
         }
33 33
         return true;
34 34
     }
35 35
     public function check($username) {	 
36 36
         $ret = null;
37
-        if(is_array($username)){
38
-            foreach($username as $key){
37
+        if (is_array($username)) {
38
+            foreach ($username as $key) {
39 39
                 $get = $this->_check($key);
40
-                if(!empty($get)){
40
+                if (!empty($get)) {
41 41
                     $ret[] = $get;
42 42
                 }
43 43
             }
44
-        } else{
44
+        } else {
45 45
                 $ret = $this->_check($username);
46 46
         }
47 47
         $ret = json_encode($ret);
48 48
         return json_decode($ret);
49 49
     }
50
-    public function clearLocked(){
50
+    public function clearLocked() {
51 51
         return $this->clear_all();
52 52
     }
53 53
 
54
-    private function _unlock($username){
54
+    private function _unlock($username) {
55 55
         $this->unlock_account($username);
56 56
     }
57
-    private function _lock($username){
57
+    private function _lock($username) {
58 58
         $this->lock_account($username);
59 59
     }
60
-    private function _check($username){
61
-        return json_decode($this->check_account($username),true);
60
+    private function _check($username) {
61
+        return json_decode($this->check_account($username), true);
62 62
     }
63 63
 }
Please login to merge, or discard this patch.