Passed
Push — master ( 05a102...8d2f81 )
by IRFA
03:53 queued 11s
created
src/Console/Commands/LockInfoPackage.php 1 patch
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.
src/Console/Commands/CheckLockedCommands.php 1 patch
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.
src/Func/Lockout.php 1 patch
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.
src/Func/Core.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     protected function eventFailedLogin($username=null){
30 30
         
31 31
         if($username != null){
32
-          $this->setPath($username);
32
+            $this->setPath($username);
33 33
         }
34 34
         if(!File::exists($this->dir)){
35 35
                 File::makeDirectory($this->dir, 0755, true);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 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 56
             File::put($this->path,json_encode($content));
57 57
             if(File::exists($this->path)){
58
-              chmod($this->path,0755);
58
+                chmod($this->path,0755);
59 59
             }
60 60
           
61 61
     }
@@ -84,31 +84,31 @@  discard block
 block discarded – undo
84 84
             }
85 85
     }
86 86
 
87
-     /**
88
-       * Check if user is locked
89
-       *
90
-       * @param  string  $username
91
-       * @return boolean
92
-     */
87
+        /**
88
+         * Check if user is locked
89
+         *
90
+         * @param  string  $username
91
+         * @return boolean
92
+         */
93 93
     protected function is_locked($username){
94 94
         $this->setPath($username);
95 95
         if(File::exists($this->path))
96 96
         {
97
-           $get = json_decode(File::get($this->path));
98
-           if($get->attemps > $this->attemps || $get->attemps == "lock"){
99
-              return true;
100
-           } else{
101
-              return false;
102
-           }
97
+            $get = json_decode(File::get($this->path));
98
+            if($get->attemps > $this->attemps || $get->attemps == "lock"){
99
+                return true;
100
+            } else{
101
+                return false;
102
+            }
103 103
         } else{
104 104
             return false;
105 105
         }
106 106
     }
107 107
 
108 108
     /**
109
-       * Show message if failed x attemps
110
-       *
111
-       * @return string
109
+     * Show message if failed x attemps
110
+     *
111
+     * @return string
112 112
      */
113 113
     protected function showMessage(){
114 114
         if(Session::has(config('irfa.lockout.message_name'))){
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     protected function lockLogin($username = null){
127 127
         
128 128
         if(php_sapi_name() == "cli" AND $username != null){
129
-          $this->setPath($username);
129
+            $this->setPath($username);
130 130
         }
131 131
 
132 132
         if(File::exists($this->path))
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
             }
154 154
     }
155 155
 
156
-     /**
157
-     * Check ip locked
158
-     *
159
-     * @return boolean
160
-     */
156
+        /**
157
+         * Check ip locked
158
+         *
159
+         * @return boolean
160
+         */
161 161
     private function checkIp($ip_list,$ip){
162 162
         if(collect($ip_list)->contains($ip)){
163 163
             return true;
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 
168 168
     }
169 169
 
170
-     /**
171
-     * Clear all locked account
172
-     *
173
-     * @return boolean
174
-     */
170
+        /**
171
+         * Clear all locked account
172
+         *
173
+         * @return boolean
174
+         */
175 175
     public function clear_all(){
176 176
         $file = new Filesystem();
177 177
         if($file->cleanDirectory($this->path)){
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
         }
182 182
     }
183 183
 
184
-     /**
185
-     * Unlocking account manually.
186
-     *
187
-     * @param string $username
188
-     * @return mixed
189
-     */
184
+        /**
185
+         * Unlocking account manually.
186
+         *
187
+         * @param string $username
188
+         * @return mixed
189
+         */
190 190
     public function unlock_account($username){
191 191
         $this->setPath($username);
192
-         if(File::exists($this->path)){
192
+            if(File::exists($this->path)){
193 193
             $readf = File::get($this->path);
194 194
                 File::delete($this->path);
195 195
             if(php_sapi_name() == "cli"){
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 return false;
208 208
             }
209 209
         }
210
-      }
210
+        }
211 211
 
212 212
     /**
213 213
      * For Testing
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function test_unlock_account($username){
218 218
         $this->setPath($username);
219
-         if(File::exists($this->path)){
219
+            if(File::exists($this->path)){
220 220
             $readf = File::get($this->path);
221 221
                 File::delete($this->path);
222 222
             if(php_sapi_name() == "cli"){
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
             }
228 228
         } else{
229 229
             if(php_sapi_name() == "cli"){
230
-               return false;
230
+                return false;
231 231
             } else{
232 232
                 return false;
233 233
             }
234 234
         }
235
-      }
235
+        }
236 236
 
237 237
     /**
238 238
      * Check account with details
@@ -241,59 +241,59 @@  discard block
 block discarded – undo
241 241
      * @return boolean
242 242
      */
243 243
     public function check_account($username){
244
-      $this->setPath($username);
245
-       if(File::exists($this->path)){
246
-              $readf = File::get($this->path);
247
-              if(php_sapi_name() == "cli"){
244
+        $this->setPath($username);
245
+        if(File::exists($this->path)){
246
+                $readf = File::get($this->path);
247
+                if(php_sapi_name() == "cli"){
248 248
                 
249
-                  return $readf;
249
+                    return $readf;
250 250
                 
251
-              } else{
252
-                  return $readf;
253
-              }
254
-          } else{
255
-              if(php_sapi_name() == "cli"){
256
-                  echo Lang::get('lockoutMessage.user_lock_404')."\n";
257
-                  exit();
258
-              } else{
259
-                  return false;
260
-              }
261
-          }
251
+                } else{
252
+                    return $readf;
253
+                }
254
+            } else{
255
+                if(php_sapi_name() == "cli"){
256
+                    echo Lang::get('lockoutMessage.user_lock_404')."\n";
257
+                    exit();
258
+                } else{
259
+                    return false;
260
+                }
261
+            }
262 262
         }
263 263
 
264
-     /**
265
-     * Locking account manually
266
-     *
267
-     * @param string $username
268
-     * @return boolean
269
-     */
264
+        /**
265
+         * Locking account manually
266
+         *
267
+         * @param string $username
268
+         * @return boolean
269
+         */
270 270
     public function lock_account($username){
271 271
         $sapi = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web";
272 272
         $this->setPath($username);
273 273
         try{
274
-          if(!File::exists($this->dir)){
275
-              File::makeDirectory($this->dir, 0755, true);
276
-          }
277
-              $login_fail = "lock";
274
+            if(!File::exists($this->dir)){
275
+                File::makeDirectory($this->dir, 0755, true);
276
+            }
277
+                $login_fail = "lock";
278 278
         
279
-              $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$sapi],'last_attemps' => date("Y-m-d H:i:s",time())];
280
-              File::put($this->path,json_encode($content));
281
-              if(File::exists($this->path)){
279
+                $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$sapi],'last_attemps' => date("Y-m-d H:i:s",time())];
280
+                File::put($this->path,json_encode($content));
281
+                if(File::exists($this->path)){
282 282
                 chmod($this->path,0755);
283
-              }
284
-              if(php_sapi_name() == "cli"){
283
+                }
284
+                if(php_sapi_name() == "cli"){
285 285
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
286 286
                 
287
-              } else{
288
-              return true;
289
-              }
290
-          } catch(Exception $e){
291
-              if(php_sapi_name() == "cli"){
287
+                } else{
288
+                return true;
289
+                }
290
+            } catch(Exception $e){
291
+                if(php_sapi_name() == "cli"){
292 292
                 return "error";
293 293
                 
294
-              } else{
294
+                } else{
295 295
                 return false;
296
-              }
297
-          }
296
+                }
297
+            }
298 298
     }
299 299
 }
300 300
\ No newline at end of file
Please login to merge, or discard this patch.
src/Console/Commands/TestingCommands.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function handle()
45 45
     {
46
-    	$curTime = microtime(true);
46
+        $curTime = microtime(true);
47 47
         $domain = 'locktest-'.md5(strtolower(config("app.name"))).'@'.strtolower(config("app.name")).".com";
48
-         $this->line('<fg=default>--------------------------------------------');
48
+            $this->line('<fg=default>--------------------------------------------');
49 49
         $this->testConfigurations();
50 50
         $this->line('<fg=default>Testing Mail : <fg=cyan>'.$domain);        
51 51
         $this->testWrite($domain);        
@@ -60,54 +60,54 @@  discard block
 block discarded – undo
60 60
     }
61 61
     private function testWrite($domain){
62 62
         $test = new Testing();
63
-         if( $test->testWriteEventFailedLogin($domain) AND $test->testWritable($domain)){
64
-           $this->line('<fg=default>Auto Lock : <fg=green>OK');
63
+            if( $test->testWriteEventFailedLogin($domain) AND $test->testWritable($domain)){
64
+            $this->line('<fg=default>Auto Lock : <fg=green>OK');
65 65
         } elseif(!$test->testWritable($domain)){
66 66
             $this->success += 1;
67 67
             $this->line('<fg=default>Auto Lock : <fg=yellow>Warning (Permission denied)');
68 68
         } else{
69 69
             $this->error += 1;
70
-             $this->line('<fg=default>Auto Lock : <fg=red>Failed');
70
+                $this->line('<fg=default>Auto Lock : <fg=red>Failed');
71 71
         }
72 72
     } 
73 73
     private function testManualLock($domain){
74 74
         $test = new Testing();
75
-         if( $test->testManualLocking($domain)){
75
+            if( $test->testManualLocking($domain)){
76 76
             $this->success += 1;
77
-           $this->line('<fg=default>Manual Lock : <fg=green>OK');
77
+            $this->line('<fg=default>Manual Lock : <fg=green>OK');
78 78
         } else{
79 79
             $this->error += 1;
80
-             $this->line('<fg=default>Manual Lock : <fg=red>Failed');
80
+                $this->line('<fg=default>Manual Lock : <fg=red>Failed');
81 81
         }
82 82
     }
83 83
     private function testUnlock($domain){
84 84
         $test = new Testing();
85
-         if( $test->testUnlocking($domain)){
86
-           $this->success += 1;
87
-           $this->line('<fg=default>Unlock Account : <fg=green>OK');
85
+            if( $test->testUnlocking($domain)){
86
+            $this->success += 1;
87
+            $this->line('<fg=default>Unlock Account : <fg=green>OK');
88 88
         } else{
89
-             $this->error += 1;
90
-             $this->line('<fg=default>Unlock Account : <fg=red>Failed');
89
+                $this->error += 1;
90
+                $this->line('<fg=default>Unlock Account : <fg=red>Failed');
91 91
         }
92 92
     }
93 93
 
94 94
     private function testLocked($domain){
95 95
         $test = new Testing();
96
-         if( $test->testLockLogin($domain)){
97
-           $this->success += 1;
98
-           $this->line('<fg=default>Try Login with locked account : <fg=green>Account is Locked');
96
+            if( $test->testLockLogin($domain)){
97
+            $this->success += 1;
98
+            $this->line('<fg=default>Try Login with locked account : <fg=green>Account is Locked');
99 99
         } else{
100
-             $this->error += 1;
101
-             $this->line('<fg=default>Try Login with locked account : <fg=red>Account logged in');
100
+                $this->error += 1;
101
+                $this->line('<fg=default>Try Login with locked account : <fg=red>Account logged in');
102 102
         }
103 103
     }
104 104
 
105 105
     private function testConfigurations(){
106
-    	 $test = new Testing();
107
-    	 $res  = $test->testConfig();
106
+            $test = new Testing();
107
+            $res  = $test->testConfig();
108 108
     	 
109
-    	 	$table = new Table($this->output);
110
-    	 	$this->line('<fg=cyan>Testing Config:');
109
+                $table = new Table($this->output);
110
+                $this->line('<fg=cyan>Testing Config:');
111 111
             $table->setRows([
112 112
                         ['<fg=default>login_attemps',isset($res['login_attemps']) ? $res['login_attemps']:"<fg=red>Not Found"],
113 113
                         ['<fg=default>logging',isset($res['logging']) ? $res['logging']:"<fg=red>Not Found"],
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
                     ]);
121 121
                         $table->render();
122 122
     	 	
123
-    	 if($res['err'] > 0 AND !empty($res['file'])){
124
-    	 	$this->line('<fg=red>Testing config failed, testing is canceled.');
125
-    	 	$this->line($res['file']);
126
-    	 	exit();
127
-    	 }
123
+            if($res['err'] > 0 AND !empty($res['file'])){
124
+                $this->line('<fg=red>Testing config failed, testing is canceled.');
125
+                $this->line($res['file']);
126
+                exit();
127
+            }
128 128
 
129 129
     }
130 130
   
Please login to merge, or discard this patch.
src/Func/Testing.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
             }
22 22
 
23 23
             if(is_bool(config('irfa.lockout.logging'))){
24
-               $ret['logging'] = '<fg=green>OK';
24
+                $ret['logging'] = '<fg=green>OK';
25 25
             } else{
26 26
 
27 27
                 $ret['err'] +=1;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                 $ret['lockout_file_path'] = '<fg=yellow>Write Permission Denied in '.config('irfa.lockout.lockout_file_path'); 
42 42
             }
43 43
 
44
-             if(!empty(config('irfa.lockout.redirect_url'))){
44
+                if(!empty(config('irfa.lockout.redirect_url'))){
45 45
                 $ret['redirect_url'] = '<fg=green>OK';
46 46
             } else{
47 47
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
                 if(!empty(config('irfa.lockout.protected_middleware_group'))){
61 61
                     $ret['protected_middleware_group'] = '<fg=green>OK';
62 62
                 } else{
63
-                     $ret['err'] +=1;
64
-                     $ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; 
63
+                        $ret['err'] +=1;
64
+                        $ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; 
65 65
                 }
66 66
             } else{
67 67
 
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
 
83 83
         return $ret;
84 84
     }
85
-	public function testWriteEventFailedLogin($username){
85
+    public function testWriteEventFailedLogin($username){
86 86
 
87
-    	$this->eventFailedLogin($username);
87
+        $this->eventFailedLogin($username);
88 88
 
89
-		$input = $username;
90
-		$dir = config('irfa.lockout.lockout_file_path');
91
-		$path = $dir.md5($input);
89
+        $input = $username;
90
+        $dir = config('irfa.lockout.lockout_file_path');
91
+        $path = $dir.md5($input);
92 92
 
93
-    	if(File::exists($path))
93
+        if(File::exists($path))
94 94
         {
95
-        	return true;
95
+            return true;
96 96
         } 
97
-    		return false;
97
+            return false;
98 98
     }
99 99
     public function testWritable($username){
100
-		$input = $username;
101
-		$dir = config('irfa.lockout.lockout_file_path');
102
-		$path = $dir.md5($input);
100
+        $input = $username;
101
+        $dir = config('irfa.lockout.lockout_file_path');
102
+        $path = $dir.md5($input);
103 103
 
104
-    	if(is_writable($path))
104
+        if(is_writable($path))
105 105
         {
106
-        	return true;
106
+            return true;
107 107
         } 
108
-    		return false;
108
+            return false;
109 109
     }
110 110
 
111 111
     public function testManualLocking($username){
Please login to merge, or discard this patch.
src/Initializing/Variable.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@
 block discarded – undo
5 5
 
6 6
 class Variable {
7 7
 
8
-		protected $ip;
9
-	    protected $input=null;
10
-	    protected $dir;
11
-	    protected $path;
12
-	    protected $attemps;
13
-	    protected $permission_code;
8
+        protected $ip;
9
+        protected $input=null;
10
+        protected $dir;
11
+        protected $path;
12
+        protected $attemps;
13
+        protected $permission_code;
14 14
 
15
-	    /**
16
-		 * Initializing variable.
17
-		 *
18
-		 * @return void
19
-		 */
20
-		protected function initVar(){
21
-			if(!empty(config('irfa.lockout'))){
22
-		        $this->ip = Request::ip();
23
-		        $this->input = Request::input(config('irfa.lockout.input_name'));
24
-		        $this->dir = config('irfa.lockout.lockout_file_path');
25
-		        $this->attemps = config('irfa.lockout.login_attemps');
26
-		        $this->path = $this->dir.md5($this->input);
27
-		    }
28
-    	}
15
+        /**
16
+         * Initializing variable.
17
+         *
18
+         * @return void
19
+         */
20
+        protected function initVar(){
21
+            if(!empty(config('irfa.lockout'))){
22
+                $this->ip = Request::ip();
23
+                $this->input = Request::input(config('irfa.lockout.input_name'));
24
+                $this->dir = config('irfa.lockout.lockout_file_path');
25
+                $this->attemps = config('irfa.lockout.login_attemps');
26
+                $this->path = $this->dir.md5($this->input);
27
+            }
28
+        }
29 29
 
30
-    	protected function setPath($username){
31
-    		$this->path = $this->dir.md5($username);
32
-    		$this->input = $username;
33
-    	}
30
+        protected function setPath($username){
31
+            $this->path = $this->dir.md5($username);
32
+            $this->input = $username;
33
+        }
34 34
 	
35
-	}
36 35
\ No newline at end of file
36
+    }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.